I'm writing an audio unit which will need to load audio files into memory. I'm confused by all the different interfaces available. Here's what I'm using so far. When I play the sound back in Process(), I get static, so I'd like to know if anybody sees anything glaring here:
OSStatus Sample::Open( std::string filename ) { FSPathMakeRef((UInt8 *)filename.c_str(), &m_fsRef, NULL); OSStatus retVal = AudioFileOpen ( &m_fsRef, fsRdPerm, 0, &m_fileID );
// should do error checking here
UInt32 uSize = sizeof( m_uLength ); AudioFileGetProperty( m_fileID, kAudioFilePropertyAudioDataByteCount, &uSize, &m_uLength);
m_fFrames.resize( m_uLength, 0.0f );
retVal = AudioFileReadBytes( m_fileID, false, 0, &m_uLength, &m_fFrames[0] );
return retVal;
return 0; } |