Blender V5.0
rna_sound.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12
13#include "rna_internal.hh"
14
15#include "DNA_sound_types.h"
16
17#include "BKE_sound.h"
18
19/* Enumeration for Audio Channels, compatible with eSoundChannels */
21 {SOUND_CHANNELS_INVALID, "INVALID", ICON_NONE, "Invalid", "Invalid"},
22 {SOUND_CHANNELS_MONO, "MONO", ICON_NONE, "Mono", "Mono"},
23 {SOUND_CHANNELS_STEREO, "STEREO", ICON_NONE, "Stereo", "Stereo"},
24 {SOUND_CHANNELS_STEREO_LFE, "STEREO_LFE", ICON_NONE, "Stereo LFE", "Stereo FX"},
25 {SOUND_CHANNELS_SURROUND4, "CHANNELS_4", ICON_NONE, "4 Channels", "4 Channels"},
26 {SOUND_CHANNELS_SURROUND5, "CHANNELS_5", ICON_NONE, "5 Channels", "5 Channels"},
27 {SOUND_CHANNELS_SURROUND51, "SURROUND_51", ICON_NONE, "5.1 Surround", "5.1 Surround"},
28 {SOUND_CHANNELS_SURROUND61, "SURROUND_61", ICON_NONE, "6.1 Surround", "6.1 Surround"},
29 {SOUND_CHANNELS_SURROUND71, "SURROUND_71", ICON_NONE, "7.1 Surround", "7.1 Surround"},
30 {0, nullptr, 0, nullptr, nullptr},
31};
32
33#ifdef RNA_RUNTIME
34
35# include "BKE_context.hh"
36# include "BKE_library.hh"
37# include "BKE_sound.h"
38
39# include "DEG_depsgraph.hh"
40
41# include "SEQ_sequencer.hh"
42# include "SEQ_utils.hh"
43
44static void rna_Sound_update(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
45{
46 bSound *sound = (bSound *)ptr->data;
49}
50
51static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr)
52{
53 rna_Sound_update(bmain, scene, ptr);
55}
56
57#else
58
59static void rna_def_sound(BlenderRNA *brna)
60{
61 StructRNA *srna;
62 PropertyRNA *prop;
63
64 srna = RNA_def_struct(brna, "Sound", "ID");
65 RNA_def_struct_sdna(srna, "bSound");
67 srna, "Sound", "Sound data-block referencing an external or packed sound file");
68 RNA_def_struct_ui_icon(srna, ICON_SOUND);
69
70 // rna_def_ipo_common(srna);
71
72 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
73 RNA_def_property_string_sdna(prop, nullptr, "filepath");
75 RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound data-block");
76 RNA_def_property_update(prop, 0, "rna_Sound_update");
77
78 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
79 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
80 RNA_def_property_ui_text(prop, "Packed File", "");
81
82 prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
84 RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
85 RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
86
87 prop = RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
88 RNA_def_property_boolean_sdna(prop, nullptr, "flags", SOUND_FLAGS_MONO);
90 prop,
91 "Mono",
92 "If the file contains multiple audio channels they are rendered to a single one");
93 RNA_def_property_update(prop, 0, "rna_Sound_update");
94
95 prop = RNA_def_property(srna, "samplerate", PROP_INT, PROP_NONE);
96 RNA_def_property_int_sdna(prop, nullptr, "samplerate");
98 RNA_def_property_ui_text(prop, "Sample Rate", "Sample rate of the audio in Hz");
99
100 prop = RNA_def_property(srna, "channels", PROP_ENUM, PROP_NONE);
101 RNA_def_property_enum_sdna(prop, nullptr, "audio_channels");
105 RNA_def_property_ui_text(prop, "Audio channels", "Definition of audio channels");
106
107 RNA_api_sound(srna);
108}
109
111{
112 rna_def_sound(brna);
113}
114
115#endif
@ SOUND_CHANNELS_STEREO
Definition BKE_sound.h:65
@ SOUND_CHANNELS_SURROUND5
Definition BKE_sound.h:68
@ SOUND_CHANNELS_SURROUND61
Definition BKE_sound.h:70
@ SOUND_CHANNELS_STEREO_LFE
Definition BKE_sound.h:66
@ SOUND_CHANNELS_SURROUND71
Definition BKE_sound.h:71
@ SOUND_CHANNELS_INVALID
Definition BKE_sound.h:63
@ SOUND_CHANNELS_SURROUND51
Definition BKE_sound.h:69
@ SOUND_CHANNELS_MONO
Definition BKE_sound.h:64
@ SOUND_CHANNELS_SURROUND4
Definition BKE_sound.h:67
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1132
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
@ SOUND_FLAGS_MONO
@ SOUND_FLAGS_CACHING
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:456
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_FILEPATH
Definition RNA_types.hh:236
void media_presence_invalidate_sound(Scene *scene, const bSound *sound)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_api_sound(StructRNA *srna)
static const EnumPropertyItem rna_enum_audio_channels_items[]
Definition rna_sound.cc:20
static void rna_def_sound(BlenderRNA *brna)
Definition rna_sound.cc:59
void RNA_def_sound(BlenderRNA *brna)
Definition rna_sound.cc:110
PointerRNA * ptr
Definition wm_files.cc:4238