Added some comments.
[ahxm.git] / ss_gen.h
blob5f007de97f3a473f83feae14f3e9455c4c1701f9
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
26 generator modes:
28 SS_GEN_PLAYING - Generator is generating sound after a call
29 to generator_play(). If sound is not looped, jumps
30 to SS_GEN_ZOMBIE when the cursor reaches loop_end.
32 SS_GEN_RELEASED - Generator is generating the sustain of a sound
33 after a call to generator_release(). When the sustain
34 ends, jumps to SS_GEN_FREE.
36 SS_GEN_ZOMBIE - Generator was playing a non-looped sound and the
37 cursor got beyond loop_end. No sound is being generated.
38 Waiting for a call to generator_release() to enter
39 SS_GEN_FREE immediately.
41 SS_GEN_FREE - Generator is free to be used.
45 #ifndef SS_GEN_NUM
46 #define SS_GEN_NUM 256
47 #endif
49 #define SS_GEN_PLAYING 3
50 #define SS_GEN_RELEASED 2
51 #define SS_GEN_FREE 0
53 struct ss_gen
55 int mode; /* SS_GEN_* */
57 int note_id; /* note ID */
58 int trk_id; /* track ID */
60 float * wave[CHANNELS]; /* the PCM waves */
61 float vol[CHANNELS]; /* the volumes */
63 double size; /* size in samples */
64 double loop_start; /* start of loop (-1, no loop) */
65 double loop_end; /* end of loop */
67 double inc; /* increment (frequency) */
68 double cursor; /* offset to next sample */
70 int sustain; /* number of samples to play after release */
71 float dvol[CHANNELS]; /* volume decrement for each sample in sustain */
73 int portamento; /* number of samples of portamento */
74 double dest_inc; /* final portamento inc */
75 double dinc; /* delta of inc */
79 int ss_gen_play(int note_id, int trk_id, float * wave[], float vol[],
80 double size, double inc, double loop_start, double loop_end,
81 int sustain);
83 int ss_gen_release(int note_id);
85 int _ss_gen_frame(struct ss_gen * g, float frame[]);
87 void ss_gen_frame(int trk_id, float frame[]);
89 int ss_gen_portamento(struct ss_gen * g, int portamento, double dest_inc);