diff options
author | Stepan Moskovchenko <stevenm@rockbox.org> | 2007-11-17 06:39:02 +0000 |
---|---|---|
committer | Stepan Moskovchenko <stevenm@rockbox.org> | 2007-11-17 06:39:02 +0000 |
commit | 7f1fbe4af2d7e44e808418a969f5d2301b002c61 (patch) | |
tree | 7cbd226bb0afc1ccaca9410225f1a4691ce4eacc /apps/plugins/midi/sequencer.c | |
parent | 39429616c3ab5dd3919b6fb0bc3a24ef0127240b (diff) | |
download | rockbox-7f1fbe4af2d7e44e808418a969f5d2301b002c61.tar.gz rockbox-7f1fbe4af2d7e44e808418a969f5d2301b002c61.zip |
MIDI: Increase percision of synthesizer by a factor of 4 - makes certain parts (guitar bends, mostly)
sound more natural. Also, completely rearrange the order of operations in the delta computation. Had to
use long longs. Probably not a good idea for speed, but the order can be optimized more later.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15652 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/sequencer.c')
-rw-r--r-- | apps/plugins/midi/sequencer.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index bd2f33b365..e2a9f7dd5c 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c | |||
@@ -144,10 +144,25 @@ static void findDelta(struct SynthObject * so, int ch, int note) | |||
144 | { | 144 | { |
145 | struct GWaveform * wf = patchSet[chPat[ch]]->waveforms[patchSet[chPat[ch]]->noteTable[note]]; | 145 | struct GWaveform * wf = patchSet[chPat[ch]]->waveforms[patchSet[chPat[ch]]->noteTable[note]]; |
146 | so->wf=wf; | 146 | so->wf=wf; |
147 | unsigned int delta= 0; | 147 | |
148 | /* Used to be unsigned int, but math had to be done in different order to avoid overflow */ | ||
149 | unsigned long long delta= 0; | ||
150 | |||
151 | /* | ||
152 | Old formula: | ||
148 | delta = (((gustable[note+chPBNoteOffset[ch]]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE)); | 153 | delta = (((gustable[note+chPBNoteOffset[ch]]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE)); |
149 | delta = (delta * chPBFractBend[ch])>> 16; | ||
150 | 154 | ||
155 | Plus some pitch stuff. See old SVN for how it used to be | ||
156 | */ | ||
157 | |||
158 | delta = (((gustable[note+chPBNoteOffset[ch]]))); /* anywhere from 8000 to 8000000 */ | ||
159 | delta = delta * wf->sampRate; /* approx 20000 - 44000 but can vary with tuning */ | ||
160 | delta = (delta * chPBFractBend[ch]); /* approx 60000 - 70000 */ | ||
161 | delta = delta / (SAMPLE_RATE); /* 44100 or 22050 */ | ||
162 | delta = delta / (wf->rootFreq); /* anywhere from 8000 to 8000000 */ | ||
163 | |||
164 | /* Pitch bend is encoded as a fractional of 16 bits, hence the 16 */ | ||
165 | delta = delta >> (16 - FRACTSIZE); /* a shift of approx 4 bits */ | ||
151 | so->delta = delta; | 166 | so->delta = delta; |
152 | } | 167 | } |
153 | 168 | ||
@@ -250,7 +265,7 @@ inline void pressNote(int ch, int note, int vol) | |||
250 | 265 | ||
251 | struct GWaveform * wf = drumSet[note]->waveforms[0]; | 266 | struct GWaveform * wf = drumSet[note]->waveforms[0]; |
252 | voices[a].wf=wf; | 267 | voices[a].wf=wf; |
253 | voices[a].delta = (((gustable[note]<<10) / wf->rootFreq) * wf->sampRate / SAMPLE_RATE); | 268 | voices[a].delta = (((gustable[note]<<FRACTSIZE) / wf->rootFreq) * wf->sampRate / SAMPLE_RATE); |
254 | if(wf->mode & 28) | 269 | if(wf->mode & 28) |
255 | // printf("\nWoah, a drum patch has a loop. Stripping the loop..."); | 270 | // printf("\nWoah, a drum patch has a loop. Stripping the loop..."); |
256 | wf->mode = wf->mode & (255-28); | 271 | wf->mode = wf->mode & (255-28); |