1 #pragma once 2 3 namespace Timidity 4 { 5 /* 6 mix.h 7 */ 8 9 extern void mix_voice(struct Renderer *song, float *buf, struct Voice *v, int c); 10 extern int recompute_envelope(struct Voice *v); 11 extern void apply_envelope_to_amp(struct Voice *v); 12 13 /* 14 playmidi.h 15 */ 16 17 /* Midi events */ 18 enum 19 { 20 ME_NOTEOFF = 0x80, 21 ME_NOTEON = 0x90, 22 ME_KEYPRESSURE = 0xA0, 23 ME_CONTROLCHANGE = 0xB0, 24 ME_PROGRAM = 0xC0, 25 ME_CHANNELPRESSURE = 0xD0, 26 ME_PITCHWHEEL = 0xE0 27 }; 28 29 /* Controllers */ 30 enum 31 { 32 CTRL_BANK_SELECT = 0, 33 CTRL_DATA_ENTRY = 6, 34 CTRL_VOLUME = 7, 35 CTRL_PAN = 10, 36 CTRL_EXPRESSION = 11, 37 CTRL_SUSTAIN = 64, 38 CTRL_HARMONICCONTENT = 71, 39 CTRL_RELEASETIME = 72, 40 CTRL_ATTACKTIME = 73, 41 CTRL_BRIGHTNESS = 74, 42 CTRL_REVERBERATION = 91, 43 CTRL_CHORUSDEPTH = 93, 44 CTRL_NRPN_LSB = 98, 45 CTRL_NRPN_MSB = 99, 46 CTRL_RPN_LSB = 100, 47 CTRL_RPN_MSB = 101, 48 CTRL_ALL_SOUNDS_OFF = 120, 49 CTRL_RESET_CONTROLLERS = 121, 50 CTRL_ALL_NOTES_OFF = 123 51 }; 52 53 /* RPNs */ 54 enum 55 { 56 RPN_PITCH_SENS = 0x0000, 57 RPN_FINE_TUNING = 0x0001, 58 RPN_COARSE_TUNING = 0x0002, 59 RPN_RESET = 0x3fff 60 }; 61 62 63 /* Causes the instrument's default panning to be used. */ 64 #define NO_PANNING -1 65 66 67 /* Voice status options: */ 68 enum 69 { 70 VOICE_RUNNING = (1<<0), 71 VOICE_SUSTAINING = (1<<1), 72 VOICE_RELEASING = (1<<2), 73 VOICE_STOPPING = (1<<3), 74 75 VOICE_LPE = (1<<4), 76 NOTE_SUSTAIN = (1<<5), 77 }; 78 79 /* Envelope stages: */ 80 enum 81 { 82 GF1_ATTACK, 83 GF1_HOLD, 84 GF1_DECAY, 85 GF1_RELEASE, 86 GF1_RELEASEB, 87 GF1_RELEASEC 88 }; 89 90 enum 91 { 92 SF2_DELAY, 93 SF2_ATTACK, 94 SF2_HOLD, 95 SF2_DECAY, 96 SF2_SUSTAIN, 97 SF2_RELEASE, 98 SF2_FINISHED 99 }; 100 101 #define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c)))) 102 103 /* 104 resample.h 105 */ 106 107 extern sample_t *resample_voice(struct Renderer *song, Voice *v, int *countptr); 108 extern void pre_resample(struct Renderer *song, Sample *sp); 109 110 /* 111 tables.h 112 */ 113 114 const double log_of_2 = 0.69314718055994529; 115 116 #define sine(x) (sin((2*PI/1024.0) * (x))) 117 118 #define note_to_freq(x) (float(8175.7989473096690661233836992789 * pow(2.0, (x) / 12.0))) 119 #define freq_to_note(x) (log((x) / 8175.7989473096690661233836992789) * (12.0 / log_of_2)) 120 121 #define calc_gf1_amp(x) (pow(2.0,((x)*16.0 - 16.0))) // Actual GUS equation 122 } 123