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
Shred Organisation and MIDI
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
DrumAliens



Joined: Jul 10, 2008
Posts: 31
Location: UK
Audio files: 1

PostPosted: Sun Jul 04, 2010 1:32 am    Post subject: Shred Organisation and MIDI Reply with quote  Mark this post and the followings unread

I want to make use of ChucK for live coding. Not a problem so far. What I also want to be is record what I have done and possible edit/mix it later. So the plan is to make use of MIDI so I can then use any DAW any VST's for notes and effects.

So I won't be using ChucK to generate the instruments just the MIDI signals ... stands back for the tirade of abuse.

So what I want to be able to use a general file which will handle all of the MIDI and then use different files for each specific instrument.

... or do I have to have the MIDI handling in each of the instrument files.

Thanks

Paul
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Sun Jul 04, 2010 3:15 am    Post subject: Reply with quote  Mark this post and the followings unread

I took a general pattern for sending MIDI that I've used and extracted it to a public class (midiInclude.ck) that you could include. I also made a little test program (midiIncTest.ck) and a main file for loading them all (midiIncTestMain.ck). Is this in the direction you want to go?

Here is the test code (I've even put some comments in there ;) ):


Code:
0 => int MIDI_OUT_DEVICE;

MidiOut midiOut;
if (!midiOut.open(MIDI_OUT_DEVICE)) {
   <<< "Couldn't open midi out ", MIDI_OUT_DEVICE >>>;
} else {
   <<< "Opened ", midiOut.name() >>>;
}

// some notes for testing
[0,5,8,2,6,10,4,8,10,5] @=> int notes[];
0 => int noteIndex;

fun int checkIndex(int index, int max) {
   if (index >= max) {
      return 0;
   } else {
      return index;
   }
}

MidiKeyboard keyboard;
keyboard.init(midiOut, 0); // device, channel

while (true) {
   // play three notes at a time, spread them a bit fancy-like
   keyboard.playNote(60 + notes[noteIndex++], 50, 1::second);
   checkIndex(noteIndex, notes.size()) => noteIndex;
   100::ms => now;
   keyboard.playNote(60 + notes[noteIndex++], 100, 900::ms);
   checkIndex(noteIndex, notes.size()) => noteIndex;
   100::ms => now;
   keyboard.playNote(60 + notes[noteIndex++], 120, 800::ms);
   checkIndex(noteIndex, notes.size()) => noteIndex;
   900::ms => now;
}


Note that I spork up a shred every time I play a note in midiInclude. This is needed to support chords - my first gut feeling was that it might be expensive to spork up loads of throwaway shreds like this, but it seems to work ok. You can solve it with a limited pool of shreds that are reused, but that solution quickly gets very complicated because there are a lot of concurrency stuff you need to take care of.

/Stefan


midiInclude.ck
 Description:
A general class for sending note events (key on + key off) in a controlled manner from a ChucK program.

Download (listen)
 Filename:  midiInclude.ck
 Filesize:  861 Bytes
 Downloaded:  283 Time(s)


midiIncTest.ck
 Description:
A test program for midiInclude.ck

Download (listen)
 Filename:  midiIncTest.ck
 Filesize:  907 Bytes
 Downloaded:  286 Time(s)


midiIncTestMain.ck
 Description:
A main ChucK program for running midiIncTest.ck.

Download (listen)
 Filename:  midiIncTestMain.ck
 Filesize:  66 Bytes
 Downloaded:  329 Time(s)


_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Sun Jul 04, 2010 3:17 am    Post subject: Reply with quote  Mark this post and the followings unread

Oh yeah, you run this test by putting all three files in the same directory, and then doing:

Code:
chuck midiIncTestMain.ck


/Stefan

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
DrumAliens



Joined: Jul 10, 2008
Posts: 31
Location: UK
Audio files: 1

PostPosted: Sun Jul 04, 2010 3:22 am    Post subject: Reply with quote  Mark this post and the followings unread

Many thanks. I am off work tommorrow (Monday) will give this a proper go then.

Thanks

Paul
Back to top
View user's profile Send private message
DrumAliens



Joined: Jul 10, 2008
Posts: 31
Location: UK
Audio files: 1

PostPosted: Sun Jul 04, 2010 3:50 am    Post subject: Reply with quote  Mark this post and the followings unread

Had a sneaky go and recorded MIDI notes.

Looking good so far. Thanks Antimon full report to follow

Paul
Back to top
View user's profile Send private message
DrumAliens



Joined: Jul 10, 2008
Posts: 31
Location: UK
Audio files: 1

PostPosted: Mon Jul 05, 2010 3:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks Antimon fair amount of success/fun today.

Think I will just make use of two files midiInclude to do the main MIDI handling and the midiIncTest for develop coding. Still trying to work out whether to use the playNote option or go the keyOn/keyOff route.

Manage to link all of this up to Cuckos Reaper with a beatsliced drum track on one channel and synth on another.

Just need to tidy things and I'm off.
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Tue Jul 06, 2010 3:12 am    Post subject: Reply with quote  Mark this post and the followings unread

Nice to see that it was useful. Smile

Now you mention, maybe I've gotten the whole machine.add() thing for classes pattern wrong. You're right - you only need two files.

/Stefan

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
MusicMan11712



Joined: Aug 08, 2009
Posts: 1082
Location: Out scouting . . .

PostPosted: Wed Jul 07, 2010 4:05 pm    Post subject: Re: Shred Organisation and MIDI Reply with quote  Mark this post and the followings unread

DrumAliens wrote:
So I won't be using ChucK to generate the instruments just the MIDI signals ... stands back for the tirade of abuse.
No tirades from me--most of the stuff I played around with using ChucK was for routing and processing midi data (no recording or playback, though).
--Steve
Back to top
View user's profile Send private message
MusicMan11712



Joined: Aug 08, 2009
Posts: 1082
Location: Out scouting . . .

PostPosted: Wed Jul 07, 2010 4:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

Antimon wrote:
I took a general pattern for sending MIDI that I've used and extracted it to a public class (midiInclude.ck) that you could include. I also made a little test program (midiIncTest.ck) and a main file for loading them all (midiIncTestMain.ck). Is this in the direction you want to go?/Stefan
Thanks for posting the code, Stefan. If I ever get back into using ChucK, this is certainly something I want to check out!
--Steve
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 [9 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