Fixed a cosmetic bug in _add_measure_event().
[ahxm.git] / event.h
blobfe713fe8b377cc27462ab515d3580188beb98d9f
1 /*
3 Ann Hell Ex Machina - Music Software
4 Copyright (C) 2003/2004 Angel Ortega <angel@triptico.com>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 http://www.triptico.com
25 /* stage 1 events */
27 typedef enum
29 EV1_TEMPO,
30 EV1_METER,
31 EV1_MEASURE,
32 EV1_NOTE,
33 EV1_SS_SUSTAIN,
34 EV1_SS_CHANNEL_MAP,
35 EV1_END
36 } ev1_type;
38 struct ev1_generic
40 ev1_type type; /* event type */
41 double time; /* event time (1: whole note) */
42 int trk_id; /* track id */
45 struct ev1_note
47 ev1_type type; /* EV1_NOTE */
48 double time;
49 int trk_id;
50 int note; /* MIDI-like note */
51 double len; /* note length (1: whole note) */
52 double vol; /* note volume (1: full volume) */
55 struct ev1_tempo
57 ev1_type type; /* EV1_TEMPO */
58 double time;
59 int trk_id; /* always -1 */
60 double tempo; /* tempo in bpm */
63 struct ev1_meter
65 ev1_type type; /* EV1_METER */
66 double time;
67 int trk_id; /* always -1 */
68 int num; /* meter numerator */
69 int den; /* meter denominator */
72 struct ev1_sustain
74 ev1_type type; /* EV1_SS_SUSTAIN */
75 double time;
76 int trk_id;
77 int sustain; /* sustain time (in frames) */
80 struct ev1_channel_map
82 ev1_type type; /* EV1_SS_CHANNEL_MAP */
83 double time;
84 int trk_id;
85 float vol[CHANNELS]; /* volume for each channel */
88 union event1
90 struct ev1_generic generic;
91 struct ev1_note note;
92 struct ev1_tempo tempo;
93 struct ev1_meter meter;
94 struct ev1_sustain sustain;
95 struct ev1_channel_map channel_map;
98 extern union event1 * _events_1;
99 extern int _n_events_1;
101 /* stage 2 events */
103 typedef enum
105 EV2_NOTE_OFF,
106 EV2_SS_SUSTAIN,
107 EV2_SS_CHANNEL_MAP,
108 EV2_NOTE_ON,
109 EV2_DEBUG,
110 EV2_END
111 } ev2_type;
113 struct ev2_generic
115 ev2_type type; /* event type */
116 int frame; /* frame number (time) */
117 int trk_id; /* track id */
121 struct ev2_note_off
123 ev2_type type; /* EV2_NOTE_OFF */
124 int frame;
125 int trk_id;
126 int note_id; /* note id */
129 struct ev2_note_on
131 ev2_type type; /* EV2_NOTE_ON */
132 int frame;
133 int trk_id;
134 int note_id; /* note id */
135 int note; /* MIDI-like note number */
136 double vol; /* volume */
139 struct ev2_sustain
141 ev2_type type; /* EV2_SS_SUSTAIN */
142 int frame;
143 int trk_id;
144 int sustain; /* sustain time (in frames) */
147 struct ev2_channel_map
149 ev2_type type; /* EV2_SS_CHANNEL_MAP */
150 int frame;
151 int trk_id;
152 float vol[CHANNELS]; /* volumes for each channel */
156 union event2
158 struct ev2_generic generic;
159 struct ev2_note_on note_on;
160 struct ev2_note_off note_off;
161 struct ev2_sustain sustain;
162 struct ev2_channel_map channel_map;
165 extern union event2 * _events_2;
166 extern int _n_events_2;
169 void event1_clear(void);
170 void new_event1(union event1 * ev);
171 void event1_sort(void);
173 void event2_clear(void);
174 void new_event2(union event2 * ev);
175 void event2_sort(void);
177 void event1_to_event2(void);