Tramway SDK
Functions
tram::Audio::API Namespace Reference

Functions

void Init ()
 
void Update ()
 
void Uninit ()
 
void SetListenerPosition (vec3 position)
 Sets the listener position. More...
 
void SetListenerOrientation (quat orientation)
 Sets the listener orientation. More...
 
void SetListenerGain (float gain)
 
audiobuffer_t MakeAudioBuffer (const int16_t *audio_data, int32_t length, int32_t samples, int32_t channels)
 Creates audio buffers from raw audio data. More...
 
void RemoveAudioBuffer (audiobuffer_t buffer)
 Deletes audio buffers. More...
 
audiosource_t MakeAudioSource ()
 Creates an audio source. More...
 
void SetAudioSourcePitch (audiosource_t source, float pitch)
 Sets the pitch of an audio source. More...
 
void SetAudioSourceGain (audiosource_t source, float gain)
 Sets the gain of an audio source. More...
 
void SetAudioSourcePosition (audiosource_t source, vec3 position)
 Sets the position of an audio source. More...
 
void SetAudioSourceVelocity (audiosource_t source, vec3 velocity)
 Sets the velocity of an audio source. More...
 
void SetAudioSourceRepeating (audiosource_t source, bool repeating)
 Sets the repetition of an audio source. More...
 
void SetAudioSourceBuffer (audiosource_t source, audiobuffer_t buffer)
 Sets the buffers that the audio source will play. More...
 
void PlayAudioSource (audiosource_t source)
 Plays an audio source. More...
 
void PauseAudioSource (audiosource_t source)
 Pauses the audio source. More...
 
void StopAudioSource (audiosource_t source)
 Stops the audio source. More...
 
bool IsAudioSourcePlaying (audiosource_t source)
 Checks if an audio source is playing. More...
 
void RemoveAudioSource (audiosource_t source)
 Deletes an audio source. More...
 

Function Documentation

◆ Init()

void tram::Audio::API::Init ( )

◆ IsAudioSourcePlaying()

bool tram::Audio::API::IsAudioSourcePlaying ( audiosource_t  source)

Checks if an audio source is playing.

Returns
True if the audio source is playing a sound, false otherwise.

◆ MakeAudioBuffer()

audiobuffer_t tram::Audio::API::MakeAudioBuffer ( const int16_t *  audio_data,
int32_t  length,
int32_t  samples,
int32_t  channels 
)

Creates audio buffers from raw audio data.

Parameters
audio_dataPointer to the raw audio data, stored as 16 bit PCM.
lengthLength of the raw audio data, in samples.
buffer_countCreated buffer count will be stored in this variable.

◆ MakeAudioSource()

audiosource_t tram::Audio::API::MakeAudioSource ( )

Creates an audio source.

Returns
A new audio source handle.

◆ PauseAudioSource()

void tram::Audio::API::PauseAudioSource ( audiosource_t  source)

Pauses the audio source.

◆ PlayAudioSource()

void tram::Audio::API::PlayAudioSource ( audiosource_t  source)

Plays an audio source.

◆ RemoveAudioBuffer()

void tram::Audio::API::RemoveAudioBuffer ( audiobuffer_t  buffer)

Deletes audio buffers.

◆ RemoveAudioSource()

void tram::Audio::API::RemoveAudioSource ( audiosource_t  source)

Deletes an audio source.

If you do this, then the audio source handle will become invalid. Call MakeAudioSource() to get a new one.

◆ SetAudioSourceBuffer()

void tram::Audio::API::SetAudioSourceBuffer ( audiosource_t  source,
audiobuffer_t  buffer 
)

Sets the buffers that the audio source will play.

◆ SetAudioSourceGain()

void tram::Audio::API::SetAudioSourceGain ( audiosource_t  source,
float  gain 
)

Sets the gain of an audio source.

Parameters
gain1.0f is the regular gain. Halving the value decreases the gain by 6dB.

◆ SetAudioSourcePitch()

void tram::Audio::API::SetAudioSourcePitch ( audiosource_t  source,
float  pitch 
)

Sets the pitch of an audio source.

Parameters
pitch1.0f is the regular pitch. Halving the value decreases the pitch by an octave. Doubling the value increases the pitch by an octave.

◆ SetAudioSourcePosition()

void tram::Audio::API::SetAudioSourcePosition ( audiosource_t  source,
vec3  position 
)

Sets the position of an audio source.

◆ SetAudioSourceRepeating()

void tram::Audio::API::SetAudioSourceRepeating ( audiosource_t  source,
bool  repeating 
)

Sets the repetition of an audio source.

Parameters
repeatingTrue if the sound repeats after playing, false if it just stops.

◆ SetAudioSourceVelocity()

void tram::Audio::API::SetAudioSourceVelocity ( audiosource_t  source,
vec3  velocity 
)

Sets the velocity of an audio source.

◆ SetListenerGain()

void tram::Audio::API::SetListenerGain ( float  gain)

◆ SetListenerOrientation()

void tram::Audio::API::SetListenerOrientation ( quat  orientation)

Sets the listener orientation.

Parameters
orientationListener orientation. Under normal circumstances, it should be the same as render view rotation.

◆ SetListenerPosition()

void tram::Audio::API::SetListenerPosition ( vec3  position)

Sets the listener position.

Parameters
positionListener position. Under normal circumstances, it should be the same as render view position.

◆ StopAudioSource()

void tram::Audio::API::StopAudioSource ( audiosource_t  source)

Stops the audio source.

◆ Uninit()

void tram::Audio::API::Uninit ( )

◆ Update()

void tram::Audio::API::Update ( )