electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
  EdisonRex Edison's Electronic Review
Please visit the chat
 Forum index » DIY Hardware and Software » Supercollider
Getting separate bytes from sysex dump into cc messages
Post new topic   Reply to topic Moderators: v-un-v
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Fozzie



Joined: Jun 04, 2004
Posts: 875
Location: Near Wageningen, the Netherlands
Audio files: 8
G2 patch files: 49

PostPosted: Mon Jan 05, 2009 4:05 am    Post subject: Getting separate bytes from sysex dump into cc messages Reply with quote  Mark this post and the followings unread

I am trying to get the separate bytes from a 256 byte sysex dump (from a Waldorf synth, but this is not really important) and use them as the value bytes of a range of cc messages. The purpose of doing this would be to send the cc values to a midi controller (NM G2 or BCR2000) in a parameter feedback scheme, to update the values of the endless rotary encoders.

I noticed that SC/PC can cope with sysex messages on a PC platform, but would my problem be solvable? The idea would be to capture the sysex string of hex bytes, and send 'em one by one (all or preferably a subset) to the midi out, packaged in the correct CC controller messages as hex value bytes. Of course, I know what sysex byte should be in what CC# message, so maybe I could use some sort of table to do this parameter mapping?

Any ideas whether this is feasible, or whether there is a more simple solution (midi-ox doesn't work since it can't handle sysex input other than storing or routing it)?

_________________
Spinning at ~0.0000115740740741 Hz
Back to top
View user's profile Send private message
Fozzie



Joined: Jun 04, 2004
Posts: 875
Location: Near Wageningen, the Netherlands
Audio files: 8
G2 patch files: 49

PostPosted: Mon Jan 05, 2009 6:54 am    Post subject: Reply with quote  Mark this post and the followings unread

I just noticed that a vbscript approach using midi-ox might be feasible as well, so I'll investigate that option as well. Still, if anyone wants to comment on PC sysex transmogrifying, please do.
_________________
Spinning at ~0.0000115740740741 Hz
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Tue Jan 06, 2009 1:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

IIRC sysex receipt in SC gives you an Int8Array with all the bytes, which you can then parse any way you choose.

Not sure exactly what the question is here...? It's quite straightforward to get individual bytes with messageArray[index], and ranges with messageArray[leftIndex .. rightIndex] (*). Like C, indices start at 0.

(*) But keep in mind, the range syntax copies part of the array into a new Array object. If using the same range more than once, it's better to save the partial copy in a variable rather than repeatedly copy the range. (Getting a single array item doesn't copy.)

Don't know if you're reassembling 14-bit ints from a pair of 7-bit values -- if so, that's easy too:

(mostSignificant7Bits << 7) | (leastSignificant7Bits)

hjh

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Fozzie



Joined: Jun 04, 2004
Posts: 875
Location: Near Wageningen, the Netherlands
Audio files: 8
G2 patch files: 49

PostPosted: Wed Jan 07, 2009 3:16 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks James, that helps. I think I will try the psycollider and midiox/vbscript options both, to see which works best. I am having some problems with the midiox scripting, but this is probably due to my relative newbieness with regard to any kind of text-based programming.

I want to 'lift' single bytes from the sysex message to incorporate them as the value byte in appropriate cc messages. The sysex dump that I want to remap to cc message lends itsself well to do this. I am yet unsure what format these bytes should be when psycollider sends cc messages out.

_________________
Spinning at ~0.0000115740740741 Hz
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Thu Jan 08, 2009 10:06 am    Post subject: Reply with quote  Mark this post and the followings unread

"Lifting" bytes... in text-programming-speak, that's array addressing. Array items start at index 0 and increase by 1 thereafter. If the array is:

a = [10, 8, 4, 7, 3, 2, 6, 9, 1, 5];

... then a[0] is 10, a[1] is 8, a[7] is 9 and so on. This is standard syntax for most languages.

a[2..5] is a new array, [4, 7, 3, 2]. Not all languages do this. SC gets the [2..5] syntax from Ruby.

Sending MIDI out in SC uses the MIDIOut object. The .control message handles standard continuous controllers. I've heard Behringer controllers sometimes use a pair of CCs to increase resolution (0..16383 instead of 0..127).

Code:
~midiOut = MIDIOut.newByName("my device", "my port");

// Continuous controller
// controllerNumber, value can be 0-127 only
// channelNumber is 0-15
~midiOut.control(channelNumber, controllerNumber, value)

// Controller pair, assumes 'x' is the 14-bit value
~midiOut.control(channel, ctlNumMostSignificantBits, value >> 7)
   .control(channel, ctlNumLeastSignificantBits, value & 127);


hjh

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Fozzie



Joined: Jun 04, 2004
Posts: 875
Location: Near Wageningen, the Netherlands
Audio files: 8
G2 patch files: 49

PostPosted: Fri Jan 09, 2009 1:23 am    Post subject: Reply with quote  Mark this post and the followings unread

dewdrop_world wrote:
"Lifting" bytes... in text-programming-speak, that's array addressing.......

Sending MIDI out in SC uses the MIDIOut object. The .control message handles standard continuous controllers. I've heard Behringer controllers sometimes use a pair of CCs to increase resolution (0..16383 instead of 0..127).


Thanks again! I understood the array thing (was just trying to get across what my intention was), but thanks for the code examples. I always struggle for some time with the exact syntax since I am not fluent in any computer language in particular.

I was a bit fuzzy on the byte format; I wasn't sure whether PC uses decimals or hex for internal sysex or other midi processing, but I now understand all processing is in decimals. Since I am also working on a midiox script - where sysex is in hex and other midi in dec - I was mixing up things.

I have been making headway in the midiox scripting last night, so at least I'm confident that I will get there one way or the other.

_________________
Spinning at ~0.0000115740740741 Hz
Back to top
View user's profile Send private message
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Fri Jan 09, 2009 9:53 am    Post subject: Reply with quote  Mark this post and the followings unread

Fozzie wrote:
I was a bit fuzzy on the byte format; I wasn't sure whether PC uses decimals or hex for internal sysex or other midi processing, but I now understand all processing is in decimals.


Processing is binary Smile but display is decimal. You can turn a byte into hex using byte.asHexString(2) -- for display -- the result is a String that doesn't do math. (For other bases, there is asStringToBase - more than you needed to know I'm sure Razz )

Good luck, feel free to post with more questions.
James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic Moderators: v-un-v
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Supercollider
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use