diff -uNr timidity-2.10.4/timidity/mix.c timidity-2.10.4-k1/timidity/mix.c --- timidity-2.10.4/timidity/mix.c Tue Mar 13 10:01:19 2001 +++ timidity-2.10.4-k1/timidity/mix.c Sun Dec 15 17:56:11 2002 @@ -161,6 +161,7 @@ return 0; } +#ifndef NO_FPU int apply_envelope_to_amp(int v) { FLOAT_T lamp=voice[v].left_amp, ramp; @@ -221,6 +222,80 @@ } return 0; } +#else /* NO_FPU */ +int apply_envelope_to_amp(int v) +{ + int32 lamp=voice[v].left_amp, ramp; + int32 la,ra; + if (voice[v].panned == PANNED_MYSTERY) + { + ramp=voice[v].right_amp; + if (voice[v].tremolo_phase_increment) + { + // lamp *= voice[v].tremolo_volume; + // ramp *= voice[v].tremolo_volume; + if(voice[v].tremolo_volume) { + lamp = lamp - (lamp << 9) / voice[v].tremolo_volume; + ramp = ramp - (ramp << 9) / voice[v].tremolo_volume; + } else { + lamp = ramp = 0; + } + } + if (voice[v].sample->modes & MODES_ENVELOPE) + { + lamp *= vol_table[voice[v].envelope_volume>>23]; + ramp *= vol_table[voice[v].envelope_volume>>23]; + } + + la = lamp >> (21 - AMP_BITS); /* 21 bit-shifted fixed real. */ + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + + ra = ramp >> (21 - AMP_BITS); + if (ra>MAX_AMP_VALUE) + ra=MAX_AMP_VALUE; + + if((voice[v].status & (VOICE_OFF | VOICE_SUSTAINED)) + && (la | ra) <= MIN_AMP_VALUE) + { + free_voice(v); + ctl_note_event(v); + return 1; + } + voice[v].left_mix=FINAL_VOLUME(la); + voice[v].right_mix=FINAL_VOLUME(ra); + } + else + { + if (voice[v].tremolo_phase_increment) { + // lamp *= voice[v].tremolo_volume; + if(voice[v].tremolo_volume) { + lamp = lamp - (lamp << 9) / voice[v].tremolo_volume; + } else { + lamp = 0; + } + } + if (voice[v].sample->modes & MODES_ENVELOPE) + lamp *= vol_table[voice[v].envelope_volume>>23]; + + la = lamp >> (21 - AMP_BITS); + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + if((voice[v].status & (VOICE_OFF | VOICE_SUSTAINED)) && + la <= MIN_AMP_VALUE) + { + free_voice(v); + ctl_note_event(v); + return 1; + } + voice[v].left_mix=FINAL_VOLUME(la); + + } + return 0; +} +#endif /* NO_FPU */ static inline int update_envelope(int v) { @@ -260,12 +335,18 @@ /* if (voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<> RATE_SHIFT) + 1.0) * depth * TREMOLO_AMPLITUDE_TUNING, 17); + /* fprintf(stderr, "tremolo vol: %4.5f\n", voice[v].tremolo_volume); */ + +#else + voice[v].tremolo_volume = ((512 << 17) / (depth * TREMOLO_AMPLITUDE_TUNING)) + / (lookup_sine(voice[v].tremolo_phase >> RATE_SHIFT) + 1.0); +#endif /* NO_FPU */ /* I'm not sure about the +1.0 there -- it makes tremoloed voices' volumes on average the lower the higher the tremolo amplitude. */ } diff -uNr timidity-2.10.4/timidity/playmidi.c timidity-2.10.4-k1/timidity/playmidi.c --- timidity-2.10.4/timidity/playmidi.c Tue Mar 13 10:28:28 2001 +++ timidity-2.10.4-k1/timidity/playmidi.c Sun Dec 15 17:59:00 2002 @@ -589,6 +589,7 @@ voice[v].sample_increment = (int32)a; } +#ifndef NO_FPU static void recompute_amp(int v) { FLOAT_T tempamp; @@ -631,6 +632,51 @@ voice[v].left_amp = TIM_FSCALENEG(tempamp, 21); } } +#else /* without FPU */ +static void recompute_amp(int v) +{ + int32 tempamp; + + tempamp = master_volume * + voice[v].velocity * + voice[v].sample->volume * + channel[voice[v].channel].volume * + channel[voice[v].channel].expression; /* 21 bits */ + + if(!(play_mode->encoding & PE_MONO)) + { + if(voice[v].panning > 60 && voice[v].panning < 68) + { + voice[v].panned = PANNED_CENTER; + // voice[v].left_amp = TIM_FSCALENEG(tempamp, 21); + voice[v].left_amp = tempamp; + } + else if (voice[v].panning < 5) + { + voice[v].panned = PANNED_LEFT; + voice[v].left_amp = tempamp << 1; + } + else if(voice[v].panning > 123) + { + voice[v].panned = PANNED_RIGHT; + /* left_amp will be used */ + voice[v].left_amp = tempamp << 1; + } + else + { + voice[v].panned = PANNED_MYSTERY; + voice[v].left_amp = tempamp >> 6; + voice[v].right_amp = voice[v].left_amp * voice[v].panning; + voice[v].left_amp *= 127 - voice[v].panning; + } + } + else + { + voice[v].panned = PANNED_CENTER; + voice[v].left_amp = tempamp; + } +} +#endif /* NO_FPU */ Instrument *play_midi_load_instrument(int dr, int bk, int prog) { diff -uNr timidity-2.10.4/timidity/playmidi.h timidity-2.10.4-k1/timidity/playmidi.h --- timidity-2.10.4/timidity/playmidi.h Tue Mar 13 10:01:19 2001 +++ timidity-2.10.4-k1/timidity/playmidi.h Sun Dec 15 18:00:21 2002 @@ -254,9 +254,13 @@ vibrato_sweep, vibrato_sweep_position; final_volume_t left_mix, right_mix; - +#ifdef NO_FPU FLOAT_T left_amp, right_amp, tremolo_volume; +#else + int32 + left_amp, right_amp, tremolo_volume; +#endif int32 vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS], vibrato_delay; int diff -uNr timidity-2.10.4/timidity/reverb.c timidity-2.10.4-k1/timidity/reverb.c --- timidity-2.10.4/timidity/reverb.c Tue Mar 13 10:01:19 2001 +++ timidity-2.10.4-k1/timidity/reverb.c Sun Dec 15 18:03:01 2002 @@ -123,7 +123,11 @@ { register int32 i; +#ifndef NO_FPU FLOAT_T send_level = (FLOAT_T)level * (REV_INP_LEV/127.0); +#else + int32 send_level = level / (127.0 / REV_INP_LEV); +#endif for(i = 0; i < n; i++) { @@ -132,6 +136,22 @@ } } +#ifdef NO_FPU + +#define REV_LOG_SCALE 3 +#define REV_SCALE (1 << REV_LOG_SCALE) +#define INT_REV_LPF_LEV ((int32 )(REV_LPF_LEV * REV_SCALE)) +#define INT_REV_LPF_INP ((int32 )(REV_LPF_INP * REV_SCALE)) +#define INT_REV_WIDTH ((int32 )(REV_WIDTH * REV_SCALE)) +#define INT_REV_FBK_LEV ((int32 )(REV_FBK_LEV * REV_SCALE)) +#define INT_REV_CMIX_LEV ((int32 )(REV_CMIX_LEV * REV_SCALE)) +#define INT_REV_EPF_LEV ((int32 )(REV_EPF_LEV * REV_SCALE)) +#define INT_REV_EPF_INP ((int32 )(REV_EPF_INP * REV_SCALE)) +#define INT_REV_INP_LEV ((int32 )(REV_INP_LEV * REV_SCALE)) +#define INT_REV_HPF_LEV ((int32 )(REV_HPF_LEV * REV_SCALE)) +#define INT_REV_HPF_INP ((int32 )(REV_HPF_INP * REV_SCALE)) + +#endif void do_ch_reverb(int32 *comp, int32 n) { @@ -139,6 +159,51 @@ for(i = 0; i < n; i++) { +#ifdef NO_FPU + /* L */ + fixp = effect_buffer[i]; + effect_buffer[i] = 0; + + LPFL = (LPFL*INT_REV_LPF_LEV + (buf2_L[spt2]+tb)*INT_REV_LPF_INP + ta*INT_REV_WIDTH) >> REV_LOG_SCALE; + ta = buf3_L[spt3]; + s = buf3_L[spt3] = buf0_L[spt0]; + buf0_L[spt0] = -LPFL; + + t = ((HPFL + fixp) * INT_REV_HPF_LEV) >> REV_LOG_SCALE; + HPFL = t - fixp; + + buf2_L[spt2] = (((s * REV_SCALE - fixp * INT_REV_FBK_LEV) >> REV_LOG_SCALE) * INT_REV_CMIX_LEV) >> REV_LOG_SCALE; + tb = buf1_L[spt1]; + buf1_L[spt1] = t; + + EPFL = (EPFL * INT_REV_EPF_LEV + ta * INT_REV_EPF_INP) >> REV_LOG_SCALE; + comp[i] = ta + EPFL + ((direct_buffer[i] * INT_REV_INP_LEV) >> REV_LOG_SCALE); + direct_buffer[i] = 0; + + /* R */ + fixp = effect_buffer[++i]; + effect_buffer[i] = 0; + + LPFR = (LPFR*INT_REV_LPF_LEV + (buf2_R[spt2]+tb)*INT_REV_LPF_INP + ta*INT_REV_WIDTH) >> REV_LOG_SCALE; + ta = buf3_R[spt3]; + s = buf3_R[spt3] = buf0_R[spt0]; + buf0_R[spt0] = LPFR; + + t = ((HPFR + fixp) * INT_REV_HPF_LEV) >> REV_LOG_SCALE; + HPFR = t - fixp; + + buf2_R[spt2] = ((s - (fixp * INT_REV_FBK_LEV) >> REV_LOG_SCALE) * INT_REV_CMIX_LEV) >> REV_LOG_SCALE; + tb = buf1_R[spt1]; + buf1_R[spt1] = t; + + EPFR = (EPFR * INT_REV_EPF_LEV + ta * INT_REV_EPF_INP) >> REV_LOG_SCALE; + comp[i] = ta + EPFR + ((direct_buffer[i] * INT_REV_INP_LEV) >> REV_LOG_SCALE); + direct_buffer[i] = 0; + + rev_ptinc(); + + +#else /* Original */ /* L */ fixp = effect_buffer[i]; effect_buffer[i] = 0; @@ -180,6 +245,7 @@ direct_buffer[i] = 0; rev_ptinc(); +#endif /* NO_FPU */ } } diff -uNr timidity-2.10.4/timidity/timidity.h timidity-2.10.4-k1/timidity/timidity.h --- timidity-2.10.4/timidity/timidity.h Sun Dec 15 17:33:56 2002 +++ timidity-2.10.4-k1/timidity/timidity.h Sun Dec 15 17:50:53 2002 @@ -92,6 +92,9 @@ typedef double FLOAT_T; /* typedef float FLOAT_T; */ +/* partially integral arithmetics */ +#define NO_FPU 1 + /* A somewhat arbitrary frequency range. The low end of this will sound terrible as no lowpass filtering is performed on most @@ -107,7 +110,7 @@ /* Default sampling rate, default polyphony, and maximum polyphony. All but the last can be overridden from the command line. */ #ifndef DEFAULT_RATE -#define DEFAULT_RATE 32000 +#define DEFAULT_RATE 22050 #endif /* DEFAULT_RATE */ #define DEFAULT_VOICES 64 @@ -131,7 +134,7 @@ */ -#define AUDIO_BUFFER_BITS 12 /* Maxmum audio buffer size (2^bits) */ +#define AUDIO_BUFFER_BITS 13 /* Maxmum audio buffer size (2^bits) */ #ifndef DEFAULT_AUDIO_BUFFER_BITS #ifdef __W32__ @@ -228,7 +231,7 @@ /* Shawn McHorse's resampling optimizations. These may not in fact be faster on your particular machine and compiler. You'll have to run a benchmark to find out. */ -#define PRECALC_LOOPS +/* #define PRECALC_LOOPS */ /* If calling ldexp() is faster than a floating point multiplication