Showing posts with label Live Coding. Show all posts
Showing posts with label Live Coding. Show all posts

Sunday, 19 October 2025

🎶 From Code to Concert: Unlocking Your Inner Musician with Sonic Pi and Strudel

Standard

Ever imagined turning a few lines of code into a live electronic music performance?

Haa Haa! If not then do not worry!
Welcome to the world of Algorave, where programming meets rhythm. Two of the most exciting tools in this space, Sonic Pi and Strudel, make it possible for both beginners and professionals to write code that makes music.

Why Code Your Music?

Traditional music production often involves heavy digital audio workstations (DAWs), expensive plugins, and hours of trial and error. Code-based music creation changes that completely.

  • You focus on patterns and logic rather than audio engineering.
  • It’s lightweight and fast, without heavy software requirements.
  • Perfect for live coding performances, workshops, or simply exploring creativity.

Sonic Pi: A Friendly Entry to Live-Coded Music

Sonic Pi, created by Sam Aaron, is an open-source live-coding environment originally built for education. Its simplicity and flexibility have made it popular among educators, hobbyists, and live performers.

Key Features

  • Written in Ruby-like syntax that is easy to read and write.
  • Built-in synths, samples, and effects.
  • Live loop support for evolving patterns in real time.
  • Runs on Windows, macOS, Raspberry Pi, and Linux.
  • Free and open source.

Strengths

  • Beginner-friendly and approachable.
  • Great for classroom use and workshops.
  • Reliable for live performances with low latency.

Limitations

  • Less modular than some modern frameworks.
  • Limited support for advanced modular synthesis compared to professional DAWs.

Strudel: Next-Generation Pattern-Based Music Coding

Strudel is a modern, browser-based live-coding environment inspired by Tidal Cycles, a popular Haskell-based music-coding tool.

Key Features

  • Runs directly in your browser with no installation required.
  • Uses JavaScript-like syntax for defining rhythmic and melodic patterns.
  • Integrates with Web Audio and external synths or MIDI gear.
  • Ideal for quick jams, workshops, and web-based live performances.

Strengths

  • Lightweight and beginner-friendly.
  • Excellent for sharing code snippets online.
  • Strong pattern manipulation for rhythms and textures.

Limitations

  • Still maturing and less feature-rich than Sonic Pi for live performance.
  • Performance depends on browser and hardware.

Sonic Pi vs Strudel: Quick Snapshot

Aspect Sonic Pi Strudel
Platform Desktop app (Windows/macOS/Linux/RPi) Browser-based
Syntax Ruby-style JavaScript-style
Best For Education, workshops, live algorave Quick pattern-based jams
Learning Curve Beginner-friendly Easy if you know JavaScript
Strength Stability and built-in synth/effects Web-native and lightweight
Limitations Fewer pattern operators Limited pro-level audio control

Common Challenges to Overcome

While coding music is exciting and expressive, both tools share a few challenges:

  • Latency and performance issues on lower-end devices.
  • Adapting to pattern-based thinking instead of traditional notation.
  • Handling live performance mistakes, as one typo can break a loop.
  • Limited collaboration tools compared to DAWs.

Tips to Get Started

  1. Begin with Sonic Pi if you are new to live coding and follow its built-in tutorials.
  2. Try Strudel in your browser for quick pattern experiments.
  3. Focus on rhythm and repetition before working on complex sound design.
  4. Record your sessions and share them online; community feedback helps improve faster.
  5. Combine both tools: use Sonic Pi for synth sounds and Strudel for patterns, routing them via MIDI.

Playground Links (How to Run the Example Codes)

Sonic Pi

Sonic Pi is a desktop application, so there is no browser version.
Download and run locally: https://sonic-pi.net/
For quick demos without installing, you can watch live-coding sessions at https://in-thread.sonic-pi.net/.

Strudel

Strudel runs entirely in the browser, so you can start coding immediately.
Try it here: https://strudel.cc/play

Example Codes: Sonic Pi and Strudel Side by Side

1. Kick + Snare Basic Beat

Sonic Pi

live_loop :beat do
  sample :bd_haus
  sleep 0.5
  sample :sn_dolf
  sleep 0.5
end

Strudel

bd("x . x .").layer("snare", " . o . o ")

2. Hi-hat 16ths with Swing

Sonic Pi

use_bpm 120
live_loop :hats do
  8.times do |i|
    sleep (i.even? ? 0.22 : 0.28)
    sample :drum_cymbal_pedal, amp: 0.8
  end
end

Strudel

stack(
  s("hat*8").swing(1/8, 0.1)
)

3. Minor Pentatonic Bass

Sonic Pi

use_bpm 100
scale_notes = scale(:e2, :minor_pentatonic)
live_loop :bass do
  play scale_notes.choose, release: 0.25, cutoff: 80
  sleep 0.5
end

Strudel

n("<0 2 3 5 7>~").scale("e2 minorPentatonic").slow(2).s("sinebass")

4. Chords + Arpeggio

Sonic Pi

use_synth :prophet
ch = chord(:a3, :minor7)
live_loop :pad do
  play ch, sustain: 2, release: 2, amp: 0.6
  sleep 2
end

live_loop :arp do
  ch.each do |n|
    play n, release: 0.15
    sleep 0.125
  end
end

Strudel

stack(
  n("a3min7").s("pad").sustain(2),
  arp("up", n("a3min7")).s("pluck").fast(4)
)

5. Euclidean Rhythm (3 hits over 8)

Sonic Pi

live_loop :euclid do
  use_synth :fm
  tick
  play :e4, release: 0.1 if (spread 3, 8).look
  sleep 0.25
end

Strudel

euclid(3,8).s("beep").fast(4)