View Single Post
  #8 (permalink)  
Old 05-09-2008, 10:53 PM
Louis Louis is offline
Knows the basics
 
Join Date: May 2007
Posts: 93
Default

Hi. It sure is, here's an example using only 1 sound, however you can use as many sounds as you like.
'Add a reference to HSSNetDesktop for the Desktop or HSSNetDevice for the PPC and Smartphones. Add a Speaker objet called speaker, a Sound object called sound1, and a Channel1 object called channel1. You must add a sound object and a channel1 object per everysound you want to load and manipulate from Basic4ppc.
Sub Globals
End Sub
Sub App_Start
speaker.new1
sound1.new1
channel1.new1

Speaker.Open(44100, 16, true, 0, 16) 'The parameters of the Open() function are from left to right:
Hurtz as Int32, 8 or 16 as Int32 for 8-bit or 16-bit files, stereo or mono as boolean true=stereo, Number of channels to allocate for MODS as Int32, and Number of channels to allocate for wavs as Int32.
sound1.load("FileToLoad.wav") 'Loads a wav file into sound1.
'Now to manipulate the sound as it plays, you'd code:
channel1.Value = speaker.channel(speaker.PlaySound(sound1.Value))
'And to freeze the program until a sound is done playing, use the channel1 object. The channel1 class also has some nice methods that let you control the sound while it plays and such. The class entitled Channel doesn't work with Basic4ppc, so Channel1 allows this.

'Anyway, simply code while the sound is playing:
do while channel1.Playing
'Code can go here while the sound plays if necessary.
DoEvents
loop
'When the sound is done the code after the loop executes.
'Don't forget to add a close event that closes the speaker when your program aborts via a call to speaker.close
End Sub
If anyone has more questions please let me know. HTH.
Reply With Quote