General Purpose Drumkit

Hi eli,
that´s almost identical to my code and i kind of love that workflow with sonic pi its so intuitiv.
Oh except that i plan on using severel samples in one line of code like this

tick
samps = (ring 0,1,2,3).look
play "Path" samps 

the rest would be the same, either with if one_in / if spread / bools

Thanks. Are you sending the clock pulses from SPi or just midi notes?

I’ve always preferred to name my samples… making
any changes in the samples folder can change the order
of the samples… not reliable.

# Oh yeah.... baby!

use_bpm 60
set_volume! 5
use_random_seed 999

live_loop :bar do
  sleep 1
end

live_loop :drums do
  sync :bar
  if rand(1) < 0.5 then
    this_sample = [:loop_compus, :loop_tabla, :loop_safari].look
  else
    this_sample = [:loop_compus, :loop_tabla, :loop_safari].choose
  end
  
  start = [ 0.0 , 0.125 , 0.25 , 0.375 , 0.5 , 0.625 , 0.75 , 0.875 ].ring
  sample this_sample , beat_stretch: 4, start: start.look, rate: 0.5
  tick
end

# Eli...

Only midi notes, I have heard of the whole MIDI clock thing, but I believe the MIDI protocol hndles the clock on it’s own. So just send midi notes with the function called (wait for it) … midi. You can feed it notes like :C4 but in the standard MIDI drum arrangement you start at midi note 35 (or :B0).

And again, remember to send the data through channel 10. here’s how you do that:

with_midi_defaults port: "find your port name on sonic pi prefences, I/O", channel: 10 do
  live_loop :kick do
    midi 35
    sleep 1
  end
end

I found this useful table from Computer music resource dot com:

Key# Note Drum Sound Key# Note Drum Sound
35 B0 Acoustic Bass Drum 59 B2 Ride Cymbal 2
36 C1 Bass Drum 1 60 C3 Hi Bongo
37 C#1 Side Stick 61 C#3 Low Bongo
38 D1 Acoustic Snare 62 D3 Mute Hi Conga
39 Eb1 Hand Clap 63 Eb3 Open Hi Conga
40 E1 Electric Snare 64 E3 Low Conga
41 F1 Low Floor Tom 65 F3 High Timbale
42 F#1 Closed Hi Hat 66 F#3 Low Timbale
43 G1 High Floor Tom 67 G3 High Agogo
44 Ab1 Pedal Hi-Hat 68 Ab3 Low Agogo
45 A1 Low Tom 69 A3 Cabasa
46 Bb1 Open Hi-Hat 70 Bb3 Maracas
47 B1 Low-Mid Tom 71 B3 Short Whistle
48 C2 Hi Mid Tom 72 C4 Long Whistle
49 C#2 Crash Cymbal 1 73 C#4 Short Guiro
50 D2 High Tom 74 D4 Long Guiro
51 Eb2 Ride Cymbal 1 75 Eb4 Claves
52 E2 Chinese Cymbal 76 E4 Hi Wood Block
53 F2 Ride Bell 77 F4 Low Wood Block
54 F#2 Tambourine 78 F#4 Mute Cuica
55 G2 Splash Cymbal 79 G4 Open Cuica
56 Ab2 Cowbell 80 Ab4 Mute Triangle
57 A2 Crash Cymbal 2 81 A4 Open Triangle
58 Bb2 Vibraslap

One thing I tried out before I discovered my Roland JV 1010 also has drums and that you can try out if you don’t have hardware to get drum sounds you can just route your midi from sonic pi to your favorite music software (or digital audio workstation or DAW for short). I use ableton Live and I made a drum rack, that is essentially a sampler you can trigger with midi. I use LoopMIDI on windows to create a virtual MIDI connection between sonic pi and Live because windows lacks MIDI routing while macOS does have routing software and I believe Linux can use jack to accomplish this…but don’t quote me on that one xD

So yeah If you don’t have hardware you can just use a DAW to trigger samples from sonic pi. I prefer triggering samples from a DAW instead of triggering them right from sonic pi because I can apply fx and so some EQ on a GUI with a DAw, and i find it easier than in sonic pi.

2 Likes

Thank you so much for the detail! I may take the plunge with some hardware now.

I would recomed you also explore some software stuff alongside hardware because it can get expensive super quick. I recomed talking a look at pure data, it’s a visual programing environment for music and it can do synthesis. Meaning you can create your own synthesizers.

There is also Supercollider, sonic pi uses spuercollider already but you can use it to also create your own syths and add them directly to sonic pi. But pure date is way easier than SC You can sue all sorts of synthesis techniques to create your own drum samples and then use them in sonic pi.

You can get easy visual synths like Helm instead of creating your own and use sonic pi to trigger Helm to make all softs of sounds. Another cool software is VCV rack, it emulates real life hardware from modular synthesizers. I really dig how you can get away with making all your tracks completely with software, hardware is cool but it gets expensive.

1 Like

True. I got deeply into VCV Rack before Sonic Pi and currently I’m using them together for what will be a live act, but also now for recording. It’s a lovely marriage! I put a fair bit of effort working out how to use them together, which isn’t a given.

Musically I can do everything I want currently with these two (and a DAW for recording, mixing, mastering) - but just for emotional reasons I fancy incorporating some hardware - no logic to it :smiley: Something around not always using a computer, you know?

If Eurorack was a quarter of the price it is I might get into that but it’s way to expensve. I’m thinking a Korg Volca or Arturia Microfreak. The problem as I see it is how to use them in combo, which includes the sync question.

That said, thank you for the Pure Data tip - I’ll have a look at that.

