Sonic Pi OSC to Improviz visuals


# 200802 1758 Sonic Pi OSC to Improviz

use_osc "localhost", 5510  # Setup OSC to Improviz port


use_bpm 70

live_loop :time, delay: 0.01 do
  sleep 1
end


with_fx :reverb, room: 0.8 do
  with_fx  :distortion, mix: 0.8 do
    
    
    live_loop :cowbell do
      sample :drum_cowbell, amp: 0.5, rate: knit(1,6, 0.5, 1).tick(:cb)
      osc "/vars/cb", rrand(1,8)  # OSC to Improviz in variable cb
      
      sleep 3
      osc "/vars/cb", 0  # OSC to Improviz in variable cb to turn off value
    end
    
    live_loop :kick do
      # stop
      osc "/vars/kick", 0 # OSC to Improviz in variable kick to turn off value
      
      sample :drum_heavy_kick, amp: 2
      sleep 1.25
      osc "/vars/kick", rrand(1,8)  # OSC to Improviz in variable kick 
    end
    
    live_loop :saf1 do
      #stop
      sample :elec_pop, slice: rrand(2,4), rate: rrand(1,2), pan: rrand(-1,1)
      sleep 0.25
    end
    
    live_loop :saf2 do
      # stop
      sample :loop_3d_printer, slice: 10, start: rrand(0.1,0.9), rate: 8, amp: 2, pan: rrand(1,-1)
      sleep 0.25
    end
    
    
    live_loop :sy do
      use_synth :growl
      play :c2
      osc "/vars/sy", 1
      sleep 4
      osc "/vars/sy", 0
      sleep 1
    end
    
    
  end  # end distortion
  
  
  live_loop :sawstrings do
    #    stop
    use_synth :saw
    sleep 5
    play [:c4, :ds5, :c6], attack: 5, amp: 1, cutoff: 90, pitch: -12
    sleep 5
    play [:c4, :ds5, :g5], attack: 5, amp: 1, cutoff: 90, pitch: -12
    sleep 5
    play [:a4, :c5, :f5], attack: 5, amp: 1, cutoff: 90, pitch: -12
    sleep 5
    play [:g4, :bb4, :d5], attack: 5, amp: 1, cutoff: 90, pitch: -12
    sleep 5
  end
  
end # end reverb



2 Likes

Your video is cool! I just downloaded Improviz and started it. It works correctly when I type Improviz commands in http://localhost:3000/editor, but I don’t get any visuals when I run your program. Any idea why? Thanks!

Thanks.

Here are the code that I used in Improviz, which you can copy to the editor, which use OSC from Sonic Pi when you run the Sonic Pi code above in Sonic Pi.

Let me know if it works :slight_smile:

β€œ#” uncomment in Atom
β€œ//” uncomment in editor

paintOver()
# https://improviz.rumblesan.com/language.html

#motionBlur()
t = time/5
scale(4) # 1 2 4
#220802 1701 ver1.pz

background(0)

r = ext(:cb, 4)
kick = ext(:kick, 4)
sy = ext(:sy, 0)
if (sy%2)
  sphere(0.001)
  noFill()
  rotate(t)
  strokeSize(0.01)
  #stroke(255) # 0 # 255
  sphere(10)
else
  fill(0)
  cube(20)

rotate(0,0,t)
#rotate(t)
strokeSize(2)
#loop 4 times
  move(r)
  #texture(:algorave)
#  rectangle(0.7,0.1,0.1)
#cube(4)
fill(255,0,0) # red
rectangle(0.05,r,0.01)
#color(1,0,0)
fill(0,0,255) # blue

triangle(0.1,kick,0.1)

stroke(255) # white
strokeSize(0.25)
rotate(t)
noFill()
rectangle(kick)

Where to get help: The Discord channel for Improviz

My exploration of Improviz before I started learning Sonic Pi.

tinyurl.com/learningImproviz (964 pages)
(Take some time to load but lots of nice code with images examples to learn from)

! MG learning Improviz 2 - Google Docs (50 pages)

That worked great! Thank you!

1 Like