Merged annhell-branch-float into trunk.
[ahxm.git] / instrument.h
blobe991d27dd4e9c4e86d9623533293b9c74f119b47
1 /*
3 PROGRAM_NAME PROGRAM_VERSION - PROGRAM_DESCRIPTION
5 Copyright (C) 2003 Angel Ortega <angel@triptico.com>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 http://www.triptico.com
25 #define NUM_NOTES 128
26 #define VALID_NOTE(n) ((n) >= 0 && (n) < NUM_NOTES)
28 #define LAYERS_PER_INSTR 32
29 #define GENERATORS_PER_INSTR 32
31 struct layer
33 int base_note; /* base note */
34 int min_note; /* minimum note */
35 int max_note; /* maximum note */
36 float * lwave; /* left channel wave */
37 float * rwave; /* right channel wave */
38 int size; /* size in samples */
39 int loop_start; /* start of loop (-1, no loop) */
40 int loop_end; /* end of loop */
41 int sustain; /* sustain in samples */
45 struct instrument
47 struct layer layers[LAYERS_PER_INSTR]; /* layers */
48 int n_layers; /* # of layers */
49 struct generator generators[GENERATORS_PER_INSTR]; /* generators */
51 int note_gen[NUM_NOTES]; /* generator for note */
55 void build_note_frequencies(void);
57 void init_instrument(struct instrument * i);
59 int add_instrument_layer(struct instrument * i, int base_note,
60 int min_note, int max_note, float * lwave, float * rwave,
61 int size, int loop_start, int loop_end, int sustain);
63 int instrument_play_note(struct instrument * i, int note, float lvol, float rvol);
64 int instrument_release_note(struct instrument * i, int note);
66 void generate_instrument(struct instrument * i, float * lsample, float * rsample);