Skip to content

Commit

Permalink
Adding files
Browse files Browse the repository at this point in the history
  • Loading branch information
cutlasses committed Oct 9, 2019
0 parents commit 619f782
Show file tree
Hide file tree
Showing 15 changed files with 27,550 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.DS_Store
Binary file added Workshop Instructions.pdf
Binary file not shown.
6,812 changes: 6,812 additions & 0 deletions Workshop_audio/AudioSamplePiano_c3_44k.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Workshop_audio/AudioSamplePiano_c3_44k.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Audio data converted from WAV file by wav2sketch

extern const unsigned int AudioSamplePiano_c3_44k[54465];
50 changes: 50 additions & 0 deletions Workshop_audio/Workshop_audio.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlayMemory playMem1; //xy=113,154
AudioOutputAnalog dac1; //xy=324,155
AudioConnection patchCord1(playMem1, dac1);
// GUItool: end automatically generated code

#include "AudioSamplePiano_c3_44k.h" // include the sample data for the piano sound


const int BUTTON_PIN(0);

Bounce button_bounce( BUTTON_PIN, 5 ); // 5ms debounce time

void setup()
{
pinMode( BUTTON_PIN, INPUT_PULLUP ); // set the pin mode for the button and enable the pull up resistor inside the Teensy

AudioMemory(10); // allocate some memory from the teensy audio libary (10 audio blocks)

Serial.begin(9600);

Serial.println("Setup complete");
}

void loop()
{
// has the button state change?
if( button_bounce.update() )
{
// is the button pressed down
if( button_bounce.fallingEdge() )
{
Serial.println("Button down!");

playMem1.play( AudioSamplePiano_c3_44k );
}
else if( button_bounce.risingEdge() )
{
Serial.println("Button up!");
}
}
}
6,812 changes: 6,812 additions & 0 deletions Workshop_delay/AudioSamplePiano_c3_44k.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Workshop_delay/AudioSamplePiano_c3_44k.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Audio data converted from WAV file by wav2sketch

extern const unsigned int AudioSamplePiano_c3_44k[54465];
94 changes: 94 additions & 0 deletions Workshop_delay/Workshop_delay.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlayMemory playMem1; //xy=74,230
AudioMixer4 mixer1; //xy=244,54
AudioEffectDelay delay1; //xy=381,170
AudioMixer4 mixer2; //xy=516,356
AudioOutputAnalog dac1; //xy=700,355
AudioConnection patchCord1(playMem1, 0, mixer1, 1);
AudioConnection patchCord2(playMem1, 0, mixer2, 1);
AudioConnection patchCord3(mixer1, delay1);
AudioConnection patchCord4(delay1, 0, mixer1, 0);
AudioConnection patchCord5(delay1, 0, mixer2, 0);
AudioConnection patchCord6(mixer2, dac1);
// GUItool: end automatically generated code



#include "AudioSamplePiano_c3_44k.h" // include the sample data for the piano sound


const int BUTTON_PIN(0);
const int POT1_PIN(A0);
const int POT2_PIN(A1);

Bounce button_bounce( BUTTON_PIN, 5 ); // 5ms debounce time

void setup()
{
pinMode( BUTTON_PIN, INPUT_PULLUP ); // set the pin mode for the button and enable the pull up resistor inside the Teensy

AudioMemory(128); // allocate some memory from the teensy audio libary

Serial.begin(9600);

Serial.println("Setup complete");

// mix dry and wet signal (50% of each)
mixer2.gain( 0, 0.5f ); // wet
mixer2.gain( 1, 0.5f ); // dry
}

void loop()
{
// has the button state change?
if( button_bounce.update() )
{
// is the button pressed down
if( button_bounce.fallingEdge() )
{
Serial.println("Button down!");

playMem1.play( AudioSamplePiano_c3_44k );
}
else if( button_bounce.risingEdge() )
{
Serial.println("Button up!");
}
}

const int min_delay_time = 50;
const int max_delay_time = 300;

static float old_pot1_val_raw = 0;
float pot1_val_raw = analogRead( POT1_PIN );

// is the difference large enough to change the delay time?
if( abs( old_pot1_val_raw - pot1_val_raw ) > 50 )
{
const float pot1_val = pot1_val_raw / 1024.0f;
const float delay_time = min_delay_time + ( max_delay_time * pot1_val );
delay1.delay( 0, delay_time );
Serial.println(delay_time);

// update the old value
old_pot1_val_raw = pot1_val_raw;
}

float pot2_val = analogRead( POT2_PIN ) / 1024.0f;
mixer1.gain( 0, pot2_val ); // feedback
mixer1.gain( 1, 1.0f ); // source audio

//Serial.print( old_pot1_val_raw / 1024.0f );
//Serial.print( "\t\t" );
//Serial.println( pot2_val );

delay(5);
}
6,812 changes: 6,812 additions & 0 deletions Workshop_part1/AudioSamplePiano_c3_44k.cpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Workshop_part1/AudioSamplePiano_c3_44k.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Audio data converted from WAV file by wav2sketch

extern const unsigned int AudioSamplePiano_c3_44k[54465];
45 changes: 45 additions & 0 deletions Workshop_part1/Workshop_part1.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <Audio.h>
#include <Bounce.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

#include "AudioSamplePiano_c3_44k.h" // include the sample data for the piano sound

const int BUTTON_PIN(0);

Bounce button_bounce( BUTTON_PIN, 5 ); // 5ms debounce time

// GUItool: begin automatically generated code
AudioPlayMemory playMem1; //xy=113,154
AudioOutputAnalog dac1; //xy=324,155
AudioConnection patchCord1(playMem1, dac1);
// GUItool: end automatically generated code


void setup()
{
pinMode( BUTTON_PIN, INPUT_PULLUP ); // set the pin mode for the button and enable the pull up resistor

AudioMemory(10); // allocate some memory from the teensy audio libary (10 audio blocks)

Serial.begin(9600);

Serial.println("Setup complete");
}

void loop()
{
// has the button state change?
if( button_bounce.update() )
{
// is the button pressed down
if( button_bounce.fallingEdge() )
{
Serial.println("Button down");

playMem1.play( AudioSamplePiano_c3_44k );
}
}
}
Loading

0 comments on commit 619f782

Please sign in to comment.