Jumping off point: Resynthesis by Max Cooper

Jumping off point: Resynthesis by Max Cooper

# 230602 2030 Sonic Pi cover of Resynthesis by Max Cooper
# Saved 230602 2030
# Created by linktr.ee/relaxnow

# Original: "Max Cooper - Resynthesis (official video by Kevin McGloughlin)"
#  https://youtu.be/Kpm1l0HfkV0
#  Amazing visuals from https://www.kevinmcgloughlin.com/world-passing-by

# Found notes and rythme here:
#  How to make the keys for the Max Cooper 'Resynthesis'
#  youtube.com/watch?v=QZQK7JYCy5w


set_volume! 2

with_fx :reverb, room: 0.7 do
  
  
  
  live_loop :a1 do
    tick
    
    
    / rythme /
    p = bools(1,1,0,0, 1,0,1,1, 1,1,0,1, 0,1,1,0,
              1,0,0,1, 0,0,1,0, 0,1,0,1, 0,1,1,0)
    
    
    / chords progression /
    n1 = [:gs2,:c3, :ds3,:fs4]
    n2 = [:gs2,:b2, :e3, :gs3, :b3,:fs4, :fs5]
    n3 = [:gs2,:cs3, :fs3,:gs4]
    n4 = [:e2,:as3, :b3,:fs4]
    l = 64
    n = knit(n1,l, n2,l, n3,l, n4,l).look
    #n = n4
    
    
    / synth /
    use_synth :saw                                #  (Full sound) :saw :dsaw :dtri :square   (thin sound) :blade
    c = line(60,100,steps: 32).mirror.look        # Synth cutoff
    amp = line(-0.5,0.5,steps: 32).mirror.look    # volume LFO on amp synth top chords
    
    
    / change synth "release" time here for tension effect /
    release = 1 #1 original
    # release = knit(1,64, 2,16,3,16).look
    #    release = 3
    case release
    when 1 # long and smooth (original)
      use_synth_defaults cutoff: c, release: [0.16,0.25].choose
    when 2 # sometimes short
      use_synth_defaults cutoff: c, release: [0.16,0.25].choose-[0,0.05,0.1].choose
    when 3 # very  short for tension
      use_synth_defaults cutoff: c, release: [0.16,0.25].choose-[0.09,0.11].choose
    end
    
    
    
    / change "synthVoices" here to explorer different synths /
    synthVoices = knit(5,64, 3,64, 2,64, 6,64, 7,64).look
    #synthVoices = 2 #2 #6arp 7arp
    
    case synthVoices
    when 0
      # No synth chords playing (only bass + drums)
    when 1 # "Single" chords
      use_synth :saw
      play n, amp: 1+amp, pan: rdist(0.25) if p.look
    when 2 # "Double up" on chords
      use_synth :saw
      play n, amp: 1+amp, pan: rdist(0.25) if p.look
      play n, amp: 1+amp, pitch: 12, pan: rdist(0.75) if p.look # extra copy to fill out chords sound
    when 3
      use_synth :dsaw
      play n, amp: 1+amp, pan: rdist(0.25) if p.look
      play n, amp: 1+amp, pitch: 12, pan: rdist(0.75) if p.look
    when 4
      use_synth :dtri
      play n, amp: 1+amp, pan: rdist(0.25) if p.look
      play n, amp: 1+amp, pitch: 12, pan: rdist(0.75) if p.look
    when 5
      use_synth :saw
      play n, amp: 1+amp, pan: rdist(0.25) if p.look
      use_synth :square
      play n, amp: 1+amp, pitch: 12, pan: rdist(0.75) if p.look
      
      # + ARP
    when 6
      #when 1 # "Single" chords
      use_synth :saw
      play n.pick(3), amp: 1+amp, pan: rdist(0.25) if p.look
      
    when 7 # +arp NICE
      #    when 2 # "Double up" on chords + arp with PICK(3)
      use_synth :saw
      play n.pick(3), amp: 1+amp, pan: rdist(0.25) if p.look
      use_synth :square
      play n.look, amp: 0.7+amp, pitch: 12, pan: rdist(0.75) if p.look
      
    end
    
    
    
    / bass /
    bass = n.take(1).look-12 #if spread(1,32).look
    #puts note_info(bass) if spread(1,32).look # Which bassnote are playing?
    play bass, amp: 1.25 if p.look
    
    
    
    / drums /
    d = 64*2
    drums = knit(0,d,1,d/2,2,d/4,3,d,4,d*2).look
    #drums = 1
    #drums = 0
    case drums
    when 0
    when 1
      sample :bd_haus, cutoff: 70, amp: 1.5 if bools(1,0,0,0).look
      sample :bd_haus, cutoff: 80, amp: 1.75 if (bools(0,0,0,0)*15+bools(0,0,1,0)).look and one_in(2)
    when 2
      sample :glitch_perc3, beat_stretch: [0.25,0.5, 1,2,4].choose, rate: [2,4].choose, slice: rrand_i(1,10), amp: 2, pan: rdist(0.5) if bools(1).look and one_in(2)
    when 3
      sample :bd_haus, cutoff: 70, amp: 1.5 if bools(1,0,0,0).look
      sample :bd_haus, cutoff: 80, amp: 1.75 if (bools(0,0,0,0)*15+bools(0,0,1,0)).look and one_in(2)
      sample :glitch_perc3, beat_stretch: [0.25,0.5, 1,2,4].choose, rate: [2,4].choose, slice: rrand_i(1,10), amp: 2, pan: rdist(0.5) if bools(1).look and one_in(2)
    when 4
      sample :bd_haus, cutoff: 70, amp: 1.5 if bools(1,0,0,0).look
      sample :bd_haus, cutoff: 80, amp: 1.75 if (bools(0,0,0,0)*15+bools(0,0,1,0)).look and one_in(2)
      sample :glitch_perc3, beat_stretch: [0.25,0.5, 1,2,4].choose, rate: [2,4].choose, slice: rrand_i(1,10), amp: 2, pan: rdist(0.5) if bools(1).look and one_in(2)
      sample :sn_generic, slice: 1, rate: 3, amp: 1.5, pan: rdist(0.75)  if bools(0,0,0,0, 1,0,0,0, 0,0,0,0, 0,0,0,0,).look #and one_in(2)
      sample :sn_generic, rate: [1,1.2,1.5].choose, finish: [0.15,0.25].choose, amp: 1.5, pan: rdist(0.75)  if bools(0,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,0,0,).look
    end
    
    
    sleep 0.125
    
  end
