Blender  V2.93
rna_sound.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdlib.h>
22 
23 #include "RNA_define.h"
24 
25 #include "rna_internal.h"
26 
27 #include "DNA_sound_types.h"
28 
29 #ifdef RNA_RUNTIME
30 
31 # include "BKE_context.h"
32 # include "BKE_sound.h"
33 
34 # include "DEG_depsgraph.h"
35 
36 # include "SEQ_sequencer.h"
37 
38 static void rna_Sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
39 {
40  bSound *sound = (bSound *)ptr->data;
42 }
43 
44 static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr)
45 {
46  rna_Sound_update(bmain, scene, ptr);
48 }
49 
50 #else
51 
52 static void rna_def_sound(BlenderRNA *brna)
53 {
54  StructRNA *srna;
55  PropertyRNA *prop;
56 
57  srna = RNA_def_struct(brna, "Sound", "ID");
58  RNA_def_struct_sdna(srna, "bSound");
60  srna, "Sound", "Sound data-block referencing an external or packed sound file");
61  RNA_def_struct_ui_icon(srna, ICON_SOUND);
62 
63  /*rna_def_ipo_common(srna); */
64 
65  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
66  RNA_def_property_string_sdna(prop, NULL, "filepath");
67  RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound data-block");
68  RNA_def_property_update(prop, 0, "rna_Sound_update");
69 
70  prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
71  RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
72  RNA_def_property_ui_text(prop, "Packed File", "");
73 
74  prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
76  RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
77  RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
78 
79  prop = RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
82  prop,
83  "Mono",
84  "If the file contains multiple audio channels they are rendered to a single one");
85  RNA_def_property_update(prop, 0, "rna_Sound_update");
86 
87  RNA_api_sound(srna);
88 }
89 
91 {
92  rna_def_sound(brna);
93 }
94 
95 #endif
#define UNUSED(x)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_AUDIO
Definition: DNA_ID.h:666
@ ID_RECALC_SEQUENCER_STRIPS
Definition: DNA_ID.h:658
@ SOUND_FLAGS_MONO
@ SOUND_FLAGS_CACHING
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_STRING
Definition: RNA_types.h:76
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FILEPATH
Definition: RNA_types.h:116
Scene scene
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2717
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
void RNA_api_sound(struct StructRNA *srna)
Definition: rna_sound_api.c:54
static void rna_def_sound(BlenderRNA *brna)
Definition: rna_sound.c:52
void RNA_def_sound(BlenderRNA *brna)
Definition: rna_sound.c:90
Definition: BKE_main.h:116
void * data
Definition: RNA_types.h:52
PointerRNA * ptr
Definition: wm_files.c:3157