diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-05-19 23:37:04 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-05-19 23:37:04 -0300 |
commit | 1e5067759420393344ce439fdea1e80e2983579a (patch) | |
tree | 4d00a6e33b6debea0ae9632b2722309da6de55f5 | |
parent | fec6aaffd81a871393a7a428921dc6e8be149d3c (diff) |
fixes on sample importing
-rw-r--r-- | core/bind/core_bind.cpp | 2 | ||||
-rw-r--r-- | scene/io/resource_format_wav.cpp | 12 | ||||
-rw-r--r-- | servers/audio/sample_manager_sw.cpp | 1 | ||||
-rw-r--r-- | 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<uint8_t> data; - data.resize(chunksize); + data.resize(len); DVector<uint8_t>::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<uint8_t> 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<uint8_t>::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<ResourceI dst_format=Sample::FORMAT_IMA_ADPCM; _compress_ima_adpcm(data,dst_data); + print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size())); } else { @@ -755,10 +756,10 @@ void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector<float>& 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 ; } |