diff options
| author | Stepan Moskovchenko <stevenm@rockbox.org> | 2006-05-01 23:22:59 +0000 |
|---|---|---|
| committer | Stepan Moskovchenko <stevenm@rockbox.org> | 2006-05-01 23:22:59 +0000 |
| commit | b2f1b5dd183b1171c81796946c868f2df8df9647 (patch) | |
| tree | 3f2fcd3bdf2e2f9e00ad253d671b5c27a52280ad /apps/plugins/midi/midifile.c | |
| parent | 9e3da0d6d5bc9d02b939dedd62e05f8893940c1a (diff) | |
| download | rockbox-b2f1b5dd183b1171c81796946c868f2df8df9647.zip rockbox-b2f1b5dd183b1171c81796946c868f2df8df9647.tar.gz rockbox-b2f1b5dd183b1171c81796946c868f2df8df9647.tar.bz2 rockbox-b2f1b5dd183b1171c81796946c868f2df8df9647.tar.xz | |
----------------------------------------------------------------------
Added Karl Kurbjun's sound output patch, cleaned up some output.
Main file is now midiplay.c, midi2wav is still in there for anyone who
wants it. Set sampling rate to 22k, and increased note decay time.
Reduced number of concurrent active voices and made new notes replace
used voices if none are available. This makes lag less apparent.
I really hope this wont go red. (turns around and runs)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9858 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/midifile.c')
| -rw-r--r-- | apps/plugins/midi/midifile.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c index 412cc61..61168f9 100644 --- a/apps/plugins/midi/midifile.c +++ b/apps/plugins/midi/midifile.c @@ -26,7 +26,7 @@ void bail(const char *); struct MIDIfile * loadFile(char * filename) { - struct MIDIfile * mf; + struct MIDIfile * mfload; int file = rb->open (filename, O_RDONLY); if(file==-1) @@ -34,15 +34,15 @@ struct MIDIfile * loadFile(char * filename) bail("Could not open file\n"); } - mf = (struct MIDIfile*)allocate(sizeof(struct MIDIfile)); + mfload = (struct MIDIfile*)malloc(sizeof(struct MIDIfile)); - if(mf==NULL) + if(mfload==NULL) { rb->close(file); bail("Could not allocate memory for MIDIfile struct\n"); } - rb->memset(mf, 0, sizeof(struct MIDIfile)); + rb->memset(mfload, 0, sizeof(struct MIDIfile)); if(readID(file) != ID_MTHD) { @@ -62,32 +62,32 @@ struct MIDIfile * loadFile(char * filename) bail("MIDI file type not supported"); } - mf->numTracks = readTwoBytes(file); - mf->div = readTwoBytes(file); + mfload->numTracks = readTwoBytes(file); + mfload->div = readTwoBytes(file); int track=0; - printf("\nnumTracks=%d div=%d\nBegin reading track data\n", mf->numTracks, mf->div); + printf("\nnumTracks=%d div=%d\nBegin reading track data\n", mfload->numTracks, mfload->div); - while(! eof(file) && track < mf->numTracks) + while(! eof(file) && track < mfload->numTracks) { unsigned char id = readID(file); if(id == ID_EOF) { - if(mf->numTracks != track) + if(mfload->numTracks != track) { - printf("\nError: file claims to have %d tracks.\n I only see %d here.\n", mf->numTracks, track); - mf->numTracks = track; + printf("\nError: file claims to have %d tracks.\n I only see %d here.\n", mfload->numTracks, track); + mfload->numTracks = track; } - return mf; + return mfload; } if(id == ID_MTRK) { - mf->tracks[track] = readTrack(file); + mfload->tracks[track] = readTrack(file); //exit(0); track++; } else @@ -98,16 +98,16 @@ struct MIDIfile * loadFile(char * filename) readChar(file); } } - return mf; + return mfload; } -int rStatus = 0; - /* Returns 0 if done, 1 if keep going */ int readEvent(int file, void * dest) { + + static int rStatus = 0; struct Event dummy; struct Event * ev = (struct Event *) dest; @@ -131,7 +131,7 @@ int readEvent(int file, void * dest) if(dest != NULL) { ev->evData = readData(file, ev->len); - printf("\nDATA: <%s>", ev->evData); +/* printf("\nDATA: <%s>", ev->evData); */ } else { @@ -173,11 +173,9 @@ int readEvent(int file, void * dest) return 1; } - - struct Track * readTrack(int file) { - struct Track * trk = (struct Track *)allocate(sizeof(struct Track)); + struct Track * trk = (struct Track *)malloc(sizeof(struct Track)); rb->memset(trk, 0, sizeof(struct Track)); trk->size = readFourBytes(file); @@ -194,7 +192,7 @@ struct Track * readTrack(int file) rb->lseek(file, pos, SEEK_SET); int trackSize = (numEvents+1) * sizeof(struct Event); - void * dataPtr = allocate(trackSize); + void * dataPtr = malloc(trackSize); trk->dataBlock = dataPtr; numEvents=0; |