amiika / ziffers

Numbered musical notation for composing algorithmic and generative melodies
MIT License
81 stars 5 forks source link

Create ziffers "tape looper" #61

Closed amiika closed 1 year ago

amiika commented 2 years ago

Something like this but actually working:

def tape(name, ziffers, delete=false)
  z = zparse ziffers
  sample_path = "~/.sonic-pi/store/default/cached_samples/"+name+".wav"
  File.delete(sample_path) if File.exist?(sample_path) and delete
  buff = buffer(name,z.duration)
  with_fx :record, buffer: buff  do
    sample buff.path if !delete
    zplay z
  end
  sample_free sample_path
  load_sample sample_path
  live_loop :name do
    sample buff.path
    sleep sample_duration buff.path
  end
end

tape "beep", "q 2 3 5"