ctford/leipzig

[question] syncing leipzig compositions with quil visuals

Opened this issue · 4 comments

hello,
I have been making some music with leipzig and I'm loving the library, but I would like to sync some live visuals to my music with quil. Is there a way to do this with leipzig?

This is a very good question. Right now, there is no good answer, because to actually synchronise means that your visuals would have to know what note is currently playing, and that's hidden away inside of play.

You could certainly synchronise a live-loop with visuals by doing (def melody ...) and (jam (var melody)) and watch melody in your Quil loop, but that would only give you the notes as one big data structure and not the current playing time.

The proposal in #14 could help with this. At the very least, you could clone play in your codebase after @pjagielski's suggestion.

You could also stash the note somewhere when your implementation of play-note is called. That is a bit annoying in that you have to do it once for each part, but it also makes it easier to do something different for each part.

Also, you could send an osc message calling at-at inside a play-note method for example I have something like this.

(ns my-space.core
    (:require
     [leipzig.live :as live]
     [leipzig.melody :refer :all]
     [overtone.live :as overtone]
     [overtone.osc :as osc]
     [overtone.at-at :as at-at]))

(def osc-client (osc/osc-client "localhost" 57120))

(defn send-note [note]
  (osc/osc-send-msg osc-client {:path "/note" :type-tag "i" :args [note]}))

(defmethod live/play-note :some-part [{pitch :pitch duration :duration instrument :instrument}] 
     (at-at/at 0 #(send-note pitch) my-pool))

In this way you can connect through osc internally and trigger events avoiding the "FAILURE IN SERVER: /path Command not found" error.

It's a suspicious hack, I know, but it's seems to work well!