#include "jokermusikk.h" | #include "jokermusikk.h" | ||||
int hastighet; | |||||
uint8_t *skala; | |||||
int *c; | |||||
int *f; | |||||
int *g; | |||||
int cm[] = {0,3,7}; | |||||
int fm[] = {0,5,8}; | |||||
int g[] = {11,7,2,5,8}; | |||||
int member = 3; | int member = 3; | ||||
int note_length = 50; | int note_length = 50; | ||||
int n = 0; | int n = 0; | ||||
void setup() { | void setup() { | ||||
// put your setup code here, to run once: | // put your setup code here, to run once: | ||||
skala = SKALA[1]; | |||||
c = treklang[0]; | |||||
f = treklang[3]; | |||||
g = treklang[4]; | |||||
} | } | ||||
void loop() { | void loop() { | ||||
seconds = millis(); | seconds = millis(); | ||||
seconds = seconds/1000; | seconds = seconds/1000; | ||||
if (prev != seconds) | if (prev != seconds) | ||||
akkord = random(0,3); | akkord = random(0,3); | ||||
prev = seconds; | prev = seconds; | ||||
member = random(3); | |||||
switch (akkord) { | switch (akkord) { | ||||
case 0: // cm | case 0: // cm | ||||
member = random(3); | |||||
n = cm[member]; | |||||
n = skala[c[member]]; | |||||
break; | break; | ||||
case 1: // fm | |||||
member = random(3); | |||||
n = fm[member]; | |||||
case 1: // f | |||||
n = skala[f[member]]; | |||||
break; | break; | ||||
case 2: // g | case 2: // g | ||||
member = random(5); | |||||
n = g[member]; | |||||
n = skala[g[member]]; | |||||
break; | break; | ||||
} | } | ||||
#include <Arduino.h> | #include <Arduino.h> | ||||
const int Output = 1; // Can be 1 or 4 | const int Output = 1; // Can be 1 or 4 | ||||
// Cater for 16MHz, 8MHz, or 1MHz clock: | // Cater for 16MHz, 8MHz, or 1MHz clock: | ||||
const int Clock = ((F_CPU/1000000UL) == 16) ? 4 : ((F_CPU/1000000UL) == 8) ? 3 : 0; | const int Clock = ((F_CPU/1000000UL) == 16) ? 4 : ((F_CPU/1000000UL) == 8) ? 3 : 0; | ||||
const uint8_t scale[] PROGMEM = {239,226,213,201,190,179,169,160,151,142,134,127}; | const uint8_t scale[] PROGMEM = {239,226,213,201,190,179,169,160,151,142,134,127}; | ||||
const uint8_t SKALA[][7] = { | |||||
{0,2,4,5,7,9,11}, | |||||
{0,2,3,5,7,9,10}, | |||||
{0,1,3,5,7,8,10}, | |||||
{0,2,4,6,7,9,11}, | |||||
{0,2,4,5,7,9,10}, | |||||
{0,2,3,5,7,8,10}, | |||||
{0,1,3,5,6,8,10}}; | |||||
const int treklang[][3] = { | |||||
{0,2,4}, | |||||
{1,3,5}, | |||||
{2,4,6}, | |||||
{0,3,5}, | |||||
{1,4,6}, | |||||
{0,2,5}, | |||||
{1,3,6}}; | |||||
void note (int n, int octave); | void note (int n, int octave); | ||||
#endif | #endif |