From 4b773c0c4c1f6c8c003038161fa44292b501e55a Mon Sep 17 00:00:00 2001 From: Stepan Moskovchenko Date: Sat, 16 Apr 2005 03:35:20 +0000 Subject: Added xxx2wav support, an icon, and some optimizations git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6306 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/midi/guspat.c | 12 ++++++++++++ apps/plugins/midi/synth.c | 22 ++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'apps/plugins/midi') diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index 6508591f74..f674b64caa 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c @@ -66,6 +66,18 @@ struct GWaveform * loadWaveform(int file) wav->res=readData(file, 36); wav->data=readData(file, wav->wavSize); + int a=0; + + //If we have a 16 bit waveform + if(wav->mode & 1 && (wav->mode & 2)) + { + for(a=0; awavSize; a+=2) //Convert it to + { + //wav->data[a]=wav->data[a]; //+((wav->mode & 2) << 6); + wav->data[a|1]=wav->data[(a)|1]+(1 << 7); + } + } + return wav; } diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 86cb43483a..99864e557e 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -186,10 +186,7 @@ inline signed short int getSample(struct GWaveform * wf, unsigned int s) { if(s<<1 >= wf->wavSize) - { - // printf("\nSAMPLE OUT OF RANGE: s=%d 2s=%d ws=%d", s, 2*s, wf->wavSize); return 0; - } /* @@ -198,14 +195,14 @@ inline signed short int getSample(struct GWaveform * wf, unsigned int s) */ - //If they are unsigned, convert them to signed - //or was it the other way around. Whatever, it works - unsigned char b1=wf->data[s<<1]+((wf->mode & 2) << 6); - unsigned char b2=wf->data[(s<<1)|1]+((wf->mode & 2) << 6); - return (b1 | (b2<<8)); + //Sign conversion moved into guspat.c + unsigned char b1=wf->data[s<<1]; //+((wf->mode & 2) << 6); + unsigned char b2=wf->data[(s<<1)|1]; //+((wf->mode & 2) << 6); + return (b1 | (b2<<8)) ; } else - { //8-bit samples + { //8-bit samples + //Do we even have anything 8-bit in our set? unsigned char b1=wf->data[s]+((wf->mode & 2) << 6); return b1<<8; } @@ -237,10 +234,6 @@ inline void setPoint(struct SynthObject * so, int pt) so->curPoint = pt; int r=0; - - - - int rate = so->wf->envRate[pt]; r=3-((rate>>6) & 0x3); // Some blatant Timidity code for rate conversion... @@ -256,7 +249,7 @@ inline void setPoint(struct SynthObject * so, int pt) default this to 10, and maybe later have an option to set it to 9 for longer decays. */ - so->curRate = r<<9; + so->curRate = r<<10; so->targetOffset = so->wf->envOffset[pt]<<(20); @@ -372,6 +365,7 @@ inline signed short int synthVoice(int v) if(so->curOffset < 0) so->isUsed=0; //This is OK + s = s * (so->curOffset >> 22); s = s>>6; -- cgit v1.2.3