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
35 #include "generator.h"
37 #include "instrument.h"
51 #define NUM_GENERATORS 64
52 struct generator _generators
[NUM_GENERATORS
];
66 struct effect_delay e
;
69 _linear_interpolation
=1;
72 memset(_generators
, '\0', sizeof(_generators
));
73 build_note_frequencies();
75 load_pat_file("samples/acpiano.pat");
76 /* load_pat_file("/cdrom/orchhit.pat"); */
79 load_wav_file("samples/01c1.wav", &size
, &ls
, &rs
);
82 add_instrument_layer(&i
, 36, 0, 128, ls
, rs
,
83 size
, 0, size
, 44100 / 3);
85 instrument_play_note(&i
, 36, 1, 1);
86 /* instrument_play_note(&i, 39, 1, 1); */
89 load_wav_file("samples/amen1.wav", &size, &ls, &rs);
91 generator_play(&_generators[0], ls, rs, size, 1, 0, size, 0.2, 1, 4410);
93 load_wav_file("samples/01c1.wav", &size, &ls, &rs);
94 generator_play(&_generators[1], ls, rs, size,
95 _note_freq[24] / _note_freq[36], 0, size, 1, 1, 44100 / 3);
97 load_wav_file("samples/05c3.wav", &size, &ls, &rs);
99 generator_play(&_generators[2], ls, rs, size,
100 _note_freq[36] / _note_freq[36], 0, size, 0.5, 0.5, 0);
102 generator_play(&_generators[3], ls, rs, size,
103 _note_freq[39] / _note_freq[36], 0, size, 0.5, 0.5, 0);
105 generator_play(&_generators[4], ls, rs, size,
106 _note_freq[43] / _note_freq[36], 0, size, 0.5, 0.5, 0);
108 load_wav_file("samples/as-al017.wav", &size, &ls, &rs);
109 generator_play(&_generators[5], ls, rs, size, 1, 0, size, 2, 2, 0);
112 f=popen("sox -V -t raw -s -r 44100 -c 2 -w - qq.wav","w");
115 if(output_open("oss", "/dev/dsp") < 0)
117 printf("Error: can't init driver\n");
121 /* init_delay(&e, 44100 / 10, 0); */
122 init_delay(&e
, (int)TIME2SAMPLES(18.0 / 1000.0), 0.1);
124 for(n
=TIME2SAMPLES(15);n
> 0;n
--)
130 for(m=0;m < NUM_GENERATORS;m++)
131 generator(&_generators[m], &l, &r);
133 generate_instrument(&i
, &l
, &r
);
135 if(n
< TIME2SAMPLES(13))
136 process_reverb(&e
, &l
, &r
);
140 /* if(n < TIME2SAMPLES(14))
141 generator_release(&_generators[1]); */