Sound: Add channels and sample rate properties to mixdown operator

Previously, they were taken from the FFMPEG parameters, from the Output
panel, and this was not very convenient.

Co-authored-by: Matthieu Carteron <rubisetcie@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/124988
This commit is contained in:
Matthieu Carteron
2024-07-19 16:33:54 +02:00
committed by Richard Antalik
parent d2fdb22b93
commit 3e12a6d622

View File

@@ -353,8 +353,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container = AUD_Container(RNA_enum_get(op->ptr, "container"));
codec = AUD_Codec(RNA_enum_get(op->ptr, "codec"));
split = RNA_boolean_get(op->ptr, "split_channels");
specs.channels = AUD_Channels(scene_eval->r.ffcodecdata.audio_channels);
specs.rate = scene_eval->r.ffcodecdata.audio_mixrate;
specs.channels = AUD_Channels(RNA_enum_get(op->ptr, "channels"));
specs.rate = RNA_int_get(op->ptr, "mixrate");
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
@@ -411,16 +411,16 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
#ifdef WITH_AUDASPACE
static const EnumPropertyItem container_items[] = {
# ifdef WITH_FFMPEG
{AUD_CONTAINER_AC3, "AC3", 0, "ac3", "Dolby Digital ATRAC 3"},
{AUD_CONTAINER_AC3, "AC3", 0, "AC3", "Dolby Digital ATRAC 3"},
# endif
{AUD_CONTAINER_FLAC, "FLAC", 0, "flac", "Free Lossless Audio Codec"},
{AUD_CONTAINER_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"},
# ifdef WITH_FFMPEG
{AUD_CONTAINER_MATROSKA, "MATROSKA", 0, "mkv", "Matroska"},
{AUD_CONTAINER_MP2, "MP2", 0, "mp2", "MPEG-1 Audio Layer II"},
{AUD_CONTAINER_MP3, "MP3", 0, "mp3", "MPEG-2 Audio Layer III"},
{AUD_CONTAINER_MATROSKA, "MATROSKA", 0, "MKV", "Matroska"},
{AUD_CONTAINER_MP2, "MP2", 0, "MP2", "MPEG-1 Audio Layer II"},
{AUD_CONTAINER_MP3, "MP3", 0, "MP3", "MPEG-2 Audio Layer III"},
# endif
{AUD_CONTAINER_OGG, "OGG", 0, "ogg", "Xiph.Org Ogg Container"},
{AUD_CONTAINER_WAV, "WAV", 0, "wav", "Waveform Audio File Format"},
{AUD_CONTAINER_OGG, "OGG", 0, "OGG", "Xiph.Org Ogg Container"},
{AUD_CONTAINER_WAV, "WAV", 0, "WAV", "Waveform Audio File Format"},
{0, nullptr, 0, nullptr, nullptr},
};
@@ -690,6 +690,18 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem channel_items[] = {
{AUD_CHANNELS_MONO, "MONO", 0, "Mono", "Single audio channel"},
{AUD_CHANNELS_STEREO, "STEREO", 0, "Stereo", "Stereo audio channels"},
{AUD_CHANNELS_STEREO_LFE, "STEREO_LFE", 0, "Stereo LFE", "Stereo with LFE channel"},
{AUD_CHANNELS_SURROUND4, "SURROUND4", 0, "4 Channels", "4 channel surround sound"},
{AUD_CHANNELS_SURROUND5, "SURROUND5", 0, "5 Channels", "5 channel surround sound"},
{AUD_CHANNELS_SURROUND51, "SURROUND51", 0, "5.1 Surround", "5.1 surround sound"},
{AUD_CHANNELS_SURROUND61, "SURROUND61", 0, "6.1 Surround", "6.1 surround sound"},
{AUD_CHANNELS_SURROUND71, "SURROUND71", 0, "7.1 Surround", "7.1 surround sound"},
{0, NULL, 0, NULL, NULL}
};
#endif /* WITH_AUDASPACE */
/* identifiers */
@@ -730,7 +742,9 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
RNA_def_enum(
ot->srna, "container", container_items, AUD_CONTAINER_FLAC, "Container", "File format");
RNA_def_enum(ot->srna, "codec", codec_items, AUD_CODEC_FLAC, "Codec", "Audio Codec");
RNA_def_enum(ot->srna, "channels", channel_items, AUD_CHANNELS_STEREO, "Channels", "Audio channel count");
RNA_def_enum(ot->srna, "format", format_items, AUD_FORMAT_S16, "Format", "Sample format");
RNA_def_int(ot->srna, "mixrate", 48000, 8000, 192000, "Samplerate", "Samplerate in samples/s", 8000, 192000);
RNA_def_int(ot->srna, "bitrate", 192, 32, 512, "Bitrate", "Bitrate in kbit/s", 32, 512);
RNA_def_boolean(ot->srna,
"split_channels",