Browse Source

implement scales and basic harmonies into library

master
Dom SP 2 years ago
parent
commit
08c4dc5693
2 changed files with 46 additions and 11 deletions
  1. +21
    -10
      AVR_code/harmonisk_improvisasjon/harmonisk_improvisasjon.ino
  2. +25
    -1
      AVR_code/harmonisk_improvisasjon/jokermusikk.h

+ 21
- 10
AVR_code/harmonisk_improvisasjon/harmonisk_improvisasjon.ino View File

#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;
} }



+ 25
- 1
AVR_code/harmonisk_improvisasjon/jokermusikk.h View File

#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

Loading…
Cancel
Save