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
  Rob Adventures in Sound
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
Midi OSC
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [2 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
BD



Joined: Mar 08, 2008
Posts: 1
Location: US

PostPosted: Sat Mar 08, 2008 6:57 pm    Post subject: Midi OSC
Subject description: Sending Midi over OSC
Reply with quote  Mark this post and the followings unread

Hi, I am new to Chuck and am working on integrating two examples that are provided with Chuck -- "gomidi.ck" and ""OSC_send.ck". Essentially, I need to send midi data via an OSC port.
my code is attached, but throws an error. There might be data mismatch problems where I am adding the Midi input data received in "gomidi.ck" (i.e. msg.data1,msg.data2, msg.data3) to the OSC send Object (xmit) . Would appreciate if anyone can take a look into this and suggest. Thanks!


Code:


"localhost" => string hostname;
// number of the device to open (see: chuck --probe)
1 => int device;
// get command line
if( me.args() ) me.arg(0) => Std.atoi => device;

// the midi event
MidiIn min;
// the message for retrieving data
MidiMsg msg;

///OSC SET-UP
6449 => int port;

// get command line
if( me.args() ) me.arg(0) => hostname;
if( me.args() > 1 ) me.arg(1) => Std.atoi => port;
////OSC SET_UP////

// send object
OscSend xmit;

// aim the transmitter
xmit.setHost( hostname, port );


// open the device
if( !min.open( device ) ) me.exit();

// print out device that was opened
<<< "MIDI device:", min.num(), " -> ", min.name() >>>;

//***work on this code from here...send midi to osc..

// infinite time loop
while( true )
{
    // start the message...
    // the type string ',f' expects a single float argument

xmit.startMsg( "/sndbuf/buf/rate", "d" );
    min => now;
    // get the message(s)
    while( min.recv(msg) )
    {
        // print out midi message
        <<< msg.data1, msg.data2, msg.data3 >>>;
        msg.data1 => xmit.addFloat;
        msg.data2 => xmit.addFloat;
        msg.data3 => xmit.addFloat;
        <<< "sent (via OSC):", msg.data1, msg.data2, msg.data3 >>>;
    }
}

Back to top
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Sun Mar 09, 2008 1:49 am    Post subject: Reply with quote  Mark this post and the followings unread

I haven't used OSC for anything yet but maybe you're supposed to have an "f" where you have xmit.startMsg( "/sndbuf/buf/rate", "d" ); . And then convert the midi messages that are of type int to type float by dividing with 127.0 . If the message is actually 14 bits in two data of 7 bits, then first recombine them and divide accordingly.
Code:
"localhost" => string hostname;
// number of the device to open (see: chuck --probe)
1 => int device;
// get command line
if( me.args() ) me.arg(0) => Std.atoi => device; //First argument

// the midi event
MidiIn min;
// the message for retrieving data
MidiMsg msg;

///OSC SET-UP
6449 => int port;

// get command line
if( me.args() > 1 ) me.arg(1) => hostname; //We already used one argument up there ^
if( me.args() > 2 ) me.arg(2) => Std.atoi => port; //Third argument
////OSC SET_UP////

// send object
OscSend xmit;

// aim the transmitter
xmit.setHost( hostname, port );


// open the device
if( !min.open( device ) ) me.exit();

// print out device that was opened
<<< "MIDI device:", min.num(), " -> ", min.name() >>>;

//***work on this code from here...send midi to osc..

// infinite time loop
while( true )
{
    // start the message...
    // the type string ',f' expects a single float argument

xmit.startMsg( "/sndbuf/buf/rate", "f" );
    min => now;
    // get the message(s)
    while( min.recv(msg) )
    {
        // print out midi message
        <<< msg.data1, msg.data2, msg.data3 >>>;
        msg.data1/127.0 => xmit.addFloat;
        msg.data2/127.0 => xmit.addFloat;
        msg.data3/127.0 => xmit.addFloat;
    }
}

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [2 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 » ChucK programming language
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