Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
sound.h
1#pragma once
2
3#include "sound_bakery/core/core_include.h"
6
7#include <boost/serialization/binary_object.hpp>
8
9namespace sbk::engine
10{
14 struct SB_CLASS encoding_sound
15 {
16 std::filesystem::path rawSoundPath;
17 std::filesystem::path encodedSoundPath;
18 sc_encoding_format encodingFormat = sc_encoding_format_vorbis;
19 };
20
22 {
23 void operator()(void* data)
24 {
25 if (data)
26 {
27 std::free(data);
28 }
29 }
30 };
31
32 using raw_sound_ptr = std::unique_ptr<void, void_deleter>;
33
34 class SB_CLASS sound : public sbk::core::database_object
35 {
36 REGISTER_REFLECTION(sound, sbk::core::database_object)
37 LEAK_DETECTOR(sound)
38
39 public:
40 auto load_synchronous() -> void;
41 auto load_asynchronous() -> void;
42
43 auto set_sound_name(std::string soundName) -> void;
44 auto set_encoded_sound_name(std::string path) -> void;
45 auto get_encoded_sound_name() const -> std::string { return encodedSoundPath.string(); }
46 auto set_is_streaming(bool streaming) -> void { m_streaming = streaming; }
47 auto set_raw_sound_data(raw_sound_ptr& data, std::size_t size) -> void
48 {
49 m_memorySoundData = std::move(data);
50 m_memorySoundDataSize = size;
51 }
52
53 auto get_sound_name() const -> std::string;
54 auto get_sound() -> sc_sound*;
55 auto get_is_streaming() const -> bool{ return m_streaming; }
56 auto get_encoding_sound_data() const -> encoding_sound;
57
58 private:
59 std::unique_ptr<sc_sound, SC_SOUND_DELETER> m_sound;
60 raw_sound_ptr m_memorySoundData;
61 std::size_t m_memorySoundDataSize = 0;
62
63 std::filesystem::path rawSoundPath;
64 std::filesystem::path encodedSoundPath;
65
66 sc_encoding_format m_encodingFormat = sc_encoding_format_vorbis;
67
68 bool m_streaming = false;
69
70 };
71} // namespace sbk::engine
Base object type for any object that can exist in the editor/database. Holds an ID and name.
Definition database_object.h:12
Definition sound.h:35
A wrapper library for miniaudio that emulates functionality of FMOD.
Provides extensions to miniaudio's encoding API.
Data for converting a sound to an encoded format.
Definition sound.h:15
Definition sound.h:22
Definition sound_chef_common.h:191