forked from len0rd/rockbox
MIDI: Allow seeking forward and backward using the left/right keys. Currently seeks in 5 second
increments, but this can be set to any amount. Also implemented a counter for playing time, which can pretty easily be used to determine the length of the file, in seconds, before playing it. The time isn't displayed anywhere right now, but all this can be useful if this thing is turned into a codec, or at least gets a nice UI. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15418 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
dc58c3d92e
commit
cd963d84ca
5 changed files with 110 additions and 8 deletions
|
@ -22,6 +22,8 @@
|
|||
#include "synth.h"
|
||||
|
||||
extern struct plugin_api * rb;
|
||||
extern int playingTime IBSS_ATTR;
|
||||
extern int samplesThisSecond IBSS_ATTR;
|
||||
|
||||
long tempo=375000;
|
||||
|
||||
|
@ -239,7 +241,7 @@ inline void pressNote(int ch, int note, int vol)
|
|||
{
|
||||
if(drumSet[note]!=NULL)
|
||||
{
|
||||
if(note<35)
|
||||
if(note<35)
|
||||
printf("NOTE LESS THAN 35, AND A DRUM PATCH EXISTS FOR THIS? WHAT THE HELL?");
|
||||
|
||||
struct GWaveform * wf = drumSet[note]->waveforms[0];
|
||||
|
@ -364,6 +366,16 @@ static void sendEvent(struct Event * ev)
|
|||
}
|
||||
}
|
||||
|
||||
void rewindFile()
|
||||
{
|
||||
int i=0;
|
||||
for(i=0; i<mf->numTracks; i++)
|
||||
{
|
||||
mf->tracks[i]->delta = 0;
|
||||
mf->tracks[i]->pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int tick(void) ICODE_ATTR;
|
||||
int tick(void)
|
||||
{
|
||||
|
@ -419,6 +431,15 @@ int tick(void)
|
|||
}
|
||||
}
|
||||
|
||||
samplesThisSecond += numberOfSamples;
|
||||
|
||||
while(samplesThisSecond >= SAMPLE_RATE)
|
||||
{
|
||||
samplesThisSecond -= SAMPLE_RATE;
|
||||
playingTime++;
|
||||
// printf("Time: %d sec\n", playingTime);
|
||||
}
|
||||
|
||||
if(tracksAdv != 0)
|
||||
return 1;
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue