This is a patch for Playmidi 2.3 and Pro Patches Lite 1.61. A few bugs remain (e.g. sample detuning in certain patches), but the player is now usable with pplt. If a patch is out of tune (e.g. church.pat) you may want to replace it with the original GUS patch, until someone fixes playmidi to correctly handle patch detuning information. claudio --8<-------------------------------------------------------------------- diff -rud --new-file playmidi-2.3.orig/BUGS playmidi-2.3/BUGS --- playmidi-2.3.orig/BUGS Sat Feb 24 11:00:00 1996 +++ playmidi-2.3/BUGS Wed Feb 11 22:25:09 1998 @@ -10,9 +10,16 @@ Gravis Ultrasound. Pressing the repeat button helps for all but GUS. Pro Patches lite patch set for gravis ultrasound is reported to have -trouble with linux playmidi. +trouble with linux playmidi. (not anymore -- claudio's fixes should +take care of that) MT-32 emulation mode (-M) isn't designed to play a file more than once (ie repeat button), so programs get all screwed up. Working on a fix. + +Added by claudio: there's a noticeable volume overdrive when playing +jazz.mid in GUS with Pro Patches Lite 1.61. + +Added by claudio: volume of shaker is incorrect when playing striving.mid. +Also a problem with the channel allocation policy. No other bugs known at this time. diff -rud --new-file playmidi-2.3.orig/Makefile playmidi-2.3/Makefile --- playmidi-2.3.orig/Makefile Sat Feb 24 11:00:00 1996 +++ playmidi-2.3/Makefile Wed Feb 11 18:13:27 1998 @@ -6,7 +6,7 @@ # I don't wish to assert any rights (copyright) for this Makefile. # This Makefile is specially designed for using "make install" # thousands of times (for developing), and will only install updated -# files. It does not write over exiting fm patch libs if you have them. +# files. It does not write over existing fm patch libs if you have them. # # 5/10/95 - Fixed a few bugs here and there. -- Alex # diff -rud --new-file playmidi-2.3.orig/README.pplt playmidi-2.3/README.pplt --- playmidi-2.3.orig/README.pplt Wed Dec 31 21:00:00 1969 +++ playmidi-2.3/README.pplt Wed Feb 11 22:22:04 1998 @@ -0,0 +1,16 @@ + +Ok, so here's my patch for Playmidi 2.3 + +WARNING! I didn't find any enveloping or scaling details in the GUS +docs, so these changes are based on what looked reasonable for me. +Your milleage may vary! + +Changes: + +- Support for scale_factor and scale_frequency for drums +- Envelope fixing for Pro Patches Lite + + +Wed Feb 11 23:59:03 EST 1998 +Claudio Matsuoka (claudio@pos.inf.ufpr.br) + diff -rud --new-file playmidi-2.3.orig/patchload.c playmidi-2.3/patchload.c --- playmidi-2.3.orig/patchload.c Sat Feb 24 11:00:00 1996 +++ playmidi-2.3/patchload.c Wed Feb 11 22:07:06 1998 @@ -15,6 +15,16 @@ Kelly Drive, Lackland AFB, TX 78236-5128, USA. *************************************************************************/ + +/************************************************************************ + Wed Feb 11 17:08:23 EST 1998 - Claudio Matsuoka + Added support for Pro Patches Lite patches for GUS: + - envelope disabled when all rates are 63 (does 63 have a special + meaning there? I didn't find anything in the docs) + - fixed scale_factor and scale_frequency handling + *************************************************************************/ + + #include "playmidi.h" #include #include @@ -29,6 +39,10 @@ extern struct synth_info card_info[MAX_CARDS]; extern void close_show(int); +/* Added by claudio */ +extern int scale_factor[256]; +extern int scale_frequency[256]; + static int use8bit = 0; void load_sysex(length, data, type) @@ -200,7 +214,7 @@ sample.scale_factor = *(unsigned short *) &buf[58]; offset = offset + 96; - patch = (struct patch_info *) malloc(sizeof(*patch) + sample.len); + patch = (struct patch_info *) calloc(1,sizeof(*patch) + sample.len); if (patch == NULL) { close(patfd); @@ -210,7 +224,7 @@ patch->device_no = gus_dev; patch->instr_no = pgm; patch->mode = sample.modes | WAVE_TREMOLO | - WAVE_VIBRATO | WAVE_SCALE; + WAVE_VIBRATO /* | WAVE_SCALE */; patch->len = (use8bit ? sample.len / 2 : sample.len); patch->loop_start = (use8bit ? sample.loop_start / 2 : sample.loop_start); @@ -227,6 +241,22 @@ patch->env_offset[j] = (736 * sample.envelope_offset[j] + 384) / 768; + /* Need these to work with Pro Patches Lite 1.61 */ + scale_factor[pgm] = sample.scale_factor; + scale_frequency[pgm] = sample.scale_frequency; + if (patch->env_rate[0] == 63 && + patch->env_rate[1] == 63 && + patch->env_rate[2] == 63 && + patch->env_rate[3] == 63 && + patch->env_rate[4] == 63 && + patch->env_rate[5] == 63) { + /* patch->mode &= ~WAVE_ENVELOPES; */ + patch->env_rate[1] = 193; + patch->env_offset[1] = 230; + } + if (pgm > 128) /* pplt snare2 has loop enabled (yikes!) */ + patch->mode &= ~WAVE_LOOPING; + if (reverb) if (pgm < 120) patch->env_rate[3] = (2 << 6) | (12 - (reverb >> 4)); @@ -241,8 +271,11 @@ patch->vibrato_rate = sample.vibrato_rate; patch->vibrato_depth = sample.vibrato_depth; - patch->scale_frequency = sample.scale_frequency; - patch->scale_factor = sample.scale_factor; + /* Not supported by OSS/Free 3.8 -- scaling is made by hand + * in playevents.c + */ + patch->scale_frequency = 60; /* sample.scale_frequency; */ + patch->scale_factor = 1024; /* sample.scale_factor; */ patch->volume = header.master_volume; diff -rud --new-file playmidi-2.3.orig/playevents.c playmidi-2.3/playevents.c --- playmidi-2.3.orig/playevents.c Sat Feb 24 11:00:00 1996 +++ playmidi-2.3/playevents.c Wed Feb 11 18:46:24 1998 @@ -38,6 +38,10 @@ extern void init_show(); extern int updatestatus(); +/* Added by claudio */ +extern int scale_factor[256]; +extern int scale_frequency[256]; + unsigned long int ticks, tempo; struct timeval start_time; @@ -81,8 +85,10 @@ unsigned char *data; double current = 0.0, dtime = 0.0; int use_dev, play_status, playing = 1; + int i, channel_pgm[16]; seq_reset(); + for (i = 16; i--; channel_pgm[i]=-1); init_show(); SEQ_START_TIMER(); load_sysex(sizeof(gm_reset), gm_reset, MIDI_SYSTEM_PREFIX); @@ -178,8 +184,16 @@ loaded = seq_set_patch(CHN, NOTE + 128); if (VEL && usevol[CHN]) VEL = usevol[CHN]; - if (loaded != -1) - seq_start_note(use_dev, CHN, NOTE, VEL); + if (loaded != -1) { + /* Must handle scale_frequency and scale_factor here + * OSS/Free 3.8 does not recognize them --claudio + */ + int p = ISPERC(CHN) ? NOTE + 128 : channel_pgm[CHN]; + int n = p < 0 || !ISPERC(CHN) ? NOTE : + (scale_frequency[p] * 1024 + + scale_factor[p] * (NOTE - 60)) / 1024; + seq_start_note(use_dev, CHN, n, VEL); + } break; case MIDI_NOTEOFF: seq_stop_note(use_dev, CHN, NOTE, VEL); @@ -195,7 +209,7 @@ break; case MIDI_PGM_CHANGE: if (ISMIDI(CHN) || !ISPERC(CHN)) - NOTE = seq_set_patch(CHN, NOTE); + channel_pgm[CHN] = NOTE = seq_set_patch(CHN, NOTE); break; case MIDI_SYSTEM_PREFIX: if (length > 1) diff -rud --new-file playmidi-2.3.orig/playmidi.c playmidi-2.3/playmidi.c --- playmidi-2.3.orig/playmidi.c Sat Feb 24 11:00:00 1996 +++ playmidi-2.3/playmidi.c Wed Feb 11 17:44:07 1998 @@ -56,6 +56,10 @@ extern void setup_show(int, char **); extern void close_show(int); +/* Added by claudio */ +int scale_factor[256]; +int scale_frequency[256]; + struct synth_info card_info[MAX_CARDS]; void synth_setup() {