Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » I need help with making a music visualizer. Can someone help me with this?
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
Hi there! It's Flat!
I need help with using the correct scripts and sprites on making the music visualizer (like those bars that move up and down that show the beat). Could someone with the correct NAWLEDGE
If you could help me, that would be awesome!
I need help with using the correct scripts and sprites on making the music visualizer (like those bars that move up and down that show the beat). Could someone with the correct NAWLEDGE

If you could help me, that would be awesome!
- Doyousketch2
-
Scratcher
93 posts
I need help with making a music visualizer. Can someone help me with this?
reset timer
play sound [Unity by The Fat Rat.mp3 v]
if <(timer) > [1]> then
broadcast [bass v]
end
if <(timer) > [1.5]> then
broadcast [snare v]
end
if <(timer) > [2]> then
broadcast [bass v]
end
if <(timer) > [2.5]> then
broadcast [cymbal v]
end
That's the basic idea.
You can put the values in a list.
Just keep checking if the timer is past the next item in the list.
I think I had trouble using “ timer = value ”
because it runs so fast.
If it happens to stutter while running one script
it might jump from say 1.99 to 2.01
…so it could miss the moment when another object
is supposed to do something at 2 secs.
That's why “ timer > # ” was used.
I did something like that in a couple of projects
https://scratch.mit.edu/projects/38646172
https://scratch.mit.edu/projects/45609908
Oh and this one. I thought it was shared a year ago, but I guess I forgot to.
https://scratch.mit.edu/projects/36449826
For the one with the dots I used a free sound program called Audacity.
I used a band-pass filter to create low, medium, high tones
then ran each segment through a beat-finder script.
Exported the list… but as I recall,
it had an extra column of useless data.
So I pulled that list into LibreOffice to delete the junk.
Once I had the beat timer data in a “one item per line” list,
then I imported that into my Scratch project
and basically used the above technique to make stuff flash on time.
Last edited by Doyousketch2 (April 4, 2016 00:19:34)
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
Wait. What do I do with the “When I Recieve” scripts for the other things, like for the bars?reset timer
play sound [Unity by The Fat Rat.mp3 v]
if <(timer) > [1]> then
broadcast [bass v]
end
if <(timer) > [1.5]> then
broadcast [snare v]
end
if <(timer) > [2]> then
broadcast [bass v]
end
if <(timer) > [2.5]> then
broadcast [cymbal v]
end
That's the basic idea.
You can put the values in a list.
Just keep checking if the timer is past the next item in the list.
I think I had trouble using “ timer = value ”
because it runs so fast.
If it happens to stutter while running one script
it might jump from say 1.99 to 2.01
…so it could miss the moment when another object
is supposed to do something at 2 secs.
That's why “ timer > # ” was used.
I did something like that in a couple of projects
https://scratch.mit.edu/projects/38646172
https://scratch.mit.edu/projects/45609908
Oh and this one. I thought it was shared a year ago, but I guess I forgot to.
https://scratch.mit.edu/projects/36449826
For the one with the dots I used a free sound program called Audacity.
I used a band-pass filter to create low, medium, high tones
then ran each segment through a beat-finder script.
Exported the list… but as I recall,
it had an extra column of useless data.
So I pulled that list into LibreOffice to delete the junk.
Once I had the beat timer data in a “one item per line” list,
then I imported that into my Scratch project
and basically used the above technique to make stuff flash on time.
- Doyousketch2
-
Scratcher
93 posts
I need help with making a music visualizer. Can someone help me with this?
Wait. What do I do with the “When I Recieve” scripts for the other things, like for the bars?
Anything you want.
The broadcast message just starts whatever script(s) are listening for that message.
For example, you could have a bass sprite:
when green flag clickedThat way you don't see it 'till the beat hits,
set size to (100) %
hide
forever
glide (3) secs to x: (pick random (-170) to (170)) y: (pick random (-150) to (150))
end
when I receive [bass v]
show
repeat (5)
change size by (5)
end
repeat (5)
change size by (-5)
end
hide
and when it does, it pulses.
Same thing with the other sprites.
They just receive a different broadcast message,
so they know when to flash.
- Prscr
-
Scratcher
100+ posts
I need help with making a music visualizer. Can someone help me with this?
Heres a simple script that you can use. For the bars it doesn't matter just use this:
and you can do whatever you want with the bars.
That's the basic idea. Later you can get into the good stuff like prerecording!
Hope this helped,
Prscr
when green flag clicked*The person has to use a mic though*
play sound [... v]
forever
set [variable v] to (loudness)
end
and you can do whatever you want with the bars.
That's the basic idea. Later you can get into the good stuff like prerecording!
Hope this helped,
Prscr
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
Wait. What do I do with the “When I Recieve” scripts for the other things, like for the bars?
Anything you want.
The broadcast message just starts whatever script(s) are listening for that message.
For example, you could have a bass sprite:when green flag clickedThat way you don't see it 'till the beat hits,
set size to (100) %
hide
forever
glide (3) secs to x: (pick random (-170) to (170)) y: (pick random (-150) to (150))
end
when I receive [bass v]
show
repeat (5)
change size by (5)
end
repeat (5)
change size by (-5)
end
hide
and when it does, it pulses.
Same thing with the other sprites.
They just receive a different broadcast message,
so they know when to flash.
And then what about the others? Sorry if I'm annoying you with these questions. I just have almost no idea on what to do with this, haha.
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
Wait. What do I do with the “When I Recieve” scripts for the other things, like for the bars?
Anything you want.
The broadcast message just starts whatever script(s) are listening for that message.
For example, you could have a bass sprite:when green flag clickedThat way you don't see it 'till the beat hits,
set size to (100) %
hide
forever
glide (3) secs to x: (pick random (-170) to (170)) y: (pick random (-150) to (150))
end
when I receive [bass v]
show
repeat (5)
change size by (5)
end
repeat (5)
change size by (-5)
end
hide
and when it does, it pulses.
Same thing with the other sprites.
They just receive a different broadcast message,
so they know when to flash.
Also, is it like a pen sprite where there is no costumes, or do I make just a bar as a costume?
- Brontosplachna
-
Scratcher
100+ posts
I need help with making a music visualizer. Can someone help me with this?
- Doyousketch2
-
Scratcher
93 posts
I need help with making a music visualizer. Can someone help me with this?
There's essentially 2 ways to go about it.
1) preprogram your beats in, according to the timer.
alternatively, you can use “wait” statements.
2) rely on the microphone to detect loudness,
then trigger stuff to happen due to the volume.
You'll 'prolly want to set the X location in the beginning and not change that.
The Y coordinate will then move up and down as the loudness changes.
Other than the users with no mic, the main limiting factor with this route
is that Scratch doesn't detect differences in tones.
Most music visualizers show different bars for low or high notes.
You can't achieve this with the microphone method,
because it only scans for overall volume.
The timer trick I showed you can be broken down
into as many separate bars as you like.
It just takes time to do, but the results could be spot-on if you do it right.
I had it right and my Wanted To looked awesome,
but then I accidentally deleted the trimmed sound file or something like that,
so the data lists no longer line up.
I figured out another method, to save the band-pass files as unique .mp3's
then pipe each one through the loudness detector script.
so as to create each low-med-high beat-detect list.
That was gonna look awesome, and right on time, but then my mic died.
I don't know exactly where, I think it's a crack in the cord.
So yeah, I have another mic downstairs somewhere.
Maybe I can get that one going, to give you a better idea what it would look like.
As I say, the idea is there. I think the blue circle was low-tones,
the orange triangle was mid-tones, and the red star was high-tones.
Instead of dancing around the screen, you'd just put ‘em in one spot.
Then do whatever visual effect you want with ’em;
change size, move up-and-down, color-shift, what-have-you.
1) preprogram your beats in, according to the timer.
alternatively, you can use “wait” statements.
2) rely on the microphone to detect loudness,
then trigger stuff to happen due to the volume.
Also, is it like a pen sprite where there is no costumes, or do I make just a bar as a costume?Bar as a costume would make sense. In that case you don't want it to randomly glide around the screen.
You'll 'prolly want to set the X location in the beginning and not change that.
The Y coordinate will then move up and down as the loudness changes.
Here is the definitive audio visualizer. Any attempt to create a better one would prove futile.My microphone died, so your program doesn't do anything at the moment…
Other than the users with no mic, the main limiting factor with this route
is that Scratch doesn't detect differences in tones.
Most music visualizers show different bars for low or high notes.
You can't achieve this with the microphone method,
because it only scans for overall volume.
The timer trick I showed you can be broken down
into as many separate bars as you like.
It just takes time to do, but the results could be spot-on if you do it right.
I had it right and my Wanted To looked awesome,
but then I accidentally deleted the trimmed sound file or something like that,
so the data lists no longer line up.
I figured out another method, to save the band-pass files as unique .mp3's
then pipe each one through the loudness detector script.
so as to create each low-med-high beat-detect list.
That was gonna look awesome, and right on time, but then my mic died.
I don't know exactly where, I think it's a crack in the cord.
So yeah, I have another mic downstairs somewhere.
Maybe I can get that one going, to give you a better idea what it would look like.
As I say, the idea is there. I think the blue circle was low-tones,
the orange triangle was mid-tones, and the red star was high-tones.
Instead of dancing around the screen, you'd just put ‘em in one spot.
Then do whatever visual effect you want with ’em;
change size, move up-and-down, color-shift, what-have-you.
Last edited by Doyousketch2 (April 4, 2016 18:50:38)
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
There's essentially 2 ways to go about it.
1) preprogram your beats in, according to the timer.
alternatively, you can use “wait” statements.
2) rely on the microphone to detect loudness,
then trigger stuff to happen due to the volume.Also, is it like a pen sprite where there is no costumes, or do I make just a bar as a costume?Bar as a costume would make sense. In that case you don't want it to randomly glide around the screen.
You'll 'prolly want to set the X location in the beginning and not change that.
The Y coordinate will then move up and down as the loudness changes.Here is the definitive audio visualizer. Any attempt to create a better one would prove futile.My microphone died, so your program doesn't do anything at the moment…
Other than the users with no mic, the main limiting factor with this route
is that Scratch doesn't detect differences in tones.
Most music visualizers show different bars for low or high notes.
You can't achieve this with the microphone method,
because it only scans for overall volume.
The timer trick I showed you can be broken down
into as many separate bars as you like.
It just takes time to do, but the results could be spot-on if you do it right.
I had it right and my Wanted To looked awesome,
but then I accidentally deleted the trimmed sound file or something like that,
so the data lists no longer line up.
I figured out another method, to save the band-pass files as unique .mp3's
then pipe each one through the loudness detector script.
so as to create each low-med-high beat-detect list.
That was gonna look awesome, and right on time, but then my mic died.
I don't know exactly where, I think it's a crack in the cord.
So yeah, I have another mic downstairs somewhere.
Maybe I can get that one going, to give you a better idea what it would look like.
As I say, the idea is there. I think the blue circle was low-tones,
the orange triangle was mid-tones, and the red star was high-tones.
Instead of dancing around the screen, you'd just put ‘em in one spot.
Then do whatever visual effect you want with ’em;
change size, move up-and-down, color-shift, what-have-you.
Awesome!!! Thanks! My music projects will be published by approximately the 10th this month!
Have a good day, and remember; stay Flat-Out-Awesome!
-Flatoutj
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
There's essentially 2 ways to go about it.
1) preprogram your beats in, according to the timer.
alternatively, you can use “wait” statements.
2) rely on the microphone to detect loudness,
then trigger stuff to happen due to the volume.Also, is it like a pen sprite where there is no costumes, or do I make just a bar as a costume?Bar as a costume would make sense. In that case you don't want it to randomly glide around the screen.
You'll 'prolly want to set the X location in the beginning and not change that.
The Y coordinate will then move up and down as the loudness changes.Here is the definitive audio visualizer. Any attempt to create a better one would prove futile.My microphone died, so your program doesn't do anything at the moment…
Other than the users with no mic, the main limiting factor with this route
is that Scratch doesn't detect differences in tones.
Most music visualizers show different bars for low or high notes.
You can't achieve this with the microphone method,
because it only scans for overall volume.
The timer trick I showed you can be broken down
into as many separate bars as you like.
It just takes time to do, but the results could be spot-on if you do it right.
I had it right and my Wanted To looked awesome,
but then I accidentally deleted the trimmed sound file or something like that,
so the data lists no longer line up.
I figured out another method, to save the band-pass files as unique .mp3's
then pipe each one through the loudness detector script.
so as to create each low-med-high beat-detect list.
That was gonna look awesome, and right on time, but then my mic died.
I don't know exactly where, I think it's a crack in the cord.
So yeah, I have another mic downstairs somewhere.
Maybe I can get that one going, to give you a better idea what it would look like.
As I say, the idea is there. I think the blue circle was low-tones,
the orange triangle was mid-tones, and the red star was high-tones.
Instead of dancing around the screen, you'd just put ‘em in one spot.
Then do whatever visual effect you want with ’em;
change size, move up-and-down, color-shift, what-have-you.
Wait. Actually, one more question. Do I use a “Make clone of myself” script, or should I have a separate sprite for the other bass and cymbal etc. sprites?
- Doyousketch2
-
Scratcher
93 posts
I need help with making a music visualizer. Can someone help me with this?
Do I use a “Make clone of myself” script, or should I have a separate sprite for the other bass and cymbal etc. sprites?I'd use separate sprites.
It's often easier that way.
Plus you could use clones in each them for fade effects or whatever.
- Flatoutj
-
Scratcher
10 posts
I need help with making a music visualizer. Can someone help me with this?
Oh. Thanks! I will use it in the future!Do I use a “Make clone of myself” script, or should I have a separate sprite for the other bass and cymbal etc. sprites?I'd use separate sprites.
It's often easier that way.
Plus you could use clones in each them for fade effects or whatever.
- rmazuel
-
Scratcher
9 posts
I need help with making a music visualizer. Can someone help me with this?
I also need help with making a music visualiser… (I'm french, excuse my spelling mistakes) . I tried using the following code, but unfortunately, I have a midding block, and I don't even know if this is correct…
Can you help me?
set size to ((tempo) + (missing block)) %
Can you help me?
Last edited by rmazuel (March 24, 2018 00:29:11)
- DecryptedGod
-
Scratcher
17 posts
I need help with making a music visualizer. Can someone help me with this?
How do you make a music visualizer for music that's already made.
- Discussion Forums
- » Help with Scripts
-
» I need help with making a music visualizer. Can someone help me with this?