39#include "RNA_prototypes.hh"
49# include <AUD_Special.h>
69 op->
customdata = pprop = MEM_new<PropertyPointerRNA>(__func__);
140 ot->name =
"Open Sound";
141 ot->description =
"Load a sound file";
142 ot->idname =
"SOUND_OT_open";
161 RNA_def_boolean(
ot->srna,
"mono",
false,
"Mono",
"Merge all the sound's channels into one");
167 ot->name =
"Open Sound Mono";
168 ot->description =
"Load a sound file as mono";
169 ot->idname =
"SOUND_OT_open_mono";
245 if (scene->
ed !=
nullptr) {
278 ot->name =
"Update Animation";
279 ot->description =
"Update animation flags";
280 ot->idname =
"SOUND_OT_update_animation_flags";
297 int oldfra = scene->
r.
cfra;
302 for (cfra = (scene->
r.
sfra > 0) ? (scene->
r.
sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) {
303 scene->
r.
cfra = cfra;
309 scene->
r.
cfra = oldfra;
318 ot->name =
"Update Animation Cache";
319 ot->description =
"Update the audio animation cache";
320 ot->idname =
"SOUND_OT_bake_animation";
340 int bitrate, accuracy;
341 AUD_DeviceSpecs specs;
342 AUD_Container container;
345 char error_message[1024] = {
'\0'};
362 const int start_frame = scene_eval->
r.
sfra;
363 const int end_frame = scene_eval->
r.
efra;
367 start_frame * specs.rate / fps,
368 (end_frame - start_frame + 1) * specs.rate / fps,
375 AUD_RESAMPLE_QUALITY_MEDIUM,
379 sizeof(error_message));
383 start_frame * specs.rate / fps,
384 (end_frame - start_frame + 1) * specs.rate / fps,
391 AUD_RESAMPLE_QUALITY_MEDIUM,
395 sizeof(error_message));
414 {AUD_CONTAINER_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
415 {AUD_CONTAINER_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
417 {AUD_CONTAINER_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
419 {AUD_CONTAINER_MATROSKA,
"MATROSKA", 0,
"MKV",
"Matroska"},
420 {AUD_CONTAINER_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
421 {AUD_CONTAINER_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
423 {AUD_CONTAINER_OGG,
"OGG", 0,
"OGG",
"Xiph.Org Ogg Container"},
424 {AUD_CONTAINER_WAV,
"WAV", 0,
"WAV",
"Waveform Audio File Format"},
425 {0,
nullptr, 0,
nullptr,
nullptr},
428static const char *snd_ext_sound[] = {
442 AUD_Container container = AUD_Container(
RNA_enum_get(op->
ptr,
"container"));
444 const char *extension =
nullptr;
448 if (item->
value == container) {
449 const char **ext = snd_ext_sound;
450 while (*ext !=
nullptr) {
502static bool sound_mixdown_draw_check_prop(
PointerRNA * ,
507 return !
STR_ELEM(prop_id,
"filepath",
"directory",
"filename");
513 {AUD_FORMAT_U8,
"U8", 0,
"U8",
"8-bit unsigned"},
514 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
516 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
518 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
519 {AUD_FORMAT_FLOAT32,
"F32", 0,
"F32",
"32-bit floating-point"},
520 {AUD_FORMAT_FLOAT64,
"F64", 0,
"F64",
"64-bit floating-point"},
521 {0,
nullptr, 0,
nullptr,
nullptr},
525 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
526 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
527 {0,
nullptr, 0,
nullptr,
nullptr},
532 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
533 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
534 {0,
nullptr, 0,
nullptr,
nullptr},
539 {AUD_CODEC_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
540 {AUD_CODEC_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
541 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
542 {AUD_CODEC_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
543 {AUD_CODEC_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
544 {AUD_CODEC_PCM,
"PCM", 0,
"PCM",
"Pulse Code Modulation (RAW)"},
545 {AUD_CODEC_OPUS,
"OPUS", 0,
"Opus",
"Opus Interactive Audio Codec"},
546 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
547 {0,
nullptr, 0,
nullptr,
nullptr},
551 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
552 {AUD_CODEC_OPUS,
"OPUS", 0,
"Opus",
"Opus Interactive Audio Codec"},
553 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
554 {0,
nullptr, 0,
nullptr,
nullptr},
566 AUD_Container container = AUD_Container(
RNA_enum_get(op->
ptr,
"container"));
578 case AUD_CONTAINER_AAC:
583 case AUD_CONTAINER_AC3:
588 case AUD_CONTAINER_FLAC:
599 case AUD_CONTAINER_MATROSKA:
626 case AUD_CODEC_VORBIS:
634 case AUD_CONTAINER_MP2:
639 case AUD_CONTAINER_MP3:
645 case AUD_CONTAINER_OGG:
650 case AUD_CONTAINER_WAV:
666 sound_mixdown_draw_check_prop,
678 {AUD_FORMAT_U8,
"U8", 0,
"U8",
"8-bit unsigned"},
679 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
680 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
681 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
682 {AUD_FORMAT_FLOAT32,
"F32", 0,
"F32",
"32-bit floating-point"},
683 {AUD_FORMAT_FLOAT64,
"F64", 0,
"F64",
"64-bit floating-point"},
684 {0,
nullptr, 0,
nullptr,
nullptr},
689 {AUD_CODEC_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
690 {AUD_CODEC_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
692 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
694 {AUD_CODEC_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
695 {AUD_CODEC_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
697 {AUD_CODEC_PCM,
"PCM", 0,
"PCM",
"Pulse Code Modulation (RAW)"},
698 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
699 {0,
nullptr, 0,
nullptr,
nullptr},
703 {AUD_CHANNELS_MONO,
"MONO", 0,
"Mono",
"Single audio channel"},
704 {AUD_CHANNELS_STEREO,
"STEREO", 0,
"Stereo",
"Stereo audio channels"},
705 {AUD_CHANNELS_STEREO_LFE,
"STEREO_LFE", 0,
"Stereo LFE",
"Stereo with LFE channel"},
706 {AUD_CHANNELS_SURROUND4,
"SURROUND4", 0,
"4 Channels",
"4 channel surround sound"},
707 {AUD_CHANNELS_SURROUND5,
"SURROUND5", 0,
"5 Channels",
"5 channel surround sound"},
708 {AUD_CHANNELS_SURROUND51,
"SURROUND51", 0,
"5.1 Surround",
"5.1 surround sound"},
709 {AUD_CHANNELS_SURROUND61,
"SURROUND61", 0,
"6.1 Surround",
"6.1 surround sound"},
710 {AUD_CHANNELS_SURROUND71,
"SURROUND71", 0,
"7.1 Surround",
"7.1 surround sound"},
711 {0,
nullptr, 0,
nullptr,
nullptr}};
716 ot->name =
"Mixdown";
717 ot->description =
"Mix the scene's audio to a sound file";
718 ot->idname =
"SOUND_OT_mixdown";
725 ot->check = sound_mixdown_check;
726 ot->ui = sound_mixdown_draw;
747 "Sample accuracy, important for animation data (the lower the value, the more accurate)",
751 ot->srna,
"container", container_items, AUD_CONTAINER_FLAC,
"Container",
"File format");
752 RNA_def_enum(
ot->srna,
"codec", codec_items, AUD_CODEC_FLAC,
"Codec",
"Audio Codec");
754 ot->srna,
"channels", channel_items, AUD_CHANNELS_STEREO,
"Channels",
"Audio channel count");
755 RNA_def_enum(
ot->srna,
"format", format_items, AUD_FORMAT_S16,
"Format",
"Sample format");
762 "Sample rate in samples/s",
765 RNA_def_int(
ot->srna,
"bitrate", 192, 32, 512,
"Bitrate",
"Bitrate in kbit/s", 32, 512);
770 "Each channel will be rendered into a mono file");
815 ot->name =
"Pack Sound";
816 ot->description =
"Pack the sound into the current blend file";
817 ot->idname =
"SOUND_OT_pack";
854 "AutoPack is enabled, so image will be packed again on file save");
889 "AutoPack is enabled, so image will be packed again on file save");
901 ot->name =
"Unpack Sound";
902 ot->description =
"Unpack the sound to the samples filename";
903 ot->idname =
"SOUND_OT_unpack";
918 ot->srna,
"id",
nullptr,
MAX_ID_NAME - 2,
"Sound Name",
"Sound data-block name to unpack");
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
FCurve * id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, bool *r_driven)
void BKE_main_id_tag_idcode(Main *mainvar, short type, int tag, bool value)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
int BKE_packedfile_unpack_sound(Main *bmain, ReportList *reports, bSound *sound, enum ePF_FileStatus how)
PackedFile * BKE_packedfile_new(ReportList *reports, const char *filepath_rel, const char *basepath)
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BKE_scene_camera_switch_update(Scene *scene)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
struct bSound * BKE_sound_new_file(struct Main *bmain, const char *filepath)
void BKE_sound_reset_scene_specs(struct Scene *scene)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
bool BLI_path_extension_check_array(const char *path, const char **ext_array) ATTR_NONNULL(1
bool BLI_path_extension_replace(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
@ ID_RECALC_SEQUENCER_STRIPS
@ SEQ_AUDIO_PITCH_ANIMATED
@ SEQ_AUDIO_VOLUME_ANIMATED
void unpack_menu(bContext *C, const char *opname, const char *id_name, const char *abs_name, const char *folder, PackedFile *pf)
static void split(const char *text, const char *seps, char ***str, int *count)
Read Guarded memory(de)allocation.
@ UI_BUT_LABEL_ALIGN_NONE
eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, bool(*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data, PropertyRNA *prop_activate_init, eButLabelAlign label_align, bool compact)
void UI_context_active_but_prop_get_templateID(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
BPy_StructRNA * depsgraph
#define ID_BLEND_PATH(_bmain, _id)
#define ID_IS_EDITABLE(_id)
DEG_id_tag_update_ex(cb_data->bmain, cb_data->owner_id, ID_RECALC_TAG_FOR_UNDO|ID_RECALC_SYNC_TO_EVAL)
void for_each_callback(ListBase *seqbase, ForEachFunc callback, void *user_data)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
const char * RNA_property_identifier(const PropertyRNA *prop)
PointerRNA RNA_id_pointer_create(ID *id)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const EnumPropertyItem rna_enum_unpack_method_items[]
static void SOUND_OT_pack(wmOperatorType *ot)
static wmOperatorStatus sound_pack_exec(bContext *C, wmOperator *op)
static void SOUND_OT_open(wmOperatorType *ot)
static void SOUND_OT_open_mono(wmOperatorType *ot)
static void sound_open_cancel(bContext *, wmOperator *op)
static wmOperatorStatus sound_update_animation_flags_exec(bContext *C, wmOperator *)
static wmOperatorStatus sound_mixdown_exec(bContext *C, wmOperator *op)
void ED_operatortypes_sound()
static bool sound_poll(bContext *C)
static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
static wmOperatorStatus sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus sound_unpack_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void SOUND_OT_bake_animation(wmOperatorType *ot)
static bool sound_update_animation_flags_fn(Strip *strip, void *user_data)
static void sound_update_animation_flags(Scene *scene)
static void SOUND_OT_mixdown(wmOperatorType *ot)
static void SOUND_OT_unpack(wmOperatorType *ot)
static wmOperatorStatus sound_open_exec(bContext *, wmOperator *op)
static wmOperatorStatus sound_open_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void sound_open_init(bContext *C, wmOperator *op)
static wmOperatorStatus sound_bake_animation_exec(bContext *C, wmOperator *)
struct PackedFile * packedfile
struct ReportList * reports
struct wmOperatorType * type
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorStatus WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)