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

SoundTable


A sound table contains many-to-many mappings from a key to a name of a sound. This allows to associate sounds with a certain category.

For example, Button entity has a sound table parameter. When it opens or close, it will look up the sounds mapped to the SOUND_OPEN and SOUND_CLOSE keys respectively. If it finds a sound that is mapped to a give key, it will play it back.

Since there can be multiple sounds mapped to the same key, if there arises such a situation when a sound is being looked up and there are multiple sounds associated with the given key, a random sound that is mapped to said key will be returned.

Programming in C++


#include <extensions/kitchensink/soundtable.h>
API documentation page.

Very simple API. It was supposed to be very simple, so it is such.

SoundTable* table = SoundTable::Find("table");

table->AddSound(SOUND_OPEN, "open1");
table->AddSound(SOUND_OPEN, "open2");
table->AddSound(SOUND_CLOSE, "close1");

// this variable will be set to "close1"
name_t sound = table->GetSound(SOUND_CLOSE);

// this will play back either "open1" or "open2"
table->Play(SOUND_OPEN);