| /* 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 "Pizzicato_samples.h" | ||||
| #include "FrenchHorns_samples.h" | #include "FrenchHorns_samples.h" | ||||
| #include "Viola_samples.h" | #include "Viola_samples.h" |
| /* 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 "Pizzicato_samples.h" | ||||
| #include "FrenchHorns_samples.h" | #include "FrenchHorns_samples.h" | ||||
| #include "Viola_samples.h" | #include "Viola_samples.h" |
| /* 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 "bassoon_samples.h" | ||||
| #include "clarinet_samples.h" | #include "clarinet_samples.h" | ||||
| #include "distortiongt_samples.h" | #include "distortiongt_samples.h" |
| /* 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 <Bounce.h> | ||||
| #include <Audio.h> | #include <Audio.h> | ||||
| #include <Wire.h> | #include <Wire.h> |
| /* 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 <Bounce.h> | ||||
| #include <Audio.h> | #include <Audio.h> | ||||
| #include <Wire.h> | #include <Wire.h> |
| #define NOTE(N) (440.0 * pow(2.0, (N - 69) / 12.0)) | #define NOTE(N) (440.0 * pow(2.0, (N - 69) / 12.0)) | ||||
| #define DECIBEL_SHIFT(dB) (pow(10.0, dB/20.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 { | struct sample_data { | ||||
| // SAMPLE VALUES | // SAMPLE VALUES | ||||
| const int16_t* sample; | const int16_t* sample; | ||||
| void playFrequency(float freq, int amp = DEFAULT_AMPLITUDE); | void playFrequency(float freq, int amp = DEFAULT_AMPLITUDE); | ||||
| void playNote(int note, int amp = DEFAULT_AMPLITUDE); | void playNote(int note, int amp = DEFAULT_AMPLITUDE); | ||||
| bool isPlaying(void) { return env_state != STATE_IDLE; } | bool isPlaying(void) { return env_state != STATE_IDLE; } | ||||
| void setFrequency(float freq); | |||||
| void setFrequency(float freq); | |||||
| virtual void update(void); | virtual void update(void); | ||||
| envelopeStateEnum getEnvState(void) { return env_state; } | envelopeStateEnum getEnvState(void) { return env_state; } |