Blender V2.61 - r43446

rna_sound.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Campbell Barton, Roland Hess
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #include <stdlib.h>
00029 
00030 #include "RNA_define.h"
00031 
00032 #include "rna_internal.h"
00033 
00034 #include "DNA_sound_types.h"
00035 #include "DNA_property_types.h"
00036 
00037 #ifdef RNA_RUNTIME
00038 
00039 #include "BKE_sound.h"
00040 #include "BKE_context.h"
00041 
00042 static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
00043 {
00044     sound_load(bmain, (bSound*)ptr->data);
00045 }
00046 
00047 static int rna_Sound_caching_get(PointerRNA *ptr)
00048 {
00049     bSound *sound = (bSound*)(ptr->data);
00050     return (sound->flags & SOUND_FLAGS_CACHING) != 0;
00051 }
00052 
00053 static void rna_Sound_caching_set(PointerRNA *ptr, const int value)
00054 {
00055     bSound *sound = (bSound*)(ptr->data);
00056     if(value)
00057         sound_cache(sound);
00058     else
00059         sound_delete_cache(sound);
00060 }
00061 
00062 static void rna_Sound_caching_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
00063 {
00064     sound_update_sequencer(bmain, (bSound*)(ptr->data));
00065 }
00066 
00067 #else
00068 
00069 static void rna_def_sound(BlenderRNA *brna)
00070 {
00071     StructRNA *srna;
00072     PropertyRNA *prop;
00073 
00074     srna= RNA_def_struct(brna, "Sound", "ID");
00075     RNA_def_struct_sdna(srna, "bSound");
00076     RNA_def_struct_ui_text(srna, "Sound", "Sound datablock referencing an external or packed sound file");
00077     RNA_def_struct_ui_icon(srna, ICON_SOUND);
00078 
00079     //rna_def_ipo_common(srna);
00080 
00081     prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
00082     RNA_def_property_string_sdna(prop, NULL, "name");
00083     RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound datablock");
00084     RNA_def_property_update(prop, 0, "rna_Sound_update");
00085 
00086     prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
00087     RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
00088     RNA_def_property_ui_text(prop, "Packed File", "");
00089 
00090     prop= RNA_def_property(srna, "use_memory_cache", PROP_BOOLEAN, PROP_NONE);
00091     RNA_def_property_boolean_funcs(prop, "rna_Sound_caching_get", "rna_Sound_caching_set");
00092     RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM");
00093     RNA_def_property_update(prop, 0, "rna_Sound_caching_update");
00094 
00095     prop= RNA_def_property(srna, "use_mono", PROP_BOOLEAN, PROP_NONE);
00096     RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_MONO);
00097     RNA_def_property_ui_text(prop, "Mono", "If the file contains multiple audio channels they are rendered to a single one");
00098     RNA_def_property_update(prop, 0, "rna_Sound_update");
00099 }
00100 
00101 void RNA_def_sound(BlenderRNA *brna)
00102 {
00103     rna_def_sound(brna);
00104 }
00105 
00106 #endif
00107 
00108