26 May '13 - 09:14 *
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 sound twice  (Read 384 times)
tomash667
Guest
« on: 24 May '12 - 14:55 »
Reply with quoteQuote

Hello, how can i play sound twice?

I have simple code:
int main()
{
BASS_Init( -1, 44100, 0, 0, NULL);

HSTREAM stream = BASS_StreamCreateFile(FALSE, "hello-3.mp3", 0, 0, 0);

while(true)
{
if(kbhit())
{
_getch();
BASS_ChannelPlay(new_stream, FALSE);
printf(".");
}
};
return 0;
}
but all channel plays use same stream. Do i need to duplicate it?
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #1 on: 24 May '12 - 15:07 »
Reply with quoteQuote

Do you mean playing the same file twice simultaneously? If so, yes, you would need to create 2 streams for it, eg. 2 BASS_StreamCreateFile calls. Or if it's a short file, you might use the sample functions instead, something like this...

HSAMPLE sample = BASS_SampleLoad(FALSE, "hello-3.mp3", 0, 0, 2, 0); // load the file as a sample
HCHANNEL chan1 = BASS_SampleGetChannel(sample, 0); // get a playback channel
HCHANNEL chan2 = BASS_SampleGetChannel(sample, 0); // and another one

Please see the documentation for details on those functions.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines