Blender V5.3
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.hh"
18
19namespace blender {
20
21/* Enumeration for Audio Channels, compatible with eSoundChannels */
23 {SOUND_CHANNELS_INVALID, "INVALID", ICON_NONE, "Invalid", "Invalid"},
24 {SOUND_CHANNELS_MONO, "MONO", ICON_NONE, "Mono", "Mono"},
25 {SOUND_CHANNELS_STEREO, "STEREO", ICON_NONE, "Stereo", "Stereo"},
26 {SOUND_CHANNELS_STEREO_LFE, "STEREO_LFE", ICON_NONE, "Stereo LFE", "Stereo FX"},
27 {SOUND_CHANNELS_SURROUND4, "CHANNELS_4", ICON_NONE, "4 Channels", "4 Channels"},
28 {SOUND_CHANNELS_SURROUND5, "CHANNELS_5", ICON_NONE, "5 Channels", "5 Channels"},
29 {SOUND_CHANNELS_SURROUND51, "SURROUND_51", ICON_NONE, "5.1 Surround", "5.1 Surround"},
30 {SOUND_CHANNELS_SURROUND61, "SURROUND_61", ICON_NONE, "6.1 Surround", "6.1 Surround"},
31 {SOUND_CHANNELS_SURROUND71, "SURROUND_71", ICON_NONE, "7.1 Surround", "7.1 Surround"},
32 {0, nullptr, 0, nullptr, nullptr},
33};
34
35} // namespace blender
36
37#ifdef RNA_RUNTIME
38
39# include "BKE_context.hh"
40# include "BKE_library.hh"
41
42# include "DEG_depsgraph.hh"
43
44# include "SEQ_sequencer.hh"
45# include "SEQ_utils.hh"
46
47namespace blender {
48
49static void rna_Sound_update(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
50{
51 bSound *sound = static_cast<bSound *>(ptr->data);
54}
55
56static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr)
57{
58 rna_Sound_update(bmain, scene, ptr);
60}
61
62} // namespace blender
63
64#else
65
66namespace blender {
67
68static void rna_def_sound(BlenderRNA *brna)
69{
70 StructRNA *srna;
71 PropertyRNA *prop;
72
73 srna = RNA_def_struct(brna, "Sound", "ID");
74 RNA_def_struct_sdna(srna, "bSound");
76 srna, "Sound", "Sound data-block referencing an external or packed sound file");
77 RNA_def_struct_ui_icon(srna, ICON_SOUND);
78
79 // rna_def_ipo_common(srna);
80
81 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
82 RNA_def_property_string_sdna(prop, nullptr, "filepath");
84 RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound data-block");
85 RNA_def_property_update(prop, 0, "rna_Sound_update");
86
87 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
88 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
89 RNA_def_property_ui_text(prop, "Packed File", "");
90
91 prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
93 RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
94 RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
95
96 prop = RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
97 RNA_def_property_boolean_sdna(prop, nullptr, "flags", SOUND_FLAGS_MONO);
99 prop,
100 "Mono",
101 "If the file contains multiple audio channels they are rendered to a single one");
102 RNA_def_property_update(prop, 0, "rna_Sound_update");
103
104 prop = RNA_def_property(srna, "samplerate", PROP_INT, PROP_NONE);
105 RNA_def_property_int_sdna(prop, nullptr, "samplerate");
107 RNA_def_property_ui_text(prop, "Sample Rate", "Sample rate of the audio in Hz");
108
109 prop = RNA_def_property(srna, "channels", PROP_ENUM, PROP_NONE);
110 RNA_def_property_enum_sdna(prop, nullptr, "audio_channels");
114 RNA_def_property_ui_text(prop, "Audio channels", "Definition of audio channels");
115
116 RNA_api_sound(srna);
117}
118
120{
121 rna_def_sound(brna);
122}
123
124} // namespace blender
125
126#endif
void media_presence_invalidate_sound(Scene *scene, const bSound *sound)
BMesh Iterators.
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
@ 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
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@ SOUND_FLAGS_CACHING
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_api_sound(StructRNA *srna)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void RNA_def_sound(BlenderRNA *brna)
Definition rna_sound.cc:119
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
void DEG_id_tag_update(ID *id, unsigned int flags)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
static void rna_def_sound(BlenderRNA *brna)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1132
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_PATH_SUPPORTS_BLEND_RELATIVE
Definition RNA_types.hh:526
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
@ PROP_FILEPATH
Definition RNA_types.hh:284
static const EnumPropertyItem rna_enum_audio_channels_items[]
Definition rna_sound.cc:22