PureData - yes looks fascinating and possibly a practical sound source. I got it running easily off SPi. Looks like a whole new learning curve. I’ll have to weigh up. I like the minimalist interface - one of the prices to pay with VCV Rack is that the (excellent) GUI does use a lot of resources. But on the other hand it’s the closest to having a real modular that us mortals will get.

Hmmm, either hours learning a new thing and it’s another thing-on-computer. Or spend some money, get a thing-not-on-computer and hours working out how to integrate it. For live work, twiddling some knobs is a nice thing.

I feel lucky to have these choices.

If u want to look into pure data i would suggest to use it with “Automatonism”, its basicly vcv rack in pure data, i am doing osc synthesis there, but how do i transmit pure data in real time to sonic pi?^^
i am just throwing in that question while i try to figure it out :stuck_out_tongue_winking_eye:

1 Like

Aaaagh another thing :scream: Seriously, though thanks for the tip!

Re routing sound around - I’m not putting anything back through SPi. I’m running SPi and Rack side-by-side (or PureData for that matter) and putting the output through WASAPI so it’s all mixed by that, using the Windows mixer. Alternatively, running on two separate computers and the two outputs into a traditional mixer.

Whatever setup, I’ll be aiming to use SPI as the ‘conductor’ because of it’s solid timing model.

that´s how it looks like, i use it only for simple synthesis,
i guess ill use the windows mixer then :smiley:

Thanks, I defo recognise modular there. Two sides to this - exploring the tech and making music. I have to be careful not to lose site of the music while diving into the tech.

Someone’s put up a PD Moog subharmonicon patch, which I couldn’t actually get to work right off but that’s a side issue. If I could run that on another RPi, triggered from SPi that sounds like a nice thing. I mean, the real thing is 800 quid or something.

Maybe if I put the RPi in a cardboard box, with the moog controls printed on…put it at the back of the stage with the right lighting, what do you think???

i know what u mean, i just tried to repeat what i did on this patch in vcv but couldnt get the same result with the same settings, i would suggest rebuild this patch i postet and see if u like it, it doesnt have to be much more complicated for some cool sounds

A PD patch? Where is it, did I miss it, I certainly would like to try it, than you

I just had a quick go on Rpi, installed no probs but it doesn’t see my midi keyboard. And I’m not sure how I’d get SPi to trigger it - there isn’t the loopMidi available on RPi, maybe there is something else. So more work needed

…whereas this w/e I ‘built’ a three-voice Rack synth in a few mins, each one on a different midi channel, all voices played from OSC commands from SPi loops. Very nice.

Implementing that idea in PD on a RPi would be great

i posted a photo of the patch :stuck_out_tongue_winking_eye: what u see is pure data but running with automanotism, its very easy to install and it transforms pd to a modular :stuck_out_tongue_winking_eye:

1 Like

Oh, you expect me to transcribe from your diagram ha ha :grinning_face_with_smiling_eyes: I can try! You’re just trying to lure me into learning PD I can see it. Must resist.

True that we have such a privilegie to choose between amazing software and hardware options. Is just that I get the impression that many people who want to get into more experimental electronic music think they have to go with hardware synths and get an eurorack but I can’t help but stress that some of the most experimental and groundbreaking music like Autechre’s is made with software and you don’t need to be left out if you don’t have the money. That’s what I love about sonic pi!

@alexesc I agree. And there’s lots of downside to hardware besides the cost - like it can break or get stolen, which is a real issue for gigging musicians. Always getting kit nicked. For a lot of people a computer is a sunk cost.

For me, since the virus I’m really missing the physicality of playing out. Well, not lugging a drum kit round but the playing. It was time not spent at the computer, which was a plus. I’m thinking a bit of kit might be good in that regard.

Bui the ‘not too much money on kit’ vibe is one of the reasons I’d like to use Raspberry Pi as much as possible rather than a high end PC. I’ve had a start look at PureData - my question is have you got that working from SPi?

And here’s my final word on the OP (until the next final word) incorporating all the goodness I’ve picked from here last few days.

It strikes a perfect balance between a drummer’s view of the world where you carefully place hits on beats, and the electronic world of random beats :stuck_out_tongue_winking_eye: ha ha ha. I’ve put in an XOR on each instrument and each beat using the lovely one_in() function. A value of 0 means it’s as written, unchanged (my world) - a large value gives bit of random - a low value gives chaos (your world) :smile:

#General purpose drum kit

use_bpm 120

live_loop :main do
  sleep 4
  cue :bar
end

live_loop :drumkit do
  sync :bar
  
  #Instrument Probs
  p1=[0,0,0,0,0,0] #Threshold for playing bar 0=always 6=never
  p2=[6,6,6,6,6,0] #Prob on each beat 0=no change, 1=lots, 100=little
  v =[5,4,3,3,1,5] #Volume
  a =0.5
  
  perc  = "x---------------"
  open  = "---------------x"
  hihat = "xxxxxxxxxxxxxxxx"
  pedal = "----x-----------"
  snare = "------------x---"
  kick  = "x---x---x---x-x-"
  
  inst = [kick, snare, pedal, hihat, open, perc]
  
  samp  = [:bd_fat,
           :sn_zome,
           :drum_cymbal_pedal,
           :drum_cymbal_soft,
           :drum_cymbal_open,
           :perc_bell]
  
  with_fx :reverb, mix: 0.2 do
    with_fx :echo, mix: 0.1 do
      i=0
      6.times do
        if dice(6)>p1[i] then
          in_thread do
            j=i
            16.times do
              sample samp[j], amp: a*v[j] if (inst[j][tick]=="x") ^ one_in(p2[j])
              sleep 0.25
            end
          end
        end
        i+=1
      end
    end #echo
  end #verb
end #drumkit
2 Likes

Here’s a demo track, all standard samples

5 Likes