Synthesizer / Mbed 2 deprecated DBSMUSICPROJ

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "main.hpp"
00003 #include "variables.hpp"
00004 float abstempo = 0;
00005 int clockcountneg;
00006 int storedduration;
00007 int runval;
00008     void fire(void){
00009     clockout = 1;
00010     wait(0.0001);
00011     clockout = 0;
00012     wait(0.0001);  
00013     }
00014 void runonce(void){
00015     getfaderdata();  
00016   //tempo calculations
00017   gettempodata();
00018   //note calculations
00019   sumprobabilitynotes(); 
00020   randomgeneratenotes();
00021   determinenotes();
00022   
00023   //octive calculation 
00024   sumprobabilityoctives(); 
00025   randomgenerateoctives();
00026   determineoctives();
00027   
00028   //duration calculation
00029   sumprobabilityduration(); 
00030   randomgenerateduration();
00031   determineduration();
00032   outputdecision();
00033   }
00034 void firetrig(void){ 
00035     if(clockcount<32){
00036     clockcount++;
00037     clockcountneg = clockcount - 1;
00038     }
00039     else
00040     {
00041     clockcount = 0;
00042     clockcount++;
00043     }
00044     if(clockcount == 1){
00045         storedduration = duration;
00046         }
00047     pc.printf("%i \n\r",clockcount);
00048     fire();
00049   //getfaderdata  
00050   if(clockcount == 1 && storedduration == 1){
00051   allledoff();
00052   getfaderdata(); 
00053   //tempo calculations
00054   gettempodata();
00055   //note calculations
00056   sumprobabilitynotes(); 
00057   randomgeneratenotes();
00058   determinenotes();
00059   //octive calculation 
00060   sumprobabilityoctives(); 
00061   randomgenerateoctives();
00062   determineoctives();
00063   //duration calculation
00064   sumprobabilityduration(); 
00065   randomgenerateduration();
00066   determineduration();
00067   outputdecision();
00068   }    
00069   if(clockcount == storedduration-1){
00070   allledoff();
00071   getfaderdata(); 
00072   //tempo calculations
00073   gettempodata();
00074   //note calculations
00075   sumprobabilitynotes(); 
00076   randomgeneratenotes();
00077   determinenotes();
00078   //octive calculation 
00079   sumprobabilityoctives(); 
00080   randomgenerateoctives();
00081   determineoctives();
00082   //duration calculation
00083   sumprobabilityduration(); 
00084   randomgenerateduration();
00085   determineduration();
00086   outputdecision();
00087 
00088   }
00089 //  pc.printf("NOTE: %i OCTIVE: %i DURATION: %i \n\r",note,octive,duration);
00090 //  pc.printf("abstemmp %f \n\r",abstempo);
00091   if(clockcount == storedduration && sumnotes > 1){
00092   senddacout();
00093   trigout = 1;
00094   wait(0.0001);
00095   trigout = 0;
00096   wait(0.0001);
00097   clockcount = 0;
00098     }
00099   if(clockcount == 1 && storedduration == 1){
00100       updateled();
00101       }
00102   if(clockcount == storedduration-1){
00103   updateled();
00104   }
00105   }
00106 int main() {
00107     clockin.mode(PullUp);
00108     clockin.fall(&firetrig);
00109     dac.format(8,0);
00110     dac.frequency(50000000);
00111     pc.baud(115200);
00112     allledoff();
00113     updateled(); 
00114     runonce();
00115   while(1) { 
00116   //pc.printf("%i \n\r",targetnumber);
00117   //pc.printf("SO %f \n\r",sumoctives);
00118 
00119 }
00120 }