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
trigger.hpp
- Committer:
- benparkes
- Date:
- 2019-07-25
- Revision:
- 15:89ff99d55466
- Parent:
- 14:a352cc410078
- Child:
- 16:f2d46570f0e6
File content as of revision 15:89ff99d55466:
#ifndef __trigger__
#define __trigger__
#include "variables.hpp"
#include "math.hpp"
void fire(void){
clockout = 1;
wait(0.0001);
clockout = 0;
wait(0.0001);
}
void loopFall(){
loop = (~loop);
pc.printf("button press \n\r");
}
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){
if (loop == 1){
ToPlay = (dataTail + PlayPos)% (MAX_SAMPLES-1);
note = loopBuffer[ToPlay].note();
octive = loopBuffer[ToPlay].octave();
duration = loopBuffer[ToPlay].duration();
senddacout();
pc.printf("Looping, PlayPos: %i, pos: %i, note: %i, octave: %i, duration: %i \n\r", PlayPos, ToPlay, note, octive, duration);
if (PlayPos >= MAX_SAMPLES){
PlayPos = 0;
}
else{
PlayPos++;
}
}
else{
//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){
allledoff();
outputdecision();
updateled();
}
if(clockcount == storedduration-1){
allledoff();
outputdecision();
updateled();
}
}
#endif