mozzi_drum_sample_test1

#include <MozziGuts.h> // Mozziの基本ヘッダファイル
#include <Oscil.h> // オシレータのテンプレート
#include <mozzi_rand.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

#include <ADSR.h>                      //エンベロープ
ADSR <AUDIO_RATE, AUDIO_RATE> envB1;

#include <mozzi_midi.h>

#include <tables/SQUARE_NO_ALIAS_2048_int8.h>

#include <tables/snaretable.h>
#include <tables/kicktable.h>
#include <tables/hihattable.h>
#include <tables/clap2.h>
#include <tables/snare2.h>
#include <tables/snare3.h>
#include <tables/snare4.h>
#include <tables/noise2.h>
#include <tables/noise3.h>

#include <tables/test1.h>
#include <tables/test2.h>
#include <tables/test3.h>

#include <tables/snap1.h>
#include <tables/kick9.h>
#include <tables/chihat2.h>
#include <tables/water1.h>

#include <Sample.h> // Sample template
Sample <SNARETABLE_NUM_CELLS, AUDIO_RATE> snare(SNARETABLE_DATA);
Sample <KICKTABLE_NUM_CELLS, AUDIO_RATE> kick(KICKTABLE_DATA);
Sample <HIHATTABLE_NUM_CELLS, AUDIO_RATE> hihat1(HIHATTABLE_DATA);
Sample <clap2_NUM_CELLS, AUDIO_RATE> clap(clap2_DATA);

Sample <test1_NUM_CELLS, AUDIO_RATE> test1(test1_DATA);
Sample <test2_NUM_CELLS, AUDIO_RATE> test2(test2_DATA);
Sample <test3_NUM_CELLS, AUDIO_RATE> test3(test3_DATA);

Sample <snare2_NUM_CELLS, AUDIO_RATE> snare2(snare2_DATA);
Sample <snare3_NUM_CELLS, AUDIO_RATE> snare3(snare3_DATA);
Sample <snare4_NUM_CELLS, AUDIO_RATE> snare4(snare4_DATA);

Sample <snap1_NUM_CELLS, AUDIO_RATE> snap1(snap1_DATA);
Sample <kick9_NUM_CELLS, AUDIO_RATE> kick9(kick9_DATA);
Sample <chihat2_NUM_CELLS, AUDIO_RATE> hihat2(chihat2_DATA);

Sample <water1_NUM_CELLS, AUDIO_RATE> water1(water1_DATA);

Sample <noise2_NUM_CELLS, AUDIO_RATE> noise2(noise2_DATA);
Sample <noise3_NUM_CELLS, AUDIO_RATE> noise3(noise3_DATA);

// トリガー(発音タイミング)のためのヘッダ
#include <EventDelay.h>
EventDelay kTriggerDelay;
EventDelay sttdelay;

// スムースに値を変化させるためのヘッダ


int count=0;
int kleady=0;

int sttutter=0;

byte pin5;
byte pulse;
int tempo;
int tempo1=0;
bool trigger;
byte check;  


bool seqsn3[]={0,0,0,0, 0,0,0,1, 0,0,0,0, 1,0,0,1, 0,0,1,0, 0,0,1,0, 0,0,0,0, 0,1,0,0};
bool seqsn4[]={0,0,0,0, 1,0,0,0, 0,0,0,0, 1,0,0,0, 0,0,0,0, 1,0,0,1, 0,0,0,0, 1,0,0,0};

bool seqk[]={1,0,0,0, 0,0,0,0, 1,0,1,0, 0,1,0,0, 1,0,0,0, 0,0,0,0, 0,0,1,0, 0,1,0,0};

bool seqh1[]={0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0, 0,0,1,0};
bool seqh2[]={1,0,1,0, 0,1,1,0, 1,0,1,0, 1,0,1,0, 1,0,1,0, 1,0,1,0, 0,0,1,0, 0,0,1,0};

bool seqcl2[]={0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,1,0, 0,0,0,1, 0,0,1,0, 1,0,0,0, 0,1,0,0};
bool seqsnap[]={1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1};
bool seqsn2[]={0,0,0,0, 1,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,0,0, 1,0,0,0, 0,0,0,0, 1,0,0,0};

float seqf1[]={3,3,3,3, 4,4,4,4, 3.75,3.75,3.75,3.75, 2.812,2.812,2.812,2.812, 2.25,2.25,2.25,2.25, 2.7,2.7,2.7,2.7, 3,3,3,3, 4,4,4,4};

bool seqm[]={0,0,40,0, 40,0,40,0, 0,40,0,40, 0,40,0,0};

bool seqt[]={0,0,0,0, 1,0,0,1, 0,0,0,0, 1,0,0,0};

//int melo[]={63,65,67,70,72,65,70,67, 70,65,70,65,63,65,67,63};
int melo[]={63,65,67,70,72,65,70,67,70,65,70,65,63,65,67,63,  70,72,70,72,74,75,72,70,77,70,72,75,70,75,72,77,   82,77,79,75,79,75,79,74,75,72,75,77,79,74,82,75 ,79,84,82,77,67,65,67,70,75,72,77,79,82,86,84,87, 77,79,75,79,82,74,70,72, 74,75,79,72,67,72,77,79, 70,86,91,77,82,84,87,79, 82,82,74,77,72,75,72,74,          82,77,79,74,87,84,77,91, 75,72,86,74,79,84,82,89, 91,86,94,82,87,77,75,91, 75,86,82,79,82,87,84,79}; 

