Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » I am trying to make a piano where it plays the note until you let go of the key
- Mandslo_bird
-
Scratcher
3 posts
I am trying to make a piano where it plays the note until you let go of the key
The “Music” code pack has “play note _ for _ beats” and there is nothing that allows it to play the note until I release the key I am pressing, I have tried many things and can not figure anything out.
The blocks in the “music” pack are very limited and I have no idea if it is even possible to play a note ONLY when the key is held down and ONLY while it is being held down.
The blocks in the “music” pack are very limited and I have no idea if it is even possible to play a note ONLY when the key is held down and ONLY while it is being held down.
Last edited by Mandslo_bird (Dec. 5, 2024 20:42:46)
- Mandslo_bird
-
Scratcher
3 posts
I am trying to make a piano where it plays the note until you let go of the key

Last edited by Mandslo_bird (Dec. 5, 2024 20:41:57)
- Paddle2See
-
Scratch Team
1000+ posts
I am trying to make a piano where it plays the note until you let go of the key
I think I was sort of able to get that to work by playing the note for a very long time - and then using the “Stop all Sounds” block triggered by the key being released. Of course - you can't use that technique for a polyphonic piano.
- Mandslo_bird
-
Scratcher
3 posts
I am trying to make a piano where it plays the note until you let go of the key
I think I was sort of able to get that to work by playing the note for a very long time - and then using the “Stop all Sounds” block triggered by the key being released. Of course - you can't use that technique for a polyphonic piano.Could you show an example? I am doing this for a school assignment and don't have as much experience with scratch as I would like lol
Last edited by Mandslo_bird (Dec. 6, 2024 03:42:59)
- BlazedYoutube
-
Scratcher
3 posts
I am trying to make a piano where it plays the note until you let go of the key
Simply add
stop all sounds
- nembence
-
Scratcher
500+ posts
I am trying to make a piano where it plays the note until you let go of the key
I think I was sort of able to get that to work by playing the note for a very long time - and then using the “Stop all Sounds” block triggered by the key being released. Of course - you can't use that technique for a polyphonic piano.This actually doesn't work:
when green flag clicked
set instrument to (\(20\) Synth Lead v) // Synth Lead doesn't fade so it's easy to hear when it stops playing
play note (60) for (2) beats
when green flag clicked
wait (0.2) seconds
stop all sounds // when this script stops the sound still continues
To be able to stop the sound make it using a sounds block:
when green flag clicked
set [pitch v] effect to ((10)*(-9)) // C(60) is 9 semitones lower than A(69)
play sound (A Piano v) until done // [start sound ()] block works, too
when green flag clicked
wait (0.2) seconds
stop all sounds
- Gladius247
-
Scratcher
100+ posts
I am trying to make a piano where it plays the note until you let go of the key
The “Music” code pack has “play note _ for _ beats” and there is nothing that allows it to play the note until I release the key I am pressing, I have tried many things and can not figure anything out.Maybe try
The blocks in the “music” pack are very limited and I have no idea if it is even possible to play a note ONLY when the key is held down and ONLY while it is being held down.
when green flag clicked?
forever
if <key [...] pressed?> then
repeat until <not <key [...] pressed?>>
play note (...) for (...) beats long
end
end
end
Or if you meant a sprite being clicked,
when this sprite clicked
repeat until <not <<mouse down?> and <touching [mouse pointer]>>
play note (...) for (...) beats long
end
- Discussion Forums
- » Help with Scripts
-
» I am trying to make a piano where it plays the note until you let go of the key




