1) Press the Play button to start. 2) Control the tempo with the slider. 3) Press the buttons to activate and de-active which sounds are played.
Reflection I decided to build a drum machine. I built one in Scratch many years ago, but there was some issues with the timing of sample playback. So I decided to use today's topic as a reason to rebuild it from scratch. While the tempo is still a little janky, it's a major improvement over the original. I'm also hopeful this will run better in Scratch 3, as my experience with it indicates that it is far more strongly timed than Scratch 2. To make this project work, I make extensive use of variables and cloning. If I were to spend more time on this, I would use samples from a real Roland-808. The presentation could be improved on. I could also organize this better by placing duplicated code into custom blocks. Update: Refactored the code which increases the performance of the drum machine. Instead of having 5 step button sprites for each row, only 1 step button is used to spawn all 80. Originally, each of the 80 step buttons we're responsible for responding to triggers. Hence, 80 if blocks were being run per trigger. Now the trigger logic has been moved into a single sprite, so now only 5 triggers / conditional blocks are used. The result is a more strongly-timed drum machine. That is, it's less janky. Update 2: Found a way to improve timing. Inside the clock sprite I created the "update step" block and enable "Run without screen refresh". Then I moved over the code from the "When I receive trigger".