// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CSoundStream
//  - prototype : bool GetPlayLength(float* pfSeconds) const
//
//  - Purpose   : Gets the stream length (seconds).
//
// -----------------------------------------------------------------------------
bool CSoundStream::GetPlayLength(float* pfSeconds) const
{
    if(!IsValid())
    {
        return false;
    }

    QWORD len  = BASS_StreamGetLength(m_handle); // length in bytes

    if(len == -1)
    {
        return false;
    }

    *pfSeconds = BASS_ChannelBytes2Seconds(m_handle, len); // the time length
    return true;
}
Example #2
0
// Load an audio file in .wav format
bool LoadAudioFile(LPCSTR szFileName)
{
  // Load the data from the specified file
  HSTREAM file_stream = BASS_StreamCreateFile(FALSE,szFileName,0,0,BASS_STREAM_DECODE);

  // Get the length and header info from the loaded file
  stream_length=BASS_StreamGetLength(file_stream); 
  BASS_ChannelGetInfo(file_stream, &info);

  // Get the audio samples from the loaded file
  data = new char[(unsigned int)stream_length];
  BASS_ChannelGetData(file_stream, data, (unsigned int)stream_length);
    
  // Set playing to begin at the beginning of the loaded data
  pos = 0;

  return false;
}