Log in

View Full Version : SelectRangeEvery - Sound


Frank62
28th March 2021, 17:08
Hi all,

we have an ugly problem with a soundtrack: It has been copied from a DigiBeta-cassette with errors that cannot be fixed machanically. Picture is ok, but sound sounds like "robot voices". There is no second copy of this old tv-movie any more. At first I tried a lot of filters from three different professional sound softwares - no way to fix this.
A section of about two minutes shows this error:
If you look at it very close, it's clearly visible that valuable sound and absolute silence change in a constant pattern of 0.02 (that is 1/50) seconds. 1/50 sound, 1/50 no sound etc. Seems logical,because it's a PAL source. So each second field has got this error.
The idea to save the sound as best as possible was to

-throw away exactly the silent portions
-bring the result back to original (double) length with a good algorithm (no problem)
-maybe clean somewhat with some filters, don't know, will see

I found that SelectRangeEvery supports also sound, so I

-cut the beginning of the sound so that it begins exactly with silence, in order to have no offset.
-generated a BlankClip with 50fps
-AudioDub-bed it with the sound
-used SelectRangeEvery(2,1,0,true)

The result gives me the wanted frames: 1,3,5, etc. I checked this with current_frame-Subtitles via ScriptClip.

But the resulting sound is even more butchered than before.
Do I overlook something obvious? Or is SelectRangeEvery not exact with sound? If so: Do you have other ideas to delete each second frame's sound?

:thanks:

StainlessS
28th March 2021, 17:24
Post a sample might be good idea.

Maybe also take a peek at WaveForm_FilmStrip() using Wonkey_Monkey WaveForm.
https://forum.doom9.org/showthread.php?p=1876933#post1876933

https://i.postimg.cc/26N4fw7f/Wave-Form-Film-Strip-00.jpg (https://postimages.org/)

Frank62
28th March 2021, 17:53
Of course, a sample:
https://we.tl/t-5COndm1Mq1

The script had been:

v=blankclip(length=600,width=720,height=576,fps=50)
a=wavsource("D:\DZ\TestinPhaseShort.wav")
v=audiodub(v,a)

#v=ScriptClip(v,"Subtitle(String(current_frame))")

v=selectrangeevery(v,2,1,1,true)

return v

Frank62
28th March 2021, 18:04
Thanks for WaveForm_FilmStrip()!
Just looked at it,and one can see that there are sometimes even more samples ok. But at least each second frame (1,3,5,7...) is ok and just "in frame" so the result should be better than it is, at least without silences. But it's just mess.

wonkey_monkey
28th March 2021, 18:55
-throw away exactly the silent portions
-bring the result back to original (double) length with a good algorithm (no problem)
-maybe clean somewhat with some filters, don't know, will see

If you think about it in terms of video, that's like splitting a frame up into 100 pixel columns, throwing away every other column, pushing the remaining columns together and then stretching it out to the original width. Even if you leave the original data in place, I don't think any algorithm is going to be able to convincingly fill in the gaps.

I think selectrangeevery as well:


v=selectrangeevery(v,2,1,1,true)


But I only got a short burst of sound at the start, even if I changed offset to 0. I'm not sure SelectRangeEvery is behaving as I'm expecting it to.

StainlessS
28th March 2021, 20:04
I'm not sure SelectRangeEvery is behaving I'm expecting it to.
Something aint right

vid=blankclip(length=600,width=720,height=576,fps=50)
aud=wavsource(".\TestinPhaseShort.wav")
audiodub(vid,aud)
ORG=Last
#return WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5) # ORIGINAL

AUDIO = false
CHANGE_RATE= False # Change from 50FPS to 25FPS
SYNC_AUDIO = True # SelectRangeEvery does NOT affect FrameRate, we use AssumeScaledFPS to do that
AUD_FROM_B = True # Audio is from top stacked clip
ORG_BOTTOM = True # Show ORG on bottom [3 waveforms] but only if not CHANGE_RATE


