View Full Version : 5 mono to stereo script
Nikos
21st February 2008, 23:42
This is my script for downmixing 5 mono wav to stereo. Please confirm that it's correct.
fl = WavSource("audio.L.wav")
fr = WavSource("audio.R.wav")
fc = WavSource("audio.C.wav")
sl = WavSource("audio.SL.wav")
sr = WavSource("audio.SR.wav")
flr = MergeChannels(fl, fr)
cc = MergeChannels(fc, fc)
lrc = MixAudio(flr, cc, 0.3694, 0.2612)
blr = MergeChannels(sl, sr)
mix = MixAudio(lrc, blr, 1.0, 0.3694)
amp = AmplifydB(mix, 3, 3)
SoundOut(amp)
:thanks:
tebasuna51
22nd February 2008, 01:50
This is my script for downmixing 5 mono wav to stereo. Please confirm that it's correct.
To obtain 'mix' you use:
fl' = 0.3694 x FL + 0.2612 x C + 0.3694 x SL
fr' = 0.3694 x FR + 0.2612 x C + 0.3694 x SR
and is a correct mix if you want simple stereo.
But for what you AmplifydB(3)?
You can clip the signal, if you want the max volume use Normalize() instead the Amplify()
Nikos
22nd February 2008, 03:10
Thanks tebasuna51 for the confirm. I taken the idea for this script from your posts :)
Yes i want simple stereo.
The AmplifydB(3, 3) is just for example.
First i run the script:
fl = WavSource("audio.L.wav")
fr = WavSource("audio.R.wav")
fc = WavSource("audio.C.wav")
sl = WavSource("audio.SL.wav")
sr = WavSource("audio.SR.wav")
flr = MergeChannels(fl, fr)
cc = MergeChannels(fc, fc)
lrc = MixAudio(flr, cc, 0.3694, 0.2612)
blr = MergeChannels(sl, sr)
mix = MixAudio(lrc, blr, 1.0, 0.3694)
SoundOut(mix)
Then with the option "Analyze Sound" i measure the right value for AmplifydB() because i don't want to maximize the volume to 0db
I prefer a small negative value for the maximum volume.
tebasuna51
22nd February 2008, 11:38
Then with the option "Analyze Sound" i measure the right value for AmplifydB() because i don't want to maximize the volume to 0db
I prefer a small negative value for the maximum volume.
Of course you can manually search the appropriate value to amplify using the SoundOut() Analyze Sound facility.
BTW, you can use any value like parameter in Normalize function, for instance to obtain a max peak at -1 dB you can use:
Normalize(0.8913)
Nikos
22nd February 2008, 14:19
Thanks again.
If you want write the operator between AmplifydB() and Normalize() values. Usually i prefer -2 or -3 db for the maximum volume.
tebasuna51
22nd February 2008, 18:14
Don't mistake Amplify with Normalize.
Normalize is done in two pass, first search the max peak value and in second pass apply the amplify needed to obtain a max peak at the fixed value. Then values less than 1 can't produce clips, values greater than 1 always clip the signal.
Amplify work in a single pass and make a fix amplify without regarding is there are clips or not.
BTW, the parameter in Normalize can be calculated by:
10^(-1dB/20) = 0.89125
10^(-2dB/20) = 0.79433
10^(-3dB/20) = 0.70795
...
Nikos
22nd February 2008, 21:38
I know the differents between Amplify and Normalize :)
With simple mathematics:
http://blue-whitegt.com/covers/amp-db.jpg
Because the power is proportional to the square of amplitude.
Nikos
15th April 2008, 14:39
Another question.
With this script (thanks tebasuna51) i convert 5.1 wav to 2.0 wav (no LFE):
a= WavSource("my.5.1.audio.wav")
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
Now i want to convert ac3 5.1 or dts 5.1 to 2.0 wav (no LFE) with NicAudio.dll, but the channel ordering (ac3 or dts) is different than wav.
5.1 AC3 --> fl, c, fr, sl, sr, LFE
5.1 dts --> c, fl, fr, sl, sr, LFE
I think that Nicaudio decode ac3 or dts to wav with the standard wav order (FL, FR, C, LFE, SL, SR), but i am not sure.
The below scripts are corrects?
a= NicAC3Source("my.5.1.audio.ac3")
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
a= NicDTSSource("my.5.1.audio.dts")
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3694, 0.2612)
blr = GetChannel(a, 5, 6)
return MixAudio(lrc, blr, 1.0, 0.3694)
Thanks for any help.
tebasuna51
15th April 2008, 17:14
I thing that Nicaudio decode ac3 or dts to wav with the standard wav order (FL, FR, C, LFE, SL, SR), but i am not sure.
Is a decoder job supply the correct order. You can use the same script safely.
This is true for any NicAudio or BassAudio (aac, ogg, wma, flac input) AviSynth decoder functions.
Nikos
15th April 2008, 18:04
Thanks again tebasuna51 for the quick and helpful reply.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.