3 Ann Hell Ex Machina - Music Software
4 Copyright (C) 2003/2005 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
29 #define VALID_NOTE(n) ((n) >= 0 && (n) < NUM_NOTES)
31 extern int ss_frequency
;
32 extern int ss_interpolation
;
33 extern int ss_nchannels
;
36 #define MS2F(ms) ((ms / 1000.0) * ss_frequency)
38 #define TIME2SAMPLES(s) ((s) * ss_frequency)
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 ss_note_frequency(int note
);
58 float ss_get_sample_raw(float * wave
, double size
, double offset
);
59 float ss_get_sample(struct ss_wave
* w
, int channel
, double offset
);
61 double ss_tempo_from_wave(struct ss_wave
* w
, int note
, double len
);
62 double ss_pitch_from_wave(struct ss_wave
* w
, double tempo
, double len
);
64 /* dynamic string manipulation macros */
66 struct ds
{ char * d
; int p
; int s
; };
67 #define ds_init(x) do { x.d=(char *)0; x.p=x.s=0; } while(0)
68 #define ds_rewind(x) x.p=0;
69 #define ds_free(x) do { if(x.d) free(x.d); ds_init(x); } while(0)
70 #define ds_redim(x) do { if(x.p >= x.s) x.d=realloc(x.d, x.s += 32); } while(0)
71 #define ds_poke(x,c) do { ds_redim(x); x.d[x.p++]=c; } while(0)
72 #define ds_pokes(x,t) do { char *p=t; while(*p) ds_poke(x, *p++); } while(0)