Browse Source

Add comments to wavetable synth examples

dds
PaulStoffregen 6 years ago
parent
commit
ab87205424
54 changed files with 52 additions and 1 deletions
  1. +10
    -0
      examples/Synthesis/Wavetable/MidiSynth/MidiSynth.ino
  2. +11
    -0
      examples/Synthesis/Wavetable/MidiSynthKeyboard/MidiSynthKeyboard.ino
  3. +9
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/MidiSynthLarge.ino
  4. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/bassoon_samples.cpp
  5. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/bassoon_samples.h
  6. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/clarinet_samples.cpp
  7. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/clarinet_samples.h
  8. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/distortiongt_samples.cpp
  9. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/distortiongt_samples.h
  10. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/epiano_samples.cpp
  11. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/epiano_samples.h
  12. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/flute_samples.cpp
  13. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/flute_samples.h
  14. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/frenchhorn_samples.cpp
  15. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/frenchhorn_samples.h
  16. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/glockenspiel_samples.cpp
  17. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/glockenspiel_samples.h
  18. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/gtfretnoise_samples.cpp
  19. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/gtfretnoise_samples.h
  20. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/harmonica_samples.cpp
  21. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/harmonica_samples.h
  22. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/harp_samples.cpp
  23. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/harp_samples.h
  24. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/mutedgtr_samples.cpp
  25. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/mutedgtr_samples.h
  26. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/nylonstrgtr_samples.cpp
  27. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/nylonstrgtr_samples.h
  28. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/oboe_samples.cpp
  29. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/oboe_samples.h
  30. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/overdrivegt_samples.cpp
  31. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/overdrivegt_samples.h
  32. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/piano_samples.cpp
  33. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/piano_samples.h
  34. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/recorder_samples.cpp
  35. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/recorder_samples.h
  36. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/standard_DRUMS_samples.cpp
  37. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/standard_DRUMS_samples.h
  38. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/steelstrgtr_samples.cpp
  39. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/steelstrgtr_samples.h
  40. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/strings_samples.cpp
  41. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/strings_samples.h
  42. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/timpani_samples.cpp
  43. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/timpani_samples.h
  44. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/trombone_samples.cpp
  45. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/trombone_samples.h
  46. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/trumpet_samples.cpp
  47. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/trumpet_samples.h
  48. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/tuba_samples.cpp
  49. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/tuba_samples.h
  50. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/vibraphone_samples.cpp
  51. +0
    -0
      examples/Synthesis/Wavetable/MidiSynthLarge/vibraphone_samples.h
  52. +14
    -0
      examples/Synthesis/Wavetable/SimpleWavetable/SimpleWavetable.ino
  53. +6
    -0
      examples/Synthesis/Wavetable/ZeldaSynth/ZeldaSynth.ino
  54. +2
    -1
      synth_wavetable.h

+ 10
- 0
examples/Synthesis/Wavetable/MidiSynth/MidiSynth.ino View File

/* 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"

+ 11
- 0
examples/Synthesis/Wavetable/MidiSynthKeyboard/MidiSynthKeyboard.ino View File

/* 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"

examples/Synthesis/Wavetable/GeneralMidiSynth/GeneralMidiSynth.ino → examples/Synthesis/Wavetable/MidiSynthLarge/MidiSynthLarge.ino View File

/* 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"

examples/Synthesis/Wavetable/GeneralMidiSynth/bassoon_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/bassoon_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/bassoon_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/bassoon_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/clarinet_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/clarinet_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/clarinet_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/clarinet_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/distortiongt_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/distortiongt_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/distortiongt_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/distortiongt_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/epiano_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/epiano_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/epiano_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/epiano_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/flute_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/flute_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/flute_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/flute_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/frenchhorn_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/frenchhorn_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/frenchhorn_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/frenchhorn_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/glockenspiel_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/glockenspiel_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/glockenspiel_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/glockenspiel_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/gtfretnoise_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/gtfretnoise_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/gtfretnoise_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/gtfretnoise_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/harmonica_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/harmonica_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/harmonica_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/harmonica_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/harp_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/harp_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/harp_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/harp_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/mutedgtr_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/mutedgtr_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/mutedgtr_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/mutedgtr_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/nylonstrgtr_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/nylonstrgtr_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/nylonstrgtr_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/nylonstrgtr_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/oboe_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/oboe_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/oboe_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/oboe_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/overdrivegt_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/overdrivegt_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/overdrivegt_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/overdrivegt_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/piano_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/piano_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/piano_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/piano_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/recorder_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/recorder_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/recorder_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/recorder_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/standard_DRUMS_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/standard_DRUMS_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/standard_DRUMS_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/standard_DRUMS_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/steelstrgtr_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/steelstrgtr_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/steelstrgtr_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/steelstrgtr_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/strings_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/strings_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/strings_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/strings_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/timpani_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/timpani_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/timpani_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/timpani_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/trombone_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/trombone_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/trombone_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/trombone_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/trumpet_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/trumpet_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/trumpet_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/trumpet_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/tuba_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/tuba_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/tuba_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/tuba_samples.h View File


examples/Synthesis/Wavetable/GeneralMidiSynth/vibraphone_samples.cpp → examples/Synthesis/Wavetable/MidiSynthLarge/vibraphone_samples.cpp View File


examples/Synthesis/Wavetable/GeneralMidiSynth/vibraphone_samples.h → examples/Synthesis/Wavetable/MidiSynthLarge/vibraphone_samples.h View File


+ 14
- 0
examples/Synthesis/Wavetable/SimpleWavetable/SimpleWavetable.ino View File

/* 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>

+ 6
- 0
examples/Synthesis/Wavetable/ZeldaSynth/ZeldaSynth.ino View File

/* 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>

+ 2
- 1
synth_wavetable.h View File

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

Loading…
Cancel
Save