GLBasic forum

Feature request => music/sound => Topic started by: Hemlos on 2015-Aug-16

Title: HUSH(channel%)
Post by: Hemlos on 2015-Aug-16
HUSH(channel%)

see my sound object below, youll see how it becomes useful.

Code: (glbasic) [Select]
TYPE lib_SOUND_Object_

SndObj_Name$
SndObj_Path$
SndObj_Buff%
SndObj_Balance%
SndObj_ID%

SndObj_Channel% //internal glbasic channel id

SndObj_Volume#
SndObj_Mute%
SndObj_IS_Playing%


// This sound is an object.
// A sound object is preloaded with independant balance and volume.
// This sounds volume level, can be controlled by a master volume input at playtime.
FUNCTION _SNDOBJ_LOAD: FilePath$, FileName$, NumBuffers%, Balance%// NumBuffers% [1..4], Returns ID%
self.SndObj_Name$ = FileName$
self.SndObj_Path$ = FilePath$
self.SndObj_Buff% = NumBuffers%
self.SndObj_Balance% = Balance%
self.SndObj_ID% = GENSOUND()
LOADSOUND ( self.SndObj_Path$ + self.SndObj_Name$ ), self.SndObj_ID%, self.SndObj_Buff%
RETURN self.SndObj_ID%
ENDFUNCTION


// is this object playing?
FUNCTION _SNDOBJ_ISPLAYING:
self.SndObj_IS_Playing% = SOUNDPLAYING(self.SndObj_Channel%)
RETURN self.SndObj_IS_Playing%
ENDFUNCTION


FUNCTION _SNDOBJ_PLAY: MasterVolume% // [0..1]
self.SndObj_Channel% = PLAYSOUND( self.SndObj_ID%, self.SndObj_Balance%, ( self.SndObj_Volume% * MasterVolume% ))
RETURN self.SndObj_Channel%
ENDFUNCTION


FUNCTION _SNDOBJ_STOP:
HUSH // HUSH(channel%) command requested
RETURN self._SNDOBJ_ISPLAYING()
ENDFUNCTION


ENDTYPE

Title: Re: HUSH(channel%)
Post by: spacefractal on 2015-Aug-17
is its not the same as STOPSOUND(Channel)? But yes its could route it to that command with HUSH as well.
Title: Re: HUSH(channel%)
Post by: Hemlos on 2015-Aug-18
Perfect, thanks.

I overlooked this command because it isnt linked to the tags in the help.
And i never even noticed it in the command list.