Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cinematix Wheels : data parsing before going into MKtlElement #117

Closed
sensestage opened this issue Nov 3, 2014 · 4 comments
Closed

Cinematix Wheels : data parsing before going into MKtlElement #117

sensestage opened this issue Nov 3, 2014 · 4 comments

Comments

@sensestage
Copy link
Contributor

Wouters cinematix wheels provide an interesting case where the MIDI data needs to be processed before you get to the actual physical controls

q = q ? ();

(
MIDIdef.noteOn( \cinematixWheel, { |val,note|
    var wheel, value;
    wheel = note.mod(16);
    value = val*8 + (note/16).round(1);
    q.put( wheel, value );
    q.postln;
});
);
@LFSaw
Copy link
Member

LFSaw commented Jun 2, 2015

as this is a one-off controller, I'd set this to optional.

@adcxyz
Copy link
Contributor

adcxyz commented Nov 13, 2016

Proposal:

  • Make a desc for a virtual MKtl that has all the elements
  • add the MIDIdef.noteOn function by hand

This allows all the advantages of having it as an MKtl, without complicated additions to the desc protocol.

// Sketched in code, which could be put in desc file as example:
// the desc for the CinematixWheel - could be cinematix-wheel.desc.scd

d = (
    idInfo: "CinematixWheel",
    protocol: \virtual,
    specs: ('lin11bit': [0, 1024, \lin, 1]),
    elementsDesc: (
        shared: (elementType: \slider, spec: 'lin11bit'),
        elements: (1..16).collect { |num| (key: num.asSymbol) }
    ),
);

// test as MKtl
c = MKtl(\cin, d);
g = c.trace.gui;
c.elAt.action = { |el| "action: %, %\n".postf(el.name, el.value.round(0.001)) };

// test with gui
c.elAt(0).deviceValueAction_(1023);
10.do { c.elAt(16.rand).deviceValueAction_(1024.rand); };

// cannot disable gui yet - fixme
c.elAt(0).disable;
c.elAt(0).deviceValueAction_(512);

// the coding in the example above seems to be:
// 7 bits of value are crude value,
// first 3 bits of note are extra precision,
// last 4 bits of note are wheel index.

// listen to the physical device, translate to MKtl
(
MIDIdef.noteOn( \cinWheel, { |val, note|
    var wheelIndex, value;
    wheelIndex = note mod: 16;
    value = val << 3 + (note >> 4);
    (wheel: wheelIndex, value: value).postln;
    c.elAt(wheelIndex).deviceValueAction_(value);
});
);

MIDIClient.init;
// test that coding is correct via midi input: 

// access wheels, last 4 bits of note
MIDIIn.noteOn.value(0, 0, 0, 0); // action: '1', 0
MIDIIn.noteOn.value(0, 0, 1, 0); // action: '2', 0
MIDIIn.noteOn.value(0, 0, 15, 0); // action: '16', 0

// higher 3 bits of note go to low bits of value
MIDIIn.noteOn.value(0, 0, 16, 0); // action: '1', 0.001
// wheel 4, value 2
MIDIIn.noteOn.value(0, 0, 32 + 4, 0); // action: '5', 0.002
MIDIIn.noteOn.value(0, 0, 112 + 15, 16); // action: '16', 0.132

// velocity sets higher bits of value
MIDIIn.noteOn.value(0, 0, 0, 1);
MIDIIn.noteOn.value(0, 0, 32, 64);
MIDIIn.noteOn.value(0, 0, 127, 127);
MIDIIn.noteOn.value(0, 0, 15, 64);

// wheel is 0-15, val = 0 - 1023
~fakeCinIn = { |wheel, val|
    var note = (val % 8 * 16) + wheel;
    var velval = val div: 8;
    MIDIIn.noteOn.value(nil, nil, note, velval);
    (note: note, vel: velval).postln;
};


~fakeCinIn.(0, 1016);
~fakeCinIn.(0, 512);
~fakeCinIn.(4, 512);

~fakeCinIn.(*[16.rand, 1023.rand].postln);

@adcxyz
Copy link
Contributor

adcxyz commented Nov 13, 2016

Option 2 would be creating a special class for it, as with MPush.

@adcxyz
Copy link
Contributor

adcxyz commented Jun 30, 2017

I think this is answered, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants