From 1e5067759420393344ce439fdea1e80e2983579a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 19 May 2015 23:37:04 -0300 Subject: fixes on sample importing --- core/bind/core_bind.cpp | 2 +- scene/io/resource_format_wav.cpp | 12 +++++++++++- servers/audio/sample_manager_sw.cpp | 1 + tools/editor/io_plugins/editor_sample_import_plugin.cpp | 5 +++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index be3ce4f44b..128bc94989 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1872,7 +1872,7 @@ _Thread::_Thread() { _Thread::~_Thread() { if (active) { - ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running..") + ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running.."); } ERR_FAIL_COND(active==true); } diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp index a37d3b0638..b246eb66f5 100644 --- a/scene/io/resource_format_wav.cpp +++ b/scene/io/resource_format_wav.cpp @@ -146,9 +146,13 @@ RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_ } int frames=chunksize; + frames/=format_channels; frames/=(format_bits>>3); + print_line("chunksize: "+itos(chunksize)); + print_line("channels: "+itos(format_channels)); + print_line("bits: "+itos(format_bits)); sample->create( (format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16, @@ -156,8 +160,14 @@ RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_ frames ); sample->set_mix_rate( format_freq ); + int len=frames; + if (format_channels==2) + len*=2; + if (format_bits>8) + len*=2; + DVector data; - data.resize(chunksize); + data.resize(len); DVector::Write dataw = data.write(); void * data_ptr = dataw.ptr(); diff --git a/servers/audio/sample_manager_sw.cpp b/servers/audio/sample_manager_sw.cpp index 5fa3c834c4..49ca5369ae 100644 --- a/servers/audio/sample_manager_sw.cpp +++ b/servers/audio/sample_manager_sw.cpp @@ -135,6 +135,7 @@ void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector ERR_EXPLAIN("Sample buffer size does not match sample size."); + print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size)); ERR_FAIL_COND(s->length_bytes!=buff_size); DVector::Read buffer_r=p_buffer.read(); const uint8_t *src = buffer_r.ptr(); diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index d1fe10df03..fa472ed033 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -610,6 +610,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref& p_data,D prev+=vpdiff ; if (prev > 32767) { - printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev); + //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev); prev=32767; } else if (prev < -32768) { - printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev); + //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev); prev = -32768 ; } -- cgit v1.2.3