Project Alice
Loading...
Searching...
No Matches
sound_win.hpp
Go to the documentation of this file.
1#pragma once
2
3struct IGraphBuilder;
4struct IMediaControl;
5struct IBasicAudio;
6struct IMediaSeeking;
7struct IMediaEventEx;
8typedef struct HWND__* HWND;
9
10namespace sound {
11
12class audio_instance {
13private:
14 IGraphBuilder* graph_interface = nullptr;
15 IMediaControl* control_interface = nullptr;
16 IBasicAudio* audio_interface = nullptr;
17 IMediaSeeking* seek_interface = nullptr;
18 IMediaEventEx* event_interface = nullptr;
19 std::atomic<bool> interface_lock;
20public:
21 std::wstring filename;
22 float volume_multiplier = 1.0f;
23
25 audio_instance(std::wstring const& file) : filename(file) { }
28 : graph_interface(o.graph_interface), control_interface(o.control_interface),
29 audio_interface(o.audio_interface), seek_interface(o.seek_interface), event_interface(o.event_interface), filename(std::move(o.filename)),
30 volume_multiplier(o.volume_multiplier) {
31
32 o.graph_interface = nullptr;
33 o.control_interface = nullptr;
34 o.audio_interface = nullptr;
35 o.seek_interface = nullptr;
36 o.event_interface = nullptr;
37 }
39
40 void set_file(std::wstring const& file) {
41 filename = file;
42 }
43 void play(float volume, bool as_music, void* window_handle);
44 void pause() const;
45 void resume() const;
46 void stop() const;
47 bool is_playing() const;
48 void change_volume(float new_volume) const;
49
50 friend class sound_impl;
51};
52
53class sound_impl {
54private:
55 audio_instance* current_effect = nullptr;
56 audio_instance* current_interface_sound = nullptr;
57
58public:
60 int32_t last_music = -1;
61 int32_t first_music = -1;
62 bool global_pause = false;
63
111
112 std::vector<audio_instance> music_list;
113
114 void play_effect(audio_instance& s, float volume);
115 void play_interface_sound(audio_instance& s, float volume);
116 void play_music(int32_t track, float volume);
117
118 void pause_effect() const;
119 void pause_interface_sound() const;
120 void pause_music() const;
121
122 void resume_effect() const;
123 void resume_interface_sound() const;
124 void resume_music() const;
125
126 void change_effect_volume(float v) const;
127 void change_interface_volume(float v) const;
128 void change_music_volume(float v) const;
129
130 bool music_finished() const;
131
135};
136
137} // namespace sound
void resume() const
Definition: sound_win.cpp:135
native_string filename
Definition: sound_nix.hpp:10
void change_volume(float new_volume) const
Definition: sound_win.cpp:156
audio_instance(std::wstring const &file)
Definition: sound_win.hpp:25
audio_instance(audio_instance &&o) noexcept
Definition: sound_win.hpp:27
void play(float volume, bool as_music, void *window_handle)
Definition: sound_win.cpp:39
audio_instance(audio_instance const &)=delete
bool is_playing() const
Definition: sound_win.cpp:144
std::wstring filename
Definition: sound_win.hpp:21
void pause() const
Definition: sound_win.cpp:131
void set_file(std::wstring const &file)
Definition: sound_win.hpp:40
void resume_interface_sound() const
Definition: sound_win.cpp:281
audio_instance province_select_sounds[4]
Definition: sound_nix.hpp:74
void pause_music() const
Definition: sound_win.cpp:270
audio_instance tab_diplomacy_sound
Definition: sound_nix.hpp:43
audio_instance land_battle_sounds[6]
Definition: sound_nix.hpp:72
int32_t first_music
Definition: sound_nix.hpp:82
audio_instance railroad_built_sound
Definition: sound_nix.hpp:63
void play_interface_sound(audio_instance &s, float volume)
Definition: sound_win.cpp:223
audio_instance revolt_sound
Definition: sound_nix.hpp:61
audio_instance decline_sound
Definition: sound_nix.hpp:67
audio_instance naval_base_built_sound
Definition: sound_nix.hpp:64
audio_instance navy_move_sound
Definition: sound_nix.hpp:51
void play_music(int32_t track, float volume)
audio_instance click_left_sound
Definition: sound_nix.hpp:33
audio_instance army_select_sound
Definition: sound_nix.hpp:50
void pause_effect() const
Definition: sound_win.cpp:262
audio_instance major_event_sound
Definition: sound_nix.hpp:66
audio_instance tab_production_sound
Definition: sound_nix.hpp:46
void resume_music() const
Definition: sound_win.cpp:285
audio_instance minor_event_sound
Definition: sound_nix.hpp:65
audio_instance console_open_sound
Definition: sound_nix.hpp:70
audio_instance checkbox_sound
Definition: sound_nix.hpp:37
audio_instance declaration_of_war_sound
Definition: sound_nix.hpp:53
audio_instance diplomatic_request_sound
Definition: sound_nix.hpp:69
std::vector< audio_instance > music_list
Definition: sound_nix.hpp:80
audio_instance tab_politics_sound
Definition: sound_nix.hpp:42
audio_instance decision_sound
Definition: sound_nix.hpp:76
audio_instance fort_built_sound
Definition: sound_nix.hpp:62
int32_t last_music
Definition: sound_nix.hpp:81
audio_instance navy_select_sound
Definition: sound_nix.hpp:52
audio_instance tab_budget_sound
Definition: sound_nix.hpp:35
void change_effect_volume(float v) const
Definition: sound_win.cpp:245
audio_instance factory_built_sound
Definition: sound_nix.hpp:59
void resume_effect() const
Definition: sound_win.cpp:277
audio_instance accept_sound
Definition: sound_nix.hpp:68
audio_instance tab_military_sound
Definition: sound_nix.hpp:44
audio_instance autochoose_sound
Definition: sound_nix.hpp:41
audio_instance army_move_sound
Definition: sound_nix.hpp:49
void change_interface_volume(float v) const
Definition: sound_win.cpp:250
void play_new_track(sys::state &ws)
audio_instance console_close_sound
Definition: sound_nix.hpp:71
audio_instance unpause_sound
Definition: sound_nix.hpp:78
void play_previous_track(sys::state &ws)
audio_instance naval_battle_sounds[6]
Definition: sound_nix.hpp:73
audio_instance delete_sound
Definition: sound_nix.hpp:40
audio_instance tab_technology_sound
Definition: sound_nix.hpp:47
void play_effect(audio_instance &s, float volume)
Definition: sound_win.cpp:213
audio_instance tab_population_sound
Definition: sound_nix.hpp:45
audio_instance subtab_sound
Definition: sound_nix.hpp:39
audio_instance click_right_sound
Definition: sound_nix.hpp:34
audio_instance error_sound
Definition: sound_nix.hpp:55
audio_instance enact_sound
Definition: sound_nix.hpp:38
audio_instance click_sound
Definition: sound_nix.hpp:32
audio_instance army_built_sound
Definition: sound_nix.hpp:57
bool music_finished()
Definition: sound_nix.cpp:78
void pause_interface_sound() const
Definition: sound_win.cpp:266
void play_next_track(sys::state &ws)
audio_instance technology_finished_sound
Definition: sound_nix.hpp:48
void change_music_volume(float v) const
Definition: sound_win.cpp:255
audio_instance chat_message_sound
Definition: sound_nix.hpp:54
audio_instance election_sound
Definition: sound_nix.hpp:60
audio_instance hover_sound
Definition: sound_nix.hpp:36
audio_instance pause_sound
Definition: sound_nix.hpp:77
audio_instance navy_built_sound
Definition: sound_nix.hpp:58
audio_instance peace_sound
Definition: sound_nix.hpp:56
audio_instance event_sound
Definition: sound_nix.hpp:75
Definition: sound.hpp:15
struct HWND__ * HWND
Definition: sound_win.hpp:8