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

Method openFile

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

Source from the content-addressed store, hash-verified

203}
204
205void SamplePlayerTest::openFile( const ci::fs::path &fullPath )
206{
207 try {
208 setSourceFile( loadFile( fullPath ) );
209 CI_LOG_I( "loaded and set new source buffer, frames: " << mSourceFile->getNumFrames() );
210 }
211 catch( exception &e ) {
212 CI_LOG_EXCEPTION( "failed to load sample file at path: " << fullPath, e );
213 }
214
215 mSamplePlayerNode->seek( 0 );
216
217 CI_LOG_I( "output samplerate: " << mSourceFile->getSampleRate() );
218
219 auto bufferPlayer = dynamic_pointer_cast<audio::BufferPlayerNode>( mSamplePlayerNode );
220 if( bufferPlayer ) {
221 if( mLoadAsync ) {
222 mAsyncLoadFuture = std::async( [=] {
223 bufferPlayer->loadBuffer( mSourceFile->clone() );
224 app::App::get()->dispatchAsync( [=] {
225 mWaveformPlot.load( bufferPlayer->getBuffer(), app::getWindowBounds() );
226 } );
227 } );
228 }
229 else {
230 bufferPlayer->loadBuffer( mSourceFile->clone() );
231 mWaveformPlot.load( bufferPlayer->getBuffer(), app::getWindowBounds() );
232 }
233 }
234 else {
235 auto filePlayer = dynamic_pointer_cast<audio::FilePlayerNode>( mSamplePlayerNode );
236 CI_ASSERT_MSG( filePlayer, "expected sample player to be either BufferPlayerNode or FilePlayerNode" );
237
238 filePlayer->setSourceFile( mSourceFile->clone() );
239 }
240
241 mSamplePlayerNode->setLoopEndTime( mSamplePlayerNode->getNumSeconds() );
242
243 CI_LOG_I( "loaded and set new source buffer, channels: " << mSourceFile->getNumChannels() << ", frames: " << mSourceFile->getNumFrames() );
244}
245
246void SamplePlayerTest::resize()
247{

Callers

nothing calls this directly

Calls 15

loadFileFunction · 0.85
getWindowBoundsFunction · 0.85
dispatchAsyncMethod · 0.80
getBufferMethod · 0.80
setLoopEndTimeMethod · 0.80
getFunction · 0.50
getNumFramesMethod · 0.45
seekMethod · 0.45
getSampleRateMethod · 0.45
loadBufferMethod · 0.45
cloneMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected