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 
17 /** \file
18  * \ingroup RNA
19  */
20 
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_sequencer.h"
33 #  include "BKE_sound.h"
34 
35 #  include "DEG_depsgraph.h"
36 
rna_Sound_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)37 static void rna_Sound_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
38 {
39   bSound *sound = (bSound *)ptr->data;
40   DEG_id_tag_update(&sound->id, ID_RECALC_AUDIO);
41 }
42 
rna_Sound_caching_update(Main * bmain,Scene * scene,PointerRNA * ptr)43 static void rna_Sound_caching_update(Main *bmain, Scene *scene, PointerRNA *ptr)
44 {
45   rna_Sound_update(bmain, scene, ptr);
46   DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
47 }
48 
49 #else
50 
rna_def_sound(BlenderRNA * brna)51 static void rna_def_sound(BlenderRNA *brna)
52 {
53   StructRNA *srna;
54   PropertyRNA *prop;
55 
56   srna = RNA_def_struct(brna, "Sound", "ID");
57   RNA_def_struct_sdna(srna, "bSound");
58   RNA_def_struct_ui_text(
59       srna, "Sound", "Sound data-block referencing an external or packed sound file");
60   RNA_def_struct_ui_icon(srna, ICON_SOUND);
61 
62   /*rna_def_ipo_common(srna); */
63 
64   prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
65   RNA_def_property_string_sdna(prop, NULL, "filepath");
66   RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound data-block");
67   RNA_def_property_update(prop, 0, "rna_Sound_update");
68 
69   prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
70   RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
71   RNA_def_property_ui_text(prop, "Packed File", "");
72 
73   prop = RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
74   RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_CACHING);
75   RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
76   RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
77 
78   prop = RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
79   RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_MONO);
80   RNA_def_property_ui_text(
81       prop,
82       "Mono",
83       "If the file contains multiple audio channels they are rendered to a single one");
84   RNA_def_property_update(prop, 0, "rna_Sound_update");
85 
86   RNA_api_sound(srna);
87 }
88 
RNA_def_sound(BlenderRNA * brna)89 void RNA_def_sound(BlenderRNA *brna)
90 {
91   rna_def_sound(brna);
92 }
93 
94 #endif
95