Synth.cpp
 All Data Structures Namespaces Files Functions Variables Macros
Data Structures | Macros | Functions | Variables
teensy.ino File Reference
#include <TimerOne.h>
#include "synth.h"
#include "voice.h"
#include "tests.h"
Include dependency graph for teensy.ino:

Go to the source code of this file.

Data Structures

class  ThreadSafeSynth
 
class  FunctionKey
 

Macros

#define KEYBOARD   1
 
#define NUM_KEYS   11
 
#define NUM_NOISY_VOICES   4
 
#define NUM_SIMPLE_VOICES   14
 
#define NUM_SQUARE_VOICES   8
 

Functions

void timer_interrupt (void)
 
uint8_t read_key (uint32_t id)
 
void setup ()
 
void loop (void)
 

Variables

Keykeyboard [NUM_KEYS]
 
ThreadSafeSynth s
 
ThreadSafeSynth s2
 
ThreadSafeSynth s3
 
ISynthsynth_ary [3]
 
int8_t pitches [] = { 0, 2, 4, 5, 7, 9, 11, 12 }
 
uint32_t tune []
 
uint32_t start_time
 
uint32_t tune_pointer
 

Macro Definition Documentation

#define KEYBOARD   1

Definition at line 7 of file teensy.ino.

#define NUM_KEYS   11

Definition at line 8 of file teensy.ino.

Referenced by loop(), and setup().

#define NUM_NOISY_VOICES   4

Referenced by setup().

#define NUM_SIMPLE_VOICES   14

Referenced by setup().

#define NUM_SQUARE_VOICES   8

Referenced by setup().

Function Documentation

void loop ( void  )

Arduino loop function

Definition at line 164 of file teensy.ino.

Here is the call graph for this function:

uint8_t read_key ( uint32_t  id)

Keyboard scanning passes thru this function because all Teensy-specific code lives in this file. If you're thinking about touch-sensitive keys or other exotica, this is the place for that. Also, if keys are assigned special functions, that should be handled here.

Definition at line 91 of file teensy.ino.

void setup ( )

Note that there are different numbers of voices assigned for the different types of voice. The more complicated a voice is, the less polyphony is possible. There are two ways to address this.

  • Lower the sampling rate, which adversely impacts sound quality.
  • Speed up the code. That means doing a lot of profiling (best done with a GPIO pin and an oscilloscope in this situation) and then write tighter C++ code and possibly some assembly language.

Definition at line 106 of file teensy.ino.

Here is the call graph for this function:

void timer_interrupt ( void  )

The timer interrupt takes audio samples from the queue and feeds them to the 12-bit DAC. If there is a queue underrun, it turns on the LED briefly but visibly.

Definition at line 68 of file teensy.ino.

Referenced by setup().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Key * keyboard

Definition at line 9 of file teensy.ino.

int8_t pitches[] = { 0, 2, 4, 5, 7, 9, 11, 12 }

Definition at line 58 of file teensy.ino.

Referenced by setup().

Definition at line 55 of file teensy.ino.

Referenced by FunctionKey::keydown(), ADSR::setS(), setup(), and use_synth_array().

Definition at line 55 of file teensy.ino.

Referenced by FunctionKey::keydown(), and setup().

Definition at line 55 of file teensy.ino.

Referenced by FunctionKey::keydown(), and setup().

uint32_t start_time

Definition at line 60 of file teensy.ino.

Referenced by loop(), and setup().

ISynth* synth_ary[3]

Definition at line 56 of file teensy.ino.

uint32_t tune[]

Definition at line 3 of file tune.cpp.

Referenced by loop().

uint32_t tune_pointer

Definition at line 61 of file teensy.ino.

Referenced by setup().