Yellow Onion
Joined: Jul 14, 2008 Posts: 7 Location: Christchurch, New Zealand
|
Posted: Mon Jul 14, 2008 6:23 pm Post subject:
drum Sequencing for Midi drum machine |
 |
|
I've written a drum sequencer, it uses hydrogen as the backend drum machine via midi
I've only been chucKing for a week so any tips would be use full
I'm looking at adding the ability to add Chucks instrument
| Code: |
MidiOut mout;
MidiMsg msg;
//under GPLv2
// drum setup for hydrogen's GMkit Drumkit
//should be the same length as (or a fraction of) "ires"
//drumline one
[ [ [1.,0.,0.,1.,0.,0.,0.,1.,1.,0.,0.,0.,0.,1.,0.,0.], //kick
[0.0], //stick
[0.,0.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.,0.,0.,0.,0.], //snare Jazz
[0.0], //Clap
[0.0], //snare Rock
[0.], // low tom
[0.], //Closed Hi-Hat
[0.], // mid tom
[0.,0.,1.,0.,0.,0.,1.,0.], //Pedal Hi-Hat // 1/2 of "ires" means repeated twice during bar
[0.], //high tom
[0.], //Open hi-hat
[0.], //cow Bell
[1.,0.,1.,.4,.5,0.,1.,0.,1.,.5,0.,.5,1.,0.,.5,1.], //Rid Jazz
[0.], //Crash
[0.], //Ride Rock
[0.] //Crash Jazz
], //drumline 2
[ [1.,0.,0.,1.,0.,0.,0.,1.,1.,0.,0.,0.,0.,1.,0.,0.], //kick
[0.0], //stick
[0.,0.,0.,0.,0.,0.,1.,0.,0.,0.,0.,1.,0.,0.,0.,0.], //snare Jazz
[0.0], //Clap
[0.0], //snare Rock
[0.], // low tom
[0.], //Closed Hi-Hat
[0.], // mid tom
[0.,0.,1.,0.,0.,0.,1.,0.], //Pedal Hi-Hat; done
[0.], //high tom
[0.], //Open hi-hat
[0.], //cow Bell
[.8,0.,1.,.4,.52,0.,.7,0.,8.,.5,0.,.5,.8,0.,.5,.8], //Rid Jazz
[0.], //Crash
[0.], //Ride Rock
[0.] //Crash Jazz
], //drumline 3
[ [00.0] ]
//drumline n
]
@=> float drumset[][][];
[ // [select drumline from drumset, select tempo]
[0,100],
[0, 60],
[0, 40]] @=> int lineup[][];
100 => int tempo; //tempo of 100bpm (overridden later)
4 => int res; // resolution of counts at 4 per beat eg 1/4 notes
res*4 => int ires; // resolution × 4 beats per bar = drumline length
1::minute/tempo/res => dur T; //count length
T - (now % T) => now;
// check if port is open
//T /
if( !mout.open( 6 ) ) me.exit();
for ( 0 => int ii; ii < lineup.cap() ; ii++) //loop through lineup[][]
{
lineup[ii][1] => tempo;
1::minute/tempo/res => dur T;
drumset[lineup[ii][0]] @=> float drum[][];
for (0 => int i ; i <= ires; i++)// loop through each count
{
for(0 => int iii; iii < drum.cap();iii++) //play each instrument
{
drum[iii][i%drum[iii].cap()] => float volu;
if ( volu != 0)
{
144 => msg.data1;
iii+36 => msg.data2;
( volu*127 - Std.rand2(0,4) ) $ int => msg.data3;
mout.send(msg);
}
}
T => now;
}
}
|
|
|