Log in

View Full Version : Function to kill segment of audio?


trolltuning
26th October 2004, 19:37
I'm trying to write my first function and I need a little help.
#Script
AVISource("C:\WINDOWS\Desktop\Scripts\Dream12.avi")
Function KillPartofAudio (int a,int b){
Trim(0,a-1)+Trim.killaudio(a,b)+trim(a,0)
}
KillPartofAudio(20,200)

Boulder
26th October 2004, 19:45
I don't think it's possible for one part of the video not to have audio while the others do. You should probably add a silent dummy audio track to the part where you want to have silence, use BlankClip for that.

EDIT: This might be helpful:

function AddAudio(clip v1) {
v2 = Blankclip()
v1 = AudioDub(v1,v2)
return v1
}

trolltuning
27th October 2004, 13:52
@ Boulder Thanks I'll switch to dubbing audio from Blankclip() to the section I want to kill the audio on.

That solves half the problem. I thought I'd test the trim part of the function before removing the audio from the middle clip so the script now reads

[
#Script
AVISource("C:\WINDOWS\Desktop\Scripts\Dream12.avi")
Function KillPartofAudio (clip last,int a,int b){
Trim(0,a-1)+Trim(a,b)+trim(a,0)
}
KillPartofAudio(20,200)
#I get a message stating illegal arguments to Trim. Where did I go wrong?

stickboy
27th October 2004, 17:41
I get a message stating illegal arguments to Trim. Where did I go wrong?Is your script exactly as you posted it? It's possible you neglected to give Trim a clip to operate on (although the trick of naming the input clip "last" should have worked).

Also, you should be careful about using Trim that way (http://forum.doom9.org/showthread.php?s=&threadid=58358).

It might be easier to use my JDL_Silence (http://www.avisynth.org/stickboy/) function with ApplyRange:ApplyRange(20, 200, "JDL_Silence")

trolltuning
27th October 2004, 20:02
Originally posted by stickboy
[B]Is your script exactly as you posted it?
You were right. I was working on a different computer before so I can't swear to it, but I pasted from the post into a new script and it worked.
Of course the one you've already made is more concise. Maybe in about 15 years I'll be able to write close to that well
:)