PDA

View Full Version : I can't figure out what's wrong with my scripts.


morphinapg
16th February 2009, 02:08
These are scripts automatically generated from ASXGui when downmixing audio:

Audio0.avs:
Loadplugin("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\ffms2.dll")
video=ffvideosource("C:\Users\Andy\Desktop\the.lion.king-special.edition.1994.720p.hdtv.x264.sample-hv.mkv")
audio=directshowsource("C:\Users\Andy\Desktop\6_Channel_ID.wav", seekzero=true).Delayaudio(0)
a=audio

function DownMix(int c)
{
(c>=6) ? Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs").Downmix6() : Last

(c==5) ? Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs").Downmix5() : Last

(c==4) ? Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs").Downmix4() : Last

(c==3) ? Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs").Downmix3() : Last
}

(audio.AudioChannels>2) ? DownMix(audio.AudioChannels) : Last

audio.Normalize()
AudioDub(video,audio)

Downmix.avs:
function Downmix6()
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.2646, 0.1870)
lfe = GetChannel(a, 4, 4)
lrc = MixAudio(lrc, lfe, 1.0, 0.1870)
bl = GetChannel(a, 5)
br = GetChannel(a, 6)
sl = MixAudio(bl, br, 0.2291, 0.1323)
sr = MixAudio(bl, br, -0.1323, -0.2291)
blr = MergeChannels(sl, sr)
MixAudio(lrc, blr, 1.0, 1.0)
}

function Downmix5()
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3, 3)
lrc = MixAudio(flr, fcc, 0.3254, 0.2301)
bl = GetChannel(a, 4)
br = GetChannel(a, 5)
sl = MixAudio(bl, br, 0.2818, 0.1627)
sr = MixAudio(bl, br, -0.1627, -0.2818)
blr = MergeChannels(sl, sr)
MixAudio(lrc, blr, 1.0, 1.0)
}

function Downmix4()
{
flr = GetChannel(a, 1, 2)
bl = GetChannel(a, 3)
br = GetChannel(a, 4)
sl = MixAudio(bl, br, 0.3714, 0.2144)
sr = MixAudio(bl, br, -0.2144, -0.3714)
blr = MergeChannels(sl, sr)
MixAudio(flr, blr, 0.4142, 1.0)
}

function Downmix3()
{
flr = GetChannel(a, 1, 2)
sl = GetChannel(a, 3)
sr = Amplify(sl, -1.0)
blr = MergeChannels(sl, sr)
MixAudio(flr, blr, 0.5858, 0.4142)
}

Error I'm Getting:
Script error: Invalid arguments to function "Downmix6"
(C:\Users\Andy\AppData\Local\Temp\ASXGui\Audio0.avs, line 8)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\Audio0.avs, line 17)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\atest.avs, line 1)

What am I doing wrong?

neuron2
16th February 2009, 02:23
Import does not generate a clip so trying to apply the . operator to it is silly.

morphinapg
16th February 2009, 02:32
Import does not generate a clip so trying to apply the . operator to it is silly.

Okay. I'm not sure how to call a function from a different script then.

kemuri-_9
16th February 2009, 02:53
You import the .avs with the function definitions and call them in your script as if they were there to begin with:

Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs")
Loadplugin("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\ffms2.dll")
video=ffvideosource("C:\Users\Andy\Desktop\the.lion.king-special.edition.1994.720p.hdtv.x264.sample-hv.mkv")
audio=directshowsource("C:\Users\Andy\Desktop\6_Channel_ID.wav", seekzero=true).Delayaudio(0)
a=audio

function DownMix(int c)
{
(c>=6) ? Downmix6() : Last
(c==5) ? Downmix5() : Last
(c==4) ? Downmix4() : Last
(c==3) ? Downmix3() : Last
}

(audio.AudioChannels>2) ? DownMix(audio.AudioChannels) : Last

audio.Normalize()
AudioDub(video,audio)

morphinapg
16th February 2009, 04:13
You import the .avs with the function definitions and call them in your script as if they were there to begin with:

Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs")
Loadplugin("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\ffms2.dll")
video=ffvideosource("C:\Users\Andy\Desktop\the.lion.king-special.edition.1994.720p.hdtv.x264.sample-hv.mkv")
audio=directshowsource("C:\Users\Andy\Desktop\6_Channel_ID.wav", seekzero=true).Delayaudio(0)
a=audio

