Previous topicNext topic

Random parameter

Questions, comments, feedback, etc.
Post Reply
Tsunoo
Posts: 27
Joined: Sun Oct 04, 2015 10:11 am
Location: Paris, France

Random parameter

Post by Tsunoo »

Hello Eric, hello all Magic users,

I recently bought Magic: it is a fantastic program!

I am trying to mimic a BPM detector. For example, if I want to show an image on every beat, I use a transparency module with amount linked to a custom frequency of 20-40 with following parameters: scale 5.0, threshold 0.5, scale -1.0, offset 1.5. In this way, the image is showing very quick on every beat. This is the result I expected.

Now, how can I get the same result with a different image on each beat? I tried with a JpegFolder module and played with the Index property: I manage to get a 0 index or a n index (using a scale parameter of n at the end). But I cannot set a different index for each beat: it is always the same n index. If I use a random parameter, the value changes on every frame, and I get several images shown on screen during the few ms of beat duration. I tried to link the FPS property to sound but the result is quite not accurate, because FPS depends on the BPM of the song played, which I don't know in advance.

Is there a way to generate a random number that will not change every frame, but will stay the same for a short time?

I read on this forum that you are planning to add a kind of BPM detector in version 1.7. Do you have news? I guess you can auto-detect a BPM from an audio source: software like Virtual DJ can manage that...

I am using pure audio sound files and don't have any MIDI device.

Thank you for any answer and again: Magic is awesome!
Sadler
Posts: 1145
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Random parameter

Post by Sadler »

Theoretically, if the increase modifier is set to zero, the modifier should increase the index whenever a sound of the chosen frequency occurs, assuming one can scale the input appropriately. However, when trying to test this theory MV hung on me with what looked like the index of JpegFolder looping to a negative integer.
jpeg_folder_limit.jpg
jpeg_folder_limit.jpg (14.64 KiB) Viewed 5757 times
It may be a coincidence, but MV might have discovered a Mersenne prime (2**31 − 1) though we'd need to see the last four digits to be sure ;)
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Random parameter

Post by Magic »

I recently bought Magic: it is a fantastic program!
Thanks! :)
Now, how can I get the same result with a different image on each beat?
What Sadler suggested is exactly how I'd do it. I'm not sure you'd want to use a random number, unless you intentionally wanted the results to be unpredictable. Even a random number that stayed the same for a short period of time might change in the middle of the beat.

In the next version of Magic (1.63) I will be adding a "Trigger" modifier that will make it easier for a beat to increment a parameter value.
the BPM of the song played, which I don't know in advance...
I am using pure audio sound files
Hmm, if you are using sound files, you might want to try just running them through a program that will report their BPM, such as http://www.abyssmedia.com/bpmcounter/ (first relevant result I found when Googling). Then you can adjust the parameter for the Increase/Ramp modifiers to match the beat perfectly.
I read on this forum that you are planning to add a kind of BPM detector in version 1.7. Do you have news? I guess you can auto-detect a BPM from an audio source: software like Virtual DJ can manage that...
My plan wasn't necessarily to add a BPM detector (which can be complicated, as well as error-prone even in the best cases), but an ability to specify a BPM globally by typing it in or using a slider to adjust it. We'll see :).
when trying to test this theory MV hung on me with what looked like the index of JpegFolder looping to a negative integer.
Hmm, that's odd! Can't seem to reproduce it. Let me know if you figure out when it's happening.
Tsunoo
Posts: 27
Joined: Sun Oct 04, 2015 10:11 am
Location: Paris, France

Re: Random parameter

Post by Tsunoo »

Thank you for your answers and explanations! I managed to have one image on the beat using the following modifiers on frequency 20-40: scale, threshold on the transparency module. I added a peak modifier to have a nice and smooth effect. But I still cannot get the image to change on each beat. I guess that I have to play with the increase modifier's parameter. For the moment, the image index in the selector sometimes changes during the beat and it really does not look nice :-(

I wish I could show you screenshots of my modules, but the img option is turned off when I write a message in this forum...

As of BPM detection, I know the BPM for every audio files I play individually. I was wondering if there could be a "live" option to detect BPM on the fly while playing live audio.

But then I have another question: assumed that I know the BPM for my audio file, I am not sure that the first beat will occur on timestamp 0:0:000. Is there a way to synchronize a module with the beat? If I use an increase parameter and assumed that I managed to compute the right parameter value for it, how can I be sure that the module's value will change with the beat?

Anyway, I will go on further exploration of this fantastic program!

Thank you again.
Sadler
Posts: 1145
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Random parameter

Post by Sadler »

