Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Play music note during pressing time of a button
- Drawixe
-
14 posts
Play music note during pressing time of a button
Hello,
I would like to make a musical project, and I would like to make a sort of piano.
But by pressing a button I only can play note during a fixed number of beat and I would like the project plays the note during the pressing time of the button and WHILE I'm pressing the button (not after).
If you've a solution
I would like to make a musical project, and I would like to make a sort of piano.
But by pressing a button I only can play note during a fixed number of beat and I would like the project plays the note during the pressing time of the button and WHILE I'm pressing the button (not after).
If you've a solution
- gdpr533f604550b2f20900645890
-
1000+ posts
Play music note during pressing time of a button
I think there may be a pause between each note, though.
Last edited by gdpr533f604550b2f20900645890 (July 18, 2014 21:30:49)
- MoreGamesNow
-
100+ posts
Play music note during pressing time of a button
For instruments that fade fairly rapidly (e.g. a piano; instrument #1 in Scratch), this should work. I'm not sure there is a nice way to do it with instruments that offer more sustained sounds. The major drawback of this solution is that it requires 1 sprite for every note:
- gdpr533f604550b2f20900645890
-
1000+ posts
Play music note during pressing time of a button
But then, the note will only play for two beats. The note needs to play while the key is pressed. This is better: For instruments that fade fairly rapidly (e.g. a piano; instrument #1 in Scratch), this should work. I'm not sure there is a nice way to do it with instruments that offer more sustained sounds. The major drawback of this solution is that it requires 1 sprite for every note:
Last edited by gdpr533f604550b2f20900645890 (July 19, 2014 08:37:12)
- MoreGamesNow
-
100+ posts
Play music note during pressing time of a button
But then, the note will only play for two beats. The note needs to play while the key is pressed. This is better:
Your concern is certainly valid, I just don't think playing the same not over and over again is a good solution. Since on a real piano notes fade fairly quickly and don't sustain forever while you hold them, I preferred my solution.
Last edited by MoreGamesNow (July 21, 2014 04:58:23)
- Drawixe
-
14 posts
Play music note during pressing time of a button
There is two problem with your both solution:
First, in your answer MoreGamesNow, when I stop pressing “b” key, the note does'nt stop in despit of the volume being 0. So note is playing 2 beats everytime I press and no matter how long I press.
Secondly, in your answer Chibi-Matoran, the note only repeat itself, a real piano doesn't do this, I want (like MoreGamesNow says) the note fades.
But I'll use your both answer for another project.
If you find any other solution ?
First, in your answer MoreGamesNow, when I stop pressing “b” key, the note does'nt stop in despit of the volume being 0. So note is playing 2 beats everytime I press and no matter how long I press.
Secondly, in your answer Chibi-Matoran, the note only repeat itself, a real piano doesn't do this, I want (like MoreGamesNow says) the note fades.
But I'll use your both answer for another project.
If you find any other solution ?
- Drawixe
-
14 posts
Play music note during pressing time of a button
Ok your solution is valid on web version of Scratch MoreGamesNow but not on 1.4 version.
I need to work offline, I'll use this project on an event so no internet connection. Is there a solution to download the web version of scratch ?
I need to work offline, I'll use this project on an event so no internet connection. Is there a solution to download the web version of scratch ?
Last edited by Drawixe (July 22, 2014 12:18:04)
- Drawixe
-
14 posts
Play music note during pressing time of a button
Doesn't work well on Ubuntu, because of Adobe Air.
Adobe Air (even in old version) doesn't work well on Ubuntu 12.04
Adobe Air (even in old version) doesn't work well on Ubuntu 12.04
Last edited by Drawixe (July 22, 2014 12:17:34)
- MoreGamesNow
-
100+ posts
Play music note during pressing time of a button
Okay, so the problem with Scratch 1.4 is that the volume of instruments does not update for sounds already-being-played. However, it does work for recorded sounds, so one could use a script like
The problem being that you have to import an audio file for every note
The problem being that you have to import an audio file for every note

- Drawixe
-
14 posts
Play music note during pressing time of a button
Yes, and for every instrument ^^'
So I've installed windows on an old computer and installed Scratch V2.
Thanks to you
So I've installed windows on an old computer and installed Scratch V2.
Thanks to you
- scratchingboy18
-
1 post
Play music note during pressing time of a button
What I did was go into the scratch library and insert the piano notes, then I made the code above and it fixed the problem……


Last edited by scratchingboy18 (Nov. 14, 2017 23:00:51)
- TTChaos
-
47 posts
Play music note during pressing time of a button
I think there may be a pause between each note, though.
Fixed formatting
What I did was go to the scratch library and insert the piano notes, then I made the code above and it fixed the problem……
Thanks scratchingboy18, I appreciate the help, but then you would have to upload each sound into each note.
Your welcome, though I was Yes, and for every instrument ^^'too late
So I've installed windows on an old computer and installed Scratch V2.
Thanks to you
- RainbowJacket1234
-
7 posts
Play music note during pressing time of a button
i know how to ask a question
- ayyyyes10135
-
100+ posts
Play music note during pressing time of a button
i know how to ask a question
Dont blockspam and necropost
- ThunderingLions
-
13 posts
Play music note during pressing time of a button
You probably have to do something like this!
My browser / operating system: ChromeOS 14541.0.0, Chrome 118.0.0.0, No Flash version detected
My browser / operating system: ChromeOS 14541.0.0, Chrome 118.0.0.0, No Flash version detected
Last edited by ThunderingLions (Dec. 12, 2023 18:47:32)
- ThunderingLions
-
13 posts
Play music note during pressing time of a button
ThunderingLions wrote:
Thank you very much!
I'm glad you're thanking me!
Last edited by ThunderingLions (Dec. 12, 2023 18:51:58)
- Discussion Forums
- » Help with Scripts
-
» Play music note during pressing time of a button