Added processing for ss_eff_fader. Also, yacc code for fader effects
[ahxm.git] / core.h
blobd5820af6fdd1858a99c598bb770cbab837c5de60
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
24 #ifndef CHANNELS
25 #define CHANNELS 16
26 #endif
28 #define NUM_NOTES 128
29 #define VALID_NOTE(n) ((n) >= 0 && (n) < NUM_NOTES)
31 extern int _frequency;
32 extern int _interpolation;
33 extern int _n_channels;
34 extern int _debug;
36 #define MS2F(ms) ((ms / 1000.0) * _frequency)
38 #define TIME2SAMPLES(s) ((s) * _frequency)
41 struct ss_wave
43 double size; /* size in samples */
44 int n_channels; /* # of channels */
45 float * wave[CHANNELS]; /* the PCM waves */
46 int s_rate; /* original sample rate */
48 double loop_start; /* start of loop (-1, no loop) */
49 double loop_end; /* end of loop */
51 double base_freq; /* base frequency */
52 double min_freq; /* minimum frequency */
53 double max_freq; /* maximum frequency */
57 double note_frequency(int note);
58 float _get_sample(float * wave, double size, double offset);
59 float get_sample(struct ss_wave * w, int channel, double offset);
60 double wave_resample(int freq, double size, int n_channels, float * wave[]);
62 double tempo_from_wave(struct ss_wave * w, int note, double len);
63 double pitch_from_wave(struct ss_wave * w, double tempo, double len);
65 /* dynamic string manipulation macros */
66 #ifndef ds_init
67 struct ds { char * d; int p; int s; };
68 #define ds_init(x) do { x.d=(char *)0; x.p=x.s=0; } while(0)
69 #define ds_rewind(x) x.p=0;
70 #define ds_free(x) do { if(x.d) free(x.d); ds_init(x); } while(0)
71 #define ds_redim(x) do { if(x.p >= x.s) x.d=realloc(x.d, x.s += 32); } while(0)
72 #define ds_poke(x,c) do { ds_redim(x); x.d[x.p++]=c; } while(0)
73 #define ds_pokes(x,t) do { char *p=t; while(*p) ds_poke(x, *p++); } while(0)
74 #endif /* ds_init */