Tramway SDK
sound.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_AUDIO_SOUND_H
4#define TRAM_SDK_AUDIO_SOUND_H
5
6#include <audio/audio.h>
7
9
16namespace tram::Audio {
17
18class Sound : public Resource {
19public:
21 int32_t channels = 0;
22 int32_t sample_rate = 0;
23 int32_t sound_length = 0;
24 int16_t* sound_data = nullptr;
25
26 void LoadFromDisk();
28 void Unload();
29
31 inline float GetLength() { return (float)sound_length/(float)sample_rate; }
32
33 static Sound* Find (name_t name);
34protected:
36 template <typename> friend class tram::Pool;
37};
38
39}
40
41#endif // TRAM_SDK_AUDIO_SOUND_H
42
Main interface for the Audio system.
Audio data resource.
Definition: sound.h:18
int32_t sample_rate
Definition: sound.h:22
audiobuffer_t sound_buffer
Definition: sound.h:20
void Unload()
Removes the sound from memory.
Definition: sound.cpp:67
Sound(name_t name)
Definition: sound.h:35
void LoadFromMemory()
Definition: sound.h:27
int32_t channels
Definition: sound.h:21
int16_t * sound_data
Definition: sound.h:24
float GetLength()
Returns sound length in seconds.
Definition: sound.h:31
int32_t sound_length
Definition: sound.h:23
static Sound * Find(name_t name)
Finds a sound by a name.
Definition: sound.cpp:75
void LoadFromDisk()
Loads the sound from the disk.
Definition: sound.cpp:37
Definition: pool.h:21
Definition: resource.h:11
name_t name
Definition: resource.h:37
System for doing audio related stuff.
Audio buffer handle.
Definition: audio.h:26
Interned string type.
Definition: uid.h:10