function DownMix(int c)
{
(c>=6) ? Downmix6() : Last
(c==5) ? Downmix5() : Last
(c==4) ? Downmix4() : Last
(c==3) ? Downmix3() : Last
}

(audio.AudioChannels>2) ? DownMix(audio.AudioChannels) : Last

audio.Normalize()
AudioDub(video,audio)


Okay, I set it up like that, but now it gives me this error:

I don't know what "a" means
(G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs, line 3)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\Audio0.avs, line 9)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\Audio0.avs, line 18)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\atest.avs, line 1)

Mug Funky
16th February 2009, 04:28
perhaps directshowsource is screwing you? try wavsource... usually more reliable.

also, friends don't let friends normalize. it's a worthless function IMHO as it has nothing to do with the actual level of the audio, just the highest peak which can be anything.

(i reckon a replaygain function could be useful, as well as a peak limiter... but as yet we don't have these)

kemuri-_9
16th February 2009, 05:16
Okay, I set it up like that, but now it gives me this error:

I don't know what "a" means
(G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs, line 3)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\Audio0.avs, line 9)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\Audio0.avs, line 18)
(C:\Users\Andy\AppData\Local\Temp\ASXGui\atest.avs, line 1)

your function definitions in Downmix.avs need some working.
change all the function definitions to take a clip parameter called 'a' as that's what you have the functions work on.
i.e.

function Downmix6(clip a)


you also don't need
a=audio in your main .avs either.

Edit:
now noticing some major problems with the functionality of your main script... it should be more like:

Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs")
Loadplugin("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\ffms2.dll")
video=ffvideosource("C:\Users\Andy\Desktop\the.lion.king-special.edition.1994.720p.hdtv.x264.sample-hv.mkv")
audio=directshowsource("C:\Users\Andy\Desktop\6_Channel_ID.wav", seekzero=true).Delayaudio(0)

function DownMix(clip a)
{
a
(AudioChannels()>=6) ? Downmix6() : Last
(AudioChannels()==5) ? Downmix5() : Last
(AudioChannels()==4) ? Downmix4() : Last
(AudioChannels()==3) ? Downmix3() : Last
}

audio = DownMix(audio)

audio = audio.Normalize()
AudioDub(video,audio)

need to set your altered audio tracks back to audio or else you'll just keep getting back the original audio track every time you call 'audio',
which will result in no work being done on the audio track; definitely not what we want in this case.

also need to pass the audio clip to DownMix() so it can pass it down to DownMix#()

at this point, you could move DownMix() to DownMix.avs to keep your main script cleaner.

morphinapg
16th February 2009, 05:53
your function definitions in Downmix.avs need some working.
change all the function definitions to take a clip parameter called 'a' as that's what you have the functions work on.
i.e.

function Downmix6(clip a)


you also don't need
a=audio in your main .avs either.

Edit:
now noticing some major problems with the functionality of your main script... it should be more like:

Import("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\Downmix.avs")
Loadplugin("G:\Users\Andy\Documents\SharpDevelop Projects\ASXGui 2.x\bin\Release\tools\ffms2.dll")
video=ffvideosource("C:\Users\Andy\Desktop\the.lion.king-special.edition.1994.720p.hdtv.x264.sample-hv.mkv")
audio=directshowsource("C:\Users\Andy\Desktop\6_Channel_ID.wav", seekzero=true).Delayaudio(0)

function DownMix(clip a)
{
a
(AudioChannels()>=6) ? Downmix6() : Last
(AudioChannels()==5) ? Downmix5() : Last
(AudioChannels()==4) ? Downmix4() : Last
(AudioChannels()==3) ? Downmix3() : Last
}

audio = DownMix(audio)

audio = audio.Normalize()
AudioDub(video,audio)

need to set your altered audio tracks back to audio or else you'll just keep getting back the original audio track every time you call 'audio',
which will result in no work being done on the audio track; definitely not what we want in this case.

also need to pass the audio clip to DownMix() so it can pass it down to DownMix#()

at this point, you could move DownMix() to DownMix.avs to keep your main script cleaner.

That did it.

:thanks: