GLBasic forum

Main forum => GLBasic - en => Topic started by: Leginus on 2010-Aug-26

Title: StopSound broken??
Post by: Leginus on 2010-Aug-26
Hi all

I am using the latest release and i cant seem to get StopSound to work.  Is this broken or is it my code (highly possible)
This is in my main loop

Code (glbasic) Select

MOUSESTATE mx, my, mb1, mb2

IF mb1
ch2 = PLAYSOUND(2,0,1)
AnimState=1
ENDIF

IF mb1=0
AnimState=0
STOPSOUND ch2
ENDIF


This has been driving me nuts all morning.  I have tried ch2 as a global as a local etc.  I even tried playing another sound to ch2 to stop the first playing and that didnt work.  I am out of ideas.

Any thoughts

Cheers
leginus
Title: Re: StopSound broken??
Post by: MrTAToad on 2010-Aug-26
Yes, STOPSOUND does appear to be a bit blorked
Title: Re: StopSound broken??
Post by: Leginus on 2010-Aug-26
Thank goodness for that lol. I thought it was me.  Thanks for quick reply
Title: Re: StopSound broken??
Post by: Leginus on 2010-Aug-26
DO you know if it was broken in the last release, and if not is there somewhere i could download the last version until this on is fixed?
Title: Re: StopSound broken??
Post by: backslider on 2010-Aug-26
Try instead of ch2 -> ch2% ?!
Don“t know if it works but you could try it!

Otherwise I think GLBasic creates a Backup in the main folder each time you update it.
Title: Re: StopSound broken??
Post by: Leginus on 2010-Aug-26
Thx for the idea but it still didnt work.

As for the backup in the glbasic folder, I tried to open it and it said archive corrupted :(.  Thats why i wondered if i could download it from anywhere else

cheers
Leginus
Title: Re: StopSound broken??
Post by: Kitty Hello on 2010-Aug-26
edit:

No bug, it works properly:

Code (glbasic) Select

// ------------------------------------------------------------- //
// PLAYSOUND Sample
// ------------------------------------------------------------- //

// Laden eines Sounds aus einer Wav-Datei / Load sound from wav-file

LOCAL channel%=-1

LOADSOUND "sensaura.wav", 5, 4 // Num: 0 - 127 max
WHILE TRUE
MOUSESTATE mx, my, b1, b2
IF my>100 THEN my=100
SETMOUSE mx, my
mx=INTEGER((mx-320)*10/32) // -100 <-> +100

// PAN
DRAWLINE 0, 100, 200, 100, RGB(255,255,255)
DRAWLINE mx+100, 90, mx+100, 110, RGB(200,255,255)
// VOL
DRAWLINE 0, 130, 200, 130, RGB(255,255,255)
DRAWLINE my*2, 120, my*2, 140, RGB(255,255,200)

IF b1 AND NOT SOUNDPLAYING(channel) THEN channel = PLAYSOUND (5, mx/100, my/100)
IF b2 THEN STOPSOUND channel

PRINT "Pan[%]:" + mx + " Vol[%]:" + my, 84, 150
PRINT channel+" on:"+SOUNDPLAYING(channel), 0,200
SHOWSCREEN
WEND
HUSH // Ruhe / Silence


Be sure to not overwrite the channel variable and play the sound twice when pressing a button.
Title: Re: StopSound broken??
Post by: Leginus on 2010-Aug-27
ok thx for looking at this I will give it another go.  I knew it was probably me all along   :giveup:
Title: Re: StopSound broken??
Post by: Leginus on 2010-Aug-28
Works perfect now :). Thanks