Log in

View Full Version : Oscilloscope with phosphor persistence rendering/simulation?


Reel.Deel
7th February 2015, 14:18
Hi, I was wondering if this cool looking oscilloscope can be created with AviSynth? I know there's Histogram("Stereo"), but it's a little plain.

Here's the video of the simulated phosphor persistence rendering: https://www.youtube.com/watch?v=RkJdADVy_Mg
The author said it was created with MatLab and gives a little info on the algorithm (http://www.eevblog.com/forum/projects/software-for-doing-phosphor-persistence-renderingsimulation/msg256898/?PHPSESSID=996b3babb78961b4bd73905d23f4dcd3#msg256898) that was inspired by: rendering PCM with simulated phosphor persistence. (http://www.windytan.com/2013/03/rendering-pcm-with-simulated-phosphor.html)

The song that was used is called Oscillofun by Atom Delta, a lossless version can be downloaded here: http://www.darkbits.org/~per/music/oscillofun.flac

Any comments/help will certainly be appreciated :).

raffriff42
9th February 2015, 03:08
I don't know about the figure drawing but the persistence is easy, if you overlay a bunch of previous frames in "add" mode. I happen to have a script for that. (First posted here (http://forum.doom9.org/showthread.php?t=168001), where there are also possibly better alternatives from StainLessS) Assert(IsClip(Last), "source missing")

return Histogram("stereo").ColorYUV(levels="TV->PC").Blurrr25(mode="add")

#################################################
### blend 25 most recent frames together
##
## @ gamma - sets decay rate; something like this -
## 20.0 = only 1st and 2nd frames visible
## 3.0 = see mostly the earlier frames
## 0.5 = all frames equal (default)
## 0.02 = 'ghost' delayed by 15 fr
## 0.01 = almost no effect
##
## version 0.42.2 - now with blend "mode"
##
function Blurrr25(C, float "gamma", string "mode")
{
gamma = Float(Default(gamma, 0.5))
mode = Default(mode, "blend")
cnt = 25.0
return
\Overlay(C.Trim( 0,0),
\Overlay(C.Trim( 1,0),
\Overlay(C.Trim( 2,0),
\Overlay(C.Trim( 3,0),
\Overlay(C.Trim( 4,0),
\Overlay(C.Trim( 5,0),
\Overlay(C.Trim( 6,0),
\Overlay(C.Trim( 7,0),
\Overlay(C.Trim( 8,0),
\Overlay(C.Trim( 9,0),
\Overlay(C.Trim(10,0),
\Overlay(C.Trim(11,0),
\Overlay(C.Trim(12,0),
\Overlay(C.Trim(13,0),
\Overlay(C.Trim(14,0),
\Overlay(C.Trim(15,0),
\Overlay(C.Trim(16,0),
\Overlay(C.Trim(17,0),
\Overlay(C.Trim(18,0),
\Overlay(C.Trim(19,0),
\Overlay(C.Trim(20,0),
\Overlay(C.Trim(21,0),
\Overlay(C.Trim(22,0),
\Overlay(C.Trim(23,0),
\Overlay(C.Trim(24,0), C,
\opacity=Pow( 1.0/cnt, gamma), mode=mode),
\opacity=Pow( 2.0/cnt, gamma), mode=mode),
\opacity=Pow( 3.0/cnt, gamma), mode=mode),
\opacity=Pow( 4.0/cnt, gamma), mode=mode),
\opacity=Pow( 5.0/cnt, gamma), mode=mode),
\opacity=Pow( 6.0/cnt, gamma), mode=mode),
\opacity=Pow( 7.0/cnt, gamma), mode=mode),
\opacity=Pow( 8.0/cnt, gamma), mode=mode),
\opacity=Pow( 9.0/cnt, gamma), mode=mode),
\opacity=Pow(10.0/cnt, gamma), mode=mode),
\opacity=Pow(11.0/cnt, gamma), mode=mode),
\opacity=Pow(12.0/cnt, gamma), mode=mode),
\opacity=Pow(13.0/cnt, gamma), mode=mode),
\opacity=Pow(14.0/cnt, gamma), mode=mode),
\opacity=Pow(15.0/cnt, gamma), mode=mode),
\opacity=Pow(16.0/cnt, gamma), mode=mode),
\opacity=Pow(17.0/cnt, gamma), mode=mode),
\opacity=Pow(18.0/cnt, gamma), mode=mode),
\opacity=Pow(19.0/cnt, gamma), mode=mode),
\opacity=Pow(20.0/cnt, gamma), mode=mode),
\opacity=Pow(21.0/cnt, gamma), mode=mode),
\opacity=Pow(22.0/cnt, gamma), mode=mode),
\opacity=Pow(23.0/cnt, gamma), mode=mode),
\opacity=Pow(24.0/cnt, gamma), mode=mode),
\opacity=Pow(25.0/cnt, gamma), mode=mode)
}

Reel.Deel
13th February 2015, 14:20
@raffriff42
I forgot about that thread, thanks for the reminder (nice to see you around btw). StainlessS' ClipBlend (http://forum.doom9.org/showthread.php?t=168048)(delay=2) seems to work OK and is also fast enough for real-time.

-----

1.) Anyone know of a better way to colorize Histogram("Stereo")?

To get red, green, or blue I can do something like this:

audio = last
Histogram("StereoY8")
ColorYUV(levels="TV->PC")
blank = BlankClip(last, color_yuv=0)
MergeRGB(blank, last, blank)
AudioDub(audio)

To get purple/blueish:
Histogram("StereoY8")
y = last
ColorYUV(levels="TV->PC")
o = last

blank = BlankClip(last, color_yuv=0)

MergeRGB(blank, blank, last)
ConvertToYV24()

u = UtoY8()
v = VtoY8().Invert()

YtoUV(u,v,y)
AudioDub(o)


2.) Is Histogram("Stereo") fixed to always output 25 FPS? I've tried an input clip with a higher frame rate but the resulting FPS is always 25. I guess I would have to use Histogram("StereoOverlay").