Sound
Sound and music in unbound is made using synths.A synth is a piece of musical equipment that generates interactive and procedural sounds, they can change and react to your game.
createSynth()
Make a synth and store in memory.
Return
Synth , a pointer to a synth in memory
setSynthVolume(synth, volumeLeft, volumeRight)
Set the volume of the synth. Range is 0.0 to 1.0.
Arguments
synth: Synth, a pointer to a synth in memory.
volumeLeft: float, left channel volume.
volumeRight: float, right channel volume.
loadSynthWav(synth, wavFileName)
Load a wav file into this synth, then play it by invoking playSynthWav(synth, true). The wave filename should be specified as "project://mySound.wav"
Arguments
synth: Synth, a pointer to a synth in memory.
wavFileName: string
playSynthWav(synth, state, loop)
Play the wav file that was previously loaded using loadSynthWav(synth, "project://mySound.wav")
Arguments
synth: Synth, a pointer to a synth in memory.
state: boolean
loop: bool
playSynthNote(synth, midiNote, sustainTime, delayTime)
Play a midi note keeping it sustained for a certain amount of time.
Playing a note also means triggering the envelope within this synth, make sure to check setSynthEnvelope() as well.
Arguments
synth: Synth, a pointer to a synth in memory.
midiNote: float, midi note.
sustainTime: float, how long the note will be sustained.
delayTime: float, how long should the note wait before being played.
stopPlayingSynthNote(synth)
Stop a note while it's still playing.
Arguments
synth: Synth, a pointer to a synth in memory.
isSynthPlaying(synth)
Check if a synth is playing.
Arguments
synth: Synth, a pointer to a synth in memory.
Return
bool
playSynth(synth, state)
Play a synth with a sustained tone until it's switched off. Use setSynthOscillatorFrequency() to change how it sounds.
Arguments
synth: Synth, a pointer to a synth in memory.
state: boolean
setSynthOscillatorWave(synth, waveShape)
Set the wave shape of a synth's oscillator.
Each synth has one oscillator that can either play a note or a continuous sound.
Arguments
synth: Synth, a pointer to a synth in memory.
waveShape: int, available values are SYNTH_WAVE_SIN, SYNTH_WAVE_TRI, SYNTH_WAVE_SAW, SYNTH_WAVE_RAMP, SYNTH_WAVE_SQUARE, SYNTH_WAVE_POLYBLEP_TRI, SYNTH_WAVE_POLYBLEP_SAW, SYNTH_WAVE_POLYBLEP_SQUARE,
setSynthOscillatorFrequency(synth, freq)
Set the frequency of an oscillator.
Arguments
synth: Synth, a pointer to a synth in memory.
freq: float, frequency of the oscillator.
getSynthOscillatorOut(synth)
Get the output of a synth's oscillator as it plays.
Arguments
synth: Synth, a pointer to a synth in memory.
Return
float
setSynthReverb(synth, value)
Set the reverb amount of a synth.
Arguments
synth: Synth, a pointer to a synth in memory.
value: number
setSynthEnvelope(synth, attackTime, decayTime, sustainLevel, releaseTime)
Set an envelope shape to modulate notes when they are being played.
Arguments
synth: Synth, a pointer to a synth in memory.
attackTime: float, how long it takes for a note to go from level 0.0 to 1.0.
decayTime: float, how long it takes for a note to go from 1.0 to sustain level.
sustainLevel: float, the level or volume at which the note will be played while sustained.
releaseTime: float, how long it takes for a note to fade back to 0.0 after it gets released.
getSynthEnvelopeOut(synth)
Get a synth envelope while a note is being played.
Arguments
synth: Synth, a pointer to a synth in memory.
Return
float
setSynthNoise(synth, noiseAmount, noiseFrequency)
Set the noise level on a synth.
Arguments
synth: Synth, a pointer to a synth in memory.
noiseAmount:
noiseFrequency:
getSynthNoiseOut(synth)
Get noise values from a synth.
Arguments
synth: Synth, a pointer to a synth in memory.
Return
float
setGlobalSynthVolume(value)
Set the global sound volume.
Arguments
value: number