electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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 
 Forum index » DIY Hardware and Software » ChucK programming language
Question about GuitarPro instruments in Chuck
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
diegohn



Joined: Nov 06, 2014
Posts: 3
Location: Spain

PostPosted: Thu Nov 06, 2014 3:59 am    Post subject: Question about GuitarPro instruments in Chuck
Subject description: Can ChucK access midi instruments that are used in GuitarPro?
Reply with quote  Mark this post and the followings unread

Hello all.

I am relatively new to ChucK, but since I'm also learning programming I find it very useful for composing music, and I'm glad I found this forum. (This is the result of a very basic program I did Smile https://www.youtube.com/watch?v=T-XUmrJJ7ck)

I know there are unit generators in ChucK. However, I also have a program called GuitarPro, which has a lot of pre-defined midi instruments (guitars, organs, brass, etc). My question is: is there a way to access those instruments in ChucK?
Back to top
View user's profile Send private message
kingcrabmeat



Joined: Sep 04, 2014
Posts: 4
Location: US and A

PostPosted: Fri Nov 14, 2014 1:14 pm    Post subject: Reply with quote  Mark this post and the followings unread

It should be a simple matter of routing the MIDI output from ChucK to a virtual midi device in the system which is routed to the MIDI input of your virtual synth. Unfortunately, I can't provide more specific details.

It's probably safe to assume that a virtual MIDI device is not included by default in most operating systems, so you may have to resort to downloading and installing one from a third party. All that is left to do after that point should be a matter of learning how to access the virtual MIDI device from both software programs.
Back to top
View user's profile Send private message
diegohn



Joined: Nov 06, 2014
Posts: 3
Location: Spain

PostPosted: Tue May 10, 2016 4:24 pm    Post subject: Reply with quote  Mark this post and the followings unread

I come back here after some time Very Happy

Turns out GuitarPro is using the general midi set (Microsoft GS Wavetable synth, as I use windows).

So Chuck's midiout functionality allows me access to this instruments... it's not very intuitive (I'm glad I found this help online: https://lists.cs.princeton.edu/pipermail/chuck-users/2007-January/001426.html), but I figured out how to make a simple program with three instruments (I copy the code in case it's useful for somebody).

I wrote me.exit() at the end because, when I execute the MiniAudicle for a second time, if I haven't removed the existing shred or cleared the virtual machine the application crashes.

Code:

MidiOut mout;
0 => int port;
if( !mout.open(port) )
{
<<< "Error: MIDI port did not open on port: ", port >>>;
me.exit();
}
MidiMsg msg;

//specifying instrument (99) to be played on channel 0 (192)
192 => msg.data1;
99 => msg.data2;
mout.send(msg);

//specifying instrument (0) to be played on channel 1 (193)
193 => msg.data1;
0 => msg.data2;
mout.send(msg);

//specifying instrument (0) to be played on channel 9 -percussion- (201)
201 => msg.data1;
0 => msg.data2;
mout.send(msg);

//function to play note
fun void MIDInote(int channel, int note, int velocity)
{
channel => msg.data1;
note => msg.data2;
velocity => msg.data3;
mout.send(msg);
}

[60,62,64,67,69] @=> int notes[];

repeat(50)
{
   
Math.random2(0,notes.cap()-1) => int z1;
Math.random2(30,127) => int velocity1;
//noteOn message to channel 0
MIDInote(144, notes[z1], velocity1);

Math.random2(0,notes.cap()-1) => int z2;
Math.random2(30,127) => int velocity2;
//noteOn message to channel 1
MIDInote(145, notes[z2], velocity2);
   
.2::second => now;
//noteOff message to channel 0
MIDInote(128,notes[z1] ,velocity1);

Math.random2(0,notes.cap()-1) => int z3;
Math.random2(30,127) => int velocity3;
MIDInote(144, notes[z3], velocity3);

//noteOn message to channel 9 (percussion) --here second arg is the instrument
MIDInote(153, 60, 90);

.05::second => now;

//noteOff message to channel 9 (percussion)
MIDInote(137, 60, 90);

Math.random2(1,3) => int z;
0 => int percInstr2;
if (z==1) 55 => percInstr2;
    else 62 => percInstr2;
MIDInote(153,percInstr2,90);
   
.05::second => now;
MIDInote(137,percInstr2,90);
MIDInote(128,notes[z3] ,velocity3);

Math.random2(0,notes.cap()-1) => int z4;
Math.random2(30,127) => int velocity4;
MIDInote(144, notes[z4], velocity4);
.1::second => now;
MIDInote(128,notes[z4] ,velocity4);

//noteOff message to channel 1
MIDInote(129,notes[z2], velocity2);

   
}
2::second => now;
me.exit();


----
In Windows, for other programs / software or more complex instrument sets it may be possible to use loopMIDI, a freeware application (http://www.tobias-erichsen.de/software/loopmidi.html).
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 [3 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


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