fixes on sample importing
This commit is contained in:
parent
fec6aaffd8
commit
1e50677594
4 changed files with 16 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue