Author |
Message |
DrumAliens

Joined: Jul 10, 2008 Posts: 31 Location: UK
Audio files: 1
|
Posted: Sun Jul 04, 2010 1:32 am Post subject:
Shred Organisation and MIDI |
 |
|
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
|
|
 |
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Sun Jul 04, 2010 3:15 am Post subject:
|
 |
|
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
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) |
Description: |
A test program for midiInclude.ck |
|
 Download (listen) |
Filename: |
midiIncTest.ck |
Filesize: |
907 Bytes |
Downloaded: |
286 Time(s) |
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
|
|
 |
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Sun Jul 04, 2010 3:17 am Post subject:
|
 |
|
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
|
|
 |
DrumAliens

Joined: Jul 10, 2008 Posts: 31 Location: UK
Audio files: 1
|
Posted: Sun Jul 04, 2010 3:22 am Post subject:
|
 |
|
Many thanks. I am off work tommorrow (Monday) will give this a proper go then.
Thanks
Paul |
|
Back to top
|
|
 |
DrumAliens

Joined: Jul 10, 2008 Posts: 31 Location: UK
Audio files: 1
|
Posted: Sun Jul 04, 2010 3:50 am Post subject:
|
 |
|
Had a sneaky go and recorded MIDI notes.
Looking good so far. Thanks Antimon full report to follow
Paul |
|
Back to top
|
|
 |
DrumAliens

Joined: Jul 10, 2008 Posts: 31 Location: UK
Audio files: 1
|
Posted: Mon Jul 05, 2010 3:10 pm Post subject:
|
 |
|
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
|
|
 |
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Tue Jul 06, 2010 3:12 am Post subject:
|
 |
|
Nice to see that it was useful.
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
|
|
 |
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Wed Jul 07, 2010 4:05 pm Post subject:
Re: Shred Organisation and MIDI |
 |
|
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
|
|
 |
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Wed Jul 07, 2010 4:10 pm Post subject:
|
 |
|
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
|
|
 |
|