summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/midiplay.c
diff options
context:
space:
mode:
authorStepan Moskovchenko <stevenm@rockbox.org>2007-10-15 05:11:37 +0000
committerStepan Moskovchenko <stevenm@rockbox.org>2007-10-15 05:11:37 +0000
commit1515ff852224c822a6d3db8c458eab2c9037704f (patch)
treee427fbec1b397d18abffc12b7fe74e67c2cad807 /apps/plugins/midi/midiplay.c
parent99f955088149d5938ce4c9ca5624377f464b1380 (diff)
downloadrockbox-1515ff852224c822a6d3db8c458eab2c9037704f.tar.gz
rockbox-1515ff852224c822a6d3db8c458eab2c9037704f.zip
MIDI: At long last, though quick and dirty, pitch bend depth! Or, I think it works. Tested on two
files. Let me know if anyone discovers any problems with this. This commit also includes Nils's synth loop optimization patch. I hope committing it does not cause problems. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15112 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/midiplay.c')
-rw-r--r--apps/plugins/midi/midiplay.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 99f05718d6..325d90c375 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -93,6 +93,7 @@ int numberOfSamples IBSS_ATTR;
93long bpm IBSS_ATTR; 93long bpm IBSS_ATTR;
94 94
95int32_t gmbuf[BUF_SIZE*NBUF]; 95int32_t gmbuf[BUF_SIZE*NBUF];
96static unsigned int samples_in_buf;
96 97
97int quit=0; 98int quit=0;
98struct plugin_api * rb; 99struct plugin_api * rb;
@@ -160,7 +161,8 @@ static inline void synthbuf(void)
160 outptr=gmbuf; 161 outptr=gmbuf;
161#endif 162#endif
162 163
163 for(i=0; i<BUF_SIZE/numberOfSamples; i++) 164 /* synth samples for as many whole ticks as we can fit in the buffer */
165 for(i=0; i < BUF_SIZE/numberOfSamples; i++)
164 { 166 {
165 synthSamples((int32_t*)outptr, numberOfSamples); 167 synthSamples((int32_t*)outptr, numberOfSamples);
166 outptr += numberOfSamples; 168 outptr += numberOfSamples;
@@ -168,11 +170,9 @@ static inline void synthbuf(void)
168 quit=1; 170 quit=1;
169 } 171 }
170 172
171 if(BUF_SIZE%numberOfSamples) 173 /* how many samples did we write to the buffer? */
172 { 174 samples_in_buf = BUF_SIZE-(BUF_SIZE%numberOfSamples);
173 synthSamples((int32_t*)outptr, BUF_SIZE%numberOfSamples); 175
174 outptr += BUF_SIZE%numberOfSamples;
175 }
176} 176}
177 177
178void get_more(unsigned char** start, size_t* size) 178void get_more(unsigned char** start, size_t* size)
@@ -187,7 +187,7 @@ void get_more(unsigned char** start, size_t* size)
187 synthbuf(); // For some reason midiplayer crashes when an update is forced 187 synthbuf(); // For some reason midiplayer crashes when an update is forced
188#endif 188#endif
189 189
190 *size = sizeof(gmbuf)/NBUF; 190 *size = samples_in_buf*sizeof(int32_t);
191#ifndef SYNC 191#ifndef SYNC
192 *start = (unsigned char*)((swap ? gmbuf : gmbuf + BUF_SIZE)); 192 *start = (unsigned char*)((swap ? gmbuf : gmbuf + BUF_SIZE));
193 swap=!swap; 193 swap=!swap;