From 2d337dab7f6d32f8a0ddd035dd904b3f51909afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Wallm=C3=A9nius?= Date: Sun, 27 Jul 2008 20:36:45 +0000 Subject: FS#9221 by Christopher Williams fixing a couple of bugs in keybox git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18138 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/midi/guspat.c | 12 +++++++----- apps/plugins/midi/synth.c | 17 +++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'apps/plugins/midi') diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index 419cfa3..1b310d2 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c @@ -162,10 +162,12 @@ struct GPatch * gusload(char * filename) int file = rb->open(filename, O_RDONLY); + DEBUGF("filename: %s\n", filename); + if(file == -1) { - char message[50]; - rb->snprintf(message, 50, "Error opening %s", filename); + char message[MAX_PATH]; + rb->snprintf(message, MAX_PATH, "Error opening %s", filename); rb->splash(HZ*2, message); return NULL; } @@ -197,12 +199,12 @@ struct GPatch * gusload(char * filename) /* printf("\nFILE: %s", filename); */ /* printf("\nlayerSamples=%d", gp->numWaves); */ - +DEBUGF("hej\n"); int a=0; for(a=0; anumWaves; a++) gp->waveforms[a] = loadWaveform(file); - +DEBUGF("hej2\n"); /* printf("\nPrecomputing note table"); */ for(a=0; a<128; a++) @@ -210,7 +212,7 @@ struct GPatch * gusload(char * filename) gp->noteTable[a] = selectWaveform(gp, a); } rb->close(file); - +DEBUGF("hej3\n"); return gp; } diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 0819722..09ea1c6 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -140,10 +140,11 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) return -1; } - char name[40]; - char fn[40]; + char name[MAX_PATH]; + char fn[MAX_PATH]; /* Scan our config file and load the right patches as needed */ + char *p; int c = 0; name[0] = '\0'; printf("Loading instruments"); @@ -151,8 +152,12 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) { while(readChar(file)!=' ' && !eof(file)); readTextBlock(file, name); - - rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name); + DEBUGF("name: %s\n", name); + p = rb->strrchr(name, '.'); + if (!p || rb->strncmp(p, ".pat", 4)) + rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name); + else + rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s", name); /* printf("\nLOADING: <%s> ", fn); */ if(patchUsed[a]==1) @@ -167,7 +172,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) c = readChar(file); } rb->close(file); - +DEBUGF("drums!!\n"); file = rb->open(drumConfig, O_RDONLY); if(file < 0) { @@ -183,7 +188,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) { readTextBlock(file, number); readTextBlock(file, name); - rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name); + rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name); idx = rb->atoi(number); if(idx == 0) -- cgit v1.1