Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 3:086e556b57f9, committed 2019-07-24
- Comitter:
- liam_grazier
- Date:
- Wed Jul 24 12:24:05 2019 +0000
- Parent:
- 2:da90c8eb0ca5
- Commit message:
- ABCS;
Changed in this revision
--- a/main.cpp Wed Jul 24 11:23:34 2019 +0000 +++ b/main.cpp Wed Jul 24 12:24:05 2019 +0000 @@ -1,120 +1,29 @@ #include "mbed.h" #include "main.hpp" #include "variables.hpp" -float abstempo = 0; -int clockcountneg; -int storedduration; -int runval; - void fire(void){ - clockout = 1; - wait(0.0001); - clockout = 0; - wait(0.0001); - } -void runonce(void){ - getfaderdata(); - //tempo calculations - gettempodata(); - //note calculations - sumprobabilitynotes(); - randomgeneratenotes(); - determinenotes(); - - //octive calculation - sumprobabilityoctives(); - randomgenerateoctives(); - determineoctives(); - - //duration calculation - sumprobabilityduration(); - randomgenerateduration(); - determineduration(); - outputdecision(); - } -void firetrig(void){ - if(clockcount<32){ - clockcount++; - clockcountneg = clockcount - 1; - } - else - { - clockcount = 0; - clockcount++; +#include "trigger.hpp" +void donothing(void){ } - if(clockcount == 1){ - storedduration = duration; - } - pc.printf("%i \n\r",clockcount); - fire(); - //getfaderdata - if(clockcount == 1 && storedduration == 1){ - allledoff(); - getfaderdata(); - //tempo calculations - gettempodata(); - //note calculations - sumprobabilitynotes(); - randomgeneratenotes(); - determinenotes(); - //octive calculation - sumprobabilityoctives(); - randomgenerateoctives(); - determineoctives(); - //duration calculation - sumprobabilityduration(); - randomgenerateduration(); - determineduration(); - outputdecision(); - } - if(clockcount == storedduration-1){ - allledoff(); - getfaderdata(); - //tempo calculations - gettempodata(); - //note calculations - sumprobabilitynotes(); - randomgeneratenotes(); - determinenotes(); - //octive calculation - sumprobabilityoctives(); - randomgenerateoctives(); - determineoctives(); - //duration calculation - sumprobabilityduration(); - randomgenerateduration(); - determineduration(); - outputdecision(); - } -// pc.printf("NOTE: %i OCTIVE: %i DURATION: %i \n\r",note,octive,duration); -// pc.printf("abstemmp %f \n\r",abstempo); - if(clockcount == storedduration && sumnotes > 1){ - senddacout(); - trigout = 1; - wait(0.0001); - trigout = 0; - wait(0.0001); - clockcount = 0; - } - if(clockcount == 1 && storedduration == 1){ - updateled(); - } - if(clockcount == storedduration-1){ - updateled(); - } - } int main() { clockin.mode(PullUp); - clockin.fall(&firetrig); dac.format(8,0); dac.frequency(50000000); pc.baud(115200); allledoff(); updateled(); runonce(); + clockin.fall(&firetrig); + while(1) { - //pc.printf("%i \n\r",targetnumber); //pc.printf("SO %f \n\r",sumoctives); - + getfaderdata(); + gettempodata(); + pc.printf("TEMPO %f \n\r",tempoval); +// if(tempoval < 32){ +//} +//else { +// clockin.fall(&donothing); +// } } }
--- a/main.hpp Wed Jul 24 11:23:34 2019 +0000 +++ b/main.hpp Wed Jul 24 12:24:05 2019 +0000 @@ -603,7 +603,7 @@ return outMin + scale*(outMax-outMin); } void gettempodata(void){ - tempoval = map(vtempo,0,255,255,32); + tempoval = map(vtempo,0,255,255,30); } void debugtempodata(void){ pc.printf("unmapped %f mapped %f\n\r",vtempo,tempoval);
--- a/math.hpp Wed Jul 24 11:23:34 2019 +0000 +++ b/math.hpp Wed Jul 24 12:24:05 2019 +0000 @@ -2,6 +2,11 @@ #define __math__ //notes variables bool matchflagnotes; +float abstempo = 0; +int clockcountneg; +int storedduration; +int runval; + float sumnotes = 0; int randomnotes = 0; int matchnotelower = 0;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trigger.hpp Wed Jul 24 12:24:05 2019 +0000 @@ -0,0 +1,105 @@ +#ifndef __trigger__ +#define __trigger__ +#include "variables.hpp" +#include "math.hpp" +void fire(void){ + clockout = 1; + wait(0.0001); + clockout = 0; + wait(0.0001); +} + +void runonce(void){ + getfaderdata(); + //tempo calculations + gettempodata(); + //note calculations + sumprobabilitynotes(); + randomgeneratenotes(); + determinenotes(); + + //octive calculation + sumprobabilityoctives(); + randomgenerateoctives(); + determineoctives(); + + //duration calculation + sumprobabilityduration(); + randomgenerateduration(); + determineduration(); + outputdecision(); + } +void firetrig(void){ + if(clockcount<32){ + clockcount++; + clockcountneg = clockcount - 1; + } + else + { + clockcount = 0; + clockcount++; + } + if(clockcount == 1){ + storedduration = duration; + } + pc.printf("%i \n\r",clockcount); + fire(); + //getfaderdata + if(clockcount == 1 && storedduration == 1){ + allledoff(); + getfaderdata(); + gettempodata(); + pc.printf("TEMPO %f \n\r",tempoval); + //tempo calculations + //note calculations + sumprobabilitynotes(); + randomgeneratenotes(); + determinenotes(); + //octive calculation + sumprobabilityoctives(); + randomgenerateoctives(); + determineoctives(); + //duration calculation + sumprobabilityduration(); + randomgenerateduration(); + determineduration(); + outputdecision(); + } + if(clockcount == storedduration-1){ + allledoff(); + getfaderdata(); + //tempo calculations + gettempodata(); + //note calculations + sumprobabilitynotes(); + randomgeneratenotes(); + determinenotes(); + //octive calculation + sumprobabilityoctives(); + randomgenerateoctives(); + determineoctives(); + //duration calculation + sumprobabilityduration(); + randomgenerateduration(); + determineduration(); + outputdecision(); + + } +// pc.printf("NOTE: %i OCTIVE: %i DURATION: %i \n\r",note,octive,duration); +// pc.printf("abstemmp %f \n\r",abstempo); + if(clockcount == storedduration && sumnotes > 1){ + senddacout(); + trigout = 1; + wait(0.0001); + trigout = 0; + wait(0.0001); + clockcount = 0; + } + if(clockcount == 1 && storedduration == 1){ + updateled(); + } + if(clockcount == storedduration-1){ + updateled(); + } + } +#endif \ No newline at end of file