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

Method init

src/cinder/audio/linux/FileAudioLoader.cpp:490–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488}
489
490void SourceFileAudioLoader::init()
491{
492 if( mDataSource->isFilePath() ) {
493 //std::cout << "Loading into stream: " << mDataSource->getFilePath().string() << std::endl;
494 mStream = ci::loadFileStream( mDataSource->getFilePath() );
495 }
496 else {
497 mStream = mDataSource->createStream();
498 }
499
500 auto extension = mDataSource->getFilePathHint().extension().string();
501 audioloader::FileType fileType = audioloader::determineFileType( extension, mStream );
502
503 /*
504 switch( fileType ) {
505 case audioloader::FileType::UNKNOWN:
506 std::cout << "fileType: UNKNOWN" << std::endl;
507 break;
508
509 case audioloader::FileType::MP3:
510 std::cout << "fileType: MP3" << std::endl;
511 break;
512
513 case audioloader::FileType::PCM:
514 std::cout << "fileType: PCM" << std::endl;
515 break;
516 }
517 */
518
519 if( audioloader::FileType::MP3 == fileType ) {
520 mFileLoader.reset( new audioloader::FileLoaderMpg123( this, mStream ) );
521 }
522 else if( audioloader::FileType::PCM == fileType ) {
523 mFileLoader.reset( new audioloader::FileLoaderSndFile( this, mStream ) );
524 }
525 else {
526 if( mDataSource->isFilePath() ) {
527 throw AudioFileExc( "Unable to determine file type for " + mDataSource->getFilePath().string() );
528 }
529 else {
530 throw AudioFileExc( "Unable to determine file type from stream" );
531 }
532 }
533
534 mNumFrames = mFileNumFrames = mFileLoader->getNumFrames();
535
536/*
537 std::cout << "Sample rate : " << getSampleRateNative() << std::endl;
538 std::cout << "Num channels : " << getNumChannels() << std::endl;
539 std::cout << "Num frames : " << getNumFrames() << std::endl;
540 std::cout << "Num seconds : " << getNumSeconds() << std::endl;
541*/
542
543 mAudioData.setSize( getMaxFramesPerRead(), mFileLoader->getNumChannels() );
544}
545
546SourceFileRef SourceFileAudioLoader::cloneWithSampleRate( size_t sampleRate ) const
547{

Callers

nothing calls this directly

Calls 11

loadFileStreamFunction · 0.85
determineFileTypeFunction · 0.85
getMaxFramesPerReadFunction · 0.85
isFilePathMethod · 0.80
createStreamMethod · 0.80
extensionMethod · 0.80
stringMethod · 0.45
resetMethod · 0.45
getNumFramesMethod · 0.45
setSizeMethod · 0.45
getNumChannelsMethod · 0.45

Tested by

no test coverage detected