Mercurial > hg > dmlib
changeset 154:969cefb2f8c3
Use dmClamp().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 06 Oct 2012 04:44:26 +0300 |
parents | 0b2866e25bf1 |
children | 2862f1571250 |
files | jssplr.c |
diffstat | 1 files changed, 4 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/jssplr.c Sat Oct 06 04:43:35 2012 +0300 +++ b/jssplr.c Sat Oct 06 04:44:26 2012 +0300 @@ -38,9 +38,7 @@ */ static int jmpNoteToAmigaPeriod(int note, int finetune) { - int tmp = (note + finetune + 8); - if (tmp < 0) tmp = 0; else - if (tmp > 103) tmp = 103; + int tmp = dmClamp(note + finetune + 8, 0, 103); return jmpXMAmigaPeriodTab[tmp]; } @@ -116,8 +114,7 @@ assert(mp != NULL); assert(mp->device != NULL); - if (volume < mpMinVol) volume = mpMinVol; else - if (volume > mpMaxVol) volume = mpMaxVol; + volume = dmClamp(volume, mpMinVol, mpMaxVol); //fprintf(stderr, "chn %d: vol=%d, fad=%d, env=%d\n", channel, volume, chn->iCFadeOutVol, chn->iCVolEnv); #if 0 @@ -667,12 +664,7 @@ { (void) channel; - // Check values - if (volume < mpMinVol) volume = mpMinVol; else - if (volume > mpMaxVol) volume = mpMaxVol; - - // Set the volume - chn->iCVolume = volume; + chn->iCVolume = dmClamp(volume, mpMinVol, mpMaxVol); JMPSETNDFLAGS(cdfNewVolume); } @@ -691,7 +683,6 @@ if (value < 0) value = 0; - // Set the new pitch chn->iCPitch = value; JMPSETNDFLAGS(cdfNewPitch); } @@ -1251,7 +1242,7 @@ chn->iCOldPitch = chn->iCPitch; // Compute new pitch - tmp = (chn->iCNote + inst->ERelNote); + tmp = dmClamp(chn->iCNote + inst->ERelNote, 0, 119); //fprintf(stderr, "HEH: %d + %d = %d\n", chn->iCNote, inst->ERelNote, tmp); if (tmp < 0) tmp = 0;