BuckyBoy
12-07-08, 01:22
This is a tutorial on how to play sounds one after the other.. for instance if you do this:
Sound_PreCacheSound("mysound1")
Sound_Play2D("mysound1")
Sound_PreCacheSound("mysound2")
Sound_Play2D("mysound2")
..then both sounds start at the same time.. not really what you want most of the time. (Sound_PlayStreamed seems to do the same as Sound_Play2D.. so it doesn't work either)
- use Mannerheim's smfconvert2 tool (http://www.harharetki.net/coh/smfconvert_v2.zip) to convert .wav to .smf + .bsc.
- copy the .bsc to Data/sound/ and the .smf to Data/sound/wav/
- use this code to play sounds:
g_streamed_sounds = {}
function Rule_Play_Streamed_Sound()
local sound_info = g_streamed_sounds[1]
Sound_PreCacheSound(sound_info.sound)
Sound_Play2D(sound_info.sound)
table.remove(g_streamed_sounds, 1)
TimeRule_RemoveMe()
if (#g_streamed_sounds > 0) then
Rule_AddOneShot(Rule_Play_Streamed_Sound, sound_info.time)
end
end
local function Play_Streamed_Sound(sound, time)
local sound_info = {
sound = sound,
time = time
}
table.insert(g_streamed_sounds, sound_info)
if (not TimeRule_Exists(Rule_Play_Streamed_Sound)) then
Rule_AddOneShot(Rule_Play_Streamed_Sound, 0)
end
end
- then play sounds like this:
Play_Streamed_Sound("mysound1", 10)
Play_Streamed_Sound("mysound2", 5)
Play_Streamed_Sound("mysound3", 1)
..this means mysound2 is played after 10 seconds and mysound3 is played after 15 seconds.
Sound_PreCacheSound("mysound1")
Sound_Play2D("mysound1")
Sound_PreCacheSound("mysound2")
Sound_Play2D("mysound2")
..then both sounds start at the same time.. not really what you want most of the time. (Sound_PlayStreamed seems to do the same as Sound_Play2D.. so it doesn't work either)
- use Mannerheim's smfconvert2 tool (http://www.harharetki.net/coh/smfconvert_v2.zip) to convert .wav to .smf + .bsc.
- copy the .bsc to Data/sound/ and the .smf to Data/sound/wav/
- use this code to play sounds:
g_streamed_sounds = {}
function Rule_Play_Streamed_Sound()
local sound_info = g_streamed_sounds[1]
Sound_PreCacheSound(sound_info.sound)
Sound_Play2D(sound_info.sound)
table.remove(g_streamed_sounds, 1)
TimeRule_RemoveMe()
if (#g_streamed_sounds > 0) then
Rule_AddOneShot(Rule_Play_Streamed_Sound, sound_info.time)
end
end
local function Play_Streamed_Sound(sound, time)
local sound_info = {
sound = sound,
time = time
}
table.insert(g_streamed_sounds, sound_info)
if (not TimeRule_Exists(Rule_Play_Streamed_Sound)) then
Rule_AddOneShot(Rule_Play_Streamed_Sound, 0)
end
end
- then play sounds like this:
Play_Streamed_Sound("mysound1", 10)
Play_Streamed_Sound("mysound2", 5)
Play_Streamed_Sound("mysound3", 1)
..this means mysound2 is played after 10 seconds and mysound3 is played after 15 seconds.