Author Topic: Strange sound at the beginning of new song  (Read 6630 times)

zajkos

  • Posts: 17
Strange sound at the beginning of new song
« on: 22 Jul '03 - 07:08 »
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:


Code: [Select]
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

  • Administrator
  • Posts: 26155
Re: Strange sound at the beginning of new song
« Reply #1 on: 22 Jul '03 - 15:14 »
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

  • Posts: 17
Re: Strange sound at the beginning of new song
« Reply #2 on: 23 Jul '03 - 06:37 »
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.
« Last Edit: 23 Jul '03 - 08:00 by zajkos »

Ian @ un4seen

  • Administrator
  • Posts: 26155
Re: Strange sound at the beginning of new song
« Reply #3 on: 23 Jul '03 - 12:23 »
Ok, that sounds like what I said above is what's happening... you should set the volume before you start playing :)

zajkos

  • Posts: 17
Re: Strange sound at the beginning of new song
« Reply #4 on: 23 Jul '03 - 12:50 »
You mean I should set the volume everytime I play next song?

georgebou

  • Posts: 189
Re: Strange sound at the beginning of new song
« Reply #5 on: 23 Jul '03 - 14:25 »
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

  • Administrator
  • Posts: 26155
Re: Strange sound at the beginning of new song
« Reply #6 on: 24 Jul '03 - 11:45 »
Quote
You 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

  • Posts: 17
Re: Strange sound at the beginning of new song
« Reply #7 on: 25 Jul '03 - 09:19 »
Thanks Ian, I think it works fine now (I haven't much time to test it bu it looks OK).