MCPcopy Create free account
hub / github.com/cinder/Cinder / testWrite

Method testWrite

test/_audio/AudioTests/src/SamplePlayerTest.cpp:374–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374void SamplePlayerTest::testWrite()
375{
376 audio::BufferRef audioBuffer = mSourceFile->loadBuffer();
377
378 try {
379 const string fileName = "out.wav";
380 audio::TargetFileRef target = audio::TargetFile::create( fileName, mSourceFile->getSampleRate(), mSourceFile->getNumChannels() ); // INT_16
381 // audio::TargetFileRef target = audio::TargetFile::create( fileName, mSourceFile->getSampleRate(), mSourceFile->getNumChannels(), audio::SampleType::FLOAT_32 );
382
383 CI_LOG_I( "writing " << audioBuffer->getNumFrames() << " frames at samplerate: " << mSourceFile->getSampleRate() << ", num channels: " << mSourceFile->getNumChannels() );
384 target->write( audioBuffer.get() );
385 CI_LOG_I( "...complete." );
386
387// size_t writeCount = 0;
388// while( numFramesConverted < audioBuffer->getNumFrames() ) {
389// for( size_t ch = 0; ch < audioBuffer->getNumChannels(); ch++ )
390// copy( audioBuffer->getChannel( ch ) + writeCount, audioBuffer->getChannel( ch ) + writeCount + sourceFormat.getFramesPerBlock(), sourceBuffer.getChannel( ch ) );
391// }
392 }
393 catch( audio::AudioFileExc &exc ) {
394 CI_LOG_E( "AudioFileExc, what: " << exc.what() );
395 }
396}
397
398// -----------------------------------------------------------------------
399// UI

Callers

nothing calls this directly

Calls 8

createFunction · 0.50
loadBufferMethod · 0.45
getSampleRateMethod · 0.45
getNumChannelsMethod · 0.45
getNumFramesMethod · 0.45
writeMethod · 0.45
getMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected