14 bit CCResponder / adding bytes

View: New views
4 Messages — Rating Filter:   Alert me  

14 bit CCResponder / adding bytes

by Tomer Harari :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am trying to use 14 bit CC option from my Behringer BCR controller.
After setting up the device to send 14 bit cc, I am using a CCResponder to grab the incoming midi infromation.
14 bit Control change message is actually two 7 bit midi messages,  
One on CC numbers 0 - 31 (MSB), and another on CC numbers 32 - 63 (LSB) respectively.
So when sending 14 bit CC on channel 2 i get :
[ 618189095, 1, 1, 0 ] // 0 is the MSB
[ 618189095, 1, 33, 81 ] // 81 is the LSB

My question is how do i add these two data bytes together so they form one number in the range of 0 - 16,385 and not two numbers in the range of 0 - 127?

Thanks,
Tomer
 



Re: 14 bit CCResponder / adding bytes

by Sciss :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

shift the MSB to left by 8 bit (or multiply it by 256), e.g.  (msb <<  
8) + lsb


Am 06.07.2008 um 11:21 schrieb Tomer Harari:

>
> Hi,
>
> I am trying to use 14 bit CC option from my Behringer BCR controller.
> After setting up the device to send 14 bit cc, I am using a  
> CCResponder to
> grab the incoming midi infromation.
> 14 bit Control change message is actually two 7 bit midi messages,
> One on CC numbers 0 - 31 (MSB), and another on CC numbers 32 - 63  
> (LSB)
> respectively.
> So when sending 14 bit CC on channel 2 i get :
> [ 618189095, 1, 1, 0 ] // 0 is the MSB
> [ 618189095, 1, 33, 81 ] // 81 is the LSB
>
> My question is how do i add these two data bytes together so they  
> form one
> number in the range of 0 - 16,385 and not two numbers in the range  
> of 0 -
> 127?
>
> Thanks,
> Tomer
>
>
>
>
> --
> View this message in context: http://www.nabble.com/14-bit- 
> CCResponder---adding-bytes-tp18300199p18300199.html
> Sent from the Supercollider - User mailing list archive at Nabble.com.
>
>
>
> _______________________________________________
> 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/


_______________________________________________
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/

Re: 14 bit CCResponder / adding bytes

by Sciss :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

or wait it's 7 bit not 8 bit, so should be  (msb << 7) + lsb


Am 07.07.2008 um 19:50 schrieb Sciss:

> shift the MSB to left by 8 bit (or multiply it by 256), e.g.  (msb  
> << 8) + lsb
>
>
> Am 06.07.2008 um 11:21 schrieb Tomer Harari:
>
>>
>> Hi,
>>
>> I am trying to use 14 bit CC option from my Behringer BCR controller.
>> After setting up the device to send 14 bit cc, I am using a  
>> CCResponder to
>> grab the incoming midi infromation.
>> 14 bit Control change message is actually two 7 bit midi messages,
>> One on CC numbers 0 - 31 (MSB), and another on CC numbers 32 - 63  
>> (LSB)
>> respectively.
>> So when sending 14 bit CC on channel 2 i get :
>> [ 618189095, 1, 1, 0 ] // 0 is the MSB
>> [ 618189095, 1, 33, 81 ] // 81 is the LSB
>>
>> My question is how do i add these two data bytes together so they  
>> form one
>> number in the range of 0 - 16,385 and not two numbers in the range  
>> of 0 -
>> 127?
>>
>> Thanks,
>> Tomer
>>
>>
>>
>>
>> --
>> View this message in context: http://www.nabble.com/14-bit- 
>> CCResponder---adding-bytes-tp18300199p18300199.html
>> Sent from the Supercollider - User mailing list archive at  
>> Nabble.com.
>>
>>
>>
>> _______________________________________________
>> 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/
>
>
> _______________________________________________
> 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/


_______________________________________________
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/

Re: 14 bit CCResponder / adding bytes

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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/