Qirky / FoxDot

Python driven environment for Live Coding
http://foxdot.org
Other
1.04k stars 135 forks source link

Sync to external MIDI #182

Open ajtribick opened 5 years ago

ajtribick commented 5 years ago

Is there a guide to setting up FoxDot+SuperCollider to synchronise with external MIDI? I see there is a sync_to_midi method on the Clock object but this ended up being unusable - I think it was missing some of the beats and ending up randomly slowing down by factors of 2 or so as a result.

Qirky commented 5 years ago

sync_to_midi is a non-reliable way of synchronising to an external midi clock device. There is some information available about synchronising with a midi device being triggered from FoxDot https://foxdot.org/documentation/setting-up-midi/

ajtribick commented 5 years ago

Thanks for that. I was trying to go the other way, i.e. use the external MIDI source to drive the FoxDot clock. What would be necessary for a more reliable sync than sync_to_midi?

Qirky commented 5 years ago

It isn't properly documented but in theory if you install the rtmidi library and the Python wrapper library then using Clock.sync_to_midi() will look for a midi-in device and clock/beat values then update the FoxDot clock.

I don't have a MIDI device to test this with and the FoxDot clock has undergone several changes since the sync_to_midi function/classes were written so I'm not sure it would work right now. I can have a look at updating it but it isn't a high priority at the moment.

If you don't mind keeping a constant bpm I would set both your MIDI device and FoxDot to the same tempo and then change the Clock.nudge value to adjust FoxDot's down beat to sync up with your device.

toboko commented 4 years ago

I read the Midi.py file and It's almost done like tempo but I personally think that main feature to implement is the sync between start and stop on external midi devices. It would be great if from my MIDI board I could start or stop in sync FoxDot + External Device. I've found that in Supercollider it's super easy to handle this events with (reference from MIDIIn.sysrt)

(
// init and connect your device
MIDIClient.init;
MIDIIn.connect(1, MIDIClient.sources[0]);
// call event 
MIDIIn.sysrt = {
   arg uid, index, data;
   if (index == 10) {
      "Start".postln;
   } { };
   if (index == 12) {
      "Stop".postln;
   }
})

I would like to improve your code but I need more references about FoxDot's flow

tuborgman commented 4 years ago

Hi there! Any news on handling MIDI sync to external MIDI or sync external MIDI gear to Foxdot ? That would be really uselful..

Qirky commented 4 years ago

Afraid not, I haven't been working on the project a whole lot to be honest, and I don't have any MIDI devices I could use to develop this feature

joesh1 commented 4 years ago

Same here Ryan.

I've tried sending the midiclock out, but it doesn't work - not unless I'm doing something wrong. FoxDot happily send notes to my external synth (a DS Rev2) which works fine, but there's not clock sync, so it just happily plays away at another tempo - other than the one FoxDot is playing/using.

Bubobubobubobubo commented 2 years ago

Bump for this issue. Has anyone been able to get MIDI sync or Link sync?

tkna91 commented 6 months ago

It appears that rtmidi cannot be expected to have synchronization capabilities, since the rtmidi page https://www.music.mcgill.ca/~gary/rtmidi/ states this.

RtMidi does not provide timing functionality (i.e., output messages are sent immediately).

However, I wish the receiver (e.g., REAPER or other DAW) could synchronize the tempo, not foxdot, to facilitate editing of MIDI and audio input to the DAW with foxdot. Is it not possible to do that as well?

tkna91 commented 6 months ago

FoxDot has its own sequencer without MIDI clocking, based on very fine sleep loops, so they are currently not possible? Perhaps SuperCollider is the synthesizer part, but not the sequencer part, and therefore MIDI to/from other DAWs, etc. is meaningless as far as MIDI clocking is concerned?

tkna91 commented 5 months ago

It seems to be possible, although some minor adjustments may be necessary.

Screencast with audio:

https://github.com/Qirky/FoxDot/assets/102382754/a3fcf378-0c5f-4f19-b40a-586503ddc856

Environment: