|
Post by jarychk on Jun 11, 2019 20:40:55 GMT
Help file gives some information about PLAYWAVE to play a sound as a loop and then says cancellation is by PLAYWAVE "".
HOW? The line PLAYWAVE "thesound.wav", loop would be playing, but at some point, either it must quit on its own or the user will want to stop the play of the thesound.wav sound. So, I ask HOW IS THIS DONE?
PLAYWAVE "" not at all enough for me to know what to do.
|
|
|
Post by Rod on Jun 12, 2019 8:29:11 GMT
You issue the command playwave with a named .wav to start it playing. While it is playing or looping you can cancel it by issuing another playwave command this time with no named .wav. A .wav will normally play once till it ends.
There is just one sound channel, so issuing another playwave command while a sound is playing will overwrite the old sound and start playing the new one. If there is nothing to play it effectively clears the channel.
|
|
|
Post by jarychk on Jun 12, 2019 19:27:22 GMT
You issue the command playwave with a named .wav to start it playing. While it is playing or looping you can cancel it by issuing another playwave command this time with no named .wav. A .wav will normally play once till it ends. There is just one sound channel, so issuing another playwave command while a sound is playing will overwrite the old sound and start playing the new one. If there is nothing to play it effectively clears the channel. I have been thinking about my original question for about a day now, and I would choose to let the user select some control in the interface, which goes to some label section of code containing the PLAYWAVE "" code line to stop the sound.
|
|
|
Post by cundo on Jun 13, 2019 0:27:54 GMT
Some code for testing. Added an empty PLAYWAVE at quit otherwise it will play forever!!
nomainwin
WindowWidth = 384 WindowHeight = 235
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.button0, "Select a File", [selectFile], UL, 22, 6, 144, 42 button #main.button1, "Play && Loop", [button1Click], UL, 22, 70, 144, 80 button #main.button2, "Stop!", [button2Click], UL, 198, 70, 144, 80 open "Playwave testing" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main playwave "" END
[selectFile] filedialog "Open","*.wav",wav$ ' notice wav$ wait
[button1Click] 'Perform action for the button named 'button1' 'Insert your own code here if wav$="" then notice "no file selected" playwave wav$, loop wait
[button2Click] 'Perform action for the button named 'button2' 'Insert your own code here playwave "" wait
|
|
|
Post by jarychk on Jun 13, 2019 3:14:34 GMT
cundo, very nice example. I was on my way to making an example like that, but yours in interesting and more extensive. An example like yours should be distributed as an example program for Just BASIC.
|
|
ntech
Junior Member
Posts: 99
|
Post by ntech on Jun 18, 2019 20:00:53 GMT
If you would like to play multiple .WAV, you could make a .TKN that runs that wave file (For example "playSound.wav" and from your main program
run "playSound.wav"
thus being able to play a second wave.
|
|
|
Post by Rod on Jun 21, 2019 7:49:13 GMT
|
|
|
Post by jarychk on Jun 22, 2019 1:51:44 GMT
Thanks people. I made some progress mostly with the helpfile AND WITH the PLAYWAVE "" line of code. Even more, sample program uses arrays to hold name and path of WAV sound files, and to let user pick different ones from the set from a COMBOBOX control.
|
|
|
Post by jarychk on Jun 22, 2019 11:38:46 GMT
I formed this to learn how to do what I wanted: note that bounce1.wav and ringout.wav need to be in the same filepath as the BAS file or as JB for this to work -----
aud$="bounce1.wav" dim audios$(12) audios$(1)="bounce1.wav" audios$(2)="ringout.wav" 'note that others may also be provided
nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.button1, "start", [button1Click], UL, 22, 61, 122, 25 button #main.button2, "stop", [button2Click], UL, 206, 61, 122, 25 COMBOBOX #main.audio, audios$(), [pickaudio], 380, 61, 122, 65 open "playwave loop" for window as #main print #main, "trapclose [quit.main]"
wait
[quit.main] timer 0 playwave "" Close #main END
[button1Click] 'Perform action for the button named 'button1' 'Insert your own code here playwave aud$,loop wait
[button2Click] 'Perform action for the button named 'button2' 'Insert your own code here playwave "" wait
[pickaudio] print #main.audio,"selection? aud$" WAIT
|
|