A = selectrangeevery(2,1,0,AUDIO)
B = selectrangeevery(2,1,1,AUDIO)
A = (CHANGE_RATE) ? A.AssumeScaledFPS(1,2,SYNC_AUDIO) : A
B = (CHANGE_RATE) ? B.AssumeScaledFPS(1,2,SYNC_AUDIO) : B

A=A.WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)
B=B.WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)


(AUD_FROM_B) ? StackVertical(B,A) : StackVertical(A,B)

(ORG_BOTTOM && !CHANGE_RATE) ? StackVertical(Last,ORG.WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)) : Last


https://i.postimg.cc/yNp0nFZ7/z-01.jpg (https://postimg.cc/VSMSk0gh)

EDIT: I got no idea what it is that I'm tryin' to do :eek:

Frank62
28th March 2021, 21:32
Thanks a lot, guys!
I unburied a more than 20 years old VB6 program I wrote for a completely other purpose and trimmed it a bit to acomplish what I thought. The result is, what I tried to achieve - but sounds terrible, too. :scared:
So this case is closed - no way to restore the audio, at least that way. If you like to hear the catastrophe I will upload.

StainlessS
28th March 2021, 21:34
Well I aint not got no idea what to do with SelectRangesEvery() thingy thangy.

But we does got alternate whotsit to try.
Needs Prune() := https://forum.doom9.org/showthread.php?t=162446

First a script to write two command files.
WriteCommands.avs

EVEN = ".\EvenFrames.txt"
ODD = ".\ODDFrames.txt"

for(i=0,599) {
RT_Writefile((i % 2 == 0)?EVEN:ODD,"0 %d",i,Append=(i>1))
}
MessageClip("DONE")



And then prune frame selection doofah
PruneThingy.avs

EVEN_FN = ".\EvenFrames.txt"
ODD_FN = ".\ODDFrames.txt"

EVEN = False # Even or Odd frames (together with audio) to select
#EVEN = true

FN = (EVEN) ? EVEN_FN : ODD_FN

vid=blankclip(length=600,width=720,height=576,fps=50)
#vid = vid.ShowFrameNumber
aud=wavsource(".\TestinPhaseShort.wav")
audiodub(vid,aud)
ORG=Last

SHOW = True
FADESPLICE = false # Linear fade at splices, avoid clicks/cracks
FADE = 0.01 # 0.01 millisecs fade duration

Prune(Last,Cmd=FN, Show=SHOW, Fade=FADE, FadeIn=False,FadeSplice=FADESPLICE, FadeOut=False)
WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)


EDIT:
Thanks a lot, guys!
Scripts above probably get exact same as your VB prog, although can also remove cracks/clicks in audio splices,
however not really intended for fading to be so often as this prob. [Also, not sure, minimum Fade might be 1.0 millisec, see Prune]

StainlessS
28th March 2021, 22:39
Last try,


EVEN_FN = ".\EvenFrames.txt"
ODD_FN = ".\ODDFrames.txt"

EVEN = False # Even or Odd frames (together with audio) to select
#EVEN = true

FN = (EVEN) ? EVEN_FN : ODD_FN

vid=blankclip(length=600,width=720,height=576,fps=50)
#vid = vid.ShowFrameNumber
aud=wavsource(".\TestinPhaseShort.wav")
audiodub(vid,aud)
ORG=Last
#Return Last

SHOW = True
FADESPLICE = false # Linear fade at splices, avoid clicks/cracks
FADE = 0.01 # 0.01 millisecs fade duration

Prune(Last,Cmd=FN, Show=SHOW, Fade=FADE, FadeIn=False,FadeSplice=FADESPLICE, FadeOut=False)
# return last # Too Fast

ConvertAudioToFloat()
TimeStretch(tempo=50.0) # Half speed
vid2=blankclip(length=300,width=720,height=576,fps=25.0) # New Vid clip @ 25fps
AudioDub(Vid2,Last)
WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)


