1
0
Fork 0

Avisynth audio provider: add option to allow no downmix

This commit is contained in:
wangqr 2019-11-02 22:26:02 -04:00 committed by arch1t3cht
parent 691ab820b8
commit e2a49b3313
2 changed files with 9 additions and 7 deletions

View File

@ -110,12 +110,14 @@ void AvisynthAudioProvider::LoadFromClip(AVSValue clip) {
if (!vi.HasAudio()) throw agi::AudioDataNotFound("No audio found.");
IScriptEnvironment *env = avs_wrapper.GetEnv();
AVSValue script;
// Convert to one channel
AVSValue script = env->Invoke(OPT_GET("Audio/Downmixer")->GetString().c_str(), clip);
if (OPT_GET("Audio/Downmixer")->GetString() != "None")
script = env->Invoke(OPT_GET("Audio/Downmixer")->GetString().c_str(), clip);
else
script = clip;
// Convert to 16 bits per sample
script = env->Invoke("ConvertAudioTo16bit", script);
vi = script.AsClip()->GetVideoInfo();
// Convert sample rate
@ -135,8 +137,8 @@ void AvisynthAudioProvider::LoadFromClip(AVSValue clip) {
channels = vi.AudioChannels();
decoded_samples = num_samples = vi.num_audio_samples;
sample_rate = vi.SamplesPerSecond();
bytes_per_sample = vi.BytesPerAudioSample();
float_samples = false;
bytes_per_sample = vi.BytesPerChannelSample();
float_samples = vi.IsSampleType(SAMPLE_FLOAT);
this->clip = tempclip;
}

View File

@ -387,8 +387,8 @@ void Advanced_Audio(wxTreebook *book, Preferences *parent) {
#ifdef WITH_AVISYNTH
auto avisynth = p->PageSizer("Avisynth");
const wxString adm_arr[3] = { "ConvertToMono", "GetLeftChannel", "GetRightChannel" };
wxArrayString adm_choice(3, adm_arr);
const wxString adm_arr[4] = { "None", "ConvertToMono", "GetLeftChannel", "GetRightChannel" };
wxArrayString adm_choice(4, adm_arr);
p->OptionChoice(avisynth, _("Avisynth down-mixer"), adm_choice, "Audio/Downmixer");
p->OptionAdd(avisynth, _("Force sample rate"), "Provider/Audio/AVS/Sample Rate");
#endif