Hi All!
I want to use FBsoud 1.2.
Is it possible, to load all sound in Memery and play them from different Subs? If yes, i would be very thankful for an example. Excuse my poor english. Regards
Load Sound in Memory (FBSound 1.2)
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Load Sound in Memory (FBSound 1.2)
What a funny question
All sounds are played from memory loaded before.
Joshy
All sounds are played from memory loaded before.
Joshy
Re: Load Sound in Memory (FBSound 1.2)
I'm sorry that the question is stupid...
I know that this is possible:
Load Sound (in memory)
Play Sound
My question was, if this is possible:
Main:
Load Sound A
Load Sound B
Load Sound C
Sub X:
Play Sound A
SubY:
Play Sound B
Play Sound C
or should i do this:
SubX:
Load Sound A
Pay Sound A
SubY:
Load Sound B
Load Sound C
Play Sound B
Play Sound C
?
Again im sorry, if this is a stupid question, my coding-skills are not so high and i never used sound librarys. I used MCISendString but there is a delayproblem, with RealTek Soundchips.
@Joshy: Thank you, for all your great work,
I know that this is possible:
Load Sound (in memory)
Play Sound
My question was, if this is possible:
Main:
Load Sound A
Load Sound B
Load Sound C
Sub X:
Play Sound A
SubY:
Play Sound B
Play Sound C
or should i do this:
SubX:
Load Sound A
Pay Sound A
SubY:
Load Sound B
Load Sound C
Play Sound B
Play Sound C
?
Again im sorry, if this is a stupid question, my coding-skills are not so high and i never used sound librarys. I used MCISendString but there is a delayproblem, with RealTek Soundchips.
@Joshy: Thank you, for all your great work,
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Load Sound in Memory (FBSound 1.2)
Yes load all sounds you need and than play it in any order or together or looped or ...
Joshy
Joshy
Re: Load Sound in Memory (FBSound 1.2)
Both are possible.amegas999 wrote: ...
My question was, if this is possible:
...
or should i do this:
...
Your question is not so much about fbsound, but more about how to access memory or variables from subroutines. What may complicate understanding is that fbsound uses ID's (integers) to access the memory (sounds / waves) instead of via pointers directly.
Here is one of many ways to do what you ask:
For fbsound 1.1, I will install and try fbsound 1.2 later
Code: Select all
'Replace the 2 lines below with your own magic code to get fbsound working
#include "fbsound-1.1/inc/fbsound_dynamic.bi"
fbs_Set_PlugPath("fbsound-1.1/")
function fbs_Get_SoundPlaying(byval hSound as integer) as boolean
dim as integer nLoops
if fbs_Get_SoundLoops(hSound, @nLoops) = false then return false
return iif(nLoops, true, false)
end function
'~ Main:
if fbs_Init() = 0 then
print "fbs_Init(): Error: " & FBS_Get_PlugError()
sleep 1000 : end -1
else
print "fbs_Init(): Ok"
end if
dim as string fileName
'The easy way: with global variables
dim shared as integer hWaveA, hWaveB, hWaveC
dim shared as integer hSoundA, hSoundB, hSoundC
'~ Load Sound A
fileName = "Ford_model_T.wav"
if fbs_Load_WAVFile(fileName, @hWaveA) = 0 then
print "fbs_Load_WAVFile: Error: " + fileName
sleep 1000 : end -1
else
print "fbs_Load_WAVFile: Ok: " + fileName
fbs_Create_Sound(hWaveA, @hSoundA)
end if
'~ Load Sound B
fileName = "OOGAhorn.wav"
if fbs_Load_WAVFile(fileName, @hWaveB) = 0 then
print "fbs_Load_WAVFile: Error: " + fileName
sleep 1000 : end -1
else
print "fbs_Load_WAVFile: Ok: " + fileName
fbs_Create_Sound(hWaveB, @hSoundB)
end if
'~ Load Sound C
fileName = "car-breaking-skid-01.wav"
if fbs_Load_WAVFile(fileName, @hWaveC) = 0 then
print "fbs_Load_WAVFile: Error: " + fileName
sleep 1000 : end -1
else
print "fbs_Load_WAVFile: Ok: " + fileName
fbs_Create_Sound(hWaveC, @hSoundC)
end if
sub X
print "fbs_Play_Sound(hSoundA)"
fbs_Play_Sound(hSoundA)
while fbs_Get_SoundPlaying(hSoundA)
sleep 10
wend
end sub
sub Y
print "fbs_Play_Sound(hSoundB)"
fbs_Play_Sound(hSoundB)
print "fbs_Play_Sound(hSoundC)"
fbs_Play_Sound(hSoundC)
while fbs_Get_SoundPlaying(hSoundC) or fbs_Get_SoundPlaying(hSoundB)
sleep 10
wend
end sub
X 'play wave/sound A and wait to fishing playing
Y 'play wave/sound B & C and wait for both to finish
print "End"
Stolen from https://freesound.org/ but I hope that no one will notice that.