38#include "RNA_prototypes.hh"
48# include <AUD_Special.h>
167 ot->
name =
"Open Sound Mono";
206 seq->
flag &= ~SEQ_AUDIO_VOLUME_ANIMATED;
214 seq->
flag &= ~SEQ_AUDIO_PITCH_ANIMATED;
222 seq->
flag &= ~SEQ_AUDIO_PAN_ANIMATED;
245 if (scene->ed !=
nullptr) {
254 scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED;
278 ot->
name =
"Update Animation";
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";
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;
366 result = AUD_mixdown_per_channel(scene_eval->
sound_scene,
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_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
416 {AUD_CONTAINER_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
418 {AUD_CONTAINER_MATROSKA,
"MATROSKA", 0,
"MKV",
"Matroska"},
419 {AUD_CONTAINER_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
420 {AUD_CONTAINER_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
422 {AUD_CONTAINER_OGG,
"OGG", 0,
"OGG",
"Xiph.Org Ogg Container"},
423 {AUD_CONTAINER_WAV,
"WAV", 0,
"WAV",
"Waveform Audio File Format"},
424 {0,
nullptr, 0,
nullptr,
nullptr},
427static const char *snd_ext_sound[] = {
440 AUD_Container container = AUD_Container(
RNA_enum_get(op->
ptr,
"container"));
442 const char *extension =
nullptr;
446 if (item->
value == container) {
447 const char **ext = snd_ext_sound;
448 while (*ext !=
nullptr) {
500static bool sound_mixdown_draw_check_prop(
PointerRNA * ,
505 return !
STR_ELEM(prop_id,
"filepath",
"directory",
"filename");
511 {AUD_FORMAT_U8,
"U8", 0,
"U8",
"8-bit unsigned"},
512 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
514 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
516 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
517 {AUD_FORMAT_FLOAT32,
"F32", 0,
"F32",
"32-bit floating-point"},
518 {AUD_FORMAT_FLOAT64,
"F64", 0,
"F64",
"64-bit floating-point"},
519 {0,
nullptr, 0,
nullptr,
nullptr},
523 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
524 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
525 {0,
nullptr, 0,
nullptr,
nullptr},
530 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
531 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
532 {0,
nullptr, 0,
nullptr,
nullptr},
537 {AUD_CODEC_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
538 {AUD_CODEC_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
539 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
540 {AUD_CODEC_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
541 {AUD_CODEC_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
542 {AUD_CODEC_PCM,
"PCM", 0,
"PCM",
"Pulse Code Modulation (RAW)"},
543 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
544 {0,
nullptr, 0,
nullptr,
nullptr},
548 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
549 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
550 {0,
nullptr, 0,
nullptr,
nullptr},
562 AUD_Container container = AUD_Container(
RNA_enum_get(op->
ptr,
"container"));
574 case AUD_CONTAINER_AC3:
579 case AUD_CONTAINER_FLAC:
590 case AUD_CONTAINER_MATROSKA:
617 case AUD_CODEC_VORBIS:
625 case AUD_CONTAINER_MP2:
630 case AUD_CONTAINER_MP3:
636 case AUD_CONTAINER_OGG:
641 case AUD_CONTAINER_WAV:
657 sound_mixdown_draw_check_prop,
669 {AUD_FORMAT_U8,
"U8", 0,
"U8",
"8-bit unsigned"},
670 {AUD_FORMAT_S16,
"S16", 0,
"S16",
"16-bit signed"},
671 {AUD_FORMAT_S24,
"S24", 0,
"S24",
"24-bit signed"},
672 {AUD_FORMAT_S32,
"S32", 0,
"S32",
"32-bit signed"},
673 {AUD_FORMAT_FLOAT32,
"F32", 0,
"F32",
"32-bit floating-point"},
674 {AUD_FORMAT_FLOAT64,
"F64", 0,
"F64",
"64-bit floating-point"},
675 {0,
nullptr, 0,
nullptr,
nullptr},
680 {AUD_CODEC_AAC,
"AAC", 0,
"AAC",
"Advanced Audio Coding"},
681 {AUD_CODEC_AC3,
"AC3", 0,
"AC3",
"Dolby Digital ATRAC 3"},
683 {AUD_CODEC_FLAC,
"FLAC", 0,
"FLAC",
"Free Lossless Audio Codec"},
685 {AUD_CODEC_MP2,
"MP2", 0,
"MP2",
"MPEG-1 Audio Layer II"},
686 {AUD_CODEC_MP3,
"MP3", 0,
"MP3",
"MPEG-2 Audio Layer III"},
688 {AUD_CODEC_PCM,
"PCM", 0,
"PCM",
"Pulse Code Modulation (RAW)"},
689 {AUD_CODEC_VORBIS,
"VORBIS", 0,
"Vorbis",
"Xiph.Org Vorbis Codec"},
690 {0,
nullptr, 0,
nullptr,
nullptr},
694 {AUD_CHANNELS_MONO,
"MONO", 0,
"Mono",
"Single audio channel"},
695 {AUD_CHANNELS_STEREO,
"STEREO", 0,
"Stereo",
"Stereo audio channels"},
696 {AUD_CHANNELS_STEREO_LFE,
"STEREO_LFE", 0,
"Stereo LFE",
"Stereo with LFE channel"},
697 {AUD_CHANNELS_SURROUND4,
"SURROUND4", 0,
"4 Channels",
"4 channel surround sound"},
698 {AUD_CHANNELS_SURROUND5,
"SURROUND5", 0,
"5 Channels",
"5 channel surround sound"},
699 {AUD_CHANNELS_SURROUND51,
"SURROUND51", 0,
"5.1 Surround",
"5.1 surround sound"},
700 {AUD_CHANNELS_SURROUND61,
"SURROUND61", 0,
"6.1 Surround",
"6.1 surround sound"},
701 {AUD_CHANNELS_SURROUND71,
"SURROUND71", 0,
"7.1 Surround",
"7.1 surround sound"},
702 {0,
nullptr, 0,
nullptr,
nullptr}};
716 ot->
check = sound_mixdown_check;
717 ot->
ui = sound_mixdown_draw;
738 "Sample accuracy, important for animation data (the lower the value, the more accurate)",
742 ot->
srna,
"container", container_items, AUD_CONTAINER_FLAC,
"Container",
"File format");
745 ot->
srna,
"channels", channel_items, AUD_CHANNELS_STEREO,
"Channels",
"Audio channel count");
746 RNA_def_enum(
ot->
srna,
"format", format_items, AUD_FORMAT_S16,
"Format",
"Sample format");
753 "Samplerate in samples/s",
756 RNA_def_int(
ot->
srna,
"bitrate", 192, 32, 512,
"Bitrate",
"Bitrate in kbit/s", 32, 512);
761 "Each channel will be rendered into a mono file");
807 ot->
description =
"Pack the sound into the current blend file";
845 "AutoPack is enabled, so image will be packed again on file save");
880 "AutoPack is enabled, so image will be packed again on file save");
892 ot->
name =
"Unpack Sound";
893 ot->
description =
"Unpack the sound to the samples filename";
909 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 struct 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
typedef double(DMatrix)[4][4]
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_tag_update_ex(Main *bmain, 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.
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
@ 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 uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
const Depsgraph * depsgraph
void SEQ_for_each_callback(ListBase *seqbase, SeqForEachFunc callback, void *user_data)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
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(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 void SOUND_OT_open(wmOperatorType *ot)
static void SOUND_OT_open_mono(wmOperatorType *ot)
static bool sound_update_animation_flags_fn(Sequence *seq, void *user_data)
static void sound_open_cancel(bContext *, wmOperator *op)
static int sound_pack_exec(bContext *C, wmOperator *op)
static int sound_open_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void ED_operatortypes_sound()
static bool sound_poll(bContext *C)
static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
static int sound_update_animation_flags_exec(bContext *C, wmOperator *)
static int sound_open_exec(bContext *, wmOperator *op)
static int sound_mixdown_exec(bContext *C, wmOperator *op)
static void SOUND_OT_bake_animation(wmOperatorType *ot)
static int sound_bake_animation_exec(bContext *C, wmOperator *)
static void sound_update_animation_flags(Scene *scene)
static void SOUND_OT_mixdown(wmOperatorType *ot)
static void SOUND_OT_unpack(wmOperatorType *ot)
static int sound_unpack_exec(bContext *C, wmOperator *op)
static void sound_open_init(bContext *C, wmOperator *op)
static int sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *)
static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
struct PackedFile * packedfile
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
bool(* check)(bContext *C, wmOperator *op)
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* ui)(bContext *C, wmOperator *op)
void(* cancel)(bContext *C, wmOperator *op)
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 *))
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)