diff -cNr timidity-2.11.2.org/timidity/mix.c timidity-2.11.2-k2/timidity/mix.c *** timidity-2.11.2.org/timidity/mix.c Wed Jan 9 19:16:49 2002 --- timidity-2.11.2-k2/timidity/mix.c Mon Dec 30 20:55:40 2002 *************** *** 197,202 **** --- 197,203 ---- return 0; } + #ifndef NO_FPU int apply_envelope_to_amp(int v) { FLOAT_T lamp=voice[v].left_amp, ramp; *************** *** 265,270 **** --- 266,345 ---- } 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) { *************** *** 304,315 **** /* if (voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<> RATE_SHIFT) + 1.0) * depth * TREMOLO_AMPLITUDE_TUNING, 17); /* I'm not sure about the +1.0 there -- it makes tremoloed voices' volumes on average the lower the higher the tremolo amplitude. */ } --- 379,396 ---- /* 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 -cNr timidity-2.11.2.org/timidity/playmidi.c timidity-2.11.2-k2/timidity/playmidi.c *** timidity-2.11.2.org/timidity/playmidi.c Sat Jan 12 18:57:44 2002 --- timidity-2.11.2-k2/timidity/playmidi.c Mon Dec 30 20:55:40 2002 *************** *** 620,625 **** --- 620,626 ---- #endif /* ABORT_AT_FATAL */ } + #ifndef NO_FPU static void recompute_amp(int v) { FLOAT_T tempamp; *************** *** 669,674 **** --- 670,720 ---- 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 -cNr timidity-2.11.2.org/timidity/playmidi.h timidity-2.11.2-k2/timidity/playmidi.h *** timidity-2.11.2.org/timidity/playmidi.h Wed Jan 9 19:14:27 2002 --- timidity-2.11.2-k2/timidity/playmidi.h Mon Dec 30 20:57:39 2002 *************** *** 268,275 **** --- 268,280 ---- left_mix_inc, right_mix_inc; #endif + #ifdef NO_FPU FLOAT_T + #else + int32 + #endif left_amp, right_amp, tremolo_volume; + int32 vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS], vibrato_delay; int diff -cNr timidity-2.11.2.org/timidity/reverb.c timidity-2.11.2-k2/timidity/reverb.c *** timidity-2.11.2.org/timidity/reverb.c Wed Jan 9 19:14:00 2002 --- timidity-2.11.2-k2/timidity/reverb.c Mon Dec 30 20:55:40 2002 *************** *** 123,129 **** --- 123,133 ---- { 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,137 **** --- 136,157 ---- } } + #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,144 **** --- 159,209 ---- 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,185 **** --- 245,251 ---- direct_buffer[i] = 0; rev_ptinc(); + #endif /* NO_FPU */ } } Binary files timidity-2.11.2.org/timidity/timidity and timidity-2.11.2-k2/timidity/timidity differ diff -cNr timidity-2.11.2.org/timidity/timidity.c timidity-2.11.2-k2/timidity/timidity.c *** timidity-2.11.2.org/timidity/timidity.c Wed Jan 9 19:21:17 2002 --- timidity-2.11.2-k2/timidity/timidity.c Mon Dec 30 21:50:34 2002 *************** *** 35,40 **** --- 35,42 ---- #endif #ifdef HAVE_UNISTD_H #include + #include + #include #endif /* HAVE_UNISTD_H */ #include /* for open */ #include *************** *** 105,110 **** --- 107,113 ---- *opt_aq_fill_buff = NULL; void timidity_init_aq_buff(void); int opt_control_ratio = 0; /* Save -C option */ + char* CONFIG_FILE; #ifdef IA_DYNAMIC MAIN_INTERFACE char dynamic_interface_id; *************** *** 2468,2474 **** #ifdef SUPPORT_SOUNDSPEC static double spectrogram_update_sec = 0.0; #endif /* SUPPORT_SOUNDSPEC */ ! int opt_buffer_fragments = -1; static int parse_opt_B(char *opt) { --- 2471,2477 ---- #ifdef SUPPORT_SOUNDSPEC static double spectrogram_update_sec = 0.0; #endif /* SUPPORT_SOUNDSPEC */ ! int opt_buffer_fragments = 20; static int parse_opt_B(char *opt) { *************** *** 2985,2992 **** #else /* UNIX */ ! if(!read_config_file(CONFIG_FILE, 0)) ! got_a_configuration = 1; #endif /* Try read configuration file which is in the --- 2988,3008 ---- #else /* UNIX */ ! { ! struct stat config_stat; ! if(! stat(CONFIG_FILE_FIRST, &config_stat)){ ! if(! read_config_file(CONFIG_FILE_FIRST, 0)){ ! got_a_configuration = 1; ! CONFIG_FILE = CONFIG_FILE_FIRST; ! } ! } ! if(! got_a_configuration){ ! if(!read_config_file(CONFIG_FILE_SECOND, 0)){ ! got_a_configuration = 1; ! CONFIG_FILE = CONFIG_FILE_SECOND; ! } ! } ! } #endif /* Try read configuration file which is in the *************** *** 3008,3015 **** cmderr = 0; if(!got_a_configuration) { ! if(try_config_again && !read_config_file(CONFIG_FILE, 0)) ! got_a_configuration = 1; } if(opt_config_string.nstring > 0) --- 3024,3049 ---- cmderr = 0; if(!got_a_configuration) { ! if(try_config_again){ ! if(CONFIG_FILE){ ! if(!read_config_file(CONFIG_FILE, 0)) ! got_a_configuration = 1; ! }else{ ! struct stat config_stat; ! if(! stat(CONFIG_FILE_FIRST, &config_stat)){ ! if(! read_config_file(CONFIG_FILE_FIRST, 0)){ ! got_a_configuration = 1; ! CONFIG_FILE = CONFIG_FILE_FIRST; ! } ! } ! if(! got_a_configuration){ ! if(!read_config_file(CONFIG_FILE_SECOND, 0)){ ! got_a_configuration = 1; ! CONFIG_FILE = CONFIG_FILE_SECOND; ! } ! } ! } ! } } if(opt_config_string.nstring > 0) *************** *** 3424,3432 **** "%s: Can't read any configuration file.\nPlease check " "%s or %s", program_name, config1, config2); #else ! ctl->cmsg(CMSG_FATAL, VERB_NORMAL, ! "%s: Can't read any configuration file.\nPlease check " ! CONFIG_FILE, program_name); #endif /* __W32__ */ } else --- 3458,3475 ---- "%s: Can't read any configuration file.\nPlease check " "%s or %s", program_name, config1, config2); #else ! if(CONFIG_FILE){ ! ctl->cmsg(CMSG_FATAL, VERB_NORMAL, ! "%s: Can't read any configuration file.\nPlease check %s", ! program_name, CONFIG_FILE); ! }else{ ! ctl->cmsg(CMSG_FATAL, VERB_NORMAL, ! "%s: Can't read any configuration file.\nPlease check " ! CONFIG_FILE_FIRST ! " or " ! CONFIG_FILE_SECOND, ! program_name); ! } #endif /* __W32__ */ } else diff -cNr timidity-2.11.2.org/timidity/timidity.h timidity-2.11.2-k2/timidity/timidity.h *** timidity-2.11.2.org/timidity/timidity.h Mon Dec 30 21:51:45 2002 --- timidity-2.11.2-k2/timidity/timidity.h Mon Dec 30 21:20:48 2002 *************** *** 38,43 **** --- 38,49 ---- #endif /* DEFAULT_PATH */ #endif /* CONFIG_FILE */ + #undef CONFIG_FILE + extern char* CONFIG_FILE; + #define CONFIG_FILE_FIRST "/etc/timidity.cfg" + #define CONFIG_FILE_SECOND "/home/QtPalmtop/etc/timidity.cfg" + + /* Filename extension, followed by command to run decompressor so that output is written to stdout. Terminate the list with a 0. *************** *** 92,97 **** --- 98,106 ---- 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,113 **** /* 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 #endif /* DEFAULT_RATE */ #define DEFAULT_VOICES 64 --- 116,122 ---- /* 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 22050 #endif /* DEFAULT_RATE */ #define DEFAULT_VOICES 64 *************** *** 131,143 **** */ ! #define AUDIO_BUFFER_BITS 12 /* Maxmum audio buffer size (2^bits) */ #ifndef DEFAULT_AUDIO_BUFFER_BITS #ifdef __W32__ #define DEFAULT_AUDIO_BUFFER_BITS 12 #else ! #define DEFAULT_AUDIO_BUFFER_BITS 11 #endif #endif --- 140,152 ---- */ ! #define AUDIO_BUFFER_BITS 13 /* Maxmum audio buffer size (2^bits) */ #ifndef DEFAULT_AUDIO_BUFFER_BITS #ifdef __W32__ #define DEFAULT_AUDIO_BUFFER_BITS 12 #else ! #define DEFAULT_AUDIO_BUFFER_BITS 12 #endif #endif *************** *** 231,237 **** /* 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 /* If calling ldexp() is faster than a floating point multiplication --- 240,246 ---- /* 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 */ /* If calling ldexp() is faster than a floating point multiplication