Mercurial > SDL_sound_CoreAudio
comparison decoders/timidity/timidity.h @ 199:2d887640d300
Initial add.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 04 Jan 2002 06:49:49 +0000 |
parents | |
children | 498240aa76f1 |
comparison
equal
deleted
inserted
replaced
198:f9a752f41ab6 | 199:2d887640d300 |
---|---|
1 /* | |
2 | |
3 TiMidity -- Experimental MIDI to WAVE converter | |
4 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi> | |
5 | |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2 of the License, or | |
9 (at your option) any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software | |
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | |
20 */ | |
21 | |
22 typedef Sint16 sample_t; | |
23 typedef Sint32 final_volume_t; | |
24 | |
25 #define VIBRATO_SAMPLE_INCREMENTS 32 | |
26 | |
27 /* Maximum polyphony. */ | |
28 #define MAX_VOICES 48 | |
29 | |
30 typedef struct { | |
31 Sint32 | |
32 loop_start, loop_end, data_length, | |
33 sample_rate, low_freq, high_freq, root_freq; | |
34 Sint32 | |
35 envelope_rate[6], envelope_offset[6]; | |
36 float | |
37 volume; | |
38 sample_t *data; | |
39 Sint32 | |
40 tremolo_sweep_increment, tremolo_phase_increment, | |
41 vibrato_sweep_increment, vibrato_control_ratio; | |
42 Uint8 | |
43 tremolo_depth, vibrato_depth, | |
44 modes; | |
45 Sint8 | |
46 panning, note_to_use; | |
47 } Sample; | |
48 | |
49 typedef struct { | |
50 int | |
51 bank, program, volume, sustain, panning, pitchbend, expression, | |
52 mono, /* one note only on this channel -- not implemented yet */ | |
53 pitchsens; | |
54 /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar | |
55 processor near you */ | |
56 float | |
57 pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ | |
58 } Channel; | |
59 | |
60 typedef struct { | |
61 Uint8 | |
62 status, channel, note, velocity; | |
63 Sample *sample; | |
64 Sint32 | |
65 orig_frequency, frequency, | |
66 sample_offset, sample_increment, | |
67 envelope_volume, envelope_target, envelope_increment, | |
68 tremolo_sweep, tremolo_sweep_position, | |
69 tremolo_phase, tremolo_phase_increment, | |
70 vibrato_sweep, vibrato_sweep_position; | |
71 | |
72 final_volume_t left_mix, right_mix; | |
73 | |
74 float | |
75 left_amp, right_amp, tremolo_volume; | |
76 Sint32 | |
77 vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; | |
78 int | |
79 vibrato_phase, vibrato_control_ratio, vibrato_control_counter, | |
80 envelope_stage, control_counter, panning, panned; | |
81 | |
82 } Voice; | |
83 | |
84 typedef struct { | |
85 int samples; | |
86 Sample *sample; | |
87 } Instrument; | |
88 | |
89 /* Shared data */ | |
90 typedef struct { | |
91 char *name; | |
92 int note, amp, pan, strip_loop, strip_envelope, strip_tail; | |
93 } ToneBankElement; | |
94 | |
95 typedef struct { | |
96 ToneBankElement *tone; | |
97 Instrument *instrument[128]; | |
98 } ToneBank; | |
99 | |
100 typedef struct { | |
101 Sint32 time; | |
102 Uint8 channel, type, a, b; | |
103 } MidiEvent; | |
104 | |
105 typedef struct { | |
106 MidiEvent event; | |
107 void *next; | |
108 } MidiEventList; | |
109 | |
110 typedef struct { | |
111 int playing; | |
112 SDL_RWops *rw; | |
113 Sint32 rate; | |
114 Sint32 encoding; | |
115 float master_volume; | |
116 Sint32 amplification; | |
117 ToneBank *tonebank[128]; | |
118 ToneBank *drumset[128]; | |
119 Instrument *default_instrument; | |
120 int default_program; | |
121 void (*write)(void *dp, Sint32 *lp, Sint32 c); | |
122 int buffer_size; | |
123 sample_t *resample_buffer; | |
124 Sint32 *common_buffer; | |
125 Sint32 *buffer_pointer; | |
126 /* These would both fit into 32 bits, but they are often added in | |
127 large multiples, so it's simpler to have two roomy ints */ | |
128 /* samples per MIDI delta-t */ | |
129 Sint32 sample_increment; | |
130 Sint32 sample_correction; | |
131 Channel channel[16]; | |
132 Voice voice[MAX_VOICES]; | |
133 int voices; | |
134 Sint32 drumchannels; | |
135 Sint32 buffered_count; | |
136 Sint32 control_ratio; | |
137 Sint32 lost_notes; | |
138 Sint32 cut_notes; | |
139 Sint32 samples; | |
140 MidiEvent *events; | |
141 MidiEvent *current_event; | |
142 MidiEventList *evlist; | |
143 Sint32 current_sample; | |
144 Sint32 event_count; | |
145 Sint32 at; | |
146 } MidiSong; | |
147 | |
148 /* Some of these are not defined in timidity.c but are here for convenience */ | |
149 | |
150 extern int Timidity_Init(void); | |
151 extern void Timidity_SetVolume(MidiSong *song, int volume); | |
152 extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len); | |
153 extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio); | |
154 extern void Timidity_Start(MidiSong *song); | |
155 extern void Timidity_FreeSong(MidiSong *song); | |
156 extern void Timidity_Exit(void); |