[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] [approve?] send MIDI clock messages in MIDIOut + sendmidi() cleanup
Tim K and I have added MIDI clock send support to MIDIOut, this required
cleaning things up to accomodate non-channel messages. See patch below. I'll
commit if a couple of days if there's no objections.
We considered modifying _SendMIDIOut to only take a full status byte (no hi
and lo) and do all the masking in lang, but it was a bigger change, and
would have broken any lang code that called send() directly, and would have
required changing the semantics of write() to make it clean (ie potentially
having writeChannelMessage() and writeSystemMessage()).
Best wishes
Ross.
MIDIOut.sc:
- changed name of chan param to loStatus in MIDIOut.write() and
MIDIOut.send()
- added midiClock, midiStart and midiStop methods to MIDIOut
diff -r1.16 MIDIOut.sc
134,135c134,135
< write { arg len, hiStatus, chan, a=0, b=0;
< this.send(port, uid, len, hiStatus, chan, a, b);
---
> write { arg len, hiStatus, loStatus, a=0, b=0;
> this.send(port, uid, len, hiStatus, loStatus, a, b);
162c162,172
< send {arg outport, uid, len, stat, chan, a=0, b=0, latency=0.1; //in ms
---
> midiClock {
> this.write(1, 16rF0, 16r08);
> }
> startClock {
> this.write(1, 16rF0, 16r0A);
> }
> stopClock {
> this.write(1, 16rF0, 16r0C);
> }
>
> send {arg outport, uid, len, hiStatus, loStatus, a=0, b=0, latency=0.1;
//in ms
SC_CoreMIDI.cpp:
- swapped order of status and chan parameters to sendmidi() to match order
in _SendMIDIOut
- added 0x0F mask for loStatus (previously unmasked) [we could have removed
all masks instead]
- renamed status & chan variables to hiStatus and loStatus
diff -r1.24 SC_CoreMIDI.cpp
458,459c458,459
< void sendmidi(int port, MIDIEndpointRef dest, int length, int chan, int
status, int aval, int bval, float late);
< void sendmidi(int port, MIDIEndpointRef dest, int length, int chan, int
status, int aval, int bval, float late)
---
> void sendmidi(int port, MIDIEndpointRef dest, int length, int hiStatus,
int loStatus, int aval, int bval, float late);
> void sendmidi(int port, MIDIEndpointRef dest, int length, int hiStatus,
int loStatus, int aval, int bval, float late)
468c468
< pk->data[0] = (Byte) chan + (status & 0xF0);
---
> pk->data[0] = (Byte) (hiStatus & 0xF0) | (loStatus & 0x0F);
478c478
< //port, uid, len, status, chan , a, b, latency
---
> //port, uid, len, hiStatus, loStatus, a, b, latency
485,486c485,486
< PyrSlot *s = g->sp - 4;
< PyrSlot *c = g->sp - 3;
---
> PyrSlot *his = g->sp - 4;
> PyrSlot *los = g->sp - 3;
493c493
< int err, outputIndex, uid, length, chan, status, aval, bval;
---
> int err, outputIndex, uid, length, hiStatus, loStatus, aval, bval;
503c503
< err = slotIntVal(s, &status);
---
> err = slotIntVal(his, &hiStatus);
505c505
< err = slotIntVal(c, &chan);
---
> err = slotIntVal(los, &loStatus);
521c521
< sendmidi(outputIndex, dest, length, chan, status, aval, bval, late);
---
> sendmidi(outputIndex, dest, length, hiStatus, loStatus, aval, bval,
late);