Skip to content

Commit

Permalink
added soundboxen example
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxly committed May 24, 2018
1 parent 5e2e2b8 commit bd0de46
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 91 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified Examples/.DS_Store
Binary file not shown.
@@ -1,6 +1,7 @@
/* FluxamasynthBendingNotes.pde
* Demonstrates note bending on the Modern Device Fluxamasynth Shield
* ModernDevice.com
/*
* FluxamasynthBendingNotes
* Demonstrates pitch bending on the Modern Device Fluxamasynth Shield
* modernDevice.com/fluxamasynth
*/

#include "Fluxamasynth.h"
Expand All @@ -11,8 +12,8 @@ int i = 512; // middle of pitch bend range

void setup()
{
Serial.begin(31250);

// Serial1.begin(31250); // Uncomment if using a Feather M0 board
synth.midiReset();
synth.programChange(127, 0, 91);
synth.pitchBendRange(0, 4); //double the pitch bend sensitivity (4 semitones)

Expand Down
7 changes: 2 additions & 5 deletions Examples/FluxamasynthCrossFading/FluxamasynthCrossFading.ino
@@ -1,7 +1,6 @@
/*
* FluxamasynthCrossFading
/* FluxamasynthCrossFading.pde
* Demonstrates cross fading on the Modern Device Fluxamasynth Shield
* modernDevice.com/fluxamasynth
* ModernDevice.com
*/

#include "Fluxamasynth.h"
Expand All @@ -18,8 +17,6 @@ int dir = 1; // direction to step in: 1 = up, -1 = dow

void setup() {

// Serial1.begin(31250); // Uncomment if using a Feather M0 board
synth.midiReset();
synth.programChange(0, 0, 90); // give our two channels different voices
synth.programChange(0, 1, 89);

Expand Down
@@ -1,10 +1,10 @@
/* FluxamasynthDrumPatternPlayer.pde
/*
* FluxamasynthDrumPatternPlayer
* A drum machine for the Modern Device Fluxamasynth Shield
* ModernDevice.com
* modernDevice.com/fluxamasynth
*
* By Michel Gutlich 26-2-2011
* A sensor signal on analog input 0 gives some tempo dynamics
* Contact at iching@xs4al.nl
*/

#include "Fluxamasynth.h"
Expand All @@ -28,8 +28,6 @@ int hho [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127, 0}; //Hi
int hhc [] = {127, 40, 80, 40,127, 40, 80, 40,127, 40, 80, 40,127, 0, 0}; //Hihat Close
int hhp [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127}; //Hihat Pedal



// * Some basic settings */
int channel = 9; // MIDI channel number
int tempo = 120; // Start tempo
Expand All @@ -38,7 +36,7 @@ int tempo = 120; // Start tempo
int tickNo; // Our tick number variable

void setup() {
Serial.begin(31250); // Set MIDI baud rate:
// Serial1.begin(31250); // Uncomment if using a Feather M0 board

synth.midiReset(); // Do a complete MIDI reset

Expand Down
83 changes: 34 additions & 49 deletions Examples/FluxamasynthPlayAllVoices/FluxamasynthPlayAllVoices.ino
@@ -1,68 +1,53 @@
/* FluxamasynthPlayAllVoices
* Plays all voices with a random algorithmic tune
* on the Modern Device Fluxamasynth Shield
/*
* FluxamasynthPlayAllVoices
* Cycles through all of the instruments
* ModernDevice.com
*/

#include <Fluxamasynth.h>
#include <PgmChange.h>

Fluxamasynth synth = Fluxamasynth();

Fluxamasynth synth = Fluxamasynth();
int counter = 0;
int channel = 0;
int voice = 0;
int j = 0;

int counter = 0;
int channel = 0;
int voice = 0;
int j = 0;

void setup() {
Serial.begin(31250);
synth.programChange(0, 9, 40);
void setup() {
// Serial1.begin(31250); // Uncomment if using a Feather M0 board
synth.midiReset();
synth.programChange(0, 9, 40);
synth.programChange(0, 1, 0);
}
}

void loop()
{
void loop() {

while(counter < 128)
{
if(voice >128)
{
while(counter < 128) {
if (voice > 128) {
voice = 0;
}

synth.programChange(channel, 0, voice);



for(int i=0; i<10; i++)
{

int note = int(random(36,100));

synth.noteOn(channel, note, 127);

int coinflip = int(random(0,20));

if(coinflip == 5)
{
while(j < 200)
{
synth.pitchBend(channel, j);
j+= 16;
delay(10);
synth.programChange(channel, 0, voice);

for(int i=0; i<10; i++) {
int note = int(random(36,100));
synth.noteOn(channel, note, 127);
int coinflip = int(random(0,20));
if (coinflip == 5) {
while(j < 200) {
synth.pitchBend(channel, j);
j+= 16;
delay(10);
}
j = 0;
}

delay(100);
synth.noteOff(channel, note);
}

voice++;

}
channel++;
counter++;
delay(100);
synth.noteOff(channel, note);
}
voice++;
}
channel++;
counter++;
}

9 changes: 8 additions & 1 deletion Examples/GenMusic1/GenMusic1.ino
@@ -1,3 +1,9 @@
/*
* GenMusic1
* An example of using the Fluxamasynth for generative music
* moderndevice.com
*/

#include <Fluxamasynth.h>
#include <PgmChange.h>

Expand All @@ -21,14 +27,15 @@ int tempo=30;
int instrument[numInstruments] = {13, 13, 13, 13};

void setup() {
// Serial1.begin(31250); // Uncomment if using a Feather M0 board
synth.midiReset();
randomSeed(millis()+analogRead(0));
Serial.begin(9600);
chooseParts();
synth.setMasterVolume(85);
for (int i=0; i<numInstruments; i++) {
synth.programChange(0, i, instrument[i]);
synth.pan(i,127/numInstruments*i);
//synth.setChannelVolume(i, volume[i]);
synth.setReverb(i, 3, 127, 25);
}
synth.setReverb(9,5,255,100); //Plate reverb
Expand Down
25 changes: 11 additions & 14 deletions Examples/GenMusic2/GenMusic2.ino
@@ -1,4 +1,8 @@
//Exploring the upper range of the instrument
/*
* GenMusic2
* Exploring the upper range of the instrument
* moderndevice.com
*/

#include <Fluxamasynth.h>
#include <PgmChange.h>
Expand All @@ -9,16 +13,16 @@ int count2 = 0;
int s = 120;

void setup() {

// Serial1.begin(31250); // Uncomment if using a Feather M0 board
delay(20);
synth.midiReset();
synth.setMasterVolume(50);
synth.setMasterVolume(50);
int instrument = 2;
randomSeed(millis()+analogRead(1));
for (int i=0; i<4; i++) {
synth.programChange(0, i, instrument);
synth.setReverb(i, 1, 127, 25);

pan(i, 127/(i+1));
synth.programChange(0, i, instrument);
synth.setReverb(i, 1, 127, 25);
synth.pan(i, 127/(i+1));
}
}

Expand Down Expand Up @@ -55,10 +59,3 @@ for (int i=n; i<n+8; i++) {
synth.noteOff(4, i+2);
}
}

void pan(int channel, int value) {
// TODO: Add this to library
byte command[3] = {
(0xb0 | (channel & 0x0f)), 0x0A, (value) };
synth.fluxWrite(command, 3);
}
19 changes: 10 additions & 9 deletions Examples/GenMusic3/GenMusic3.ino
@@ -1,11 +1,16 @@
/*
* GenMusic1
* A variation on GenMusic1
* moderndevice.com
*/

#include <Fluxamasynth.h>
#include <PgmChange.h>

Fluxamasynth synth = Fluxamasynth();

#define numInstruments 4


byte parts[4];
int measures[16];
int notes[16];
Expand All @@ -31,13 +36,16 @@ int timesig = 16;
int instrument[numInstruments] = {41, 41, 41, 41};

void setup() {
// Serial1.begin(31250); // Uncomment if using a Feather M0 board
delay(20);
synth.midiReset();
randomSeed(millis()+analogRead(0));
Serial.begin(9600);
chooseParts();
synth.setMasterVolume(100);
for (int i=0; i<numInstruments; i++) {
synth.programChange(0, i, instrument[i]);
pan(i,127/numInstruments*i);
synth.pan(i,127/numInstruments*i);
//synth.setChannelVolume(i, volume[i]);
synth.setReverb(i, 3, 127, 25);
}
Expand Down Expand Up @@ -214,10 +222,3 @@ void loop() {
digitalWrite(12, LOW);
pinMode(12, INPUT);
}

void pan(int channel, int value) {
// TODO: Add this to library
byte command[3] = {
(0xb0 | (channel & 0x0f)), 0x0A, (value) };
synth.fluxWrite(command, 3);
}
69 changes: 69 additions & 0 deletions Examples/Looper1/Looper1.ino
@@ -0,0 +1,69 @@
// Fluxamasynth out of sync tape loop example
// Inspired by Eno's Music for Airports #2: F2 G#2 C3 C#3 D#3 F3 G#3
// Won't make sense without 10k poteniometers on pins A0-A5
// https://vimeo.com/252388252

#include "Fluxamasynth.h"
Fluxamasynth synth;

int tones[6] = { 29, 32, 36, 37, 39, 41 };
int instruments[6] = { 55, 55, 55, 55, 55, 55 };
int tapeLength[6] = { 30, 31, 32, 33, 34, 35 };
int startingPoint[6] = { 0, 1, 2, 3, 4, 5 };
int length[6] = { 100, 110, 120, 130, 140, 150 };
int lengthCount[6] = { 0, 0, 0, 0, 0, 0 };
int tempo[6] = { 1000, 2000, 3000, 4000, 5000, 6000 };
int tempoCount[6] = { 0, 0, 0, 0, 0, 0 };
long int startTime = 0;

void setup() {
// Serial1.begin(31250); // Uncomment if using a Feather M0 board
Serial.begin(9600);
int seed = 0;
for (int i=0; i<6; i++) {
seed += analogRead(i);
}

randomSeed(seed);
delay(100);
for (int i=0; i<6; i++) {
synth.setChannelVolume(i, 255 );
synth.allNotesOff(i);
synth.setReverb(i, 5, 64, 0);
synth.pan(5-i,127/(6*(i+1)));
}
changeProgram();
startTime = 0;
}

void changeProgram() {
for (int i=0; i<6; i++) {
synth.programChange(0, i,random(127));
}
}

void loop() {
if (millis() > (startTime + 20000)) {
changeProgram();
startTime = millis();
Serial.println("changeProgram");
}
int ledTempo = 0;
for (int i=0; i<6; i++) {
int val = analogRead(i);
tempo[i] = 5100 - map(val, 0, 1023, 100, 5000);
tempoCount[i]++;
if (tempoCount[i] > tempo[i]) {
if (lengthCount[i] == 0) {
synth.noteOn(i, tones[i], 127);
}
lengthCount[i]++;
if (lengthCount[i] > length[i]) {
synth.noteOff(i, tones[i]);
lengthCount[i] = 0;
tempoCount[i] = 0;
}
}
}
delay(1);
}
4 changes: 3 additions & 1 deletion Examples/TerryRiley_s_In_C/TerryRiley_s_In_C.ino
Expand Up @@ -145,7 +145,9 @@ void setNextNote(int j) {
}

void setup() {
// The tempo is determined by a potentiometer on Analog 0.
// Serial1.begin(31250); // Uncomment if using a Feather M0 board

// The tempo is determined by a potentiometer on Analog 1
pinMode(A0, OUTPUT);
pinMode(A2, OUTPUT);
digitalWrite(A0, LOW);
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Expand Up @@ -6,4 +6,4 @@ sentence=A library for the Modern Device Fluxamasynth Shield for Arduino, ESP32,
paragraph=
category=Communication
url=http://moderndevice.com/fluxamasynth
architectures=samd,avr,esp32
architectures=samd,avr,esp32

0 comments on commit bd0de46

Please sign in to comment.