BBC BASIC for Windows
Programming >> Sound, Music and Video >> Fading gently away
http://bb4w.conforums.com/index.cgi?board=multimedia&action=display&num=1371210346

Fading gently away
Post by Ken Down on Jun 14th, 2013, 11:45am

Using the code below, which I got from the Wiki, (http://bb4w.wikispaces.com/Playing+a+media+file+using+Direct+Show) I can make my program play mp3 and mpg files (audio and video). I have also programme a hot key so that I can instantly stop playback of either.

SYS!(!m_mediaControl%+44),m_mediaControl%,FNwide(soundfile$),0TOhr%
SYS!(!m_mediaControl%+28),m_mediaControl%TOhr%

However stopping music in the middle is always abrupt and I would love a way of gently fading the music to nothing before stopping it.

Any help appreciated.
Re: Fading gently away
Post by admin on Jun 14th, 2013, 12:56pm

on Jun 14th, 2013, 11:45am, Guest-Ken Down wrote:
However stopping music in the middle is always abrupt and I would love a way of gently fading the music to nothing before stopping it.

I assume you've already tried the method given in the main Help documentation (SYS "waveOutSetVolume"):

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#playsound

If that doesn't work, presumably it's because the wrong 'volume control' is being manipulated. In that case open up your audio mixer (usually by double-clicking on the loudspeaker icon in the systray) and see what control it gives you over the MP3 volume. Assuming you can change it, use the code in this Wiki article to do it in your program:

http://bb4w.wikispaces.com/Controlling+the+audio+mixer

Richard.
Re: Fading gently away
Post by Ken Down on Jun 28th, 2013, 6:49pm

Thanks. I finally got round to trying your suggestions out. The second one didn't work - possibly because of my sound card - but the first one did, though playing an mp4 file the sound faded but subsequent attempts to play the file resulted in it sort of stuttering! I had to restart the program. Curious.

No problem with mp3s, however.

Many thanks again.
Re: Fading gently away
Post by Ken Down on Jun 29th, 2013, 06:14am

Hmmm. Subsequent investigation shows that it is just one particular mp4 file which stutters if an attempt to restart it is made. It was created using a different - more modern! - program, so presumably there is a problem with the codec rather than BB4W.

Now all I need is a way to simultaneously fade the video to black!