I tried to get the Midi Beat Clock and the Increase modifier to work together. On it's own (but with a step to limit it increment to integers) the Beat Clock changes the numbers (0-1-0-1...) in time but doesn't increment. Combined with the increase modifier it does increase but at a much slower (fractional rather than integral) rate than expected. See screen capture (maximise to see index changing)
For the Increase modifier the MV manual says "The input value is added to the parameter, and instantaneously increases the rate." How often does it do this? I would expect the index to increase by 1.0 each time the Beat Clock reaches 1.0 (with the Step). I also think it could be the Increase modifier that is making the audio input difficult to tune for audio based beats.

The program sending the Beat Clock is Human Synchroniser (30 day trial).

RE: JpegFolder - I did get the index to loop past the 32bit integer limit again reaching that negative value which stopped the index increasing but didn't hang MV this time and the Increase modifier kept going without updating the index. Insert an Increase modifier at 1,000,000,000.0 scaled by 1,000,000,000.0 and it gets there in a reasonable time. Will have to do more testing to nail this down.
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Random parameter

Post by Magic »

I wish I could show you screenshots of my modules, but the img option is turned off when I write a message in this forum...
You can use attachments instead of the img tag. When you are writing your post just click on "Upload attachment" below the Submit button. We disabled the img tag because it has the potential to create a security error when linking to a non-https image. By using attachments, the image is hosted on our site, so it's guaranteed to be https-friendly.
As of BPM detection, I know the BPM for every audio files I play individually. I was wondering if there could be a "live" option to detect BPM on the fly while playing live audio.
I haven't made BPM detection a priority because it's an inexact science, and it's complicated, and there is also a nice little util called Waveclock (http://wavesum.net/products.html#waveclock) which does it fairly well already. You might want to give it a try. I know the creator, he's a pretty nice guy.
But then I have another question: assumed that I know the BPM for my audio file, I am not sure that the first beat will occur on timestamp 0:0:000. Is there a way to synchronize a module with the beat? If I use an increase parameter and assumed that I managed to compute the right parameter value for it, how can I be sure that the module's value will change with the beat?
I think the best way to handle this would be to use the Playlist to make a new scene start when the beat starts. You can have the first scene last exactly for the amount of time it takes to get to the first beat, and then make the second scene last for the rest of the song, or whatever you want. See the Playlist section in the User's Guide for more info: https://magicmusicvisuals.com/downloads ... listWindow

Also, make sure to click the "Audio file control" option in the Playlist window so the Playlist starts when you start playing your audio file: https://magicmusicvisuals.com/downloads ... ileControl
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Random parameter

Post by Magic »

For the Increase modifier the MV manual says "The input value is added to the parameter, and instantaneously increases the rate." How often does it do this? I would expect the index to increase by 1.0 each time the Beat Clock reaches 1.0 (with the Step). I also think it could be the Increase modifier that is making the audio input difficult to tune for audio based beats.
The issue is that the Increase modifier (and the other oscillators: Ramp/Sine/Tri) aren't really supposed to be used in this way. They treat their input and parameter values as "increments per second". So let's say your Increase parameter is 1. That means it will increase by 1 every second. But if your Magic Window is running at 60fps, it actually increments at 1/60 per frame. By doing this, the timing remains constant regardless of your frame rate. Almost all of Magic is built this way, and it's important because there are monitors which run at 75Hz or 120Hz or 144Hz for example, so if you created a project on a 60Hz monitor and then ran it on a faster monitor, all the timing would otherwise be off. I try to never assume that the monitor is running at 60Hz, even though most are.

Anyway, I'm adding a new modifier to 1.63 which won't be fps-dependent, and will be more friendly with the beat clock and with audio-based beats. It should be a decent solution.
Tsunoo
Posts: 27
Joined: Sun Oct 04, 2015 10:11 am
Location: Paris, France

Re: Random parameter

Post by Tsunoo »

Thank you, Eric, for your answers.

I wish I could try Waveclock, but it is only available for the OS-X platform and I use a Windows PC...

I am currently using the playlist with scenes duration and an example of yours for a beat counter. I guess I will make that working according to my needs...
Tsunoo
Posts: 27
Joined: Sun Oct 04, 2015 10:11 am
Location: Paris, France

Re: Random parameter

Post by Tsunoo »

Anyway, I'm adding a new modifier to 1.63 which won't be fps-dependent, and will be more friendly with the beat clock and with audio-based beats. It should be a decent solution.
I'm looking forward!
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Random parameter

Post by Magic »

I wish I could try Waveclock, but it is only available for the OS-X platform and I use a Windows PC...
Oh, you are right! It used to be available for Windows, but I guess they stopped offering it. Sorry about that.
Post Reply