YSE sound engine  1.0
cross platform sound engine
 All Classes Namespaces Functions Pages
YSE::SOUND::interfaceObject Class Reference

Public Member Functions

 interfaceObject (const interfaceObject &)=delete
 
interfaceObjectcreate (const char *fileName, channel *ch=nullptr, Bool loop=false, Flt volume=1.0f, Bool streaming=false)
 
interfaceObjectcreate (DSP::dspSourceObject &dsp, channel *ch=nullptr, Flt volume=1.0f)
 
interfaceObjectcreate (SYNTH::interfaceObject &synth, channel *ch=nullptr, Flt volume=1.0f)
 
Bool isValid ()
 
interfaceObjectsetPosition (const Vec &v)
 
Vec getPosition ()
 
interfaceObjectsetSpread (Flt value)
 
Flt getSpread ()
 
interfaceObjectsetSpeed (Flt value)
 
Flt getSpeed ()
 
interfaceObjectsetSize (Flt value)
 
Flt getSize ()
 
interfaceObjectsetLooping (Bool value)
 
Bool isLooping ()
 
interfaceObjectsetVolume (Flt value, UInt time=0)
 
Flt getVolume ()
 
interfaceObjectfadeAndStop (UInt time)
 
interfaceObjectplay ()
 
Bool isPlaying ()
 
interfaceObjectpause ()
 
Bool isPaused ()
 
interfaceObjectstop ()
 
Bool isStopped ()
 
interfaceObjecttoggle ()
 
interfaceObjectrestart ()
 
interfaceObjectsetTime (Flt value)
 
Flt getTime ()
 
UInt getLength ()
 
interfaceObjectsetRelative (Bool value)
 
Bool isRelative ()
 
interfaceObjectsetDoppler (Bool value)
 
Bool getDoppler ()
 
interfaceObjectset2D (Bool value)
 
Bool is2D ()
 
Bool isStreaming ()
 
Bool isReady ()
 
interfaceObjectsetOcclusion (Bool value)
 
Bool getOcclusion ()
 
interfaceObjectmoveTo (channel &target)
 
interfaceObjectsetDSP (DSP::dspObject *value)
 
DSP::dspObjectgetDSP ()
 

Detailed Description

A sound object is needed for every kind of sound you want to use.

Sounds can use audio files (wav, ogg, flac, and more on some systems) or can be linked to a DSP source. Sounds can be mono, stereo or multichannel.

If a soundfile is streamed, it will use its own soundbuffer. Otherwise YSE will create a new buffer only if needed or re-use and existing buffer if another file with the same filename has already been loaded. Unloading of soundfiles and clearing memory is done internally: when a buffer is not used by any sound any more, it will be flagged for deletion.

Definition at line 36 of file soundInterface.hpp.

Member Function Documentation

interfaceObject& YSE::SOUND::interfaceObject::create ( const char *  fileName,
channel ch = nullptr,
Bool  loop = false,
Flt  volume = 1.0f,
Bool  streaming = false 
)

Create a filebased sound and register it with the soundsystem.

Other functions will not work as long as a sound hasn't been created. In debug mode, an assertion will be called if you try to do so. On the other hand, create cannot be called twice. If you need another sound, create a new sound object.

Parameters
fileNameThis can be an absolute path or something relative to the working directory.
channelThe sound channel you want to attach the sound to. Sounds can be moved to other channels at any time. If no channel is provided, the sound will be added to the global channel (mainMix).
loopUse true to loop this sound continuously. If not provided, the sound will not loop.
volumeThe initial volume to play this sound. This should be a value between 0.0 and 1.0. Default is 1.0.
streamingWhether or not this sound should be streamed. Defaults to false. Streaming is mainly intended for big audio files that are only used by a single sound. When a sound is used repeatedly, avoid streaming.
interfaceObject& YSE::SOUND::interfaceObject::create ( DSP::dspSourceObject dsp,
channel ch = nullptr,
Flt  volume = 1.0f 
)

Create a DSP sound and register it with the soundsystem.

In contrast to a filebased sound, the source if this soundobject will be generated by a dspSourceObject you provide yourself.

Parameters
dspYou provide a reference to an object for sound generation. Such objects must be based on dspSourceOBject.
channelThe channel to attach the sound to. If no channel is provided, the sound will be added to the global channel (mainMix).
volumeThe volume at which to start playing this sound.
interfaceObject& YSE::SOUND::interfaceObject::create ( SYNTH::interfaceObject synth,
channel ch = nullptr,
Flt  volume = 1.0f 
)

