Tramway SDK
sound.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_AUDIO_SOUND_H
5#define TRAM_SDK_AUDIO_SOUND_H
6
7#include <audio/audio.h>
8
10
11namespace tram::Audio {
12
13class Sound : public Resource {
14public:
16 int32_t channels = 0;
17 int32_t sample_rate = 0;
18 int32_t sound_length = 0;
19 int16_t* sound_data = nullptr;
20
21 void LoadFromDisk();
23 void Unload();
24
26 inline float GetLength() { return (float)sound_length/(float)sample_rate; }
27
28 static Sound* Find (name_t name);
29protected:
31 template <typename> friend class tram::Pool;
32};
33
34}
35
36#endif // TRAM_SDK_AUDIO_SOUND_H
37
Definition: sound.h:13
int32_t sample_rate
Definition: sound.h:17
audiobuffer_t sound_buffer
Definition: sound.h:15
void Unload()
Removes the sound from memory.
Definition: sound.cpp:42
Sound(name_t name)
Definition: sound.h:30
void LoadFromMemory()
Definition: sound.h:22
int32_t channels
Definition: sound.h:16
int16_t * sound_data
Definition: sound.h:19
float GetLength()
Returns sound length in seconds.
Definition: sound.h:26
int32_t sound_length
Definition: sound.h:18
static Sound * Find(name_t name)
Finds a sound by a name.
Definition: sound.cpp:50
void LoadFromDisk()
Loads the sound from the disk.
Definition: sound.cpp:23
Definition: pool.h:14
Definition: resource.h:12
name_t name
Definition: resource.h:38
Definition: api.h:9
Definition: audio.h:19
Definition: uid.h:11