Sonic Pi

can you create sonic pi code for interstellar planetary music

Absolutely, David! Here’s a Sonic Pi composition that evokes the feeling of drifting through distant planetary systems—layered textures, shimmering tones, and pulsar-like rhythms:

use_bpm 40  # Slow tempo to match the vastness of space
use_synth_defaults release: 2, amp: 0.8

# Ambient star field shimmer
live_loop :starfield do
  use_synth :hollow
  play choose([:C5, :E5, :G5, :B5, :D6]), pan: rrand(-1, 1), attack: 0.5, release: 3
  sleep rrand(0.5, 1.5)
end

# Pulsar rhythm echoing planetary rotation
live_loop :planetary_pulse do
  use_synth :prophet
  with_fx :echo, phase: 0.25, mix: 0.4 do
    play choose([:C2, :E2, :G2]), release: 0.8
  end
  sleep 2
end

# Harmonic waves for atmosphere sweep
live_loop :atmospheric_sweep do
  with_fx :slicer, phase: 0.25, mix: 0.3 do
    use_synth :dark_ambience
    play choose(scale(:c3, :minor, num_octaves: 2)), release: 4
  end
  sleep 4
end

# Celestial chimes
live_loop :comet_chimes, delay: 8 do
  use_synth :pretty_bell
  play choose([:C6, :G6, :B6]), pan: rrand(-1, 1), attack: 0.2, release: 2
  sleep 6
end

# Bass gravity pull
live_loop :graviton_bass, delay: 4 do
  use_synth :fm
  play choose([:C1, :A1, :G1]), divisor: 2, depth: 3, release: 1
  sleep 4
end

This creates an evolving, otherworldly soundscape—perfect for a classroom audio experience or a planetary visualisation. Would you like me to customize this for specific planets, themes (e.g., lunar tides or Martian winds), or make it interactive with live coding prompts? 🌌🔭🎶

can you extend the code to illustrate drifting through distant planetary systems, followed by shooting through a Black Hole and exiting into a distant planetary system

Oh yes, let’s give this soundscape some cosmic drama! 🌠 This version expands the journey: you’ll start by drifting past shimmering planetary systems, get pulled into a Black Hole (with sonic turbulence and time dilation), and then emerge into a strange new realm with its own celestial tones.

Here’s your extended Sonic Pi composition:

use_bpm 40
use_synth_defaults release: 2, amp: 0.8

# Section 1: Drifting through planetary systems
live_loop :starfield do
  use_synth :hollow
  play choose([:C5, :E5, :G5, :B5, :D6]), pan: rrand(-1, 1), attack: 0.5, release: 3
  sleep rrand(0.5, 1.5)
end

live_loop :planetary_pulse do
  use_synth :prophet
  with_fx :echo, phase: 0.25, mix: 0.4 do
    play choose([:C2, :E2, :G2]), release: 0.8
  end
  sleep 2
end

# Section 2: Entering the Black Hole
live_loop :blackhole_entrance, delay: 32 do
  with_fx :reverb, room: 1 do
    use_synth :dark_ambience
    6.times do
      play rrand_i(40, 50), release: 0.2, pan: rrand(-1, 1), amp: 0.6
      sleep rrand(0.1, 0.4)
    end
  end
end

live_loop :event_horizon, delay: 36 do
  with_fx :flanger, depth: 3, phase: 0.25 do
    sample :ambi_haunted_hum, rate: -1
  end
  sleep 8
end

# Section 3: Time distortion and acceleration
live_loop :spacetime_turbulence, delay: 40 do
  with_fx :bitcrusher, bits: 4 do
    sample :elec_fuzz_tom, rate: 0.5
  end
  sleep 0.5
end

# Section 4: Exit into new planetary system
live_loop :new_system_chimes, delay: 48 do
  use_synth :pretty_bell
  with_fx :echo, phase: 0.25, mix: 0.4 do
    play choose(scale(:eb5, :lydian)), release: 2, pan: rrand(-1, 1)
  end
  sleep rrand(1.5, 2.5)
end

live_loop :new_atmosphere_sweep, delay: 52 do
  use_synth :blade
  with_fx :gverb, room: 50, release: 6 do
    play choose(scale(:eb3, :lydian, num_octaves: 2)), release: 5
  end
  sleep 3
end

This is a full interstellar adventure in code, ready to be performed live or adapted for your modular learning kits. Would you like me to help build a parallel visual narrative or child-friendly audio story to match the journey—from planetary drift to cosmic rebirth? 🚀🌀✨