Compiler works again.
[ahxm.git] / instrument.h
blob37d6e84378e3ce06167a602d651b0cafe512d895
1 /*
3 Ann Hell Ex Machina - Music Software
4 Copyright (C) 2003 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
24 #define NUM_NOTES 128
25 #define VALID_NOTE(n) ((n) >= 0 && (n) < NUM_NOTES)
27 #define LAY_PER_INSTR 32
28 #define GEN_PER_INSTR 32
30 struct layer
32 int base_note; /* base note */
33 int min_note; /* minimum note */
34 int max_note; /* maximum note */
36 int n_channels; /* # of channels */
37 float * wave[CHANNELS]; /* the PCM waves */
39 double size; /* size in samples */
40 double loop_start; /* start of loop (-1, no loop) */
41 double loop_end; /* end of loop */
45 struct instrument
47 struct layer layers[LAY_PER_INSTR]; /* layers */
48 int n_layers; /* # of layers */
49 struct generator generators[GEN_PER_INSTR]; /* generators */
51 float vol[CHANNELS]; /* channel map */
52 int sustain; /* sustain */
54 int note_gen[NUM_NOTES]; /* generator / note index */
58 void build_note_frequencies(void);
60 void init_instrument(struct instrument * i);
62 int add_instrument_layer(struct instrument * i,
63 int base_note, int min_note, int max_note,
64 int n_channels, float * wave[],
65 double size, double loop_start, double loop_end);
67 void instrument_set_channel_map(struct instrument * i,
68 int n_channels, float vol[]);
69 void instrument_set_sustain(struct instrument * i, int sustain);
71 int instrument_play_note(struct instrument * i, int note, float vol);
72 int instrument_release_note(struct instrument * i, int note);
74 void generate_instrument(struct instrument * i, float sample[]);