audio question

cmartins

Member
Licensed User
Longtime User
Hi All


How can I run 2 different audios at the same time.

I tried it but all the time when I load the last file or a beep the first file loaded stop.
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
What exactly have you tried, can you post some code so we don't have to start from scratch and know which libraries you are looking at.
 
Upvote 0

cmartins

Member
Licensed User
Longtime User
My application use around 100 litte wave file to inform the speed that vehicle should run (1 km/h to 85km/h) and other advises.

can I load all WAV files in soundspool and play when the application ask or load and play the WAV file and after use unload?
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
I've succesfully loaded 250 ogg files (3 MB total) into memory, and play several of them at the same time using soundpool, unloading them, playing another bunch, etc.
 
Upvote 0

joseluis

Active Member
Licensed User
Longtime User
This is an example. If you have 100 sounds under ./Files/snd/ named sound1.wav, sound2,wav ... sound99.wav, then:

B4X:
Dim soundsLoaded(100) As Int ' IDs of loaded sounds
Dim SP As SoundPool ' SoundPool Object
SP.Initialize(16)   ' Max number of sounds in soundpool playing sametime
soundsPlaying(16) As Int ' Here are stored the IDs of the sounds playing, so we can stop them

Do While (i < 100)
   filename = "sound" & i & ".wav"
   soundsLoaded(i) = SP.Load(File.DirAssets, "subfolder/" & soundname )
   i = i + 1
Loop

And:
B4X:
' To play a sound
soundsPlaying(0) = SP.Play(soundsLoaded(x), 1, 1, 1, 0, 1)

' To stop a sound
SP.Stop(soundsPlaying(X)) ' X should be a number from 0 to 15, in this case

' To stop all sounds
For n = 0 To 16
   SP.Stop(soundsPlaying(X))
Next
 
Upvote 0

cmartins

Member
Licensed User
Longtime User
I've succesfully loaded 250 ogg files (3 MB total) into memory, and play several of them at the same time using soundpool, unloading them, playing another bunch, etc.

Joseluis

what kind of files can we use with soundpool? I tried open ogg files but it doesnt work
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…