electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 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
drum Sequencing for Midi drum machine
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [1 Post]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Yellow Onion



Joined: Jul 14, 2008
Posts: 7
Location: Christchurch, New Zealand

PostPosted: Mon Jul 14, 2008 6:23 pm    Post subject: drum Sequencing for Midi drum machine Reply with quote  Mark this post and the followings unread

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;
   }
}
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 [1 Post]
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

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, 2004, 2005, 2006 and 2007 by electro-music.com