2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-18 14:05:18 +01:00
|
|
|
*/
|
|
|
|
|
2019-11-29 11:42:18 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-08-09 16:10:32 +02:00
|
|
|
#define SOUND_WAVE_SAMPLES_PER_SECOND 250
|
|
|
|
|
2017-08-18 08:24:12 +02:00
|
|
|
#if defined(WITH_AUDASPACE)
|
|
|
|
# include <AUD_Device.h>
|
2014-03-04 13:44:15 +01:00
|
|
|
#endif
|
|
|
|
|
2019-06-14 02:12:10 +02:00
|
|
|
struct Depsgraph;
|
2009-08-09 23:16:39 +02:00
|
|
|
struct Main;
|
2010-02-08 00:41:17 +01:00
|
|
|
struct Sequence;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct bSound;
|
2022-05-19 20:58:55 +02:00
|
|
|
struct SoundInfo;
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2012-05-10 17:22:29 +02:00
|
|
|
typedef struct SoundWaveform {
|
2011-08-09 16:10:32 +02:00
|
|
|
int length;
|
|
|
|
float *data;
|
|
|
|
} SoundWaveform;
|
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_init_once(void);
|
|
|
|
void BKE_sound_exit_once(void);
|
2010-04-24 18:35:16 +02:00
|
|
|
|
2015-07-29 02:43:32 +02:00
|
|
|
void *BKE_sound_get_device(void);
|
2014-11-12 12:33:28 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_init(struct Main *main);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_init_main(struct Main *bmain);
|
2011-08-09 10:38:14 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_exit(void);
|
2006-11-25 14:07:28 +01:00
|
|
|
|
2015-07-24 15:44:17 +02:00
|
|
|
void BKE_sound_force_device(const char *device);
|
2009-12-07 21:39:57 +01:00
|
|
|
|
2015-10-06 10:40:15 +02:00
|
|
|
struct bSound *BKE_sound_new_file(struct Main *main, const char *filepath);
|
|
|
|
struct bSound *BKE_sound_new_file_exists_ex(struct Main *bmain,
|
|
|
|
const char *filepath,
|
|
|
|
bool *r_exists);
|
|
|
|
struct bSound *BKE_sound_new_file_exists(struct Main *bmain, const char *filepath);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2021-08-26 04:27:17 +02:00
|
|
|
#if 0 /* UNUSED */
|
2015-03-26 11:39:08 +01:00
|
|
|
struct bSound *BKE_sound_new_buffer(struct Main *bmain, struct bSound *source);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-04-17 08:24:14 +02:00
|
|
|
struct bSound *BKE_sound_new_limiter(struct Main *bmain,
|
|
|
|
struct bSound *source,
|
|
|
|
float start,
|
|
|
|
float end);
|
2002-10-12 13:37:38 +02:00
|
|
|
#endif
|
2002-10-30 03:07:20 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_cache(struct bSound *sound);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_delete_cache(struct bSound *sound);
|
2009-08-26 20:20:17 +02:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
void BKE_sound_reset_runtime(struct bSound *sound);
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_load(struct Main *main, struct bSound *sound);
|
2019-06-04 16:52:48 +02:00
|
|
|
void BKE_sound_ensure_loaded(struct Main *bmain, struct bSound *sound);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2019-06-11 10:55:13 +02:00
|
|
|
/* Matches AUD_Channels. */
|
|
|
|
typedef enum eSoundChannels {
|
|
|
|
SOUND_CHANNELS_INVALID = 0,
|
|
|
|
SOUND_CHANNELS_MONO = 1,
|
|
|
|
SOUND_CHANNELS_STEREO = 2,
|
|
|
|
SOUND_CHANNELS_STEREO_LFE = 3,
|
|
|
|
SOUND_CHANNELS_SURROUND4 = 4,
|
|
|
|
SOUND_CHANNELS_SURROUND5 = 5,
|
|
|
|
SOUND_CHANNELS_SURROUND51 = 6,
|
|
|
|
SOUND_CHANNELS_SURROUND61 = 7,
|
|
|
|
SOUND_CHANNELS_SURROUND71 = 8,
|
|
|
|
} eSoundChannels;
|
|
|
|
|
|
|
|
typedef struct SoundInfo {
|
|
|
|
struct {
|
|
|
|
eSoundChannels channels;
|
2022-05-19 20:58:55 +02:00
|
|
|
int samplerate;
|
2019-06-11 10:55:13 +02:00
|
|
|
} specs;
|
|
|
|
float length;
|
|
|
|
} SoundInfo;
|
|
|
|
|
2021-08-30 22:36:02 +02:00
|
|
|
typedef struct SoundStreamInfo {
|
|
|
|
double duration;
|
|
|
|
double start;
|
|
|
|
} SoundStreamInfo;
|
|
|
|
|
2019-06-11 10:55:13 +02:00
|
|
|
/* Get information about given sound. Returns truth on success., false if sound can not be loaded
|
|
|
|
* or if the codes is not supported. */
|
|
|
|
bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *sound_info);
|
2019-06-04 16:52:48 +02:00
|
|
|
|
2021-08-30 22:36:02 +02:00
|
|
|
/* Get information about given sound. Returns truth on success., false if sound can not be loaded
|
|
|
|
* or if the codes is not supported. */
|
|
|
|
bool BKE_sound_stream_info_get(struct Main *main,
|
|
|
|
const char *filepath,
|
|
|
|
int stream,
|
|
|
|
SoundStreamInfo *sound_info);
|
|
|
|
|
2017-08-18 08:24:12 +02:00
|
|
|
#if defined(WITH_AUDASPACE)
|
2020-03-13 07:27:11 +01:00
|
|
|
AUD_Device *BKE_sound_mixdown(const struct Scene *scene,
|
|
|
|
AUD_DeviceSpecs specs,
|
|
|
|
int start,
|
|
|
|
float volume);
|
2010-02-08 00:41:17 +01:00
|
|
|
#endif
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2019-06-04 16:52:48 +02:00
|
|
|
void BKE_sound_reset_scene_runtime(struct Scene *scene);
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_create_scene(struct Scene *scene);
|
2019-06-04 16:52:48 +02:00
|
|
|
void BKE_sound_ensure_scene(struct Scene *scene);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_destroy_scene(struct Scene *scene);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2020-03-29 07:34:23 +02:00
|
|
|
void BKE_sound_lock(void);
|
|
|
|
void BKE_sound_unlock(void);
|
2020-03-23 09:33:02 +01:00
|
|
|
|
2017-01-06 18:18:20 +01:00
|
|
|
void BKE_sound_reset_scene_specs(struct Scene *scene);
|
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_mute_scene(struct Scene *scene, int muted);
|
2011-04-11 00:40:37 +02:00
|
|
|
|
2019-06-11 10:55:13 +02:00
|
|
|
void BKE_sound_update_fps(struct Main *bmain, struct Scene *scene);
|
2011-07-26 15:56:31 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_update_scene_listener(struct Scene *scene);
|
2011-08-03 11:25:40 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void *BKE_sound_scene_add_scene_sound(
|
|
|
|
struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip);
|
2023-08-30 22:36:36 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void *BKE_sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence);
|
2010-03-20 12:15:16 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void *BKE_sound_add_scene_sound(
|
|
|
|
struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip);
|
|
|
|
void *BKE_sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_remove_scene_sound(struct Scene *scene, void *handle);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2022-08-26 07:57:43 +02:00
|
|
|
void BKE_sound_mute_scene_sound(void *handle, bool mute);
|
2010-02-08 00:41:17 +01:00
|
|
|
|
2022-06-02 01:39:40 +02:00
|
|
|
void BKE_sound_move_scene_sound(const struct Scene *scene,
|
2021-07-06 19:48:06 +02:00
|
|
|
void *handle,
|
|
|
|
int startframe,
|
|
|
|
int endframe,
|
|
|
|
int frameskip,
|
|
|
|
double audio_offset);
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence);
|
2010-02-08 00:41:17 +01:00
|
|
|
|
2023-08-30 22:36:36 +02:00
|
|
|
/* Join the Sequence with the structure in Audaspace, the second parameter is a bSound */
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_update_scene_sound(void *handle, struct bSound *sound);
|
2011-07-26 15:56:31 +02:00
|
|
|
|
2023-08-30 22:36:36 +02:00
|
|
|
/* Join the Sequence with the structure in Audaspace, the second parameter is the AUD_Sound created
|
|
|
|
* in Audaspace previously
|
|
|
|
*/
|
|
|
|
void BKE_sound_update_sequence_handle(void *handle, void *sound_handle);
|
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_set_scene_volume(struct Scene *scene, float volume);
|
3D Audio GSoC:
Implemented basic audio animation.
* AnimatableProperty: Propper cache writing and spline interpolation for reading (the solution for stair steps in audio animation)
* Animatable properties so far are: volume, pitch, panning
* Users note: Changing the pitch of a sound results in wrong seeking, due to the resulting playback length difference.
* Users note: Panning only works for mono sources, values are in the range [-2..2], this basically controls the angle of the sound, 0 is front, -1 left, 1 right and 2 and -2 are back. Typical stereo panning only supports [-1..1].
* Disabled animation of audio related ffmpeg output parameters.
* Scene Audio Panel: 3D Listener settings also for Renderer, new Volume property (animatable!), Update/Bake buttons for animation problems, moved sampling rate and channel count here
2011-07-28 15:58:59 +02:00
|
|
|
|
2024-01-31 18:57:06 +01:00
|
|
|
void BKE_sound_set_scene_sound_volume_at_frame(void *handle,
|
|
|
|
int frame,
|
|
|
|
float volume,
|
|
|
|
char animated);
|
3D Audio GSoC:
Implemented basic audio animation.
* AnimatableProperty: Propper cache writing and spline interpolation for reading (the solution for stair steps in audio animation)
* Animatable properties so far are: volume, pitch, panning
* Users note: Changing the pitch of a sound results in wrong seeking, due to the resulting playback length difference.
* Users note: Panning only works for mono sources, values are in the range [-2..2], this basically controls the angle of the sound, 0 is front, -1 left, 1 right and 2 and -2 are back. Typical stereo panning only supports [-1..1].
* Disabled animation of audio related ffmpeg output parameters.
* Scene Audio Panel: 3D Listener settings also for Renderer, new Volume property (animatable!), Update/Bake buttons for animation problems, moved sampling rate and channel count here
2011-07-28 15:58:59 +02:00
|
|
|
|
2023-06-14 04:47:53 +02:00
|
|
|
void BKE_sound_set_scene_sound_pitch_at_frame(void *handle, int frame, float pitch, char animated);
|
|
|
|
|
|
|
|
void BKE_sound_set_scene_sound_pitch_constant_range(void *handle,
|
|
|
|
int frame_start,
|
|
|
|
int frame_end,
|
|
|
|
float pitch);
|
|
|
|
|
2024-01-31 18:57:06 +01:00
|
|
|
void BKE_sound_set_scene_sound_pan_at_frame(void *handle, int frame, float pan, char animated);
|
3D Audio GSoC:
Implemented basic audio animation.
* AnimatableProperty: Propper cache writing and spline interpolation for reading (the solution for stair steps in audio animation)
* Animatable properties so far are: volume, pitch, panning
* Users note: Changing the pitch of a sound results in wrong seeking, due to the resulting playback length difference.
* Users note: Panning only works for mono sources, values are in the range [-2..2], this basically controls the angle of the sound, 0 is front, -1 left, 1 right and 2 and -2 are back. Typical stereo panning only supports [-1..1].
* Disabled animation of audio related ffmpeg output parameters.
* Scene Audio Panel: 3D Listener settings also for Renderer, new Volume property (animatable!), Update/Bake buttons for animation problems, moved sampling rate and channel count here
2011-07-28 15:58:59 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_update_sequencer(struct Main *main, struct bSound *sound);
|
2011-07-26 15:56:31 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_play_scene(struct Scene *scene);
|
2010-02-08 00:41:17 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_stop_scene(struct Scene *scene);
|
2010-02-08 00:41:17 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2020-05-03 15:25:52 +02:00
|
|
|
double BKE_sound_sync_scene(struct Scene *scene);
|
2010-02-19 13:20:29 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
int BKE_sound_scene_playing(struct Scene *scene);
|
2010-02-21 19:01:41 +01:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void BKE_sound_free_waveform(struct bSound *sound);
|
2011-08-09 16:10:32 +02:00
|
|
|
|
2022-11-04 08:37:25 +01:00
|
|
|
void BKE_sound_read_waveform(struct Main *bmain, struct bSound *sound, bool *stop);
|
2009-08-09 23:16:39 +02:00
|
|
|
|
2019-06-07 10:58:51 +02:00
|
|
|
void BKE_sound_update_scene(struct Depsgraph *depsgraph, struct Scene *scene);
|
2011-08-09 10:38:14 +02:00
|
|
|
|
2015-03-26 11:35:41 +01:00
|
|
|
void *BKE_sound_get_factory(void *sound);
|
2012-05-10 17:10:51 +02:00
|
|
|
|
2019-06-11 10:55:13 +02:00
|
|
|
float BKE_sound_get_length(struct Main *bmain, struct bSound *sound);
|
2011-06-06 00:06:29 +02:00
|
|
|
|
2015-07-29 02:43:32 +02:00
|
|
|
char **BKE_sound_get_device_names(void);
|
2015-07-24 15:44:17 +02:00
|
|
|
|
2020-05-03 15:25:52 +02:00
|
|
|
typedef void (*SoundJackSyncCallback)(struct Main *bmain, int mode, double time);
|
2019-06-04 16:52:48 +02:00
|
|
|
|
|
|
|
void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback);
|
2020-05-03 15:25:52 +02:00
|
|
|
void BKE_sound_jack_scene_update(struct Scene *scene, int mode, double time);
|
2019-06-04 16:52:48 +02:00
|
|
|
|
|
|
|
/* Dependency graph evaluation. */
|
|
|
|
|
|
|
|
struct Depsgraph;
|
|
|
|
|
|
|
|
void BKE_sound_evaluate(struct Depsgraph *depsgraph, struct Main *bmain, struct bSound *sound);
|
|
|
|
|
2019-11-29 11:42:18 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|