Skip to content

Latest commit

 

History

History
163 lines (142 loc) · 4.08 KB

timidity.h

File metadata and controls

163 lines (142 loc) · 4.08 KB
 
Oct 21, 1999
Oct 21, 1999
1
/*
Oct 18, 2017
Oct 18, 2017
2
Oct 21, 1999
Oct 21, 1999
3
4
5
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
Dec 31, 2011
Dec 31, 2011
6
7
This program is free software; you can redistribute it and/or modify
it under the terms of the Perl Artistic License, available in COPYING.
Oct 18, 2017
Oct 18, 2017
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
*/
#ifndef TIMIDITY_H
#define TIMIDITY_H
#ifdef __cplusplus
extern "C" {
#endif
typedef Sint16 sample_t;
typedef Sint32 final_volume_t;
#define VIBRATO_SAMPLE_INCREMENTS 32
/* Maximum polyphony. */
/* #define MAX_VOICES 48 */
#define MAX_VOICES 256
#define MAXCHAN 16
/* #define MAXCHAN 64 */
#define MAXBANK 128
typedef struct {
Sint32
loop_start, loop_end, data_length,
Oct 21, 2017
Oct 21, 2017
31
sample_rate, low_freq, high_freq, root_freq;
Oct 18, 2017
Oct 18, 2017
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Sint32
envelope_rate[6], envelope_offset[6];
float
volume;
sample_t *data;
Sint32
tremolo_sweep_increment, tremolo_phase_increment,
vibrato_sweep_increment, vibrato_control_ratio;
Uint8
tremolo_depth, vibrato_depth,
modes;
Sint8
panning, note_to_use;
} Sample;
typedef struct {
int
bank, program, volume, sustain, panning, pitchbend, expression,
mono, /* one note only on this channel -- not implemented yet */
pitchsens;
/* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
processor near you */
float
pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
} Channel;
typedef struct {
Uint8
status, channel, note, velocity;
Sample *sample;
Sint32
orig_frequency, frequency,
sample_offset, sample_increment,
envelope_volume, envelope_target, envelope_increment,
tremolo_sweep, tremolo_sweep_position,
tremolo_phase, tremolo_phase_increment,
vibrato_sweep, vibrato_sweep_position;
final_volume_t left_mix, right_mix;
float
left_amp, right_amp, tremolo_volume;
Sint32
vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
int
vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
envelope_stage, control_counter, panning, panned;
Oct 21, 1999
Oct 21, 1999
79
Oct 18, 2017
Oct 18, 2017
80
} Voice;
Oct 21, 1999
Oct 21, 1999
81
Oct 18, 2017
Oct 18, 2017
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
typedef struct {
int samples;
Sample *sample;
} Instrument;
/* Shared data */
typedef struct {
char *name;
int note, amp, pan, strip_loop, strip_envelope, strip_tail;
} ToneBankElement;
typedef struct {
ToneBankElement *tone;
Instrument *instrument[128];
} ToneBank;
typedef struct {
Sint32 time;
Uint8 channel, type, a, b;
} MidiEvent;
typedef struct {
MidiEvent event;
void *next;
} MidiEventList;
typedef struct {
int playing;
SDL_RWops *rw;
Sint32 rate;
Sint32 encoding;
float master_volume;
Sint32 amplification;
ToneBank *tonebank[MAXBANK];
ToneBank *drumset[MAXBANK];
Instrument *default_instrument;
int default_program;
void (*write)(void *dp, Sint32 *lp, Sint32 c);
int buffer_size;
sample_t *resample_buffer;
Sint32 *common_buffer;
Sint32 *buffer_pointer;
/* These would both fit into 32 bits, but they are often added in
large multiples, so it's simpler to have two roomy ints */
/* samples per MIDI delta-t */
Sint32 sample_increment;
Sint32 sample_correction;
Channel channel[MAXCHAN];
Voice voice[MAX_VOICES];
int voices;
Sint32 drumchannels;
Sint32 buffered_count;
Sint32 control_ratio;
Sint32 lost_notes;
Sint32 cut_notes;
Sint32 samples;
MidiEvent *events;
MidiEvent *current_event;
MidiEventList *evlist;
Sint32 current_sample;
Sint32 event_count;
Sint32 at;
Sint32 groomed_event_count;
} MidiSong;
/* Some of these are not defined in timidity.c but are here for convenience */
extern int Timidity_Init(void);
extern int Timidity_Init_NoConfig(void);
extern void Timidity_SetVolume(MidiSong *song, int volume);
extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len);
extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio);
Oct 21, 1999
Oct 21, 1999
154
extern void Timidity_Start(MidiSong *song);
Oct 18, 2017
Oct 18, 2017
155
156
extern void Timidity_Seek(MidiSong *song, Uint32 ms);
extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */
Oct 21, 1999
Oct 21, 1999
157
extern void Timidity_FreeSong(MidiSong *song);
Oct 18, 2017
Oct 18, 2017
158
159
160
161
162
163
extern void Timidity_Exit(void);
#ifdef __cplusplus
}
#endif
#endif /* TIMIDITY_H */