Latest version:
Tramway SDK 0.0.9
Github
Quick links
Home
Get Started

Audio Component


This EntityComponent is a wrapper for audio sources.

Pass in the sound which it needs to play, the position of the audio source and it will play it. Very easy. Very simple.

Programming in C++


#include <components/audio.h>
API documentation page.

Currently sounds won't get automatically streamed in via the Async system, so make sure that the sound is already loaded before passing it to the component:

Sound::Find("my-sound")->Load();

Remember to store the Component<> smart pointer in a class, static variable, or otherwise ensure that it doesn't immediately get destructed.

Component<AudioComponent> audio;

audio.make();
audio->SetLocation({0.0f, 0.0f, 0.0f});
audio->SetSound("my-sound");
audio->SetRepeating(true);
audio->Init();

After initialization, you can begin playback of the sound, pause it or stop it completely.

audio->Play();  // Begins the playback of the sound
audio->Pause(); // Pauses the playback
audio->Stop();  // Cancels the playback

You can also check the status of the playback.

// Since we stopped the playback, this will
// evaluate to false
if (audio->IsPlaying()) {
    printf("Audio source is playing.");
} else {
    printf("Audio source has stopped.");
}


Scripting in Lua


Not yet implemented.