-support for stereo ima-adpcm sample compression & playback

-support for converting samples to ima-adpcm upon export
This commit is contained in:
Juan Linietsky
2015-11-09 00:49:18 -03:00
parent 3fcfdfec0a
commit 61c4c5795f
13 changed files with 312 additions and 71 deletions
+4 -4
View File
@@ -38,12 +38,8 @@ SampleManagerSW::~SampleManagerSW()
RID SampleManagerMallocSW::sample_create(AS::SampleFormat p_format, bool p_stereo, int p_length) {
ERR_EXPLAIN("IMA-ADPCM and STEREO are not a valid combination for sample format.");
ERR_FAIL_COND_V( p_format == AS::SAMPLE_FORMAT_IMA_ADPCM && p_stereo,RID());
Sample *s = memnew( Sample );
int datalen = p_length;
if (p_stereo)
datalen*=2;
if (p_format==AS::SAMPLE_FORMAT_PCM16)
datalen*=2;
else if (p_format==AS::SAMPLE_FORMAT_IMA_ADPCM) {
@@ -53,6 +49,10 @@ RID SampleManagerMallocSW::sample_create(AS::SampleFormat p_format, bool p_stere
datalen/=2;
datalen+=4;
}
if (p_stereo)
datalen*=2;
#define SAMPLE_EXTRA 16
s->data = memalloc(datalen+SAMPLE_EXTRA); //help the interpolator by allocating a little more..