Blender V5.3
BKE_sound.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 * SPDX-FileCopyrightText: 2025 Blender Authors
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later */
5#pragma once
6
10
11#include <string>
12
13#include "BKE_sound_types.hh"
14
15#include "BLI_vector.hh"
16
17#if defined(WITH_AUDASPACE)
18# include <file/IWriter.h>
19#endif
20
21#define SOUND_WAVE_SAMPLES_PER_SECOND 250
22
23namespace blender {
24
25struct Depsgraph;
26struct Main;
27struct ReportList;
28struct Scene;
29struct Strip;
30struct bSound;
31
34
35void BKE_sound_init(Main *bmain);
36
37void BKE_sound_refresh_callback_bmain(Main *bmain);
38
39void BKE_sound_force_device(const char *device);
40
45bSound *BKE_sound_new_file_exists(Main *bmain, const char *filepath, short stream_index = 0);
46bSound *BKE_sound_new_file(Main *bmain, const char *filepath, short stream_index = 0);
47
48void BKE_sound_load(Main *bmain, bSound *sound);
49
56void BKE_sound_packfile_ensure(Main *bmain, bSound *sound, ReportList *reports);
57
70
71struct SoundInfo {
72 struct {
74 int samplerate;
76 float length;
77};
78
80 double duration;
81 double start;
82};
83
89bool BKE_sound_info_get(Main *main, bSound *sound, SoundInfo *sound_info);
90
97 const char *filepath,
98 int stream,
99 SoundStreamInfo *sound_info);
100
105int BKE_sound_stream_count(Main *main, const char *filepath);
106
107#if defined(WITH_AUDASPACE)
108AUD_Device BKE_sound_mixdown(const Scene *scene,
109 const aud::DeviceSpecs &specs,
110 int start,
111 float volume);
112#endif
113
114void BKE_sound_create_scene(Scene *scene);
115void BKE_sound_ensure_scene(Scene *scene);
116
117void BKE_sound_destroy_scene(Scene *scene);
118
119void BKE_sound_lock();
120void BKE_sound_unlock();
121
123
124void BKE_sound_mute_scene(Scene *scene, bool muted);
125
126void BKE_sound_update_fps(Main *bmain, Scene *scene);
127
129
132
134
135void BKE_sound_mute_scene_sound(AUD_SequenceEntry handle, bool mute);
136
137void BKE_sound_move_scene_sound(const Scene *scene,
138 AUD_SequenceEntry handle,
139 int startframe,
140 int endframe,
141 int frameskip,
142 double audio_offset);
144
147
154
155void BKE_sound_set_scene_volume(Scene *scene, float volume);
156
158 int frame,
159 float volume,
160 bool animated);
161
163 int frame,
164 float pitch,
165 bool animated);
166
168 int frame_start,
169 int frame_end,
170 float pitch);
171
173 int frame,
174 float time_stretch,
175 bool animated);
176
178 int frame_start,
179 int frame_end,
180 float time_stretch);
181
183 int frame,
184 float pan,
185 bool animated);
186
188
189void BKE_sound_play_scene(Scene *scene);
190
191void BKE_sound_stop_scene(Scene *scene);
192
193void BKE_sound_seek_scene(Main *bmain, Scene *scene);
194
195double BKE_sound_sync_scene(Scene *scene);
196
197void BKE_sound_read_waveform(Main *bmain, bSound *sound, bool *stop);
198
199void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene);
200
202
203float BKE_sound_get_length(Main *bmain, bSound *sound);
204
206
207typedef void (*SoundJackSyncCallback)(Main *bmain, int mode, double time);
208
210void BKE_sound_jack_scene_update(Scene *scene, int mode, double time);
211
212void BKE_sound_evaluate(Depsgraph *depsgraph, Main *bmain, bSound *sound);
213
215
217 AUD_Sound *r_cache,
218 AUD_Sound *r_playback_handle,
219 Vector<float> **r_waveform);
220void BKE_sound_runtime_state_set(const bSound *sound,
221 AUD_Sound cache,
222 AUD_Sound playback_handle,
223 Vector<float> *waveform);
224
226
230
231#if defined(WITH_AUDASPACE)
232namespace bke {
233void sound_system_initialize();
234AUD_Device sound_device_init(const char *device,
235 const aud::DeviceSpecs &specs,
236 int buffersize,
237 const char *name);
238void sound_device_exit();
239AUD_Handle sound_device_play(AUD_Device device, AUD_Sound sound);
240bool sound_device_read(AUD_Device device, unsigned char *buffer, int length);
241AUD_Handle sound_pause_after(AUD_Handle handle, double seconds);
242SoundInfo sound_info_get(AUD_Sound sound);
243float *sound_read_file_buffer(const char *filename,
244 float low,
245 float high,
246 float attack,
247 float release,
248 float threshold,
249 bool accumulate,
250 bool additive,
251 bool square,
252 float sthreshold,
253 double samplerate,
254 int stream,
255 int *length);
256
257bool sound_mixdown(AUD_Sequence sequence,
258 unsigned int start,
259 unsigned int length,
260 unsigned int buffersize,
261 const char *filename,
262 const aud::DeviceSpecs &specs,
263 aud::Container format,
264 aud::Codec codec,
265 unsigned int bitrate,
266 bool split_channels,
267 std::string &r_error,
268 bool (*progress_callback)(float, void *),
269 void *progress_data);
270
271} // namespace bke
272#endif // #if defined(WITH_AUDASPACE)
273
274} // namespace blender
std::shared_ptr< void > AUD_Sequence
std::shared_ptr< void > AUD_SequenceEntry
std::shared_ptr< void > AUD_Sound
std::shared_ptr< void > AUD_Handle
std::shared_ptr< void > AUD_Device
Definition scene.h:133
#define main()
float length(VecOp< float, D >) RET
float square(float v)
std::string filename(const std::string_view &str, size_t pos)
BMesh Iterators.
void BKE_sound_force_device(const char *device)
void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene)
@ SOUND_CHANNELS_INVALID
Definition BKE_sound.hh:60
@ SOUND_CHANNELS_SURROUND4
Definition BKE_sound.hh:64
@ SOUND_CHANNELS_MONO
Definition BKE_sound.hh:61
@ SOUND_CHANNELS_SURROUND5
Definition BKE_sound.hh:65
@ SOUND_CHANNELS_STEREO_LFE
Definition BKE_sound.hh:63
@ SOUND_CHANNELS_SURROUND51
Definition BKE_sound.hh:66
@ SOUND_CHANNELS_SURROUND61
Definition BKE_sound.hh:67
@ SOUND_CHANNELS_STEREO
Definition BKE_sound.hh:62
@ SOUND_CHANNELS_SURROUND71
Definition BKE_sound.hh:68
AUD_Sound BKE_sound_playback_handle_get(const bSound *sound)
void BKE_sound_move_scene_sound_defaults(Scene *scene, Strip *strip)
void BKE_sound_mute_scene_sound(AUD_SequenceEntry handle, bool mute)
void BKE_sound_ensure_scene(Scene *scene)
void BKE_sound_jack_scene_update(Scene *scene, int mode, double time)
void BKE_sound_refresh_callback_bmain(Main *bmain)
bool BKE_sound_stream_info_get(Main *main, const char *filepath, int stream, SoundStreamInfo *sound_info)
void BKE_sound_move_scene_sound(const Scene *scene, AUD_SequenceEntry handle, int startframe, int endframe, int frameskip, double audio_offset)
void BKE_sound_reset_scene_specs(Scene *scene)
bSound * BKE_sound_new_file_exists(Main *bmain, const char *filepath, short stream_index=0)
bool BKE_sound_info_get(Main *main, bSound *sound, SoundInfo *sound_info)
AUD_SequenceEntry BKE_sound_add_scene_sound(Scene *scene, Strip *strip)
void BKE_sound_set_scene_sound_time_stretch_at_frame(AUD_Sound handle, int frame, float time_stretch, bool animated)
double BKE_sound_sync_scene(Scene *scene)
void BKE_sound_update_scene_listener(Scene *scene)
const Vector< float > * BKE_sound_runtime_get_waveform(const bSound *sound)
void BKE_sound_update_sequencer(Main *main, bSound *sound)
void BKE_sound_runtime_state_set(const bSound *sound, AUD_Sound cache, AUD_Sound playback_handle, Vector< float > *waveform)
void BKE_sound_play_scene(Scene *scene)
void BKE_sound_set_scene_sound_pitch_constant_range(AUD_SequenceEntry handle, int frame_start, int frame_end, float pitch)
int BKE_sound_stream_count(Main *main, const char *filepath)
float BKE_sound_get_length(Main *bmain, bSound *sound)
void(*) SoundJackSyncCallback(Main *bmain, int mode, double time)
Definition BKE_sound.hh:207
void BKE_sound_packfile_ensure(Main *bmain, bSound *sound, ReportList *reports)
void BKE_sound_runtime_state_get_and_clear(const bSound *sound, AUD_Sound *r_cache, AUD_Sound *r_playback_handle, Vector< float > **r_waveform)
void BKE_sound_set_scene_volume(Scene *scene, float volume)
char ** BKE_sound_get_device_names()
bSound * BKE_sound_new_file(Main *bmain, const char *filepath, short stream_index=0)
void BKE_sound_create_scene(Scene *scene)
void BKE_sound_set_scene_sound_time_stretch_constant_range(AUD_Sound handle, int frame_start, int frame_end, float time_stretch)
void BKE_sound_init(Main *bmain)
void BKE_sound_mute_scene(Scene *scene, bool muted)
void BKE_sound_update_fps(Main *bmain, Scene *scene)
void BKE_sound_runtime_clear_waveform_loading_tag(bSound *sound)
void BKE_sound_update_scene_sound(AUD_SequenceEntry handle, bSound *sound)
void BKE_sound_destroy_scene(Scene *scene)
void BKE_sound_read_waveform(Main *bmain, bSound *sound, bool *stop)
void BKE_sound_set_scene_sound_pitch_at_frame(AUD_SequenceEntry handle, int frame, float pitch, bool animated)
void BKE_sound_load(Main *bmain, bSound *sound)
void BKE_sound_remove_scene_sound(Scene *scene, AUD_SequenceEntry handle)
void BKE_sound_stop_scene(Scene *scene)
void BKE_sound_seek_scene(Main *bmain, Scene *scene)
AUD_SequenceEntry BKE_sound_scene_add_scene_sound(Scene *scene, Strip *strip)
void BKE_sound_set_scene_sound_volume_at_frame(AUD_SequenceEntry handle, int frame, float volume, bool animated)
AUD_Sound BKE_sound_get_factory(void *sound)
AUD_Sound BKE_sound_ensure_time_stretch_effect(const Strip *strip, float fps)
void BKE_sound_evaluate(Depsgraph *depsgraph, Main *bmain, bSound *sound)
void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback)
void BKE_sound_set_scene_sound_pan_at_frame(AUD_SequenceEntry handle, int frame, float pan, bool animated)
void BKE_sound_update_sequence_handle(AUD_SequenceEntry handle, AUD_Sound sound_handle)
bool BKE_sound_runtime_start_waveform_loading(bSound *sound)
struct blender::SoundInfo::@227301210053207103375114031212057322370226174015 specs