Still not sure where I'm going wrong. Can you take a look at the full code snippet and let me know what I'm doing wrong? There are actually one of these segments of code for the left and right foot.
I load the sounds like....
SND_CrateCreek1 = LoadSound("Crate_Creek_1.wav")
SND_CrateCreek3 = LoadSound("Crate_Creek_3.wav")
Then they are played at specified times, based on how close the tile is to crumbling (TBC = Time Before Crumble) like this.....
If CrumbleTiles[1].TBC > 1000
SilenceCrateCreeking(1)
ElseIf CrumbleTiles[1].TBC =< 1000 and CrumbleTiles[1].TBC >= 500 // Creeking and animation of nails falling out
// Start Sound 1 if it is not playing. If it is playing, ramp up the volume
If GetSoundInstancePlaying(CrumbleTiles[1].Sound1) = 1
CrumbleTiles[1].Sound1Vol = CrumbleTiles[1].Sound1Vol + (LSF#*200) // Ramp up to 100 in half a second
SetSoundInstanceVolume( CrumbleTiles[1].Sound1, CrumbleTiles[1].Sound1Vol)
Else
CrumbleTiles[1].Sound1Vol = 0
CrumbleTiles[1].Sound1 = PlaySound(SND_CrateCreek1,CrumbleTiles[1].Sound1Vol)
Endif
// Stop Sound 2 if it is playing
If GetSoundInstancePlaying(CrumbleTiles[1].Sound2) = 1
CrumbleTiles[1].Sound2Vol = CrumbleTiles[1].Sound2Vol - (LSF#*200) // Ramp down to 0 in half a second
SetSoundInstanceVolume( CrumbleTiles[1].Sound2, CrumbleTiles[1].Sound2Vol)
If CrumbleTiles[1].Sound2Vol <=0
StopSoundInstance(CrumbleTiles[1].Sound2)
Endif
EndIf
ElseIf CrumbleTiles[1].TBC < 500 And CrumbleTiles[1].TBC > 0 // Cracking and animations of nails and pieces of wood falling out
// Start Sound 2 if it is not playing. If it is playing, increase the volume
If GetSoundInstancePlaying(CrumbleTiles[1].Sound2) = 1
CrumbleTiles[1].Sound2Vol = CrumbleTiles[1].Sound2Vol + (LSF#*200) // Ramp up to 100 in half a second
SetSoundInstanceVolume( CrumbleTiles[1].Sound2, CrumbleTiles[1].Sound2Vol)
Else
CrumbleTiles[1].Sound2Vol = 0
CrumbleTiles[1].Sound2 = PlaySound(SND_CrateCreek3, CrumbleTiles[1].Sound2Vol)
Endif
// Stop Sound 1 if it is playing
If GetSoundInstancePlaying(CrumbleTiles[1].Sound1) = 1
CrumbleTiles[1].Sound1Vol = CrumbleTiles[1].Sound1Vol - (LSF#*200) // Ramp down to 0 in half a second
SetSoundInstanceVolume( CrumbleTiles[1].Sound1, CrumbleTiles[1].Sound1Vol)
If CrumbleTiles[1].Sound1Vol <=0
StopSoundInstance(CrumbleTiles[1].Sound1)
Endif
EndIf
Endif
I'm then getting the following commands to report back to me and it's saying that there are an ever increasing number of sound instances playing (each sound instance never seems to die)
GetSoundInstances(SND_CrateCreek1)
GetSoundInstances(SND_CrateCreek3)
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)