Skip to content

Commit e2a49b3

Browse files
wangqrarch1t3cht
authored andcommitted
Avisynth audio provider: add option to allow no downmix
1 parent 691ab82 commit e2a49b3

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/audio_provider_avs.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ void AvisynthAudioProvider::LoadFromClip(AVSValue clip) {
110110
if (!vi.HasAudio()) throw agi::AudioDataNotFound("No audio found.");
111111

112112
IScriptEnvironment *env = avs_wrapper.GetEnv();
113+
AVSValue script;
113114

114115
// Convert to one channel
115-
AVSValue script = env->Invoke(OPT_GET("Audio/Downmixer")->GetString().c_str(), clip);
116+
if (OPT_GET("Audio/Downmixer")->GetString() != "None")
117+
script = env->Invoke(OPT_GET("Audio/Downmixer")->GetString().c_str(), clip);
118+
else
119+
script = clip;
116120

117-
// Convert to 16 bits per sample
118-
script = env->Invoke("ConvertAudioTo16bit", script);
119121
vi = script.AsClip()->GetVideoInfo();
120122

121123
// Convert sample rate
@@ -135,8 +137,8 @@ void AvisynthAudioProvider::LoadFromClip(AVSValue clip) {
135137
channels = vi.AudioChannels();
136138
decoded_samples = num_samples = vi.num_audio_samples;
137139
sample_rate = vi.SamplesPerSecond();
138-
bytes_per_sample = vi.BytesPerAudioSample();
139-
float_samples = false;
140+
bytes_per_sample = vi.BytesPerChannelSample();
141+
float_samples = vi.IsSampleType(SAMPLE_FLOAT);
140142

141143
this->clip = tempclip;
142144
}

src/preferences.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ void Advanced_Audio(wxTreebook *book, Preferences *parent) {
387387

388388
#ifdef WITH_AVISYNTH
389389
auto avisynth = p->PageSizer("Avisynth");
390-
const wxString adm_arr[3] = { "ConvertToMono", "GetLeftChannel", "GetRightChannel" };
391-
wxArrayString adm_choice(3, adm_arr);
390+
const wxString adm_arr[4] = { "None", "ConvertToMono", "GetLeftChannel", "GetRightChannel" };
391+
wxArrayString adm_choice(4, adm_arr);
392392
p->OptionChoice(avisynth, _("Avisynth down-mixer"), adm_choice, "Audio/Downmixer");
393393
p->OptionAdd(avisynth, _("Force sample rate"), "Provider/Audio/AVS/Sample Rate");
394394
#endif

0 commit comments

Comments
 (0)