Page 1 of 1

Oscilloscope fully in Magic

Posted: Tue Jan 03, 2017 9:13 am
by tongleiter
Dear Magic community

Did anyone of you manage to create an oscilloscope fully in Magic? If yes, how do you do it?

Cheers,
Silvan

Re: Oscilloscope fully in Magic

Posted: Tue Jan 03, 2017 4:26 pm
by artnik
There are a couple of implementations of this at Shadertoy.com when you search for "oscilloscope":
Both of these should be convertable to V1 ISF with Eric's "Shadertoy-to-ISF" script, with minor tweaking: https://magicmusicvisuals.com/utils/sha ... to_isf.php

If you haven't messed with ISF scripting yet using this script and the live editor at http://www.interactiveshaderformat.com, it's a valuable skill to pick up. If you give it a go and run into issues, myself or someone else may be able to help. I'm just jammed today and can't give it a go right now.

Re: Oscilloscope fully in Magic

Posted: Thu Jan 05, 2017 11:06 am
by Terry Payman
tongleiter wrote:..How did you manage to create the centered-animation (in red) from the video you have posted on vimeo - it looks much like an oscilloscope to me.. (in the external application "Shadertoy" I guess)?
(ref viewtopic.php?f=4&t=1103#p5012 onwards)

I did indeed start my experiments in the Shadertoy environment, modifying https://www.shadertoy.com/view/4tdXzX. I then converted to ISF as detailed by Artnik, added the extra parameters and incorporated the mods I had tried in Shadertoy.

Here are the source files for my basic Magic project. The two ISF modules will need to be installed in an Additional Module Folder (see User's Guide). Audio input will need to be specified in the Audio/MIDI Window.

My XY Oscilloscope2b.fs module was just a very quick hack. I need to do more work on this (contributions welcome!) - especially in the light of the subsequently posted https://www.shadertoy.com/view/XttSzf that artnik found which I want to compare to the original https://www.shadertoy.com/view/MsXGDn

Re: Oscilloscope fully in Magic

Posted: Thu Jan 05, 2017 11:08 am
by Terry Payman
... ref above, as I couldn't add this image as a fourth attachment.

Edit: I had made a few variants of the XY 'scope with different sample lengths as it seems impossible to have a variable length for-loop in GLSL. I settled for having a fixed "variable" to identify each variant clearly.

Smaller loops will give faster rendering, but at the expense of image quality. This is a very inefficient shader, and even my very fast GPU (GTX 1070) is heavily loaded.

In the ShaderToy environment I believe there is a "correct" setting for the ReturnTuning if one wishes to accurately plot the left audio channel against the right, but I don't think that's applicable in the Magic environment as AudioToImage presumably has a single channel output to match its single channel input.

Re: Oscilloscope fully in Magic

Posted: Thu Jan 05, 2017 5:10 pm
by artnik
Variable FOR LOOPs are not impossible. :-)

In the header JSON, define a FLOAT that has the range of the number of loops you want. So in the following example NumSamples has a max value of 1000, and so the FOR LOOP is initialized with that. Then, you insert a break condition into the loop.

As far as I know, FOR LOOPS are unrolled on the GPU, in this case, it will unroll all the iterations as a monolithic chunk of code, but you can break out of it. Not the most elegant approach perhaps, but it works around the limitation of loops needing to be defined as a fixed length.

for( int i=0; i<1000; i++ )
{
if ( i > int (NumSamples) ) { break; } // The Magic happens here. :-)
YOUR CODE HERE;
}

Re: Oscilloscope fully in Magic

Posted: Sat Jan 07, 2017 9:41 am
by Terry Payman
artnik wrote:Variable FOR LOOPs are not impossible... you can break out...
Thanks artnik, very effective :D

Updated version attached. Sample count can now be varied to facilitate tradeoff between resolution and speed.

Re: Oscilloscope fully in Magic

Posted: Wed Feb 28, 2024 1:49 pm
by TEHK
Found this post incredibly useful !! THANK YOU!
I borrowed the oscilloscope code to create a video for my latest mix:

Re: Oscilloscope fully in Magic

Posted: Thu Feb 29, 2024 5:01 pm
by Terry Payman
TEHK wrote: Wed Feb 28, 2024 1:49 pm Found this post incredibly useful !! THANK YOU! ...
You're welcome! It's by far my favourite effect.

Thanks for the thanks! :D
377 downloads and yours is the first in seven years!

I really like your mix. I'm going to find it (and your other podcasts) a very inspiring source of audio when I'm working on Magic effects, and I'm very glad the 'scope module is useful for your videos. I love using waveforms to accompany music, and I'm certain you can develop this more - imho it really suits the type of music I hear on your YouTube channel.

Here's an example, made to accompany one of my son's remixes. You'll recognise the centre element! All done in Magic.

Re: Oscilloscope fully in Magic

Posted: Thu Mar 14, 2024 3:39 pm
by TEHK
Terry Payman wrote: Thu Feb 29, 2024 5:01 pm
TEHK wrote: Wed Feb 28, 2024 1:49 pm Found this post incredibly useful !! THANK YOU! ...
You're welcome! It's by far my favourite effect.

Thanks for the thanks! :D
377 downloads and yours is the first in seven years!

I really like your mix. I'm going to find it (and your other podcasts) a very inspiring source of audio when I'm working on Magic effects, and I'm very glad the 'scope module is useful for your videos. I love using waveforms to accompany music, and I'm certain you can develop this more - imho it really suits the type of music I hear on your YouTube channel.

Here's an example, made to accompany one of my son's remixes. You'll recognise the centre element! All done in Magic.
Some pretty interesting uses of Magic in the videos you have, thanks for sharing them -- sure to give me some more inspiration!

Just dropped in to share that the oscilloscope works REALLY well on square videos as in this one...

Re: Oscilloscope fully in Magic

Posted: Sun Mar 17, 2024 12:50 pm
by Terry Payman
Thanks!

A square format also works really well for the Waveform module in Circle mode.

Many of my projectors are 4:3 aspect ratio, some are 16:9 or 16:10.
I sometimes stretch a circular scene horizontally to fit the wider display, giving an oval shape. This too also works well imho.