Blender V4.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
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_sound.h"
37
38# include "DEG_depsgraph.hh"
39
40# include "SEQ_sequencer.hh"
41# include "SEQ_utils.hh"
42
43static void rna_Sound_update(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
44{
45 bSound *sound = (bSound *)ptr->data;
48}
49
50static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr)
51{
52 rna_Sound_update(bmain, scene, ptr);
54}
55
56#else
57
58static void rna_def_sound(BlenderRNA *brna)
59{
60 StructRNA *srna;
61 PropertyRNA *prop;
62
63 srna = RNA_def_struct(brna, "Sound", "ID");
64 RNA_def_struct_sdna(srna, "bSound");
66 srna, "Sound", "Sound data-block referencing an external or packed sound file");
67 RNA_def_struct_ui_icon(srna, ICON_SOUND);
68
69 // rna_def_ipo_common(srna);
70
71 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
72 RNA_def_property_string_sdna(prop, nullptr, "filepath");
73 RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound data-block");
74 RNA_def_property_update(prop, 0, "rna_Sound_update");
75
76 prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
77 RNA_def_property_pointer_sdna(prop, nullptr, "packedfile");
78 RNA_def_property_ui_text(prop, "Packed File", "");
79
80 prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
82 RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
83 RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
84
85 prop = RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
86 RNA_def_property_boolean_sdna(prop, nullptr, "flags", SOUND_FLAGS_MONO);
88 prop,
89 "Mono",
90 "If the file contains multiple audio channels they are rendered to a single one");
91 RNA_def_property_update(prop, 0, "rna_Sound_update");
92
93 prop = RNA_def_property(srna, "samplerate", PROP_INT, PROP_NONE);
94 RNA_def_property_int_sdna(prop, nullptr, "samplerate");
96 RNA_def_property_ui_text(prop, "Sample Rate", "Sample rate of the audio in Hz");
97
98 prop = RNA_def_property(srna, "channels", PROP_ENUM, PROP_NONE);
99 RNA_def_property_enum_sdna(prop, nullptr, "audio_channels");
103 RNA_def_property_ui_text(prop, "Audio channels", "Definition of audio channels");
104
105 RNA_api_sound(srna);
106}
107
109{
110 rna_def_sound(brna);
111}
112
113#endif
@ SOUND_CHANNELS_STEREO
Definition BKE_sound.h:71
@ SOUND_CHANNELS_SURROUND5
Definition BKE_sound.h:74
@ SOUND_CHANNELS_SURROUND61
Definition BKE_sound.h:76
@ SOUND_CHANNELS_STEREO_LFE
Definition BKE_sound.h:72
@ SOUND_CHANNELS_SURROUND71
Definition BKE_sound.h:77
@ SOUND_CHANNELS_INVALID
Definition BKE_sound.h:69
@ SOUND_CHANNELS_SURROUND51
Definition BKE_sound.h:75
@ SOUND_CHANNELS_MONO
Definition BKE_sound.h:70
@ SOUND_CHANNELS_SURROUND4
Definition BKE_sound.h:73
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1099
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1089
@ SOUND_FLAGS_MONO
@ SOUND_FLAGS_CACHING
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FILEPATH
Definition RNA_types.hh:139
void media_presence_invalidate_sound(Scene *scene, const bSound *sound)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
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_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:58
void RNA_def_sound(BlenderRNA *brna)
Definition rna_sound.cc:108
void * data
Definition RNA_types.hh:42
PointerRNA * ptr
Definition wm_files.cc:4126