Still crap but a [EDIT: slightly] better class of crap.
https://i.postimg.cc/wjYhfXjp/Prune-Thingy-00.jpg (https://postimages.org/)

A Bit Dalek-ish, exterminieren ... exterminieren.

Frank62
28th March 2021, 23:23
Thanks again! Fading out/in seems worth a try, but I don't have much hope, because the remaining errors are no bigger clicks, only still-not-understandable speech.
I will look if I can get this to work.

StainlessS
28th March 2021, 23:37
FadeIn/FadeOut are for start and end of entire clip, FadeSplice is prune splice fade for [in your case] individual frames.
[However, I seem to remember a max limit of 1 millisec or half frame duration, on Fade time, and with it happening at every frame it
would have a probably disasterous effect , somewhat like a triangle waveform modulating the audio, sort of].
Have you listened to the output of prev script, I thought it reasonably understandable [assuming that you can understand Dalek].
[also, methinks that Dalek voice changer gadget essentially blanks audio every so often, kinda like you have here].

Frank62
29th March 2021, 12:23
Honestly, I don't get the last script to work without an amount of time, which I again don't have at the moment. Can you upload the result somewhere, so that I can check if the German is understandable? I fear it can't, but I would love to hear it.

StainlessS
29th March 2021, 12:29
Its on sendSpace, below my sig.

EDIT: Have to leasve the house now for an hour or two.

Frank62
29th March 2021, 13:17
I can't hear a bigger difference to the original? Did you maybe upload the original?

StainlessS
29th March 2021, 13:52
OK, you aint impressed :)

but you can see [if not hear] the diff with this [Maybe try VDub2]


vid1=blankclip(length=600,width=720,height=576,fps=50)
aud1=wavsource(".\TestinPhaseShort.wav")
V1=audiodub(vid1,aud1)
vid2=blankclip(length=300,width=720,height=576,fps=25)
aud2=wavsource(".\PruneThingy.wav")
V2=audiodub(vid2,aud2)

#V1
V2

WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)


EDIT: Maybe V2 looks similar to your VB6 extracted audio.

EDIT:
A Bit Dalek-ish, exterminieren ... exterminieren.
https://www.youtube.com/watch?v=xGx7c-QBotE

Frank62
29th March 2021, 14:22
This is my result of the short testsequence:
https://we.tl/t-MWa2wj6LZE
Also if you stretch it to original length, no matter how, one can't understand a word, just the first few.

You may not believe, but I never saw any episode of Dr. Who in my life. A shame, maybe.

StainlessS
29th March 2021, 15:56
HeHeHe, this is truly horrible.


vid1=blankclip(length=600,width=720,height=576,fps=50)
aud1=wavsource(".\TestinPhaseShort.wav")
V1=audiodub(vid1,aud1)

vid2=blankclip(length=300,width=720,height=576,fps=25)
aud2=wavsource(".\PruneThingy.wav") # Already TimeStretched
V2=audiodub(vid2,aud2)

aud3=wavsource(".\testinPhaseShortMonoNoZeroes.wav")
aud3=aud3.ConvertAudioToFloat()
vid3=blankclip(length=300,width=720,height=576,fps=25)
V3=audiodub(vid3,aud3)
V3=V3.TimeStretch(tempo=50.0) # TimeStretch


V1 = V1.WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)
V2 = V2.WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)
V3 = V3.WaveForm_FilmStrip(Window=3,Height=128,Under=true,Zoom=5.0,SubSize=0.5)

StackVertical(V2,V3) # StackVertical Should use Audio from first clip, but what is it doin' ? [Note Stereo + Mono]
#StackVertical(V3,V2)

Frank62
30th March 2021, 11:46
Just had to cut the scenes. No way. Interesting that the picture was repairable, the sound wasn't.
Thanks for your help.