@@ -1,3 +1,13 @@ | |||
/* Play notes when your computer sends USB MIDI messages. | |||
To use this example, you must run software on your computer which | |||
sends MIDI. Tools > USB Type must be set to MIDI when uploading. | |||
Requires Teensy 3.6 due to 520 kbytes of wavetable data | |||
Requires Audio Shield: https://www.pjrc.com/store/teensy3_audio.html | |||
*/ | |||
// TODO: smaller samples, to fit in Teensy 3.2 memory | |||
#include "Pizzicato_samples.h" | |||
#include "FrenchHorns_samples.h" | |||
#include "Viola_samples.h" |
@@ -1,3 +1,14 @@ | |||
/* Play notes with a regular USB MIDI Instrument. | |||
To use this example, connect a USB instrument to Teensy 3.6's | |||
USB host port. This cable is recommended: | |||
https://www.pjrc.com/store/cable_usb_host_t36.html | |||
Requires Teensy 3.6 for USB host capability. | |||
Requires Audio Shield: https://www.pjrc.com/store/teensy3_audio.html | |||
*/ | |||
#include "Pizzicato_samples.h" | |||
#include "FrenchHorns_samples.h" | |||
#include "Viola_samples.h" |
@@ -1,3 +1,12 @@ | |||
/* Play notes when your computer sends USB MIDI messages. | |||
To use this example, you must run software on your computer which | |||
sends MIDI. Tools > USB Type must be set to MIDI when uploading. | |||
Requires Teensy 3.6 due to 820 kbytes of wavetable data | |||
Requires Audio Shield: https://www.pjrc.com/store/teensy3_audio.html | |||
*/ | |||
#include "bassoon_samples.h" | |||
#include "clarinet_samples.h" | |||
#include "distortiongt_samples.h" |
@@ -1,3 +1,17 @@ | |||
/* Play a flute sound when a button is pressed. | |||
Connect a pushbutton to pin 1 and pots to pins A2 & A3. | |||
The audio tutorial kit is the intended hardware: | |||
https://www.pjrc.com/store/audio_tutorial_kit.html | |||
Without pots connected, this program will play a very | |||
strange sound due to rapid random fluctuation of the | |||
pitch and volume! | |||
Requires Teensy 3.2 or higher. | |||
Requires Audio Shield: https://www.pjrc.com/store/teensy3_audio.html | |||
*/ | |||
#include <Bounce.h> | |||
#include <Audio.h> | |||
#include <Wire.h> |
@@ -1,3 +1,9 @@ | |||
/* Play Zelda music. | |||
Requires Teensy 3.6 due to 520 kbytes of wavetable data | |||
Requires Audio Shield: https://www.pjrc.com/store/teensy3_audio.html | |||
*/ | |||
#include <Bounce.h> | |||
#include <Audio.h> | |||
#include <Wire.h> |
@@ -46,6 +46,7 @@ enum envelopeStateEnum { STATE_IDLE, STATE_DELAY, STATE_ATTACK, STATE_HOLD, STAT | |||
#define NOTE(N) (440.0 * pow(2.0, (N - 69) / 12.0)) | |||
#define DECIBEL_SHIFT(dB) (pow(10.0, dB/20.0)) | |||
// TODO: move all this stuff into the AudioSynthWavetable class, not global scope | |||
struct sample_data { | |||
// SAMPLE VALUES | |||
const int16_t* sample; | |||
@@ -166,7 +167,7 @@ public: | |||
void playFrequency(float freq, int amp = DEFAULT_AMPLITUDE); | |||
void playNote(int note, int amp = DEFAULT_AMPLITUDE); | |||
bool isPlaying(void) { return env_state != STATE_IDLE; } | |||
void setFrequency(float freq); | |||
void setFrequency(float freq); | |||
virtual void update(void); | |||
envelopeStateEnum getEnvState(void) { return env_state; } |