Oscilloscope fully in Magic
-
- Posts: 7
- Joined: Sat Dec 17, 2016 11:04 am
Oscilloscope fully in Magic
Dear Magic community
Did anyone of you manage to create an oscilloscope fully in Magic? If yes, how do you do it?
Cheers,
Silvan
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
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.
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.
-
- Posts: 720
- Joined: Sun Sep 14, 2014 8:15 am
- Location: UK
- Contact:
Re: Oscilloscope fully in Magic
(ref viewtopic.php?f=4&t=1103#p5012 onwards)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)?
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
- Attachments
-
- Edge Blur.fs
- A useful blur from the VidVox ISF collection at http://vidvox.net/rays_oddsnends/ISF%20files.zip
- (5.14 KiB) Downloaded 605 times
-
- XY Oscilloscope2b.fs
- My quick hack of https://www.shadertoy.com/view/4tdXzX
- (3.14 KiB) Downloaded 581 times
-
- eg xy scope.magic
- Example Magic project. Will need audio input to be specified in the Audio/MIDI Window.
- (1.68 KiB) Downloaded 652 times
-
- Posts: 720
- Joined: Sun Sep 14, 2014 8:15 am
- Location: UK
- Contact:
Re: Oscilloscope fully in Magic
... 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.
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.
- Attachments
-
- eg XY scope.jpg (72.31 KiB) Viewed 14026 times
Re: Oscilloscope fully in Magic
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;
}
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;
}
-
- Posts: 720
- Joined: Sun Sep 14, 2014 8:15 am
- Location: UK
- Contact:
Re: Oscilloscope fully in Magic
Thanks artnik, very effectiveartnik wrote:Variable FOR LOOPs are not impossible... you can break out...
Updated version attached. Sample count can now be varied to facilitate tradeoff between resolution and speed.
- Attachments
-
- XY Oscilloscope2b.fs
- Updated version, using artnik's technique to give adjustable sample count.
- (2.86 KiB) Downloaded 628 times
Re: Oscilloscope fully in Magic
Found this post incredibly useful !! THANK YOU!
I borrowed the oscilloscope code to create a video for my latest mix:
I borrowed the oscilloscope code to create a video for my latest mix:
-
- Posts: 720
- Joined: Sun Sep 14, 2014 8:15 am
- Location: UK
- Contact:
Re: Oscilloscope fully in Magic
You're welcome! It's by far my favourite effect.
Thanks for the thanks!
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
Some pretty interesting uses of Magic in the videos you have, thanks for sharing them -- sure to give me some more inspiration!Terry Payman wrote: ↑Thu Feb 29, 2024 5:01 pmYou're welcome! It's by far my favourite effect.
Thanks for the thanks!
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.
Just dropped in to share that the oscilloscope works REALLY well on square videos as in this one...
-
- Posts: 720
- Joined: Sun Sep 14, 2014 8:15 am
- Location: UK
- Contact:
Re: Oscilloscope fully in Magic
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.
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.
Re: Oscilloscope fully in Magic
Hi there. Sorry for a stupid question, but I can't work out how to actually make this (XY Oscilloscope2b.fs) work with audio...I've got the module up in MMV, but not sure how to proceed. Thanks for any help! Cheers.Terry Payman wrote: ↑Sat Jan 07, 2017 9:41 amThanks artnik, very effectiveartnik wrote:Variable FOR LOOPs are not impossible... you can break out...
Updated version attached. Sample count can now be varied to facilitate tradeoff between resolution and speed.
-
- Posts: 720
- Joined: Sun Sep 14, 2014 8:15 am
- Location: UK
- Contact:
Re: Oscilloscope fully in Magic
See my post(s) above.
There's a screenshot showing how to pass audio to the oscilloscope module.
viewtopic.php?p=5129#p5129
There's a screenshot showing how to pass audio to the oscilloscope module.
viewtopic.php?p=5129#p5129
Re: Oscilloscope fully in Magic
Oh, thanks so much - sorry, I didn’t see that! Cheers.