Sound is one of the ten categories of Scratch blocks. They are color-coded pink and are used to control sound (and formerly MIDI) functions.
There are currently 9 Sound blocks: 8 Stack blocks and 1 Reporter block.
Music Extension
- Main article: Music Extension
Instrument blocks (such as drum, note, rest, and tempo) were originally Sound Blocks in older versions of Scratch, but in Scratch 3.0, they were put under the Music Extension instead. This decision was made in order to prevent confusing New Scratchers.[1]
Blocks
| Click on a block to learn more about it. |
Scratch 3.0 has the following 8 Sound Stack blocks:
play sound ( v) until donestart sound ( v)stop all soundschange [ v] effect by ()::soundset [ v] effect to ()::soundclear sound effectschange volume by ()set volume to ()%
Scratch 3.0 has the following Sound Reporter block:
Uses for Sounds
Sounds are used for many things, and many different types are used. Sounds effects may be used in games, and music can be used in the background or as part of an intro or outro.
Scratch 2.0 Sounds
| This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective. |
Scratch 2.0 MIDI instruments had a fairly low sound quality because of Flash's small sound library, so the Scratch Team put their own sounds into the blocks instead. This remained in place in Scratch 3.0, due to it being developed in HTML5.
Because of this, the following two blocks were replaced in Scratch 2.0 with updated versions of the block:
Quirks
Sound blocks can have some unexpected side-effects when run. Any blocks that update volume or sound effects will cause that stack of blocks to wait one frame[2][3]. This can be demonstrated with the following script:
when green flag clicked forever turn cw [15] degrees set volume to [100]% set volume to [100]% set volume to [100]% set volume to [100]% set volume to [100]% set volume to [100]% end
Running this script will have a sprite constantly turn 15 degrees in a choppy motion. Removing the volume blocks smooths it out.
Additionally, a bug exists where any blocks that are marked as "run without screen refresh" will stop being run without screen refresh once they execute a volume block or sound effect block[4].
References
- ↑ https://github.com/LLK/scratch-vm/pull/769
- ↑ // Yield until the next tick https://github.com/scratchfoundation/scratch-editor/blob/8c54f603b327813c0578b01dc5f4979abf84abf5/packages/scratch-vm/src/blocks/scratch3_sound.js#L284
- ↑ // Yield until the next tick https://github.com/scratchfoundation/scratch-editor/blob/8c54f603b327813c0578b01dc5f4979abf84abf5/packages/scratch-vm/src/blocks/scratch3_sound.js#L331
- ↑ https://scratch.mit.edu/projects/1309152698/