84 cout <<
"////////////////////////////////////////////////////////////"
86 <<
"// Testing class Nsound::Mixer"
88 <<
"////////////////////////////////////////////////////////////"
94 <<
"Mixer::add(), Mixer::getStream() ... " << flush;
96 uint32 SAMPLES_PER_SECOND = 10;
98 Sine sine(SAMPLES_PER_SECOND);
103 as1 << sine.drawLine(1.0,1.0,1.0);
108 mixer.
add(0.0, 30.0, as1);
116 if(result.
getLength() != 4.0 * (1.0 * SAMPLES_PER_SECOND))
120 <<
"result has incorrect length! FAILURE"
135 testRange(result[0], 0, 10, 1.0, __LINE__);
136 testRange(result[0], 10, 10, 0.0, __LINE__);
137 testRange(result[0], 20, 10, 1.0, __LINE__);
138 testRange(result[0], 30, 10, 0.0, __LINE__);
140 cout <<
Toc() <<
" seconds: SUCCESS"
143 <<
"Mixer::add(), Mixer::getStream() ... " << flush;
146 mixer.
add(0.0, 30.0, as1);
158 testRange(result[0], 0, 10, 2.0, __LINE__);
159 testRange(result[0], 10, 10, 0.0, __LINE__);
160 testRange(result[0], 20, 10, 2.0, __LINE__);
161 testRange(result[0], 30, 10, 0.0, __LINE__);
163 cout <<
Toc() <<
" seconds: SUCCESS"
166 <<
"Mixer::add(), Mixer::getStream() with offset ... " << flush;
170 if(result.
getLength() != 4.0 * (1.0 * SAMPLES_PER_SECOND))
174 <<
"result has incorrect length! FAILURE"
190 testRange(result[0], 0, 5, 2.0, __LINE__);
191 testRange(result[0], 5, 10, 0.0, __LINE__);
192 testRange(result[0], 15, 10, 2.0, __LINE__);
193 testRange(result[0], 25, 10, 0.0, __LINE__);
194 testRange(result[0], 35, 5, 2.0, __LINE__);
196 cout <<
Toc() <<
" seconds: SUCCESS"
199 <<
"Mixer::add(), Mixer::clear() ... " << flush;
203 if(mixer.
size() != 0)
206 <<
"mixer.size() should be 0.0, found "
212 cout <<
Toc() <<
" seconds: SUCCESS"
215 <<
"Mixer::add(), Mixer::add() with different BPM ... " << flush;
219 mixer.
add(0.0, 30.0, as1);
220 mixer.
add(0.5, 30.0, as1);
239 testRange(result[0], 0, 5, 1.0, __LINE__);
240 testRange(result[0], 5, 5, 2.0, __LINE__);
241 testRange(result[0], 10, 5, 1.0, __LINE__);
242 testRange(result[0], 15, 5, 0.0, __LINE__);
243 testRange(result[0], 20, 5, 1.0, __LINE__);
244 testRange(result[0], 25, 5, 2.0, __LINE__);
245 testRange(result[0], 30, 5, 1.0, __LINE__);
246 testRange(result[0], 35, 5, 0.0, __LINE__);
248 cout <<
Toc() <<
" seconds: SUCCESS"
251 <<
"Mixer::add(), Mixer::getStream() with offset ... " << flush;
257 if(result.
getLength() != 4.0 * (1.0 * SAMPLES_PER_SECOND))
261 <<
"result has incorrect length! FAILURE"
280 testRange(result[0], 0, 5, 2.0, __LINE__);
281 testRange(result[0], 5, 5, 1.0, __LINE__);
282 testRange(result[0], 10, 5, 0.0, __LINE__);
283 testRange(result[0], 15, 5, 1.0, __LINE__);
284 testRange(result[0], 20, 5, 2.0, __LINE__);
285 testRange(result[0], 25, 5, 1.0, __LINE__);
286 testRange(result[0], 30, 5, 0.0, __LINE__);
287 testRange(result[0], 35, 5, 1.0, __LINE__);
289 cout <<
Toc() <<
" seconds: SUCCESS"
292 <<
"Mixer::add(), Mixer::getStream() with zero bpm ... " << flush;
296 as2 << sine.drawLine(0.5,3.0,3.0);
298 mixer.
add(1.5, 0.0, as2);
319 testRange(result[0], 0, 5, 2.0, __LINE__);
320 testRange(result[0], 5, 5, 1.0, __LINE__);
321 testRange(result[0], 10, 5, 3.0, __LINE__);
322 testRange(result[0], 15, 5, 1.0, __LINE__);
323 testRange(result[0], 20, 5, 2.0, __LINE__);
324 testRange(result[0], 25, 5, 1.0, __LINE__);
325 testRange(result[0], 30, 5, 0.0, __LINE__);
326 testRange(result[0], 35, 5, 1.0, __LINE__);
328 cout <<
Toc() <<
" seconds: SUCCESS"
void add(float64 first_beat_time, float64 beats_per_minute, const AudioStream &audio_stream)
This method inserts the AudioStream to the Mixer's LinkList.
uint32 getLength() const
Returns the number of samples of audio data in the stream.
This class enables easy scheduling and mixing of multiple AudioStreams.
#define TEST_HEADER2(line)
#define TEST_ERROR_HEADER
AudioStream getStream(float64 end_time)
This method returns one AudioStream composed of all AudioStreams stored in the Mixer's LinkList...
void testRange(const Buffer &buffer, uint32 start_index, uint32 n_samples, float64 value, unsigned int line)
void clear()
This method removes all streams from the mixer.
uint32 size() const
This method returns the number of stream stored in it.