Skip to content

Instantly share code, notes, and snippets.

@manualbashing
Last active December 10, 2022 17:50
Show Gist options
  • Save manualbashing/f7b91ecb9ad2169edd7844d7c7f0c07c to your computer and use it in GitHub Desktop.
Save manualbashing/f7b91ecb9ad2169edd7844d7c7f0c07c to your computer and use it in GitHub Desktop.
Build a drum grid with emojis in #SonicPi

The other day I was going through one of MrBomb's awesome SonicPi tutorials, where he used a nifty trick with arrays to build a drum grid similar to this one: https://learningmusic.ableton.com/make-beats/make-beats.html

This already worked perfectly, but I thought it could be taken one step further by building the arrays from strings of emojis:

use_bpm 98

open_hat   = "⬜⬜❎⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜".split("")
closed_hat = "❎❎⬜⬜❎⬜❎⬜❎⬜❎⬜❎⬜❎⬜".split("")
clap       = "⬜⬜⬜⬜❎⬜⬜⬜⬜⬜⬜⬜❎⬜⬜⬜".split("")
kick       = "❎⬜⬜⬜⬜⬜⬜❎⬜⬜❎⬜⬜⬜⬜❎".split("")

marker = "❎"

live_loop :drum_machine do
  16.times do |i|
    sample :bd_haus if kick[i] == marker
    sample :sn_zome if clap[i] == marker
    sample :drum_cymbal_closed if closed_hat[i] == marker
    sample :drum_cymbal_pedal if open_hat[i] == marker
    sleep 0.25
  end
end
published: true
@nischalshrestha
Copy link

This is so clever!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment