Strange sound at the beginning of new song

Started by zajkos,

zajkos

When I start to play a mp3 sometimes there happen a small strange sound at the very first moment of playing the song. It lasts abot 0.1 second. Here is my code:


HSTREAM stream;
bool playing;
Bass_Init(-1,44100,0,Form1->Handle);  

if (Bass_Start()==0) ShowMessage("BASS START ERROR");


void Play(String song)
 {


if (stream!=NULL) Bass_StreamFree(stream);
stream=Bass_StreamCreateFile(0,song.c_str(),0,0,0);
if (stream==NULL) ShowMessage("ERROR OPENING FILE");
playing=Bass_StreamPlay(stream,0,0);
Bass_ChannelSetAttributes(stream,-1,volume,-1);

if (playing==0) ShowMessage("ERROR PLAYING FILE");
                        
 }

I don't know maybe I'm incorrectly freeing the stream? I'm totally stuck.

Ian @ un4seen

What volume level are you using in the BASS_ChannelSetAttributes call? It could be that the "strange sound" is just the volume initially being at 100 (default) when you start playback, before you decrease it. Try setting the volume before you call BASS_StreamPlay.

zajkos

#2
Actually it's set to 0 (mute) or very low. I made a few tests yesterday and I realized that it happens only when I play songs from one specified album. But the sound is not the part of the songs on this album. Also playing the album with Winamp doesn't produce the sound.

The sound sounds something like "tick" and it's differs from time to time.

Ian @ un4seen

Ok, that sounds like what I said above is what's happening... you should set the volume before you start playing :)

zajkos

You mean I should set the volume everytime I play next song?

georgebou

I have the same problem some times and it gives me the sense that the strange sound is caused because the buffer is not emptied from the previous song!But i'm not sure.

Ian @ un4seen

QuoteYou mean I should set the volume everytime I play next song?
Yes. The default volume when you create a stream is 100 (max). If you don't want to play the stream at that level, then you should change the volume before you start playing.

If you do as in your code above, it's going to have a split-second being played at volume 100 before you set the volume level you want.

zajkos

Thanks Ian, I think it works fine now (I haven't much time to test it bu it looks OK).