71 <<
"AudioStream::operator<<, AudioStream::operator[] ... " << flush;
75 uint32 test_size = 29 * 3 + 1;
79 for(
uint32 i = 0; i < test_size; ++i)
83 if(as1[0][i] != test_value || as1[1][i] != test_value)
97 cout <<
Toc() <<
" seconds: SUCCESS"
99 <<
TEST_HEADER <<
"testing AudioStream::getLength() ... " << flush;
103 if(as1.getLength() != test_size)
106 <<
"as1.getLength() should equal "
116 cout <<
Toc() <<
" seconds: SUCCESS"
118 <<
TEST_HEADER <<
"testing AudioStream::operator== ... " << flush;
124 if(as1 == as2 || as2 == as1)
127 <<
"as1 should _NOT_ equal as2"
132 for(
uint32 i = 0; i < test_size; i++)
137 if(as1 != as2 || as2 != as1)
140 <<
"as1 _SHOULD_ equal as2"
145 cout <<
Toc() <<
" seconds: SUCCESS"
147 <<
TEST_HEADER <<
"testing AudioStream::AudioStream(&) ... " << flush;
153 if(as1 != as3 || as3 != as1)
156 <<
"as1 _SHOULD_ equal as3"
161 cout <<
Toc() <<
" seconds: SUCCESS"
163 <<
TEST_HEADER <<
"testing AudioStream::operator+,-,*,/ ... " << flush;
171 if(1 + as4 * 2 != 2 * as4 + 1)
174 <<
"left hand side _SHOULD_ equal right hand side"
179 if(1 - as4 / 2 != -1 * as4 / 2 + 1)
182 <<
"left hand side _SHOULD_ equal right hand side"
187 if(2.0 / as4 != 2.0 * (1.0 / as4))
190 <<
"left hand side _SHOULD_ equal right hand side"
195 cout <<
Toc() <<
" seconds: SUCCESS"
197 <<
TEST_HEADER <<
"test AudioStream::operator+= ... " << flush;
202 as5 << sine.generate(1.0,1.0);
209 for(
uint32 i = 0; i < n_samples; ++i)
211 if(as5[0][i] != 0.0 || as5[1][i] != 0.0)
214 <<
"as5 + as6 _SHOULD_ be all zeros!"
220 cout <<
Toc() <<
" seconds: SUCCESS"
224 cout <<
TEST_HEADER <<
"test AudioStream::reverse() ... " << flush;
226 as5 = sine.generate(4.0,1.0);
230 Buffer envelope = sine.drawLine(4.0,1.0,0.0);
245 for(
uint32 i = 0; i < length; ++i)
247 if(as5[0][i] != 0.0 || as5[1][i] != 0.0)
250 <<
"as6 should be all zeros!"
256 cout <<
Toc() <<
" seconds: SUCCESS"
258 <<
TEST_HEADER <<
"test AudioStream::pan() ... " << flush;
262 as7 << sine.drawLine(1.0,1.0,1.0);
279 for(
uint32 i = 0; i < as7.getLength(); ++i)
281 if(as7[0][i] != 0.75 || as7[1][i] != 0.25)
284 <<
"AudioStream::pan(float64 d) is borken!"
292 as7[0] = sine.drawLine(1.0,1.0,1.0);
293 as7[1] = sine.drawLine(1.0,1.0,1.0);
298 for(
uint32 i = 0; i < as7.getLength(); ++i)
300 if(as7[0][i] != 0.25 || as7[1][i] != 0.75)
303 <<
"AudioStream::pan(float64 d) is borken!"
309 cout <<
Toc() <<
" seconds: SUCCESS"
311 <<
TEST_HEADER <<
"test AudioStream::pan(Buffer b) ... " << flush;
315 Buffer pan = sine.generate(1.0,1.0);
319 as7[0] = sine.drawLine(1.0,1.0,1.0);
320 as7[1] = sine.drawLine(1.0,1.0,1.0);
329 Buffer left_test = (pan + 1) / 2;
333 if(as7[0] != left_test)
336 <<
"AudioStream::pan(Buffer b) is borken!"
346 Buffer right_test = left_test * -1.0 + 1.0;
350 Buffer difference = as7[1] - right_test;
359 if(difference[i] > 0.0000001 || difference[i] < -0.0000001)
362 <<
"AudioStream::pan(Buffer b) is borken!"
368 cout <<
Toc() <<
" seconds: SUCCESS"
374 cout <<
TEST_HEADER <<
"test AudioStream::substream() ... " << flush;
380 for(
uint32 i = 0; i < 44100; ++i)
382 as8 << static_cast<float64>(i);
388 AudioStream substr(as8.substream(start_index, n_samples));
391 for(
uint32 ch = 0; ch < 10; ++ch)
393 for(
uint32 i = 0; i < 44100; ++i)
395 if(static_cast<uint32>(substr[ch][i]) != i)
398 <<
"as8.substream() error!"
408 substr = as8.substream(1000, 1000);
410 for(
uint32 ch = 0; ch < 10; ++ch)
412 for(
uint32 i = 1000; i < 1000; ++i)
414 if(static_cast<uint32>(substr[ch][i]) != i)
417 <<
"as8.substream() error!"
425 substr = as8.substream(0.0, 1.0);
428 for(
uint32 ch = 0; ch < 10; ++ch)
430 for(
uint32 i = 0; i < 44100; ++i)
432 if(static_cast<uint32>(substr[ch][i]) != i)
435 <<
"as8.substream() error!"
442 substr = as8.substream(1000.0 / 44100.0, 1000.0 / 44100.0);
444 for(
uint32 ch = 0; ch < 10; ++ch)
446 for(
uint32 i = 1000; i < 1000; ++i)
448 if(static_cast<uint32>(substr[ch][i]) != i)
451 <<
"as8.substream() error!"
458 cout <<
Toc() <<
" seconds: SUCCESS" << endl;
uint32 getLength() const
Returns the number of samples of audio data in the stream.
void reverse()
Reverses the AudioStream.
uint32 getLength() const
Returns the number of samples in the Buffer.
#define TEST_ERROR_HEADER
A Buffer for storing audio samples.