Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Music Block Chords
- Akira_Roido
-
18 posts
Music Block Chords
I am currently making a collection of eight songs from various video-games and anime and a lot of the sheet music I am using for the transposition are for piano, and have a lot of chords. But when I try to do the chords, it failed. I tried making to different music scripts and having the chord block string rest until the chord it needed to come in at, but the problem with this is: if you get even the slightest bit of internet lag, the two music strings would fall out of sync with one another, what I mean is that the chords were no longer coming in when they needed to, even though I had all of the beats correct. Do you guys, gals, or non-binary pals (lololol) know how to make chords in scratch without this happening?
- MiniCoder11
-
100+ posts
Music Block Chords
One solution to your problem would be to sync all of your scripts with “wait until blocks”. Here is a example:
This is an example where each note waits for the beat to be increased to play. Any solution where you use variables to sync the notes should work fine.
when green flag clicked
forever
change [Beat v] by (1)
wait (tempo) secs
end
when green flag clicked
wait until <(Beat) = [1]>
play note (60) for (0.25) beats
wait until <(Beat) = [2]>
play note (60) for (0.25) beats
wait until <(Beat) = [3]>
play note (60) for (0.25) beats
wait until <(Beat) = [4]>
play note (60) for (0.25) beats
This is an example where each note waits for the beat to be increased to play. Any solution where you use variables to sync the notes should work fine.
Last edited by MiniCoder11 (June 21, 2019 04:07:23)
- Akira_Roido
-
18 posts
Music Block Chords
@MiniCoder11 When I do this, the Beat variable doesn't increase how you want it to. Instead of waiting for 1 beat of the tempo, it is waiting for the tempo EX: My tempo is currently 120, so it is waiting 120 seconds.
- GunChleoc
-
500+ posts
Music Block Chords
You'll need to wait for 1/tempo secs then.
For the second part, it might also be more robust to
in case that part of the script is experiencing lag. Try the solution above first though.
wait ((1) / (tempo)) secs
For the second part, it might also be more robust to
wait until <not <(Beat) < [1]>>
in case that part of the script is experiencing lag. Try the solution above first though.
- codeman1044
-
1000+ posts
Music Block Chords
I think you'll actually want to divide 60 by the tempo, not 1. You could add operators to change how many beats it waits. For instance, multiplying the result by 2 would wait 2 beats. You'll need to wait for 1/tempo secs then.wait ((1) / (tempo)) secs
wait (((60)/(tempo))*[number]) secsIf you wanted to make it easier, you could just use the rest block:
rest for () beatsOr if you really wanted to use wait blocks, you could make a custom block:
Rest for () beats::customHope this helps!
define Rest for (number) beats
wait (((60)/(tempo))*(number)) secs
- Rocket-Flier
-
100+ posts
Music Block Chords
I recommend using a broadcast loop like this:
when green flag clickedThis helps keep different parts of the song from drifting apart. Here is an example of how to use it:
set [measure v] to [0]
repeat (song length)
change [measure v] by (1)
broadcast (measure) and wait
end
when I receive [1 v]
play note (60 v) for (1) beats
play note (64 v) for (1) beats
play note (67 v) for (1) beats
when I receive [1 v]
play note (48 v) for (3) beats
when I receive [2 v]
play note (67 v) for (1) beats
play note (64 v) for (1) beats
play note (60 v) for (1) beats
when I receive [2 v]
play note (55 v) for (3) beats
when I receive [3 v]
play note (60 v) for (1) beats
when I receive [3 v]
play note (64 v) for (1) beats
when I receive [3 v]
play note (67 v) for (1) beats
- cs4287022
-
4 posts
Music Block Chords
define (1) (2) (3) (4) for (5) beats
set [1] to (1)
set [2] to (2)
set [3] to (3)
set [4] to (4)
set [5] to (5)
broadcast [1]
broadcast [2]
broadcast [3]
broadcast [4]
when I receive [1]
play note ((1)) for ((5)) beats
Last edited by cs4287022 (Feb. 4, 2021 18:18:41)
- Discussion Forums
- » Help with Scripts
-
» Music Block Chords