39#include "RNA_prototypes.hh"
51# include <AUD_Special.h>
71 op->
customdata = pprop = MEM_new<PropertyPointerRNA>(__func__);
142 ot->name =
"Open Sound";
143 ot->description =
"Load a sound file";
144 ot->idname =
"SOUND_OT_open";
163 RNA_def_boolean(
ot->srna,
"mono",
false,
"Mono",
"Merge all the sound's channels into one");
169 ot->name =
"Open Sound Mono";
170 ot->description =
"Load a sound file as mono";
171 ot->idname =
"SOUND_OT_open_mono";
247 if (scene->
ed !=
nullptr) {
280 ot->name =
"Update Animation";
281 ot->description =
"Update animation flags";
282 ot->idname =
"SOUND_OT_update_animation_flags";
299 int oldfra = scene->
r.
cfra;
304 for (cfra = (scene->
r.
sfra > 0) ? (scene->
r.
sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) {
305 scene->
r.
cfra = cfra;
311 scene->
r.
cfra = oldfra;
320 ot->name =
"Update Animation Cache";
321 ot->description =
"Update the audio animation cache";
322 ot->idname =
"SOUND_OT_bake_animation";
342 int bitrate, accuracy;
343 AUD_DeviceSpecs specs;
344 AUD_Container container;
347 char error_message[1024] = {
'\0'};
364 const int start_frame = scene_eval->
r.
sfra;
365 const int end_frame = scene_eval->
r.
efra;
369 start_frame * specs.rate / fps,
370 (end_frame - start_frame + 1) * specs.rate / fps,
377 AUD_RESAMPLE_QUALITY_MEDIUM,
381 sizeof(error_message));
385 start_frame * specs.rate / fps,
386 (end_frame - start_frame + 1) * specs.rate / fps,
393 AUD_RESAMPLE_QUALITY_MEDIUM,
397 sizeof(error_message));
416 {AUD_CONTAINER_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
417 {AUD_CONTAINER_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
419 {AUD_CONTAINER_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
421 {AUD_CONTAINER_MATROSKA,
"MATROSKA", 0,
"MKV",
"Matroska"},
422 {AUD_CONTAINER_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
423 {AUD_CONTAINER_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
425 {AUD_CONTAINER_OGG,
"OGG", 0,
"OGG",
"Xiph.Org Ogg Container"},
426 {AUD_CONTAINER_WAV,
"WAV", 0,
"WAV",
"Waveform Audio File Format"},
427 {0,
nullptr, 0,
nullptr,
nullptr},
430static const char *snd_ext_sound[] = {
444 AUD_Container container = AUD_Container(
RNA_enum_get(op->
ptr,
"container"));
446 const char *extension =
nullptr;
450 if (item->
value == container) {
451 const char **ext = snd_ext_sound;
452 while (*ext !=
nullptr) {
504static bool sound_mixdown_draw_check_prop(
PointerRNA * ,
509 return !
STR_ELEM(prop_id,
"filepath",
"directory",
"filename");
515 {AUD_FORMAT_U8,
"U8", 0,
"U8",
"8-bit unsigned"},
516 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
518 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
520 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
521 {AUD_FORMAT_FLOAT32,
"F32", 0,
"F32",
"32-bit floating-point"},
522 {AUD_FORMAT_FLOAT64,
"F64", 0,
"F64",
"64-bit floating-point"},
523 {0,
nullptr, 0,
nullptr,
nullptr},
527 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
528 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
529 {0,
nullptr, 0,
nullptr,
nullptr},
534 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
535 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
536 {0,
nullptr, 0,
nullptr,
nullptr},
541 {AUD_CODEC_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
542 {AUD_CODEC_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
543 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
544 {AUD_CODEC_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
545 {AUD_CODEC_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
546 {AUD_CODEC_PCM,
"PCM", 0,
"PCM",
"Pulse Code Modulation (RAW)"},
547 {AUD_CODEC_OPUS,
"OPUS", 0,
"Opus",
"Opus Interactive Audio Codec"},
548 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
549 {0,
nullptr, 0,
nullptr,
nullptr},
553 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
554 {AUD_CODEC_OPUS,
"OPUS", 0,
"Opus",
"Opus Interactive Audio Codec"},
555 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
556 {0,
nullptr, 0,
nullptr,
nullptr},
568 AUD_Container container = AUD_Container(
RNA_enum_get(op->
ptr,
"container"));
580 case AUD_CONTAINER_AAC:
585 case AUD_CONTAINER_AC3:
590 case AUD_CONTAINER_FLAC:
601 case AUD_CONTAINER_MATROSKA:
628 case AUD_CODEC_VORBIS:
636 case AUD_CONTAINER_MP2:
641 case AUD_CONTAINER_MP3:
647 case AUD_CONTAINER_OGG:
652 case AUD_CONTAINER_WAV:
668 sound_mixdown_draw_check_prop,
680 {AUD_FORMAT_U8,
"U8", 0,
"U8",
"8-bit unsigned"},
681 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
682 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
683 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
684 {AUD_FORMAT_FLOAT32,
"F32", 0,
"F32",
"32-bit floating-point"},
685 {AUD_FORMAT_FLOAT64,
"F64", 0,
"F64",
"64-bit floating-point"},
686 {0,
nullptr, 0,
nullptr,
nullptr},
691 {AUD_CODEC_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
692 {AUD_CODEC_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
694 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
696 {AUD_CODEC_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
697 {AUD_CODEC_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
699 {AUD_CODEC_PCM,
"PCM", 0,
"PCM",
"Pulse Code Modulation (RAW)"},
700 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
701 {0,
nullptr, 0,
nullptr,
nullptr},
705 {AUD_CHANNELS_MONO,
"MONO", 0,
"Mono",
"Single audio channel"},
706 {AUD_CHANNELS_STEREO,
"STEREO", 0,
"Stereo",
"Stereo audio channels"},
707 {AUD_CHANNELS_STEREO_LFE,
"STEREO_LFE", 0,
"Stereo LFE",
"Stereo with LFE channel"},
708 {AUD_CHANNELS_SURROUND4,
"SURROUND4", 0,
"4 Channels",
"4 channel surround sound"},
709 {AUD_CHANNELS_SURROUND5,
"SURROUND5", 0,
"5 Channels",
"5 channel surround sound"},
710 {AUD_CHANNELS_SURROUND51,
"SURROUND51", 0,
"5.1 Surround",
"5.1 surround sound"},
711 {AUD_CHANNELS_SURROUND61,
"SURROUND61", 0,
"6.1 Surround",
"6.1 surround sound"},
712 {AUD_CHANNELS_SURROUND71,
"SURROUND71", 0,
"7.1 Surround",
"7.1 surround sound"},
713 {0,
nullptr, 0,
nullptr,
nullptr}};
718 ot->name =
"Mixdown";
719 ot->description =
"Mix the scene's audio to a sound file";
720 ot->idname =
"SOUND_OT_mixdown";
727 ot->check = sound_mixdown_check;
728 ot->ui = sound_mixdown_draw;
749 "Sample accuracy, important for animation data (the lower the value, the more accurate)",
753 ot->srna,
"container", container_items, AUD_CONTAINER_FLAC,
"Container",
"File format");
754 RNA_def_enum(
ot->srna,
"codec", codec_items, AUD_CODEC_FLAC,
"Codec",
"Audio Codec");
756 ot->srna,
"channels", channel_items, AUD_CHANNELS_STEREO,
"Channels",
"Audio channel count");
757 RNA_def_enum(
ot->srna,
"format", format_items, AUD_FORMAT_S16,
"Format",
"Sample format");
764 "Sample rate in samples/s",
767 RNA_def_int(
ot->srna,
"bitrate", 192, 32, 512,
"Bitrate",
"Bitrate in kbit/s", 32, 512);
772 "Each channel will be rendered into a mono file");
817 ot->name =
"Pack Sound";
818 ot->description =
"Pack the sound into the current blend file";
819 ot->idname =
"SOUND_OT_pack";
856 "AutoPack is enabled, so image will be packed again on file save");
891 "AutoPack is enabled, so image will be packed again on file save");
903 ot->name =
"Unpack Sound";
904 ot->description =
"Unpack the sound to the samples filename";
905 ot->idname =
"SOUND_OT_unpack";
920 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)
Scene * CTX_data_sequencer_scene(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
#define ID_BLEND_PATH(_bmain, _id)
#define ID_IS_EDITABLE(_id)
@ 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)
BPy_StructRNA * depsgraph
DEG_id_tag_update_ex(cb_data->bmain, cb_data->owner_id, ID_RECALC_TAG_FOR_UNDO|ID_RECALC_SYNC_TO_EVAL)
void foreach_strip(ListBase *seqbase, ForEachFunc callback, void *user_data)
Editing * editing_get(const Scene *scene)
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)
int RNA_int_get(PointerRNA *ptr, const char *name)
std::string RNA_string_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
void use_property_decorate_set(bool is_sep)
void use_property_split_set(bool value)
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 *)