Blender  V3.3
rna_sound.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdlib.h>
8 
9 #include "RNA_define.h"
10 
11 #include "rna_internal.h"
12 
13 #include "DNA_sound_types.h"
14 
15 #include "BKE_sound.h"
16 
17 /* Enumeration for Audio Channels, compatible with eSoundChannels */
19  {SOUND_CHANNELS_INVALID, "INVALID", ICON_NONE, "Invalid", "Invalid"},
20  {SOUND_CHANNELS_MONO, "MONO", ICON_NONE, "Mono", "Mono"},
21  {SOUND_CHANNELS_STEREO, "STEREO", ICON_NONE, "Stereo", "Stereo"},
22  {SOUND_CHANNELS_STEREO_LFE, "STEREO_LFE", ICON_NONE, "Stereo LFE", "Stereo FX"},
23  {SOUND_CHANNELS_SURROUND4, "CHANNELS_4", ICON_NONE, "4 Channels", "4 Channels"},
24  {SOUND_CHANNELS_SURROUND5, "CHANNELS_5", ICON_NONE, "5 Channels", "5 Channels"},
25  {SOUND_CHANNELS_SURROUND51, "SURROUND_51", ICON_NONE, "5.1 Surround", "5.1 Surround"},
26  {SOUND_CHANNELS_SURROUND61, "SURROUND_61", ICON_NONE, "6.1 Surround", "6.1 Surround"},
27  {SOUND_CHANNELS_SURROUND71, "SURROUND_71", ICON_NONE, "7.1 Surround", "7.1 Surround"},
28  {0, NULL, 0, NULL, NULL},
29 };
30 
31 #ifdef RNA_RUNTIME
32 
33 # include "BKE_context.h"
34 # include "BKE_sound.h"
35 
36 # include "DEG_depsgraph.h"
37 
38 # include "SEQ_sequencer.h"
39 
40 static void rna_Sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
41 {
42  bSound *sound = (bSound *)ptr->data;
44 }
45 
46 static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr)
47 {
48  rna_Sound_update(bmain, scene, ptr);
50 }
51 
52 #else
53 
54 static void rna_def_sound(BlenderRNA *brna)
55 {
56  StructRNA *srna;
57  PropertyRNA *prop;
58 
59  srna = RNA_def_struct(brna, "Sound", "ID");
60  RNA_def_struct_sdna(srna, "bSound");
62  srna, "Sound", "Sound data-block referencing an external or packed sound file");
63  RNA_def_struct_ui_icon(srna, ICON_SOUND);
64 
65  // rna_def_ipo_common(srna);
66 
67  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
68  RNA_def_property_string_sdna(prop, NULL, "filepath");
69  RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound data-block");
70  RNA_def_property_update(prop, 0, "rna_Sound_update");
71 
72  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
73  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
74  RNA_def_property_ui_text(prop, "Packed File", "");
75 
76  prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
78  RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
79  RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
80 
81  prop = RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
84  prop,
85  "Mono",
86  "If the file contains multiple audio channels they are rendered to a single one");
87  RNA_def_property_update(prop, 0, "rna_Sound_update");
88 
89  prop = RNA_def_property(srna, "samplerate", PROP_INT, PROP_NONE);
90  RNA_def_property_int_sdna(prop, NULL, "samplerate");
92  RNA_def_property_ui_text(prop, "Samplerate", "Samplerate of the audio in Hz");
93 
94  prop = RNA_def_property(srna, "channels", PROP_ENUM, PROP_NONE);
95  RNA_def_property_enum_sdna(prop, NULL, "audio_channels");
99  RNA_def_property_ui_text(prop, "Audio channels", "Definition of audio channels");
100 
101  RNA_api_sound(srna);
102 }
103 
105 {
106  rna_def_sound(brna);
107 }
108 
109 #endif
@ SOUND_CHANNELS_STEREO
Definition: BKE_sound.h:70
@ SOUND_CHANNELS_SURROUND5
Definition: BKE_sound.h:73
@ SOUND_CHANNELS_SURROUND61
Definition: BKE_sound.h:75
@ SOUND_CHANNELS_STEREO_LFE
Definition: BKE_sound.h:71
@ SOUND_CHANNELS_SURROUND71
Definition: BKE_sound.h:76
@ SOUND_CHANNELS_INVALID
Definition: BKE_sound.h:68
@ SOUND_CHANNELS_SURROUND51
Definition: BKE_sound.h:74
@ SOUND_CHANNELS_MONO
Definition: BKE_sound.h:69
@ SOUND_CHANNELS_SURROUND4
Definition: BKE_sound.h:72
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_AUDIO
Definition: DNA_ID.h:848
@ ID_RECALC_SEQUENCER_STRIPS
Definition: DNA_ID.h:838
@ SOUND_FLAGS_MONO
@ SOUND_FLAGS_CACHING
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_FILEPATH
Definition: RNA_types.h:129
Scene scene
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2740
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2236
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
Definition: rna_define.c:2106
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2695
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1048
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2900
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2601
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1245
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2343
void RNA_api_sound(struct StructRNA *srna)
Definition: rna_sound_api.c:38
static const EnumPropertyItem rna_enum_audio_channels_items[]
Definition: rna_sound.c:18
static void rna_def_sound(BlenderRNA *brna)
Definition: rna_sound.c:54
void RNA_def_sound(BlenderRNA *brna)
Definition: rna_sound.c:104
Definition: BKE_main.h:121
void * data
Definition: RNA_types.h:38
PointerRNA * ptr
Definition: wm_files.c:3480