int ser=0;
int sertime=10;
int rseqs,rseqk,rseqh,rseqc,rmel1;
int pseq1,pseq2,pseq3,pseq4,pseq5,pseq6,pseq7,pseq8,pseq9,pseq10;

Oscil <SQUARE_NO_ALIAS_2048_NUM_CELLS, AUDIO_RATE> squa1(SQUARE_NO_ALIAS_2048_DATA);


// コントロールレートをあらかじめ定義
#define CONTROL_RATE 128

void setup(){

test2.setEnd (10000+random(10000));
test2.setStart (random(5000));
//lcd.print("happy bithday! happy bithday! happy bithday! happy bithday!");
 
 startMozzi(CONTROL_RATE);
 kTriggerDelay.start(100);// トリガーのタイミング指定(100ms)
 randSeed();
   snare2.setFreq( 6*(float)snare2_SAMPLERATE/(float)snare2_NUM_CELLS );
   snare3.setFreq( 6*(float)snare3_SAMPLERATE/(float)snare3_NUM_CELLS );
   snare4.setFreq( 6*(float)snare4_SAMPLERATE/(float)snare4_NUM_CELLS );
   
   kick.setFreq( 16*(float)KICKTABLE_SAMPLERATE/(float)KICKTABLE_NUM_CELLS );
   hihat1.setFreq( 20*(float)HIHATTABLE_SAMPLERATE/(float)HIHATTABLE_NUM_CELLS );
   clap.setFreq( 6*(float)clap2_SAMPLERATE/(float)clap2_NUM_CELLS );

   test1.setFreq( 3*(float)test1_SAMPLERATE/(float)test1_NUM_CELLS );
  
   test3.setFreq( 3*(float)test3_SAMPLERATE/(float)test3_NUM_CELLS );
   
   snap1.setFreq( (float)6*(float)snap1_SAMPLERATE/(float)snap1_NUM_CELLS );
   kick9.setFreq( (float)5*(float)kick9_SAMPLERATE/(float)kick9_NUM_CELLS );
   hihat2.setFreq( (float)7*(float)chihat2_SAMPLERATE/(float)chihat2_NUM_CELLS );
   
//   water1.setFreq( (float)6*(float)water1_SAMPLERATE/(float)water1_NUM_CELLS );

}


void updateControl(){

     test2.setFreq((float) seqf1[tempo1]*(float)test2_SAMPLERATE/(float)test2_NUM_CELLS ); 
    if((ser>950)&&sttdelay.ready()){
   //  snap1.start();
  //   kick.start();
     hihat1.start();
     snare3.start();
     sttdelay.start(5+sertime);
     }                                 


   if(kTriggerDelay.ready()){
     kleady+=1; 
     kleady=0; 
     
     ser=random(1000);
     sertime=random(30);
     rseqs=random(1000);
     rseqk=random(1000);
     rseqh=random(1000);
     rseqc=random(1000);
     rmel1=random(1000);
   
     pseq1=random(1000);
     pseq2=random(1000);
     pseq3=random(1000); 
//     pseq4=random(1000);
 //    pseq5=random(1000);
     pseq6=random(1000);  
     
     
    
/*      
if((rseqs<160)){
     snare2.start();

    }
if((rseqk<250)){
     kick.start();

    }
if((rseqh<200)){
     hihat2.start();

     
    }
if((rseqc<160)){
     clap.start();
     
    }
*/
   
//   if(seqsn2[count])  snare2.start(); 
  if(seqsn3[count])  snare4.start();
  if(seqsn4[count])  snare3.start();
             

    if(seqsnap[tempo1]) { 
     test2.setLoopingOn ();
     }else{
       test2.setLoopingOff (); 
       }
 //   if(seqsn2[count])test3.start();
     
    if(seqk[count]) { 
     kick9.start();
     }
     
    if(seqh1[count])  {
     hihat1.start();
     }
         
    if(seqh2[count])  {
     hihat2.start();
     }
       
  if(seqsn3[count])   clap.start();
//    if(pseq5<100)  noise2.start();
     
//    if(pseq6<100)  noise3.start();
  
   
   

 
      count +=1;
    if(count==32){
     count=0;
     tempo1+=4;
     if(tempo1>=32)tempo1=0;
    }
      kTriggerDelay.start(200);
       
  }    //  kTrigger if文終わり
}        //void updateControl()終わり 


int updateAudio(){
 
 //  envB1.update();
// (envB1.next()*(squa1.next()>>4)>>4)

    return (test2.next()+snare3.next()+snare4.next() +kick9.next()+(hihat1.next())+(hihat2.next()) +(clap.next()) )>>1;
}


void loop(){
 audioHook();
} 

よろしければサポートお願いします!