overtone

plins 2019-11-16T00:25:47.001600Z

hello everyone, I'm trying to loop a simple beat sending 2 midi notes interchangeably, but the two notes are triggered at the function evaluation, not at the scheduled time

(def metro (metronome 150))

(defn player [beat]
  (at (metro beat) (m/midi-note midi-out (note :c2) 100 100 0))
  (at (metro (+ 0.50 beat)) (m/midi-note midi-out (note :g2) 100 100 0))
  (apply-by (metro (inc beat)) #'player (inc beat) []))

(player (metro))
am I missing something?

2019-11-16T18:49:20.004100Z

since I use overtone with my own clock bindings, I've kinda forgotten about at. But as far as I remember, it accepts a timestamp and will dereference to a scheduled concurrent event. The metronome is just a tool to dereference timestamps. So I'd compare the value of (now) and (metro 0) to see if they don't match up. And you're doing it right calling recursively with apply-by, which will trigger another round of player @plins

👍 1
plins 2019-11-18T14:22:52.005300Z

why do you use it with your own clock bindings? I'd like to sync it with external midi clocks in the future, would you say that this is achievable with the internal implementation of overtone of the metronome ?

2019-11-18T23:50:39.005500Z

Yes sure. At least syncing midi devices to the at-at clock should be easy. But the other way around, I assume you'd need to do some work yourself. I use my own clock for live-coding, based to Abelton Link. The clock is everything in live-coding, but the reason isn't that at-at clock is bad in any way, it's just that my main environment comes from csound and ableton link makes it easy to synchronize many different clients. I don't think the midi implementation in Overtone takes midi clocks into account, and actually the midi clock standard is very poor in most applications I know, since DAW's and music applications offer quite good clocks. Using OSC, the standard of SC would always be a better clock source, and there are many apps that can translate OSC into midi.

plins 2019-11-19T16:27:33.005700Z

thanks for the detailed response 🙂

2019-11-16T18:51:51.005100Z

So it could be that you just need to (+ (now) (metro 0.25)) or smt, if I remember correctly, the metronome also gives beats per second so it's easier to convert to absolute time value.