23 May '13 - 16:18 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Play music using "BASS_StreamCreate"  (Read 421 times)
jaeminem
Posts: 3


« on: 14 May '12 - 03:30 »
Reply with quoteQuote

I want to play music using "BASS_StreamCreate" but it doesn't work well. I can't hear the sound. Cry

I make two HSTREM(m_stream ,m_PlayStream ) . One is used for opening a file which has dates. And the other one is used for playing.
Brief procedure is like this.

//open//
m_stream = BASS_StreamCreateFile(FALSE,strAFileName,0,0,BASS_STREAM_DECODE);
BASS_ChannelGetInfo(m_stream, &m_info);
m_PlayStream = BASS_StreamCreate(m_info.freq, m_info.chans, 16, &BASSStreamCallback, (DWORD)this);
//play//
BASS_ChannelPlay(m_PlayStream, TRUE);
//BASSStreamCallback//
DWORD CALLBACK BASSStreamCallback(HSTREAM handle, void *buffer, DWORD length, DWORD user)
{
     CBassWrapper *pHost = (CBassWrapper*)user;
     BASS_ChannelGetData(pHost->m_stream, buffer, length);
     return 0;
}

"buffer" gets m_stream's data but I can't hear anything.
If you have a advice or know basic example which plays music using "BASS_StreamCreate", please let me know.
Thank you.
« Last Edit: 14 May '12 - 04:00 by jaeminem » Logged
Ian @ un4seen
Administrator
Posts: 15270


« Reply #1 on: 14 May '12 - 15:19 »
Reply with quoteQuote

A STREAMPROC function should return the amount of data that it has placed in the buffer, so the BASSStreamCallback function above needs to be modified something like this...

DWORD CALLBACK BASSStreamCallback(HSTREAM handle, void *buffer, DWORD length, void *user)
{
     CBassWrapper *pHost = (CBassWrapper*)user;
     DWORD r=BASS_ChannelGetData(pHost->m_stream, buffer, length);
     if (r==(DWORD)-1) return BASS_STREAMPROC_END; // signal the end
     return r;
}
Logged
jaeminem
Posts: 3


« Reply #2 on: 15 May '12 - 03:05 »
Reply with quoteQuote

Thank you Smiley
It works well.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines