diff -ruN timidity-0.2i/Makefile timidity-0.2i.pl1/Makefile --- timidity-0.2i/Makefile Sun May 26 18:26:46 1996 +++ timidity-0.2i.pl1/Makefile Wed Apr 29 09:24:01 1998 @@ -75,7 +75,6 @@ #SYSTEM += -DSUN -DSOLARIS -DAU_SUN #SYSEXTRAS += sun_a.c #EXTRAINCS += -I/usr/demo/SOUND/include -#EXTRALIBS += -L/usr/demo/SOUND/lib -laudio -lsocket ## Select the DEC MMS audio server #SYSTEM += -DDEC -DAU_DEC @@ -228,10 +227,10 @@ wav2pat: wav2pat.c $(CC) $(CFLAGS) -o wav2pat wav2pat.c -depends depend dep: - $(CC) $(CFLAGS) -MM $(CSRCS) $(OPTSRCS) $(TOOLSRCS) > depends - -include depends +#depends depend dep: +# $(CC) $(CFLAGS) -MM $(CSRCS) $(OPTSRCS) $(TOOLSRCS) > depends +# +#include depends ########### Installation targets diff -ruN timidity-0.2i/config.h timidity-0.2i.pl1/config.h --- timidity-0.2i/config.h Sat Jun 1 21:54:49 1996 +++ timidity-0.2i.pl1/config.h Wed Apr 29 09:01:32 1998 @@ -55,8 +55,8 @@ On the other hand, some files know that 16 is not a drum channel and try to play music on it. This is now a runtime option, so this isn't a critical choice anymore. */ -/*#define DEFAULT_DRUMCHANNELS (1<<9) */ -#define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15)) +#define DEFAULT_DRUMCHANNELS (1<<9) +/* #define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15)) */ /* A somewhat arbitrary frequency range. The low end of this will sound terrible as no lowpass filtering is performed on most @@ -287,8 +287,8 @@ #endif #ifdef USE_LDEXP -# define FSCALE(a,b) ldexp((a),(b)) -# define FSCALENEG(a,b) ldexp((a),-(b)) +# define FSCALE(a,b) ldexp((double)(a),(b)) +# define FSCALENEG(a,b) ldexp((double)(a),-(b)) #else # define FSCALE(a,b) ((a) * (double)(1<<(b))) # define FSCALENEG(a,b) ((a) * (1.0L / (double)(1<<(b)))) diff -ruN timidity-0.2i/controls.h timidity-0.2i.pl1/controls.h --- timidity-0.2i/controls.h Mon May 20 22:09:46 1996 +++ timidity-0.2i.pl1/controls.h Wed Apr 29 08:45:14 1998 @@ -75,7 +75,7 @@ void (*note)(int v); void (*master_volume)(int mv); - void (*program)(int channel, int val); /* val<0 means drum set -val */ + void (*program)(int channel, int val); void (*volume)(int channel, int val); void (*expression)(int channel, int val); void (*panning)(int channel, int val); diff -ruN timidity-0.2i/filter.c timidity-0.2i.pl1/filter.c --- timidity-0.2i/filter.c Mon May 20 22:09:46 1996 +++ timidity-0.2i.pl1/filter.c Wed Apr 29 08:54:49 1998 @@ -103,6 +103,10 @@ * Note that we simulate leading and trailing 0 at the border of the * data buffer */ + +/* This is quick hack for antialiasing filter's bug fix. */ +#define sample_t int16 + static void filter(sample_t *result,sample_t *data, int32 length,float coef[]) { int32 sample,i,sample_window; @@ -197,7 +201,7 @@ temp = safe_malloc(sp->data_length); memcpy(temp,sp->data,sp->data_length); - filter(sp->data,temp,sp->data_length/sizeof(sample_t),fir_symetric); + filter((int16 *)sp->data,temp,sp->data_length/sizeof(sample_t),fir_symetric); free(temp); } diff -ruN timidity-0.2i/getopt.c timidity-0.2i.pl1/getopt.c --- timidity-0.2i/getopt.c Mon May 20 23:24:14 1996 +++ timidity-0.2i.pl1/getopt.c Wed Apr 29 08:45:45 1998 @@ -129,8 +129,10 @@ return EOF; gopError: - optarg = NULL; - errno = EINVAL; + if (argc > optind) + optind++; + optarg = letP = NULL; + errno = EINVAL; if (opterr) perror ("get command line option"); return ('?'); diff -ruN timidity-0.2i/mix.c timidity-0.2i.pl1/mix.c --- timidity-0.2i/mix.c Mon May 20 22:09:46 1996 +++ timidity-0.2i.pl1/mix.c Wed Apr 29 08:48:48 1998 @@ -66,7 +66,9 @@ } voice[v].envelope_stage=stage+1; - if (voice[v].envelope_volume==voice[v].sample->envelope_offset[stage]) + if (voice[v].envelope_volume==voice[v].sample->envelope_offset[stage] || + (stage > 2 && voice[v].envelope_volume < + voice[v].sample->envelope_offset[stage])) return recompute_envelope(v); voice[v].envelope_target=voice[v].sample->envelope_offset[stage]; voice[v].envelope_increment = voice[v].sample->envelope_rate[stage]; @@ -520,7 +522,8 @@ if (c>=MAX_DIE_TIME) c=MAX_DIE_TIME; sp=resample_voice(v, &c); - ramp_out(sp, buf, v, c); + if(c > 0) + ramp_out(sp, buf, v, c); vp->status=VOICE_FREE; } else diff -ruN timidity-0.2i/motif_p.c timidity-0.2i.pl1/motif_p.c --- timidity-0.2i/motif_p.c Mon May 20 22:09:46 1996 +++ timidity-0.2i.pl1/motif_p.c Wed Apr 29 09:11:00 1998 @@ -142,12 +142,41 @@ str[slen]='\0'; /* Append a terminal 0 */ } -int pipe_read_ready() +#if defined(sgi) +#include +#endif + +#if defined(SOLARIS) +#include +#endif + +int pipe_read_ready(void) { +#if defined(sgi) + fd_set fds; + int cnt; + struct timeval timeout; + + FD_ZERO(&fds); + FD_SET(fpip_in, &fds); + timeout.tv_sec = timeout.tv_usec = 0; + if((cnt = select(fpip_in + 1, &fds, NULL, NULL, &timeout)) < 0) + { + perror("select"); + return -1; + } + + return cnt > 0 && FD_ISSET(fpip_in, &fds) != 0; +#else int num; - - ioctl(fpip_in,FIONREAD,&num); /* see how many chars in buffer. */ + + if(ioctl(fpip_in,FIONREAD,&num) < 0) /* see how many chars in buffer. */ + { + perror("ioctl: FIONREAD"); + return -1; + } return num; +#endif } void pipe_open() diff -ruN timidity-0.2i/playmidi.c timidity-0.2i.pl1/playmidi.c --- timidity-0.2i/playmidi.c Mon May 20 22:09:46 1996 +++ timidity-0.2i.pl1/playmidi.c Wed Apr 29 08:48:12 1998 @@ -969,8 +969,6 @@ /* else fall through */ case RC_QUIT: - play_mode->close_output(); - ctl->close(); return; } } diff -ruN timidity-0.2i/readmidi.c timidity-0.2i.pl1/readmidi.c --- timidity-0.2i/readmidi.c Mon May 20 22:09:47 1996 +++ timidity-0.2i.pl1/readmidi.c Wed Apr 29 09:06:38 1998 @@ -199,8 +199,7 @@ { case 7: control=ME_MAINVOLUME; break; case 10: control=ME_PAN; break; - case 11: control=ME_EXPRESSION; break; - case 64: control=ME_SUSTAIN; break; + case 64: control=ME_SUSTAIN; b = (b >= 64); break; case 120: control=ME_ALL_SOUNDS_OFF; break; case 121: control=ME_RESET_CONTROLLERS; break; case 123: control=ME_ALL_NOTES_OFF; break; @@ -213,11 +212,13 @@ warnings about undefined tone banks. */ case 0: control=ME_TONE_BANK; break; case 32: - if (b!=0) - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - "(Strange: tone bank change 0x20%02x)", b); - else - control=ME_TONE_BANK; + if (b!=0) + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + "(Strange: tone bank change 0x%02x)", b); +#if 0 /* `Bank Select LSB' is not worked at GS. Please ignore it. */ + else + control=ME_TONE_BANK; +#endif break; case 100: nrpn=0; rpn_msb[lastchan]=b; break; @@ -409,9 +410,6 @@ if (meep->event.type==ME_TEMPO) { - tempo= - meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; - compute_sample_increment(tempo, divisions); skip_this_event=1; } else if ((quietchannels & (1<event.channel))) @@ -504,6 +502,12 @@ st += samples_to_do; } else if (counting_time==1) counting_time=0; + if (meep->event.type==ME_TEMPO) + { + tempo= + meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; + compute_sample_increment(tempo, divisions); + } if (!skip_this_event) { /* Add the event to the list */ diff -ruN timidity-0.2i/resample.c timidity-0.2i.pl1/resample.c --- timidity-0.2i/resample.c Mon May 20 22:09:47 1996 +++ timidity-0.2i.pl1/resample.c Wed Apr 29 09:08:17 1998 @@ -46,14 +46,14 @@ v2=src[(ofs>>FRACTION_BITS)+1];\ *dest++ = v1 + (((v2-v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); # endif -# define INTERPVARS sample_t v1, v2 +# define INTERPVARS sample_t v1, v2; #else /* Earplugs recommended for maximum listening enjoyment */ # define RESAMPLATION *dest++=src[ofs>>FRACTION_BITS]; # define INTERPVARS #endif -#define FINALINTERP if (ofs == le) *dest++=src[ofs>>FRACTION_BITS]; +#define FINALINTERP if (ofs == le) *dest++=src[(ofs>>FRACTION_BITS)-1]/2; /* So it isn't interpolation. At least it's final. */ static sample_t resample_buffer[AUDIO_BUFFER_SIZE]; @@ -65,7 +65,7 @@ /* Play sample until end, then free the voice. */ - INTERPVARS; + INTERPVARS Voice *vp=&voice[v]; sample_t @@ -132,7 +132,7 @@ /* Play sample until end-of-loop, skip back and continue. */ - INTERPVARS; + INTERPVARS int32 ofs=vp->sample_offset, incr=vp->sample_increment, @@ -147,8 +147,7 @@ while (count) { - if (ofs >= le) - /* NOTE: Assumes that ll > incr and that incr > 0. */ + while (ofs >= le) ofs -= ll; /* Precalc how many times we should go through the loop */ i = (le - ofs) / incr + 1; @@ -180,7 +179,7 @@ static sample_t *rs_bidir(Voice *vp, int32 count) { - INTERPVARS; + INTERPVARS int32 ofs=vp->sample_offset, incr=vp->sample_increment, @@ -367,7 +366,7 @@ /* Play sample until end, then free the voice. */ - INTERPVARS; + INTERPVARS Voice *vp=&voice[v]; sample_t *dest=resample_buffer, @@ -414,7 +413,7 @@ /* Play sample until end-of-loop, skip back and continue. */ - INTERPVARS; + INTERPVARS int32 ofs=vp->sample_offset, incr=vp->sample_increment, @@ -434,7 +433,7 @@ while (count) { /* Hopefully the loop is longer than an increment */ - if(ofs >= le) + while(ofs >= le) ofs -= ll; /* Precalc how many times to go through the loop, taking the vibrato control ratio into account this time. */ @@ -483,7 +482,7 @@ static sample_t *rs_vib_bidir(Voice *vp, int32 count) { - INTERPVARS; + INTERPVARS int32 ofs=vp->sample_offset, incr=vp->sample_increment, @@ -681,8 +680,9 @@ { double a, xdiff; int32 incr, ofs, newlen, count; - int16 *newdata, *dest, *src = (int16 *) sp->data; - int16 v1, v2, v3, v4, *vptr; + int16 *newdata, *dest, *src = (int16 *) sp->data, *vptr; + int32 v, v1, v2, v3, v4, i; + static const char note_name[12][3] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" @@ -694,8 +694,8 @@ a = ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]) / ((double) (sp->root_freq) * play_mode->rate); - newlen = sp->data_length / a; - dest = newdata = safe_malloc(newlen >> (FRACTION_BITS - 1)); + newlen = (int32)(sp->data_length / a); + dest = newdata = safe_malloc((newlen >> (FRACTION_BITS - 1)) + 2); count = (newlen >> FRACTION_BITS) - 1; ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count; @@ -705,7 +705,8 @@ /* Since we're pre-processing and this doesn't have to be done in real-time, we go ahead and do the full sliding cubic interpolation. */ - while (--count) + count--; + for(i = 0; i < count; i++) { vptr = src + (ofs >> FRACTION_BITS); v1 = *(vptr - 1); @@ -713,8 +714,14 @@ v3 = *(vptr + 1); v4 = *(vptr + 2); xdiff = FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS); - *dest++ = v2 + (xdiff / 6.0) * (-2 * v1 - 3 * v2 + 6 * v3 - v4 + - xdiff * (3 * (v1 - 2 * v2 + v3) + xdiff * (-v1 + 3 * (v2 - v3) + v4))); + v = (int32)(v2 + (xdiff / 6.0) * (-2 * v1 - 3 * v2 + 6 * v3 - v4 + + xdiff * (3 * (v1 - 2 * v2 + v3) + xdiff * (-v1 + 3 * (v2 - v3) + v4)))); + if(v < -32768) + *dest++ = -32768; + else if(v > 32767) + *dest++ = 32767; + else + *dest++ = (int16)v; ofs += incr; } @@ -722,14 +729,16 @@ { v1 = src[ofs >> FRACTION_BITS]; v2 = src[(ofs >> FRACTION_BITS) + 1]; - *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + *dest++ = (int16)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS)); } else *dest++ = src[ofs >> FRACTION_BITS]; + *dest = *(dest - 1) / 2; + *dest = *(dest - 1) / 2; sp->data_length = newlen; - sp->loop_start = sp->loop_start / a; - sp->loop_end = sp->loop_end / a; + sp->loop_start = (int32)(sp->loop_start / a); + sp->loop_end = (int32)(sp->loop_end / a); free(sp->data); sp->data = (sample_t *) newdata; sp->sample_rate = 0; diff -ruN timidity-0.2i/timidity.c timidity-0.2i.pl1/timidity.c --- timidity-0.2i/timidity.c Wed May 22 04:16:20 1996 +++ timidity-0.2i.pl1/timidity.c Wed Apr 29 08:58:04 1998 @@ -324,9 +324,12 @@ } for (i=1; i0) + { switch(c) - { - case 'U': free_instruments_afterwards=1; break; + { case 'U': free_instruments_afterwards=1; break; case 'L': add_to_pathlist(optarg); try_config_again=1; break; case 'c': if (read_config_file(optarg)) cmderr++; @@ -662,6 +665,7 @@ default: cmderr++; break; } + if(cmderr) break; if (!got_a_configuration) { diff -ruN timidity-0.2i/tk_c.c timidity-0.2i.pl1/tk_c.c --- timidity-0.2i/tk_c.c Mon May 20 22:14:24 1996 +++ timidity-0.2i.pl1/tk_c.c Wed Apr 29 09:10:52 1998 @@ -474,11 +474,41 @@ } -static int pipe_read_ready() +#if defined(sgi) +#include +#endif + +#if defined(SOLARIS) +#include +#endif + +int pipe_read_ready(void) { +#if defined(sgi) + fd_set fds; + int cnt; + struct timeval timeout; + + FD_ZERO(&fds); + FD_SET(fpip_in, &fds); + timeout.tv_sec = timeout.tv_usec = 0; + if((cnt = select(fpip_in + 1, &fds, NULL, NULL, &timeout)) < 0) + { + perror("select"); + return -1; + } + + return cnt > 0 && FD_ISSET(fpip_in, &fds) != 0; +#else int num; - ioctl(fpip_in,FIONREAD,&num); /* see how many chars in buffer. */ + + if(ioctl(fpip_in,FIONREAD,&num) < 0) /* see how many chars in buffer. */ + { + perror("ioctl: FIONREAD"); + return -1; + } return num; +#endif } diff -ruN timidity-0.2i/wav2pat.c timidity-0.2i.pl1/wav2pat.c --- timidity-0.2i/wav2pat.c Mon May 20 22:09:47 1996 +++ timidity-0.2i.pl1/wav2pat.c Wed Apr 29 08:55:34 1998 @@ -240,8 +240,8 @@ /* hammer together something that looks like a GUS patch header */ #define pound(a) *point++=(a); -#define pounds(a) { *((int16 *)point)=LE_SHORT(a); point+=2; } -#define poundl(a) { *((int32 *)point)=LE_LONG(a); point+=4; } +#define pounds(a) { int16 x = LE_SHORT(a); memcpy(point, &x, 2); point+=2; } +#define poundl(a) { int32 x = LE_LONG(a); memcpy(point, &x, 4); point+=4; } #define bounce(a) point += a; memset(thing, 0, 335); diff -ruN timidity-0.2i/wave_a.c timidity-0.2i.pl1/wave_a.c --- timidity-0.2i/wave_a.c Mon May 20 22:10:15 1996 +++ timidity-0.2i.pl1/wave_a.c Wed Apr 29 08:49:35 1998 @@ -135,7 +135,9 @@ if ((dpm.encoding & (PE_MONO | PE_16BIT)) == PE_MONO) RIFFheader[32]='\001'; - else if (!(dpm.encoding & PE_MONO) || (dpm.encoding & PE_16BIT)) + else if (!(dpm.encoding & PE_MONO) && (dpm.encoding & PE_16BIT)) + RIFFheader[32]='\004'; + else RIFFheader[32]='\002'; if (!(dpm.encoding & PE_16BIT)) RIFFheader[34]='\010';