« Return to Thread: 14 bit CCResponder / adding bytes

Re: 14 bit CCResponder / adding bytes

by James Harkins-2 :: Rate this Message:

Reply to Author | View in Thread

Well, the real problem is that the MSB and LSB come in at separate
times, and you can't control which one comes in first.

So what you need is an object that receives MSB and LSB separately,
and fires the action only after both arrive.

Something like this prototype would do it:

x = (
        action: { |value| value.debug("got both bytes") },
        testFire: { |z|
                if(z.lsb.notNil and: { z.msb.notNil }) {
                        z[\action].value(z.msb << 7 + z.lsb);
                        z.put(\msb, nil).put(\lsb, nil);
                }
        },
        msb_: { |z, byte|
                z.put(\msb, byte);
                z.testFire;
                z
        },
        lsb_: { |z, byte|
                z.put(\lsb, byte);
                z.testFire;
                z
        }
);

Then set your CCResponder objects so that the one for cc1 does the
action "x.msb = byte" and cc31 does "x.lsb = byte" -- the action
function saved in the prototype will run only after both messages come
in.

hjh



--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

 « Return to Thread: 14 bit CCResponder / adding bytes

LightInTheBox - Buy quality products at wholesale price!