Registers a synth with the soundsystem.

In contrast to a filebased sound, the source if this soundobject will be generated by a synth you provide yourself.

Parameters
synthYou provide a reference to an synth for sound generation.
channelThe channel to attach the sound to. If no channel is provided, the sound will be added to the global channel (mainMix).
volumeThe volume at which to start playing this sound.
interfaceObject& YSE::SOUND::interfaceObject::setSpread ( Flt  value)

This is only useful for multichannel sounds.

If a sound has more than one channel, the channels can be spread out over the stereo or surround field. This defines how much space there is between the position of the channels.

interfaceObject& YSE::SOUND::interfaceObject::setSpeed ( Flt  value)

The speed at which a sound plays back alters it's pitch.

The actual speed will also be affected by velocity (doppler effect) unless doppler is disabled.

Internally this value will never be set entirely to zero, because that would result in static output that might damage speakers.

A negative value is also possible and will result in the sound being played backwards. Streaming sounds will not be played backwards though, because this would require an insane amount of disk activity. (This might change later on because SSD disks do not suffer from this.

interfaceObject& YSE::SOUND::interfaceObject::setSize ( Flt  value)

Set the 'size' of the sound.

This defines from how far away in the virtual space a sound will be heard.

Flt YSE::SOUND::interfaceObject::getSize ( )

Returns the current size of the sound, ie.

how far away it will be heard.

interfaceObject& YSE::SOUND::interfaceObject::setLooping ( Bool  value)

Set if this sound is looping or one-shot.

Should be obvious, right?

interfaceObject& YSE::SOUND::interfaceObject::setVolume ( Flt  value,
UInt  time = 0 
)

Sets the volume for this sound.

You can use this as a fader by supplying a time value.

Parameters
valueThe target volume.
timeIf supplied, do a smooth change to the target volume over 'time' milliseconds. (Default is 0.)
Flt YSE::SOUND::interfaceObject::getVolume ( )

Get the current volume.

This can be different from the current target volume if a time has been supplied when setVolume() is used.

interfaceObject& YSE::SOUND::interfaceObject::fadeAndStop ( UInt  time)

Fadeout the over 'time' milliseconds.

Then stop the sound.

interfaceObject& YSE::SOUND::interfaceObject::pause ( )

Pause this sound.

Starting it again will continue from the current position.

interfaceObject& YSE::SOUND::interfaceObject::stop ( )

Stop this sound.

The position in the source file will be reset to zero. If started again, the sound will start from the beginning.

interfaceObject& YSE::SOUND::interfaceObject::setTime ( Flt  value)

Set the current plahing position in the file.

Don't get confused here with setPosition, which sets the position in the virtual space where the sound will be rendered.

Parameters
valueThe new position in samples. Must be between 0 and the length of the file.
Flt YSE::SOUND::interfaceObject::getTime ( )

Get the current playing position in the file.

Don't get confused here with getPosition, which gets the position in the virtual space where the sound will be rendered.

Returns
the current position in samples.
UInt YSE::SOUND::interfaceObject::getLength ( )

Get the length of the file.

Returns
the length in samples.
interfaceObject& YSE::SOUND::interfaceObject::setRelative ( Bool  value)

Make a sound relative to the Listener() object.

This is YSE's alternative to '2D' sounds. Relative sounds can still move, but they move along with the player. By default this is how Gui sounds and music are used in most gaming sound setups.

But there's more: by making the sounds relative instead of fixed, you can still to other stuff with them. The sound can still be moving.

interfaceObject& YSE::SOUND::interfaceObject::setDoppler ( Bool  value)

Enable / disable doppler for this sound.

See Also
System().setDopplerScale() for global doppler behaviour
Bool YSE::SOUND::interfaceObject::isReady ( )

Will be true if the sound is ready to be played (or if it is already playing).

This can take a while if a sound is not streaming because loading sounds into memory is done in a seperate time as not to obstruct the audio callback. Not that it is not needed to wait for this result to be true before you can use most other functions with this sound. For instance, if you use the play() function, the sound will be played when it becomes ready.

interfaceObject& YSE::SOUND::interfaceObject::setOcclusion ( Bool  value)

This will enable sound occlusion for this sound.

Remember to setup an occlusion callback function in System() first.

interfaceObject& YSE::SOUND::interfaceObject::moveTo ( channel target)

Moves the sound to another channel.

Parameters
targetThe target channel

The documentation for this class was generated from the following file: