| 203 | } |
| 204 | |
| 205 | void 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 | |
| 246 | void SamplePlayerTest::resize() |
| 247 | { |
nothing calls this directly
no test coverage detected