diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/midi/midiutil.h | 2 | ||||
-rw-r--r-- | apps/plugins/midi/sequencer.c | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h index 18d493b23a..c3c5d91f47 100644 --- a/apps/plugins/midi/midiutil.h +++ b/apps/plugins/midi/midiutil.h | |||
@@ -17,7 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #define FRACTSIZE 10 | 20 | #define FRACTSIZE 12 |
21 | 21 | ||
22 | #define BUF_SIZE 8192 /* 32 kB output buffers */ | 22 | #define BUF_SIZE 8192 /* 32 kB output buffers */ |
23 | #define NBUF 2 | 23 | #define NBUF 2 |
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); |