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 #include "RNA_enum_types.h"
25 
26 #include "rna_internal.h"
27 
28 #include "DNA_sound_types.h"
29 #include "DNA_speaker_types.h"
30 
31 #include "BLT_translation.h"
32 
33 #ifdef RNA_RUNTIME
34 
35 #  include "MEM_guardedalloc.h"
36 
37 #  include "BKE_main.h"
38 
39 #  include "WM_api.h"
40 #  include "WM_types.h"
41 
42 #else
43 
rna_def_speaker(BlenderRNA * brna)44 static void rna_def_speaker(BlenderRNA *brna)
45 {
46   StructRNA *srna;
47   PropertyRNA *prop;
48 
49   srna = RNA_def_struct(brna, "Speaker", "ID");
50   RNA_def_struct_ui_text(srna, "Speaker", "Speaker data-block for 3D audio speaker objects");
51   RNA_def_struct_ui_icon(srna, ICON_SPEAKER);
52 
53   prop = RNA_def_property(srna, "muted", PROP_BOOLEAN, PROP_NONE);
54   RNA_def_property_boolean_sdna(prop, NULL, "flag", SPK_MUTED);
55   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
56   RNA_def_property_ui_text(prop, "Mute", "Mute the speaker");
57   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
58   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
59 
60   prop = RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE);
61   RNA_def_property_struct_type(prop, "Sound");
62   RNA_def_property_flag(prop, PROP_EDITABLE);
63   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
64   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
65   RNA_def_property_ui_text(prop, "Sound", "Sound data-block used by this speaker");
66   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_sound_set", NULL); */
67   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
68 
69   prop = RNA_def_property(srna, "volume_max", PROP_FLOAT, PROP_FACTOR);
70   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
71   RNA_def_property_range(prop, 0.0f, 1.0f);
72   RNA_def_property_ui_text(
73       prop, "Maximum Volume", "Maximum volume, no matter how near the object is");
74   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_volume_max_set", NULL); */
75   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
76 
77   prop = RNA_def_property(srna, "volume_min", PROP_FLOAT, PROP_FACTOR);
78   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
79   RNA_def_property_range(prop, 0.0f, 1.0f);
80   RNA_def_property_ui_text(
81       prop, "Minimum Volume", "Minimum volume, no matter how far away the object is");
82   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_volume_min_set", NULL); */
83   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
84 
85   prop = RNA_def_property(srna, "distance_max", PROP_FLOAT, PROP_NONE);
86   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
87   RNA_def_property_range(prop, 0.0f, FLT_MAX);
88   RNA_def_property_ui_text(
89       prop,
90       "Maximum Distance",
91       "Maximum distance for volume calculation, no matter how far away the object is");
92   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_distance_max_set", NULL); */
93   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
94 
95   prop = RNA_def_property(srna, "distance_reference", PROP_FLOAT, PROP_NONE);
96   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
97   RNA_def_property_range(prop, 0.0f, FLT_MAX);
98   RNA_def_property_ui_text(
99       prop, "Reference Distance", "Reference distance at which volume is 100 %");
100   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_distance_reference_set", NULL); */
101   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
102 
103   prop = RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE);
104   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
105   RNA_def_property_range(prop, 0.0f, FLT_MAX);
106   RNA_def_property_ui_text(
107       prop, "Attenuation", "How strong the distance affects volume, depending on distance model");
108   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_attenuation_set", NULL); */
109   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
110 
111   prop = RNA_def_property(srna, "cone_angle_outer", PROP_FLOAT, PROP_NONE);
112   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
113   RNA_def_property_range(prop, 0.0f, 360.0f);
114   RNA_def_property_ui_text(
115       prop,
116       "Outer Cone Angle",
117       "Angle of the outer cone, in degrees, outside this cone the volume is "
118       "the outer cone volume, between inner and outer cone the volume is interpolated");
119   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_cone_angle_outer_set", NULL); */
120   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
121 
122   prop = RNA_def_property(srna, "cone_angle_inner", PROP_FLOAT, PROP_NONE);
123   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
124   RNA_def_property_range(prop, 0.0f, 360.0f);
125   RNA_def_property_ui_text(
126       prop,
127       "Inner Cone Angle",
128       "Angle of the inner cone, in degrees, inside the cone the volume is 100 %");
129   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_cone_angle_inner_set", NULL); */
130   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
131 
132   prop = RNA_def_property(srna, "cone_volume_outer", PROP_FLOAT, PROP_FACTOR);
133   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
134   RNA_def_property_range(prop, 0.0f, 1.0f);
135   RNA_def_property_ui_text(prop, "Outer Cone Volume", "Volume outside the outer cone");
136   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_cone_volume_outer_set", NULL); */
137   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
138 
139   prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_FACTOR);
140   RNA_def_property_range(prop, 0.0f, 1.0f);
141   RNA_def_property_ui_text(prop, "Volume", "How loud the sound is");
142   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
143   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_volume_set", NULL); */
144   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
145 
146   prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE);
147   RNA_def_property_range(prop, 0.1f, 10.0f);
148   RNA_def_property_ui_text(prop, "Pitch", "Playback pitch of the sound");
149   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_SOUND);
150   /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_pitch_set", NULL); */
151   /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */
152 
153   /* common */
154   rna_def_animdata_common(srna);
155 }
156 
RNA_def_speaker(BlenderRNA * brna)157 void RNA_def_speaker(BlenderRNA *brna)
158 {
159   rna_def_speaker(brna);
160 }
161 
162 #endif
163