October 28, 2020, 05:55:24 AM

Author Topic: [bb] Sound Managment (replacing playsound and emitsound) by Ziltch [ 1+ years ago ]  (Read 1214 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Sound Managment  (replacing playsound and emitsound)
Author : Ziltch
Posted : 1+ years ago

Description : Use this function instead of playsound and emitsound.
This should help manage your game sounds.

eg
  change   playsound(backtrack) to playsnd(backtrack)
  and      roar=emitsound(roar,lion) to roar=playsnd(roar,lion)

You can also set the samples volume using the vol parameter.

eg

  full volume   backingsample=playsnd(backtrack)
  half volume   backingsample=playsnd(backtrack,0,.5)


Code :
Code: BlitzBasic
  1. type sample
  2.         field snd
  3. end type
  4.  
  5. Function playsnd(snd,src_ent=0,vol#=1)
  6.   nosounds = true
  7.   If snd = 0 Then
  8. ;   DebugLog "no sound to play"
  9.     Return
  10.   end if
  11.   For as.sample = each sample
  12.     If Not ChannelPlaying(assnd) Then
  13.       nosounds = false
  14.       exit
  15.     end if
  16.   Next
  17.   if nosounds then as.sample = new sample
  18.   SoundVolume snd,vol
  19.  
  20.   If src_ent = 0 Then
  21.     assnd=PlaySound(snd)
  22.   Else
  23.     assnd=EmitSound(snd,src_ent)
  24.   End If
  25.  
  26. ;       debuglog snd +" = " +           assnd
  27.   return assnd
  28.                  
  29. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal