Mercurial > SDL_sound_CoreAudio
annotate decoders/timidity/timidity.h @ 591:8faf61a640f0 tip
Resynced fixes for unit conversion bugs in the Ogg Tremor decoder from SoundDecoder/ALmixer.
Ogg Vorbis uses seconds and we multiply by 1000 to convert to milliseconds. But Ogg Tremor already uses milliseconds but I was still multiplying by 1000.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Thu, 25 Oct 2012 16:34:18 -0700 |
parents | c66080364dff |
children |
rev | line source |
---|---|
199 | 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 | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
22 #ifndef TIMIDITY_H |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
23 #define TIMIDITY_H |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
24 #ifdef __cplusplus |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
25 extern "C" { |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
26 #endif |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
27 |
199 | 28 typedef Sint16 sample_t; |
29 typedef Sint32 final_volume_t; | |
30 | |
31 #define VIBRATO_SAMPLE_INCREMENTS 32 | |
32 | |
33 /* Maximum polyphony. */ | |
34 #define MAX_VOICES 48 | |
35 | |
36 typedef struct { | |
37 Sint32 | |
38 loop_start, loop_end, data_length, | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
39 sample_rate, low_vel, high_vel, low_freq, high_freq, root_freq; |
199 | 40 Sint32 |
41 envelope_rate[6], envelope_offset[6]; | |
42 float | |
43 volume; | |
44 sample_t *data; | |
45 Sint32 | |
46 tremolo_sweep_increment, tremolo_phase_increment, | |
47 vibrato_sweep_increment, vibrato_control_ratio; | |
48 Uint8 | |
49 tremolo_depth, vibrato_depth, | |
50 modes; | |
51 Sint8 | |
52 panning, note_to_use; | |
53 } Sample; | |
54 | |
55 typedef struct { | |
56 int | |
57 bank, program, volume, sustain, panning, pitchbend, expression, | |
58 mono, /* one note only on this channel -- not implemented yet */ | |
59 pitchsens; | |
60 /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar | |
61 processor near you */ | |
62 float | |
63 pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ | |
64 } Channel; | |
65 | |
66 typedef struct { | |
67 Uint8 | |
68 status, channel, note, velocity; | |
69 Sample *sample; | |
70 Sint32 | |
71 orig_frequency, frequency, | |
72 sample_offset, sample_increment, | |
73 envelope_volume, envelope_target, envelope_increment, | |
74 tremolo_sweep, tremolo_sweep_position, | |
75 tremolo_phase, tremolo_phase_increment, | |
76 vibrato_sweep, vibrato_sweep_position; | |
77 | |
78 final_volume_t left_mix, right_mix; | |
79 | |
80 float | |
81 left_amp, right_amp, tremolo_volume; | |
82 Sint32 | |
83 vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; | |
84 int | |
85 vibrato_phase, vibrato_control_ratio, vibrato_control_counter, | |
86 envelope_stage, control_counter, panning, panned; | |
87 | |
88 } Voice; | |
89 | |
90 typedef struct { | |
91 int samples; | |
92 Sample *sample; | |
93 } Instrument; | |
94 | |
95 /* Shared data */ | |
96 typedef struct { | |
97 char *name; | |
98 int note, amp, pan, strip_loop, strip_envelope, strip_tail; | |
99 } ToneBankElement; | |
100 | |
101 typedef struct { | |
102 ToneBankElement *tone; | |
103 Instrument *instrument[128]; | |
104 } ToneBank; | |
105 | |
106 typedef struct { | |
107 Sint32 time; | |
108 Uint8 channel, type, a, b; | |
109 } MidiEvent; | |
110 | |
111 typedef struct { | |
112 MidiEvent event; | |
113 void *next; | |
114 } MidiEventList; | |
115 | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
116 struct _DLS_Data; |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
117 typedef struct _DLS_Data DLS_Patches; |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
118 |
199 | 119 typedef struct { |
120 int playing; | |
121 SDL_RWops *rw; | |
122 Sint32 rate; | |
123 Sint32 encoding; | |
124 float master_volume; | |
125 Sint32 amplification; | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
126 DLS_Patches *patches; |
199 | 127 ToneBank *tonebank[128]; |
128 ToneBank *drumset[128]; | |
129 Instrument *default_instrument; | |
130 int default_program; | |
131 void (*write)(void *dp, Sint32 *lp, Sint32 c); | |
132 int buffer_size; | |
133 sample_t *resample_buffer; | |
134 Sint32 *common_buffer; | |
135 Sint32 *buffer_pointer; | |
136 /* These would both fit into 32 bits, but they are often added in | |
137 large multiples, so it's simpler to have two roomy ints */ | |
138 /* samples per MIDI delta-t */ | |
139 Sint32 sample_increment; | |
140 Sint32 sample_correction; | |
141 Channel channel[16]; | |
142 Voice voice[MAX_VOICES]; | |
143 int voices; | |
144 Sint32 drumchannels; | |
145 Sint32 buffered_count; | |
146 Sint32 control_ratio; | |
147 Sint32 lost_notes; | |
148 Sint32 cut_notes; | |
149 Sint32 samples; | |
150 MidiEvent *events; | |
151 MidiEvent *current_event; | |
152 MidiEventList *evlist; | |
153 Sint32 current_sample; | |
154 Sint32 event_count; | |
155 Sint32 at; | |
474
c66080364dff
Most decoders now report total sample play time, now. Technically, this
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
156 Sint32 groomed_event_count; |
199 | 157 } MidiSong; |
158 | |
159 /* Some of these are not defined in timidity.c but are here for convenience */ | |
160 | |
161 extern int Timidity_Init(void); | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
162 extern int Timidity_Init_NoConfig(void); |
199 | 163 extern void Timidity_SetVolume(MidiSong *song, int volume); |
164 extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len); | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
165 extern DLS_Patches *Timidity_LoadDLS(SDL_RWops *rw); |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
166 extern void Timidity_FreeDLS(DLS_Patches *patches); |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
167 extern MidiSong *Timidity_LoadDLSSong(SDL_RWops *rw, DLS_Patches *patches, SDL_AudioSpec *audio); |
199 | 168 extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio); |
169 extern void Timidity_Start(MidiSong *song); | |
312 | 170 extern void Timidity_Seek(MidiSong *song, Uint32 ms); |
474
c66080364dff
Most decoders now report total sample play time, now. Technically, this
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
171 extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */ |
199 | 172 extern void Timidity_FreeSong(MidiSong *song); |
173 extern void Timidity_Exit(void); | |
455
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
174 |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
175 #ifdef __cplusplus |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
176 } |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
177 #endif |
cbc2a4ffeeec
* Added support for loading DLS format instruments:
hercules
parents:
312
diff
changeset
|
178 #endif /* TIMIDITY_H */ |