Mercurial > audlegacy-plugins
comparison src/Input/timidity/libtimidity/timidity_internal.h @ 0:13389e613d67 trunk
[svn] - initial import of audacious-plugins tree (lots to do)
| author | nenolod |
|---|---|
| date | Mon, 18 Sep 2006 01:11:49 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:13389e613d67 |
|---|---|
| 1 #ifndef TIMIDITY_INTERNAL_H | |
| 2 #define TIMIDITY_INTERNAL_H | |
| 3 | |
| 4 #include "timidity.h" | |
| 5 | |
| 6 #if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \ | |
| 7 (defined(__alpha__) || defined(__alpha)) || \ | |
| 8 defined(__arm__) || \ | |
| 9 (defined(__mips__) && defined(__MIPSEL__)) || \ | |
| 10 defined(__SYMBIAN32__) || \ | |
| 11 defined(__x86_64__) || \ | |
| 12 defined(__LITTLE_ENDIAN__) | |
| 13 #ifndef LITTLE_ENDIAN | |
| 14 #define LITTLE_ENDIAN | |
| 15 #endif | |
| 16 #undef BIG_ENDIAN | |
| 17 #else | |
| 18 #ifndef BIG_ENDIAN | |
| 19 #define BIG_ENDIAN | |
| 20 #endif | |
| 21 #undef LITTLE_ENDIAN | |
| 22 #endif | |
| 23 | |
| 24 /* Instrument files are little-endian, MIDI files big-endian, so we | |
| 25 need to do some conversions. */ | |
| 26 | |
| 27 #define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) | |
| 28 #ifdef __i486__ | |
| 29 # define XCHG_LONG(x) \ | |
| 30 ({ sint32 __value; \ | |
| 31 asm ("bswap %1; movl %1,%0" : "=g" (__value) : "r" (x)); \ | |
| 32 __value; }) | |
| 33 #else | |
| 34 # define XCHG_LONG(x) ((((x)&0xFF)<<24) | \ | |
| 35 (((x)&0xFF00)<<8) | \ | |
| 36 (((x)&0xFF0000)>>8) | \ | |
| 37 (((x)>>24)&0xFF)) | |
| 38 #endif | |
| 39 | |
| 40 #ifdef LITTLE_ENDIAN | |
| 41 #define SWAPLE16(x) x | |
| 42 #define SWAPLE32(x) x | |
| 43 #define SWAPBE16(x) XCHG_SHORT(x) | |
| 44 #define SWAPBE32(x) XCHG_LONG(x) | |
| 45 #else | |
| 46 #define SWAPBE16(x) x | |
| 47 #define SWAPBE32(x) x | |
| 48 #define SWAPLE16(x) XCHG_SHORT(x) | |
| 49 #define SWAPLE32(x) XCHG_LONG(x) | |
| 50 #endif | |
| 51 | |
| 52 #ifdef DEBUG | |
| 53 #define DEBUG_MSG(...) fprintf(stderr, __VA_ARGS__) | |
| 54 #else | |
| 55 #define DEBUG_MSG(...) | |
| 56 #endif | |
| 57 | |
| 58 | |
| 59 #define MID_VIBRATO_SAMPLE_INCREMENTS 32 | |
| 60 | |
| 61 /* Maximum polyphony. */ | |
| 62 #define MID_MAX_VOICES 48 | |
| 63 | |
| 64 typedef sint16 sample_t; | |
| 65 typedef sint32 final_volume_t; | |
| 66 | |
| 67 typedef struct _MidSample MidSample; | |
| 68 struct _MidSample | |
| 69 { | |
| 70 sint32 | |
| 71 loop_start, loop_end, data_length, | |
| 72 sample_rate, low_vel, high_vel, low_freq, high_freq, root_freq; | |
| 73 sint32 envelope_rate[6], envelope_offset[6]; | |
| 74 float volume; | |
| 75 sample_t *data; | |
| 76 sint32 | |
| 77 tremolo_sweep_increment, tremolo_phase_increment, | |
| 78 vibrato_sweep_increment, vibrato_control_ratio; | |
| 79 uint8 tremolo_depth, vibrato_depth, modes; | |
| 80 sint8 panning, note_to_use; | |
| 81 }; | |
| 82 | |
| 83 typedef struct _MidChannel MidChannel; | |
| 84 struct _MidChannel | |
| 85 { | |
| 86 int bank, program, volume, sustain, panning, pitchbend, expression; | |
| 87 int mono; /* one note only on this channel -- not implemented yet */ | |
| 88 int pitchsens; | |
| 89 /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar | |
| 90 processor near you */ | |
| 91 float pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ | |
| 92 }; | |
| 93 | |
| 94 typedef struct _MidVoice MidVoice; | |
| 95 struct _MidVoice | |
| 96 { | |
| 97 uint8 status, channel, note, velocity; | |
| 98 MidSample *sample; | |
| 99 sint32 | |
| 100 orig_frequency, frequency, | |
| 101 sample_offset, sample_increment, | |
| 102 envelope_volume, envelope_target, envelope_increment, | |
| 103 tremolo_sweep, tremolo_sweep_position, | |
| 104 tremolo_phase, tremolo_phase_increment, | |
| 105 vibrato_sweep, vibrato_sweep_position; | |
| 106 | |
| 107 final_volume_t left_mix, right_mix; | |
| 108 | |
| 109 float left_amp, right_amp, tremolo_volume; | |
| 110 sint32 vibrato_sample_increment[MID_VIBRATO_SAMPLE_INCREMENTS]; | |
| 111 int | |
| 112 vibrato_phase, vibrato_control_ratio, vibrato_control_counter, | |
| 113 envelope_stage, control_counter, panning, panned; | |
| 114 | |
| 115 }; | |
| 116 | |
| 117 typedef struct _MidInstrument MidInstrument; | |
| 118 struct _MidInstrument | |
| 119 { | |
| 120 int samples; | |
| 121 MidSample *sample; | |
| 122 }; | |
| 123 | |
| 124 typedef struct _MidToneBankElement MidToneBankElement; | |
| 125 struct _MidToneBankElement | |
| 126 { | |
| 127 char *name; | |
| 128 int note, amp, pan, strip_loop, strip_envelope, strip_tail; | |
| 129 }; | |
| 130 | |
| 131 typedef struct _MidToneBank MidToneBank; | |
| 132 struct _MidToneBank | |
| 133 { | |
| 134 MidToneBankElement *tone; | |
| 135 MidInstrument *instrument[128]; | |
| 136 }; | |
| 137 | |
| 138 typedef struct _MidEvent MidEvent; | |
| 139 struct _MidEvent | |
| 140 { | |
| 141 sint32 time; | |
| 142 uint8 channel, type, a, b; | |
| 143 }; | |
| 144 | |
| 145 typedef struct _MidEventList MidEventList; | |
| 146 struct _MidEventList | |
| 147 { | |
| 148 MidEvent event; | |
| 149 void *next; | |
| 150 }; | |
| 151 | |
| 152 struct _MidSong | |
| 153 { | |
| 154 int playing; | |
| 155 sint32 rate; | |
| 156 sint32 encoding; | |
| 157 int bytes_per_sample; | |
| 158 float master_volume; | |
| 159 sint32 amplification; | |
| 160 MidDLSPatches *patches; | |
| 161 MidToneBank *tonebank[128]; | |
| 162 MidToneBank *drumset[128]; | |
| 163 MidInstrument *default_instrument; | |
| 164 int default_program; | |
| 165 void (*write) (void *dp, sint32 * lp, sint32 c); | |
| 166 int buffer_size; | |
| 167 sample_t *resample_buffer; | |
| 168 sint32 *common_buffer; | |
| 169 /* These would both fit into 32 bits, but they are often added in | |
| 170 large multiples, so it's simpler to have two roomy ints */ | |
| 171 /* samples per MIDI delta-t */ | |
| 172 sint32 sample_increment; | |
| 173 sint32 sample_correction; | |
| 174 MidChannel channel[16]; | |
| 175 MidVoice voice[MID_MAX_VOICES]; | |
| 176 int voices; | |
| 177 sint32 drumchannels; | |
| 178 sint32 control_ratio; | |
| 179 sint32 lost_notes; | |
| 180 sint32 cut_notes; | |
| 181 sint32 samples; | |
| 182 MidEvent *events; | |
| 183 MidEvent *current_event; | |
| 184 MidEventList *evlist; | |
| 185 sint32 current_sample; | |
| 186 sint32 event_count; | |
| 187 sint32 at; | |
| 188 sint32 groomed_event_count; | |
| 189 char *meta_data[8]; | |
| 190 }; | |
| 191 | |
| 192 #endif /* TIMIDITY_INTERNAL_H */ |