end

5 Likes

This is amazing work! Thanks so much for sharing!

1 Like

Hello @Relaxnow

This is really good work but it doesnt work on my computer. Im always encountering with this error on my console log:

Timing error: can't keep up...
Timing warning: running slightly behind...
!! Out of time, skipping: synth :saw, etc.

Is it about my CPU power or do I skip something when I run this code?

Guess you could try to add

use_debug false

in front of the code so Sonic pi dont log so much during running.

ā€œEnable or disable messages created on synth triggers. If this is set to false, the synths will be silent until debug is turned back on. Silencing debug messages can reduce output noise and also increase performance on slower platforms. See with_debug for setting the debug value only for a specific do/end block.ā€

Else perhaps turn off reverb.

Iā€™m using a big gamer computer.

Thank you very much for your answer, I tried to add use_debug false but it doesnt work for me. So I changed sleep time to 0.25 and it worked, just like slow version :smiley:

I have gaming laptop but I think cpu power isnt enough for this kind of code and sometimes it is really annoying that I am seeing some code here but I cant run it :sweat_smile:

1 Like

THIS is soooooo :cool: :star::star::star::star::star:

Thanks for sharing! Grrrrrrrr8 workšŸ¤˜šŸ»

:question:Can this be ran by anyone on windows?!

I also have to drop the bpm, even without the reverb fx, even though my rudimentary tick test show SP can tick pretty quick!

If yes, do you need anything in particular, like

  • usb audio device
  • any required config like ASIO/JACK?

Am wondering what about stuff like thresholds and limitations, and causes, and benchmarking, if SP_linux (or mac or rasp) is better, or if itā€™s more CPU thatā€™s needed (although Iā€™ve read reports from other windows users with similar timing issues, with ample resources

I want this! && More like this!

:bulb: test on other machines, other OS, and with other audio card.

Hi @samaaron, I guess this works on your old rasppi?
I wondered if itā€™s worth trying to spin up an XP machine, or if SPā€™s wonā€™t run on XP, or no reason why it should perform any better on that beloved relic.

Also wondered if we can get performance + benchmarking stats in debug mode, or if any recommendedations on test_scripts to try - I just use a crude loop with lots of ticks, incrementing bpm to see how long before inevitable timing errors ensue, to try and establish if changing stuff like block_size and sample_rate in audio_settings made a diff, like the proverbial optometrist.

Part of me assumes SP can and does run like a dream even on windows, as thatā€™s likely to be the most common OS in academia, or am I wrong there too?!

:metal:t2:

Iā€™ve finally got this to work, even with the fx, with sched_ahead_time 8ā€¦
Iā€™m not sure exactly how long the loop should run before the most challenging bits kick in (faster rates etc).

Iā€™ve been looking at sc and cpu stuff, and in gaming land I found lots of interesting stuff.

With instructions for process lasso I tried the script without fx and with increasing bpm, after elevating process priority (scsynth ruby sonicpi). I was going to try the cpu affinity bit, but first tested disabling hyperthreading on those. After success I eventually tried with reverb and with 60bpm, and it worked. With lower sched_ahead like 4 I did get timing errors reported.

Now that thread mentions to processes in process lasso need re-configuring each time, and Iā€™ve got this edge case bug that causes sc to stop making sounds after I stop in sp, so I restart a lot.

I retried and again saw no issues, so Iā€™m retesting now to see if the issue is msedge (or anything else process lasso reports as consuming lots of system resources).

image

Even though Iā€™d closed edge I still had processes in memory, but once removed sonicpi ran this ā€œokā€ (no timing errors reported in sp)

One (other!) thing thatā€™s not clear is whether setting disable hyperthreading on sp and sc (and maybe ruby) persisted, or even had any effectā€¦

but if nothing else running process lasso may help identify anything that may affect system responsiveness.