From b08b78404ee5c2e8771857214d2304f6e3f0d2c7 Mon Sep 17 00:00:00 2001 From: Gaudi Date: Tue, 27 Sep 2016 17:05:28 +0200 Subject: [PATCH] First Version of Software V3 Still needs some work. --- Open_Theremin_V3/OTPinDefs.h | 56 ++ Open_Theremin_V3/Open_Theremin_V3.ino | 79 ++ Open_Theremin_V3/application.cpp | 480 ++++++++++++ Open_Theremin_V3/application.h | 69 ++ Open_Theremin_V3/build.h | 14 + Open_Theremin_V3/hw.h | 19 + Open_Theremin_V3/ihandlers.cpp | 209 +++++ Open_Theremin_V3/ihandlers.h | 44 ++ Open_Theremin_V3/mcpDac.h | 151 ++++ Open_Theremin_V3/theremin_sintable.c | 1032 ++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable2.c | 1032 ++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable3.c | 1032 ++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable4.c | 1033 +++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable5.c | 1032 ++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable6.c | 1032 ++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable7.c | 1033 +++++++++++++++++++++++++ Open_Theremin_V3/theremin_sintable8.c | 1032 ++++++++++++++++++++++++ Open_Theremin_V3/timer.cpp | 17 + Open_Theremin_V3/timer.h | 39 + 19 files changed, 9435 insertions(+) create mode 100644 Open_Theremin_V3/OTPinDefs.h create mode 100644 Open_Theremin_V3/Open_Theremin_V3.ino create mode 100644 Open_Theremin_V3/application.cpp create mode 100644 Open_Theremin_V3/application.h create mode 100644 Open_Theremin_V3/build.h create mode 100644 Open_Theremin_V3/hw.h create mode 100644 Open_Theremin_V3/ihandlers.cpp create mode 100644 Open_Theremin_V3/ihandlers.h create mode 100644 Open_Theremin_V3/mcpDac.h create mode 100644 Open_Theremin_V3/theremin_sintable.c create mode 100644 Open_Theremin_V3/theremin_sintable2.c create mode 100644 Open_Theremin_V3/theremin_sintable3.c create mode 100644 Open_Theremin_V3/theremin_sintable4.c create mode 100644 Open_Theremin_V3/theremin_sintable5.c create mode 100644 Open_Theremin_V3/theremin_sintable6.c create mode 100644 Open_Theremin_V3/theremin_sintable7.c create mode 100644 Open_Theremin_V3/theremin_sintable8.c create mode 100644 Open_Theremin_V3/timer.cpp create mode 100644 Open_Theremin_V3/timer.h diff --git a/Open_Theremin_V3/OTPinDefs.h b/Open_Theremin_V3/OTPinDefs.h new file mode 100644 index 0000000..cdd9996 --- /dev/null +++ b/Open_Theremin_V3/OTPinDefs.h @@ -0,0 +1,56 @@ +/** + * \file + * Pin definitions + */ + +#ifndef WavePinDefs_h +#define WavePinDefs_h + +//------------------------------------------------------------------------------ +// DAC pin definitions + +// LDAC may be connected to ground to save a pin +/** Set USE_MCP_DAC_LDAC to 0 if LDAC is grounded. */ +#define USE_MCP_DAC_LDAC 1 + +// use arduino pins 2, 3, 4, 5 for DAC + +// pin 2 is DAC chip select + +/** Data direction register for DAC chip select. */ +#define MCP_DAC_CS_DDR DDRB +#define MCP_DAC2_CS_DDR DDRB +/** Port register for DAC chip select. */ +#define MCP_DAC_CS_PORT PORTB +/** Port bit number for DAC chip select. */ +#define MCP_DAC_CS_BIT 2 +#define MCP_DAC2_CS_BIT 1 + +// pin 3 is DAC serial clock +/** Data direction register for DAC clock. */ +#define MCP_DAC_SCK_DDR DDRB +/** Port register for DAC clock. */ +#define MCP_DAC_SCK_PORT PORTB +/** Port bit number for DAC clock. */ +#define MCP_DAC_SCK_BIT 5 + +// pin 4 is DAC serial data in + +/** Data direction register for DAC serial in. */ +#define MCP_DAC_SDI_DDR DDRB +/** Port register for DAC clock. */ +#define MCP_DAC_SDI_PORT PORTB +/** Port bit number for DAC clock. */ +#define MCP_DAC_SDI_BIT 3 + +// pin 5 is LDAC if used +#if USE_MCP_DAC_LDAC +/** Data direction register for Latch DAC Input. */ +#define MCP_DAC_LDAC_DDR DDRD +/** Port register for Latch DAC Input. */ +#define MCP_DAC_LDAC_PORT PORTD +/** Port bit number for Latch DAC Input. */ +#define MCP_DAC_LDAC_BIT 7 +#endif // USE_MCP_DAC_LDAC + +#endif // WavePinDefs_h diff --git a/Open_Theremin_V3/Open_Theremin_V3.ino b/Open_Theremin_V3/Open_Theremin_V3.ino new file mode 100644 index 0000000..c162e94 --- /dev/null +++ b/Open_Theremin_V3/Open_Theremin_V3.ino @@ -0,0 +1,79 @@ +/* + * Open.Theremin control software for Arduino.UNO + * Version 3.0 + * Copyright (C) 2010-2016 by Urs Gaudenz + * + * Open.Theremin.UNO control software is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Open.Theremin.UNO control software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * the Open.Theremin.UNO control software. If not, see . + * + * With important contributions by + * David Harvey + * Michael Margolis + */ + +/** +Building the code +================= +build.h contains #defines that control the compilation of the code + +ENABLE_SERIAL - if non-0, the build will include code to write the detected + pitch to the serial connection every 100 milliseconds. Set serial + receive baud to 115200 + +ENABLE_CV - if non-0, emit cv output on pin 6 (EXPERIMENTAL!) + +Structure of the code +===================== +** Open_Theremin_UNO.ino ** +This file. Creates and hooks up the application object to the arduino setup() +and loop() callbacks. + +** application.h/application.cpp ** +Main application object. Holds the state of the app (playing, calibrating), deals +with initialisation and the app main loop, reads pitch and volume changed flags +from the interrupt handlers and sets pitch and volume values which the timer +interrupt sends to the DAC. + +** OTPinDefs.h ** +Pin definitions for the DAC. + +** build.h ** +Preprocessor definitions for build (see above). + +** hw.h ** +Definitions for hardware button and LED. + +** ihandlers.h/ihandlers.cpp +Interrupt handler code and volatile variables implementing the communication between +the app and its input/output. + +** theremin_sinetable.c ** +Wavetable data for a variety of sounds. Switchable via the potentiometer. + +** timer.h/timer.cpp ** +Definitions and functions for setting delays in tics and in milliseconds + +*/ + +#include "application.h" + +Application app; + +void setup() { + app.setup(); +} + +void loop() { + app.loop(); +} + diff --git a/Open_Theremin_V3/application.cpp b/Open_Theremin_V3/application.cpp new file mode 100644 index 0000000..ba9c768 --- /dev/null +++ b/Open_Theremin_V3/application.cpp @@ -0,0 +1,480 @@ +#include "Arduino.h" + +#include "application.h" + +#include "hw.h" +#include "mcpDac.h" +#include "ihandlers.h" +#include "timer.h" + +const AppMode AppModeValues[] = {MUTE,NORMAL}; + +static int32_t pitchCalibrationBase = 0; +static int32_t pitchCalibrationBaseFreq = 0; +static int32_t pitchCalibrationConstant = 0; +static int32_t pitchSensitivityConstant = 70000; +static float qMeasurement = 0; + +static int32_t volCalibrationBase = 0; + +Application::Application() + : _state(PLAYING), + _mode(NORMAL) { +}; + +void Application::setup() { +#if SERIAL_ENABLED + Serial.begin(Application::BAUD); +#endif + + HW_LED1_ON;HW_LED2_OFF; + + pinMode(Application::BUTTON_PIN, INPUT_PULLUP); + pinMode(Application::LED_PIN_1, OUTPUT); + pinMode(Application::LED_PIN_2, OUTPUT); + + digitalWrite(Application::LED_PIN_1, HIGH); // turn the LED off by making the voltage LOW + + + initialiseTimer(); + initialiseInterrupts(); + + mcpDacInit(); +/// TEST + + calibrate_pitch(); + calibrate_volume(); + + + initialiseTimer(); + initialiseInterrupts(); + + +#if CV_ENABLED + initialiseCVOut(); +#endif + + playStartupSound(); + calibrate(); + +} + +void Application::initialiseTimer() { + ihInitialiseTimer(); +} + +void Application::initialiseInterrupts() { + ihInitialiseInterrupts(); +} + +void Application::InitialisePitchMeasurement() { + ihInitialisePitchMeasurement(); +} + +void Application::InitialiseVolumeMeasurement() { + ihInitialiseVolumeMeasurement(); +} + +unsigned long Application::GetQMeasurement() +{ + int qn=0; + + TCCR1B = (1<> 7; + + + if (_state == PLAYING && HW_BUTTON_PRESSED) { + _state = CALIBRATING; + resetTimer(); + } + + if (_state == CALIBRATING && HW_BUTTON_RELEASED) { + if (timerExpired(1500)) { + + _mode = nextMode(); + if (_mode==NORMAL) {HW_LED1_ON;HW_LED2_OFF;} else {HW_LED1_OFF;HW_LED2_ON;}; + // playModeSettingSound(); + + + } + _state = PLAYING; + }; + + if (_state == CALIBRATING && timerExpired(10000)) { + + HW_LED2_ON; + playCalibratingCountdownSound(); + + calibrate(); + + _mode=NORMAL; + HW_LED2_OFF; + + while (HW_BUTTON_PRESSED) + ; // NOP + _state = PLAYING; + }; + +#if CV_ENABLED + OCR0A = pitch & 0xff; +#endif + +#if SERIAL_ENABLED + if (timerExpired(TICKS_100_MILLIS)) { + resetTimer(); + Serial.write(pitch & 0xff); // Send char on serial (if used) + Serial.write((pitch >> 8) & 0xff); + } +#endif + + if (pitchValueAvailable) { // If capture event + + pitch_v=pitch; // Averaging pitch values + pitch_v=pitch_l+((pitch_v-pitch_l)>>2); + pitch_l=pitch_v; + + pitch_f=FREQ_FACTOR/pitch_v; + +//HW_LED2_ON; + + + // set wave frequency for each mode + switch (_mode) { + case MUTE : /* NOTHING! */; break; + case NORMAL : setWavetableSampleAdvance((pitchCalibrationBase-pitch_v)/4+2048-(pitchPotValue<<2)); break; + }; + + // HW_LED2_OFF; + + pitchValueAvailable = false; + } + + if (volumeValueAvailable) { + vol = max(vol, 5000); + + vol_v=vol; // Averaging volume values + vol_v=vol_l+((vol_v-vol_l)>>2); + vol_l=vol_v; + + switch (_mode) { + case MUTE: vol_v = 0; break; + case NORMAL: vol_v = MAX_VOLUME-(volCalibrationBase-vol_v)/2+(volumePotValue<<2)-1024; break; + }; + + // Limit and set volume value + vol_v = min(vol_v, 4095); + // vol_v = vol_v - (1 + MAX_VOLUME - (volumePotValue << 2)); + vol_v = vol_v ; + vol_v = max(vol_v, 0); + vScaledVolume = vol_v >> 4; + + volumeValueAvailable = false; + } + + goto mloop; // End of main loop +} + +void Application::calibrate() +{ + resetPitchFlag(); + resetTimer(); + savePitchCounter(); + while (!pitchValueAvailable && timerUnexpiredMillis(10)) + ; // NOP + pitchCalibrationBase = pitch; + pitchCalibrationBaseFreq = FREQ_FACTOR/pitchCalibrationBase; + pitchCalibrationConstant = FREQ_FACTOR/pitchSensitivityConstant/2+200; + + resetVolFlag(); + resetTimer(); + saveVolCounter(); + while (!volumeValueAvailable && timerUnexpiredMillis(10)) + ; // NOP + volCalibrationBase = vol; +} + +void Application::calibrate_pitch() +{ + +static int16_t pitchXn0 = 0; +static int16_t pitchXn1 = 0; +static int16_t pitchXn2 = 0; +static float q0 = 0; +static long pitchfn0 = 0; +static long pitchfn1 = 0; +static long pitchfn = 0; + + Serial.begin(9600); + Serial.println("Pitch calibration"); + + + InitialisePitchMeasurement(); + interrupts(); + mcpDacInit(); + +qMeasurement = GetQMeasurement(); +Serial.print("Q "); +Serial.println(qMeasurement); + +q0 = (16000000/qMeasurement*500000); +Serial.println(q0); + +pitchXn0 = 0; +pitchXn1 = 4095; + +pitchfn = q0-600; + +mcpDac2BSend(1600); + +mcpDac2ASend(pitchXn0); +delay(100); +pitchfn0 = GetPitchMeasurement(); + +mcpDac2ASend(pitchXn1); +delay(100); +pitchfn1 = GetPitchMeasurement(); + +Serial.print(pitchfn0); + Serial.print(" "); + Serial.println(pitchfn1); + + +while(abs(pitchfn0-pitchfn1)>10){ + +mcpDac2ASend(pitchXn0); +delay(100); +pitchfn0 = GetPitchMeasurement()-pitchfn; + +mcpDac2ASend(pitchXn1); +delay(100); +pitchfn1 = GetPitchMeasurement()-pitchfn; + +pitchXn2=pitchXn1-((pitchXn1-pitchXn0)*pitchfn1)/(pitchfn1-pitchfn0); + + Serial.print(pitchXn0); + Serial.print(" "); + Serial.println(pitchfn0); + + Serial.print(pitchXn1); + Serial.print(" "); + + Serial.println(pitchfn1); + Serial.println(pitchXn2); + + Serial.println(); +pitchXn0 = pitchXn1; +pitchXn1 = pitchXn2; + +HW_LED2_TOGGLE; + +} + digitalWrite(Application::LED_PIN_2, LOW); // turn the LED off by making the voltage LOW + +} + +void Application::calibrate_volume() +{ + + +static int16_t volumeXn0 = 0; +static int16_t volumeXn1 = 0; +static int16_t volumeXn2 = 0; +static float q0 = 0; +static long volumefn0 = 0; +static long volumefn1 = 0; +static long volumefn = 0; + + Serial.begin(9600); + Serial.println("Volume calibration"); + + InitialiseVolumeMeasurement(); + interrupts(); + mcpDacInit(); + + +volumeXn0 = 0; +volumeXn1 = 4095; + +q0 = (16000000/qMeasurement*460765); + +volumefn = q0-600; + + +mcpDac2BSend(volumeXn0); +delay_NOP(44316);//44316=100ms + +volumefn0 = GetVolumeMeasurement(); + +mcpDac2BSend(volumeXn1); + +delay_NOP(44316);//44316=100ms +volumefn1 = GetVolumeMeasurement(); + + +Serial.print(volumefn0); + Serial.print(" "); + Serial.println(volumefn1); + + +while(abs(volumefn0-volumefn1)>10){ + +mcpDac2BSend(volumeXn0); +delay_NOP(44316);//44316=100ms +volumefn0 = GetVolumeMeasurement()-volumefn; + +mcpDac2BSend(volumeXn1); +delay_NOP(44316);//44316=100ms +volumefn1 = GetVolumeMeasurement()-volumefn; + +volumeXn2=volumeXn1-((volumeXn1-volumeXn0)*volumefn1)/(volumefn1-volumefn0); + + Serial.print(volumeXn0); + Serial.print(" "); + Serial.println(volumefn0); + + Serial.print(volumeXn1); + Serial.print(" "); + + Serial.println(volumefn1); + Serial.println(volumeXn2); + + Serial.println(); +volumeXn0 = volumeXn1; +volumeXn1 = volumeXn2; +HW_LED2_TOGGLE; + +} + digitalWrite(Application::LED_PIN_2, HIGH); // turn the LED off by making the voltage LOW + +} + +void Application::hzToAddVal(float hz) { + setWavetableSampleAdvance((uint16_t)(hz * HZ_ADDVAL_FACTOR)); +} + +void Application::playNote(float hz, uint16_t milliseconds = 500, uint8_t volume = 255) { + vScaledVolume = volume; + hzToAddVal(hz); + millitimer(milliseconds); + vScaledVolume = 0; +} + +void Application::playStartupSound() { + playNote(MIDDLE_C, 150, 25); + playNote(MIDDLE_C * 2, 150, 25); + playNote(MIDDLE_C * 4, 150, 25); +} + +void Application::playCalibratingCountdownSound() { + for (int i = 0; i < 5; i++) { + playNote(MIDDLE_C, 500, 25); + millitimer(150); + } + playNote(MIDDLE_C * 2, 1000, 25); +} + +void Application::playModeSettingSound() { + for (int i = 0; i <= _mode; i++) { + playNote(MIDDLE_C * 2, 200, 25); + millitimer(100); + } +} + +void Application::delay_NOP(unsigned long time) { + volatile unsigned long i = 0; + for (i = 0; i < time; i++) { + __asm__ __volatile__ ("nop"); + } +} + + + + diff --git a/Open_Theremin_V3/application.h b/Open_Theremin_V3/application.h new file mode 100644 index 0000000..841b528 --- /dev/null +++ b/Open_Theremin_V3/application.h @@ -0,0 +1,69 @@ +#ifndef _APPLICATION_H +#define _APPLICATION_H + +#include + +#include "build.h" + +enum AppState {CALIBRATING = 0, PLAYING}; +enum AppMode {MUTE = 0, NORMAL}; + +class Application { + public: + Application(); + + void setup(); + void loop(); + + private: + static const uint16_t MAX_VOLUME = 4095; + static const uint32_t TRIM_PITCH_FACTOR = 33554432; + static const uint32_t FREQ_FACTOR = 1600000000; + + static const int16_t BUTTON_PIN = 6; + static const int16_t LED_PIN_1 = 18; + static const int16_t LED_PIN_2 = 19; + + + static const int16_t PITCH_POT = 0; + static const int16_t VOLUME_POT = 1; + static const int16_t WAVE_SELECT_POT = 2; + static const int16_t REGISTER_SELECT_POT = 3; + + + +#if SERIAL_ENABLED + static const int BAUD = 115200; +#endif + + AppState _state; + AppMode _mode; + + void calibrate(); + void calibrate_pitch(); + void calibrate_volume(); + + + AppMode nextMode(); + + void initialiseTimer(); + void initialiseInterrupts(); + void InitialisePitchMeasurement(); + void InitialiseVolumeMeasurement(); + unsigned long GetPitchMeasurement(); + unsigned long GetVolumeMeasurement(); + unsigned long GetQMeasurement(); + + + static const float HZ_ADDVAL_FACTOR = 2.09785; + static const float MIDDLE_C = 261.6; + + void playNote(float hz, uint16_t milliseconds, uint8_t volume); + void hzToAddVal(float hz); + void playStartupSound(); + void playCalibratingCountdownSound(); + void playModeSettingSound(); + void delay_NOP(unsigned long time); +}; + +#endif // _APPLICATION_H diff --git a/Open_Theremin_V3/build.h b/Open_Theremin_V3/build.h new file mode 100644 index 0000000..bfa8e72 --- /dev/null +++ b/Open_Theremin_V3/build.h @@ -0,0 +1,14 @@ +// Build definitions + +#ifndef _BUILD_H +#define _BUILD_H + + +// Set to build with serial support +#define SERIAL_ENABLED 0 + +// Set to build with control voltage output (experimental) +#define CV_ENABLED 0 + + +#endif // _BUILD_H diff --git a/Open_Theremin_V3/hw.h b/Open_Theremin_V3/hw.h new file mode 100644 index 0000000..f28c2eb --- /dev/null +++ b/Open_Theremin_V3/hw.h @@ -0,0 +1,19 @@ +#ifndef _HW_H +#define _HW_H + +#define HW_BUTTON_STATE (PIND & (1<>6) & 0x3ff; + + // Read next wave table value (3.0us) + // The slightly odd tactic here is to provide compile-time expressions for the wavetable + // positions. Making addr1 the index into the wavtables array breaks the time limit for + // the interrupt handler + switch (vWavetableSelector) { + case 1: waveSample = (int16_t) pgm_read_word_near(wavetables[1] + offset); break; + case 2: waveSample = (int16_t) pgm_read_word_near(wavetables[2] + offset); break; + case 3: waveSample = (int16_t) pgm_read_word_near(wavetables[3] + offset); break; + case 4: waveSample = (int16_t) pgm_read_word_near(wavetables[4] + offset); break; + case 5: waveSample = (int16_t) pgm_read_word_near(wavetables[5] + offset); break; + case 6: waveSample = (int16_t) pgm_read_word_near(wavetables[6] + offset); break; + case 7: waveSample = (int16_t) pgm_read_word_near(wavetables[7] + offset); break; + default: waveSample = (int16_t) pgm_read_word_near(wavetables[0] + offset); break; + }; + + if (waveSample > 0) { // multiply 16 bit wave number by 8 bit volume value (11.2us / 5.4us) + scaledSample = MCP_DAC_BASE + (mul_16_8(waveSample, vScaledVolume) >> 9); + } else { + scaledSample = MCP_DAC_BASE - (mul_16_8(-waveSample, vScaledVolume) >> 9); + } + + mcpDacSend(scaledSample); //Send result to Digital to Analogue Converter (audio out) (9.6 us) + + pointer = pointer + vPointerIncrement; // increment table pointer (ca. 2us) + incrementTimer(); // update 32us timer + + if (PC_STATE) debounce_p++; + if (debounce_p == 3) { + noInterrupts(); + pitch_counter = ICR1; // Get Timer-Counter 1 value + pitch = (pitch_counter - pitch_counter_l); // Counter change since last interrupt -> pitch value + pitch_counter_l = pitch_counter; // Set actual value as new last value + }; + + if (debounce_p == 5) { + pitchValueAvailable = true; + }; + + if (INT0_STATE) debounce_v++; + if (debounce_v == 3) { + noInterrupts(); + vol_counter = vol_counter_i; // Get Timer-Counter 1 value + vol = (vol_counter - vol_counter_l); // Counter change since last interrupt + vol_counter_l = vol_counter; // Set actual value as new last value + }; + + if (debounce_v == 5) { + volumeValueAvailable = true; + }; + + noInterrupts(); + enableInt1(); +} + +/* VOLUME read - interrupt service routine for capturing volume counter value */ +ISR (INT0_vect) { + vol_counter_i = TCNT1; + debounce_v = 0; +}; + + +/* PITCH read - interrupt service routine for capturing pitch counter value */ +ISR (TIMER1_CAPT_vect) { + debounce_p = 0; +}; + + +/* PITCH read absolute frequency - interrupt service routine for calibration measurement */ +ISR(TIMER0_COMPA_vect) +{ + timer_overflow_counter++; + } + +/* VOLUME read absolute frequency - interrupt service routine for calibration measurement */ +ISR(TIMER1_OVF_vect) +{ + timer_overflow_counter++; +} + + diff --git a/Open_Theremin_V3/ihandlers.h b/Open_Theremin_V3/ihandlers.h new file mode 100644 index 0000000..d6de5d0 --- /dev/null +++ b/Open_Theremin_V3/ihandlers.h @@ -0,0 +1,44 @@ +#ifndef _IHANDLERS_H +#define _IHANDLERS_H + +extern volatile uint16_t pitch; // Pitch value +extern volatile uint16_t vol; // Volume value +extern volatile uint8_t vScaledVolume; // Volume byte + +extern volatile uint16_t pitch_counter; // Pitch counter +extern volatile uint16_t pitch_counter_l; // Last value of pitch counter + +extern volatile uint16_t vol_counter; // Pitch counter +extern volatile uint16_t vol_counter_l; // Last value of pitch counter + +extern volatile uint16_t timer_overflow_counter; // counter for frequency measurement + + +extern volatile bool volumeValueAvailable; // Volume read flag +extern volatile bool pitchValueAvailable; // Pitch read flag +extern volatile bool reenableInt1; // Pitch read flag + +extern volatile uint8_t vWavetableSelector; +extern volatile uint16_t vPointerIncrement; // Table pointer increment + +inline void resetPitchFlag() { pitchValueAvailable = false; } +inline void resetVolFlag() { volumeValueAvailable = false; } + +inline void savePitchCounter() { pitch_counter_l=pitch_counter; } +inline void saveVolCounter() { vol_counter_l=vol_counter; }; + +inline void setWavetableSampleAdvance(uint16_t val) { vPointerIncrement = val;} + +inline void disableInt1() { EIMSK &= ~ (1 << INT1); } +inline void enableInt1() { if (reenableInt1) EIMSK |= (1 << INT1); } + +void ihInitialiseTimer(); +void ihInitialiseInterrupts(); +void ihInitialisePitchMeasurement(); +void ihInitialiseVolumeMeasurement(); +void resetPitchFlag(); +void resetVolFlag(); +void savePitchCounter(); +void saveVolCounter(); + +#endif // _IHANDLERS_H diff --git a/Open_Theremin_V3/mcpDac.h b/Open_Theremin_V3/mcpDac.h new file mode 100644 index 0000000..ddbb1ce --- /dev/null +++ b/Open_Theremin_V3/mcpDac.h @@ -0,0 +1,151 @@ +/* Arduino WaveHC Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino WaveHC Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino WaveHC Library. If not, see + * . + */ +/** + * Macros and inline functions for MCP4921 DAC + */ +#ifndef mcpDac_h +#define mcpDac_h + +#include +#include "OTPinDefs.h" + + +//------------------------------------------------------------------------------ +#define mcpDacCsLow() MCP_DAC_CS_PORT &= ~_BV(MCP_DAC_CS_BIT) +#define mcpDacCsHigh() MCP_DAC_CS_PORT |= _BV(MCP_DAC_CS_BIT) + +#define mcpDac2CsLow() MCP_DAC_CS_PORT &= ~_BV(MCP_DAC2_CS_BIT) +#define mcpDac2CsHigh() MCP_DAC_CS_PORT |= _BV(MCP_DAC2_CS_BIT) + +#define mcpDacSckLow() MCP_DAC_SCK_PORT &= ~_BV(MCP_DAC_SCK_BIT) +#define mcpDacSckHigh() MCP_DAC_SCK_PORT |= _BV(MCP_DAC_SCK_BIT) +#define mcpDacSckPulse() {mcpDacSckHigh();mcpDacSckLow();} + +#define mcpDacSdiLow() MCP_DAC_SDI_PORT &= ~_BV(MCP_DAC_SDI_BIT) +#define mcpDacSdiHigh() MCP_DAC_SDI_PORT |= _BV(MCP_DAC_SDI_BIT) +#define mcpDacSdiSet(v) if(v){mcpDacSdiHigh();}else{mcpDacSdiLow();} + +// send bit b of d +#define mcpDacSendBit(d, b) {mcpDacSdiSet(d&_BV(b));mcpDacSckPulse();} + +//------------------------------------------------------------------------------ +// init dac I/O ports +inline void mcpDacInit(void) { + // set all to output mode + MCP_DAC_CS_DDR |= _BV(MCP_DAC_CS_BIT); + MCP_DAC2_CS_DDR |= _BV(MCP_DAC2_CS_BIT); + + MCP_DAC_SCK_DDR |= _BV(MCP_DAC_SCK_BIT); + MCP_DAC_SDI_DDR |= _BV(MCP_DAC_SDI_BIT); + // chip select high + mcpDacCsHigh(); + mcpDac2CsHigh(); + +#if USE_MCP_DAC_LDAC + // LDAC low always - use unbuffered mode + MCP_DAC_LDAC_DDR |= _BV(MCP_DAC_LDAC_BIT); + MCP_DAC_LDAC_PORT &= ~_BV(MCP_DAC_LDAC_BIT); +#endif // USE_MCP_DAC_LDAC +} +//------------------------------------------------------------------------------ +// send 12 bits to dac +// trusted compiler to optimize and it does +// csLow to csHigh takes 8 - 9 usec on a 16 MHz Arduino +inline void mcpDacSend(uint16_t data) { + mcpDacCsLow(); + // send DAC config bits + mcpDacSdiLow(); + mcpDacSckPulse(); // DAC A + mcpDacSdiHigh(); + mcpDacSckPulse(); // buffered REF + + mcpDacSckPulse(); // 1X gain + mcpDacSckPulse(); // no SHDN + // send 12 data bits + mcpDacSendBit(data, 11); + mcpDacSendBit(data, 10); + mcpDacSendBit(data, 9); + mcpDacSendBit(data, 8); + mcpDacSendBit(data, 7); + mcpDacSendBit(data, 6); + mcpDacSendBit(data, 5); + mcpDacSendBit(data, 4); + mcpDacSendBit(data, 3); + mcpDacSendBit(data, 2); + mcpDacSendBit(data, 1); + mcpDacSendBit(data, 0); + mcpDacCsHigh(); +} + +inline void mcpDac2ASend(uint16_t data) { + mcpDac2CsLow(); + // send DAC config bits + mcpDacSdiLow(); + mcpDacSckPulse(); // DAC A + mcpDacSdiHigh(); + mcpDacSckPulse(); // buffered REF + + mcpDacSckPulse(); // 1X gain + mcpDacSckPulse(); // no SHDN + // send 12 data bits + mcpDacSendBit(data, 11); + mcpDacSendBit(data, 10); + mcpDacSendBit(data, 9); + mcpDacSendBit(data, 8); + mcpDacSendBit(data, 7); + mcpDacSendBit(data, 6); + mcpDacSendBit(data, 5); + mcpDacSendBit(data, 4); + mcpDacSendBit(data, 3); + mcpDacSendBit(data, 2); + mcpDacSendBit(data, 1); + mcpDacSendBit(data, 0); + mcpDac2CsHigh(); +} + +inline void mcpDac2BSend(uint16_t data) { + mcpDac2CsLow(); + // send DAC config bits + mcpDacSdiHigh(); + mcpDacSckPulse(); // DAC A + mcpDacSdiHigh(); + mcpDacSckPulse(); // buffered REF + + mcpDacSckPulse(); // 1X gain + mcpDacSckPulse(); // no SHDN + // send 12 data bits + mcpDacSendBit(data, 11); + mcpDacSendBit(data, 10); + mcpDacSendBit(data, 9); + mcpDacSendBit(data, 8); + mcpDacSendBit(data, 7); + mcpDacSendBit(data, 6); + mcpDacSendBit(data, 5); + mcpDacSendBit(data, 4); + mcpDacSendBit(data, 3); + mcpDacSendBit(data, 2); + mcpDacSendBit(data, 1); + mcpDacSendBit(data, 0); + mcpDac2CsHigh(); +} + + + +#endif //mcpDac_h diff --git a/Open_Theremin_V3/theremin_sintable.c b/Open_Theremin_V3/theremin_sintable.c new file mode 100644 index 0000000..44ea01b --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable.c @@ -0,0 +1,1032 @@ +/* Theremin WAVE Table - 1024 entries full table,\ amplitude -2048..2048*/ + +#include + +const int16_t sine_table[1024] PROGMEM = {\ +273,\ +288,\ +302,\ +317,\ +330,\ +345,\ +358,\ +373,\ +387,\ +401,\ +416,\ +429,\ +444,\ +457,\ +472,\ +485,\ +500,\ +513,\ +527,\ +540,\ +555,\ +568,\ +581,\ +596,\ +609,\ +623,\ +636,\ +650,\ +663,\ +676,\ +690,\ +703,\ +716,\ +730,\ +743,\ +756,\ +770,\ +783,\ +796,\ +808,\ +821,\ +835,\ +848,\ +860,\ +873,\ +885,\ +898,\ +911,\ +923,\ +936,\ +948,\ +960,\ +973,\ +985,\ +998,\ +1010,\ +1022,\ +1033,\ +1046,\ +1058,\ +1070,\ +1081,\ +1093,\ +1105,\ +1116,\ +1128,\ +1140,\ +1151,\ +1163,\ +1174,\ +1185,\ +1197,\ +1207,\ +1219,\ +1230,\ +1241,\ +1251,\ +1263,\ +1273,\ +1284,\ +1295,\ +1305,\ +1316,\ +1326,\ +1336,\ +1347,\ +1357,\ +1368,\ +1377,\ +1387,\ +1397,\ +1407,\ +1417,\ +1427,\ +1436,\ +1446,\ +1455,\ +1465,\ +1474,\ +1483,\ +1493,\ +1502,\ +1511,\ +1520,\ +1528,\ +1537,\ +1546,\ +1555,\ +1563,\ +1572,\ +1581,\ +1589,\ +1598,\ +1606,\ +1614,\ +1623,\ +1630,\ +1639,\ +1646,\ +1654,\ +1662,\ +1669,\ +1677,\ +1684,\ +1691,\ +1700,\ +1707,\ +1714,\ +1720,\ +1727,\ +1735,\ +1742,\ +1749,\ +1755,\ +1762,\ +1768,\ +1775,\ +1781,\ +1787,\ +1794,\ +1800,\ +1806,\ +1812,\ +1818,\ +1823,\ +1829,\ +1835,\ +1841,\ +1847,\ +1851,\ +1857,\ +1863,\ +1868,\ +1873,\ +1878,\ +1883,\ +1888,\ +1893,\ +1898,\ +1902,\ +1907,\ +1911,\ +1916,\ +1921,\ +1924,\ +1929,\ +1933,\ +1937,\ +1941,\ +1945,\ +1949,\ +1953,\ +1956,\ +1959,\ +1963,\ +1966,\ +1970,\ +1973,\ +1977,\ +1980,\ +1982,\ +1986,\ +1989,\ +1992,\ +1994,\ +1997,\ +2000,\ +2002,\ +2004,\ +2007,\ +2009,\ +2011,\ +2014,\ +2016,\ +2018,\ +2020,\ +2022,\ +2023,\ +2026,\ +2027,\ +2028,\ +2031,\ +2032,\ +2033,\ +2035,\ +2036,\ +2036,\ +2038,\ +2039,\ +2039,\ +2041,\ +2041,\ +2042,\ +2043,\ +2043,\ +2045,\ +2045,\ +2045,\ +2046,\ +2045,\ +2046,\ +2046,\ +2047,\ +2046,\ +2046,\ +2046,\ +2046,\ +2046,\ +2045,\ +2045,\ +2045,\ +2044,\ +2044,\ +2043,\ +2042,\ +2041,\ +2041,\ +2040,\ +2039,\ +2038,\ +2037,\ +2035,\ +2034,\ +2033,\ +2031,\ +2030,\ +2029,\ +2028,\ +2026,\ +2024,\ +2023,\ +2021,\ +2019,\ +2018,\ +2016,\ +2014,\ +2012,\ +2010,\ +2008,\ +2006,\ +2003,\ +2001,\ +1999,\ +1996,\ +1994,\ +1991,\ +1988,\ +1986,\ +1983,\ +1980,\ +1977,\ +1975,\ +1972,\ +1969,\ +1967,\ +1963,\ +1960,\ +1957,\ +1953,\ +1951,\ +1947,\ +1944,\ +1941,\ +1937,\ +1934,\ +1930,\ +1926,\ +1923,\ +1920,\ +1915,\ +1912,\ +1908,\ +1904,\ +1900,\ +1897,\ +1893,\ +1889,\ +1885,\ +1880,\ +1876,\ +1872,\ +1867,\ +1863,\ +1859,\ +1855,\ +1850,\ +1845,\ +1841,\ +1837,\ +1832,\ +1828,\ +1823,\ +1818,\ +1813,\ +1809,\ +1803,\ +1799,\ +1793,\ +1789,\ +1784,\ +1779,\ +1773,\ +1768,\ +1763,\ +1758,\ +1753,\ +1747,\ +1742,\ +1736,\ +1731,\ +1726,\ +1721,\ +1715,\ +1710,\ +1704,\ +1698,\ +1692,\ +1687,\ +1681,\ +1675,\ +1670,\ +1664,\ +1658,\ +1652,\ +1646,\ +1640,\ +1634,\ +1628,\ +1622,\ +1616,\ +1610,\ +1604,\ +1597,\ +1591,\ +1585,\ +1579,\ +1573,\ +1566,\ +1559,\ +1553,\ +1546,\ +1540,\ +1533,\ +1527,\ +1520,\ +1514,\ +1507,\ +1500,\ +1493,\ +1486,\ +1480,\ +1473,\ +1466,\ +1460,\ +1452,\ +1445,\ +1439,\ +1431,\ +1425,\ +1417,\ +1411,\ +1403,\ +1396,\ +1389,\ +1381,\ +1375,\ +1367,\ +1360,\ +1352,\ +1345,\ +1337,\ +1330,\ +1323,\ +1315,\ +1308,\ +1301,\ +1293,\ +1285,\ +1277,\ +1269,\ +1262,\ +1254,\ +1246,\ +1239,\ +1231,\ +1223,\ +1215,\ +1207,\ +1199,\ +1191,\ +1183,\ +1176,\ +1168,\ +1159,\ +1151,\ +1143,\ +1135,\ +1127,\ +1118,\ +1111,\ +1102,\ +1094,\ +1086,\ +1077,\ +1069,\ +1061,\ +1052,\ +1044,\ +1035,\ +1027,\ +1018,\ +1010,\ +1001,\ +993,\ +984,\ +976,\ +966,\ +958,\ +949,\ +941,\ +931,\ +923,\ +914,\ +905,\ +897,\ +887,\ +879,\ +869,\ +860,\ +852,\ +842,\ +833,\ +824,\ +815,\ +806,\ +796,\ +788,\ +778,\ +769,\ +760,\ +750,\ +741,\ +732,\ +722,\ +713,\ +703,\ +694,\ +685,\ +675,\ +666,\ +656,\ +647,\ +637,\ +627,\ +618,\ +608,\ +599,\ +588,\ +579,\ +569,\ +559,\ +549,\ +540,\ +529,\ +520,\ +510,\ +500,\ +490,\ +480,\ +470,\ +460,\ +450,\ +440,\ +430,\ +420,\ +410,\ +400,\ +389,\ +380,\ +369,\ +359,\ +348,\ +339,\ +328,\ +317,\ +307,\ +297,\ +287,\ +276,\ +266,\ +255,\ +245,\ +234,\ +224,\ +213,\ +203,\ +192,\ +182,\ +171,\ +160,\ +150,\ +139,\ +128,\ +118,\ +107,\ +97,\ +85,\ +75,\ +64,\ +54,\ +42,\ +32,\ +21,\ +10,\ +0,\ +-11,\ +-22,\ +-33,\ +-44,\ +-55,\ +-66,\ +-77,\ +-88,\ +-99,\ +-109,\ +-121,\ +-132,\ +-143,\ +-154,\ +-165,\ +-176,\ +-187,\ +-198,\ +-209,\ +-220,\ +-231,\ +-242,\ +-253,\ +-264,\ +-275,\ +-287,\ +-298,\ +-309,\ +-320,\ +-331,\ +-343,\ +-354,\ +-365,\ +-376,\ +-387,\ +-398,\ +-410,\ +-421,\ +-432,\ +-443,\ +-455,\ +-465,\ +-477,\ +-488,\ +-499,\ +-511,\ +-521,\ +-532,\ +-544,\ +-555,\ +-567,\ +-578,\ +-588,\ +-599,\ +-611,\ +-622,\ +-633,\ +-644,\ +-656,\ +-667,\ +-678,\ +-689,\ +-700,\ +-711,\ +-723,\ +-733,\ +-744,\ +-756,\ +-767,\ +-778,\ +-789,\ +-799,\ +-811,\ +-822,\ +-833,\ +-844,\ +-854,\ +-866,\ +-877,\ +-887,\ +-898,\ +-909,\ +-920,\ +-931,\ +-941,\ +-952,\ +-963,\ +-974,\ +-985,\ +-996,\ +-1006,\ +-1017,\ +-1028,\ +-1038,\ +-1049,\ +-1060,\ +-1070,\ +-1081,\ +-1091,\ +-1101,\ +-1112,\ +-1122,\ +-1133,\ +-1144,\ +-1154,\ +-1163,\ +-1174,\ +-1184,\ +-1195,\ +-1205,\ +-1215,\ +-1225,\ +-1235,\ +-1245,\ +-1255,\ +-1265,\ +-1275,\ +-1285,\ +-1295,\ +-1304,\ +-1314,\ +-1324,\ +-1334,\ +-1343,\ +-1353,\ +-1363,\ +-1372,\ +-1382,\ +-1392,\ +-1400,\ +-1410,\ +-1419,\ +-1428,\ +-1438,\ +-1447,\ +-1456,\ +-1465,\ +-1474,\ +-1483,\ +-1492,\ +-1501,\ +-1509,\ +-1518,\ +-1528,\ +-1536,\ +-1545,\ +-1553,\ +-1562,\ +-1570,\ +-1578,\ +-1587,\ +-1595,\ +-1603,\ +-1611,\ +-1619,\ +-1628,\ +-1636,\ +-1643,\ +-1651,\ +-1660,\ +-1667,\ +-1674,\ +-1683,\ +-1690,\ +-1697,\ +-1704,\ +-1712,\ +-1719,\ +-1726,\ +-1734,\ +-1741,\ +-1748,\ +-1755,\ +-1762,\ +-1768,\ +-1776,\ +-1782,\ +-1788,\ +-1796,\ +-1802,\ +-1808,\ +-1815,\ +-1821,\ +-1826,\ +-1833,\ +-1839,\ +-1844,\ +-1850,\ +-1856,\ +-1862,\ +-1867,\ +-1873,\ +-1879,\ +-1884,\ +-1890,\ +-1895,\ +-1899,\ +-1904,\ +-1910,\ +-1915,\ +-1919,\ +-1924,\ +-1929,\ +-1933,\ +-1938,\ +-1942,\ +-1946,\ +-1951,\ +-1955,\ +-1959,\ +-1963,\ +-1966,\ +-1970,\ +-1975,\ +-1978,\ +-1982,\ +-1985,\ +-1988,\ +-1991,\ +-1994,\ +-1997,\ +-2000,\ +-2003,\ +-2006,\ +-2009,\ +-2012,\ +-2014,\ +-2017,\ +-2019,\ +-2020,\ +-2023,\ +-2025,\ +-2027,\ +-2029,\ +-2030,\ +-2032,\ +-2034,\ +-2035,\ +-2036,\ +-2038,\ +-2039,\ +-2040,\ +-2041,\ +-2042,\ +-2042,\ +-2043,\ +-2043,\ +-2044,\ +-2044,\ +-2045,\ +-2045,\ +-2046,\ +-2045,\ +-2045,\ +-2045,\ +-2044,\ +-2044,\ +-2044,\ +-2043,\ +-2042,\ +-2041,\ +-2041,\ +-2040,\ +-2038,\ +-2037,\ +-2036,\ +-2034,\ +-2033,\ +-2031,\ +-2029,\ +-2027,\ +-2026,\ +-2024,\ +-2022,\ +-2020,\ +-2016,\ +-2014,\ +-2012,\ +-2009,\ +-2006,\ +-2003,\ +-2001,\ +-1997,\ +-1994,\ +-1991,\ +-1988,\ +-1984,\ +-1981,\ +-1977,\ +-1973,\ +-1969,\ +-1966,\ +-1961,\ +-1957,\ +-1952,\ +-1949,\ +-1944,\ +-1939,\ +-1934,\ +-1929,\ +-1924,\ +-1919,\ +-1914,\ +-1909,\ +-1904,\ +-1898,\ +-1893,\ +-1888,\ +-1882,\ +-1876,\ +-1871,\ +-1864,\ +-1858,\ +-1852,\ +-1846,\ +-1839,\ +-1833,\ +-1826,\ +-1820,\ +-1814,\ +-1806,\ +-1800,\ +-1792,\ +-1785,\ +-1778,\ +-1770,\ +-1764,\ +-1756,\ +-1748,\ +-1740,\ +-1733,\ +-1725,\ +-1717,\ +-1709,\ +-1700,\ +-1692,\ +-1684,\ +-1675,\ +-1667,\ +-1658,\ +-1649,\ +-1641,\ +-1632,\ +-1623,\ +-1614,\ +-1605,\ +-1595,\ +-1586,\ +-1577,\ +-1568,\ +-1558,\ +-1548,\ +-1539,\ +-1529,\ +-1519,\ +-1509,\ +-1499,\ +-1490,\ +-1479,\ +-1468,\ +-1458,\ +-1447,\ +-1438,\ +-1427,\ +-1417,\ +-1405,\ +-1394,\ +-1383,\ +-1373,\ +-1362,\ +-1350,\ +-1340,\ +-1329,\ +-1317,\ +-1306,\ +-1294,\ +-1282,\ +-1272,\ +-1260,\ +-1248,\ +-1236,\ +-1224,\ +-1212,\ +-1200,\ +-1188,\ +-1176,\ +-1164,\ +-1152,\ +-1140,\ +-1127,\ +-1114,\ +-1102,\ +-1090,\ +-1077,\ +-1065,\ +-1052,\ +-1039,\ +-1026,\ +-1014,\ +-1001,\ +-988,\ +-974,\ +-962,\ +-949,\ +-936,\ +-922,\ +-909,\ +-896,\ +-882,\ +-869,\ +-856,\ +-843,\ +-829,\ +-815,\ +-801,\ +-788,\ +-775,\ +-760,\ +-747,\ +-733,\ +-719,\ +-706,\ +-692,\ +-678,\ +-664,\ +-649,\ +-636,\ +-622,\ +-607,\ +-594,\ +-580,\ +-565,\ +-551,\ +-537,\ +-523,\ +-509,\ +-494,\ +-480,\ +-465,\ +-451,\ +-437,\ +-422,\ +-408,\ +-394,\ +-379,\ +-365,\ +-351,\ +-336,\ +-322,\ +-307,\ +-292,\ +-278,\ +-264,\ +-250,\ +-234,\ +-220,\ +-206,\ +-190,\ +-176,\ +-162,\ +-147,\ +-133,\ +-118,\ +-103,\ +-89,\ +-74,\ +-60,\ +-44,\ +-30,\ +-16,\ +-1,\ +13,\ +28,\ +42,\ +57,\ +71,\ +86,\ +100,\ +115,\ +129,\ +144,\ +159,\ +173,\ +188,\ +201,\ +216,\ +230,\ +245,\ +259,\ +}; + + diff --git a/Open_Theremin_V3/theremin_sintable2.c b/Open_Theremin_V3/theremin_sintable2.c new file mode 100644 index 0000000..42ecf37 --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable2.c @@ -0,0 +1,1032 @@ +/* Theremin WAVE Table "Phoenix" - 1024 entries full table, amplitude -2048..2048*/ + +#include + +const int16_t sine_table2[1024] PROGMEM = {\ +0, +2, +3, +5, +6, +10, +11, +13, +14, +16, +19, +21, +22, +24, +26, +29, +30, +32, +33, +36, +38, +40, +41, +43, +46, +48, +49, +51, +53, +56, +58, +59, +61, +63, +67, +69, +70, +72, +74, +78, +80, +82, +84, +88, +89, +92, +94, +96, +100, +102, +104, +106, +108, +112, +114, +116, +118, +120, +124, +126, +128, +130, +132, +136, +138, +140, +142, +146, +148, +150, +152, +154, +158, +161, +163, +165, +167, +171, +174, +176, +178, +181, +185, +188, +190, +192, +197, +199, +202, +204, +207, +212, +214, +217, +219, +222, +227, +229, +232, +235, +237, +243, +246, +248, +251, +254, +260, +263, +267, +270, +276, +279, +283, +286, +290, +297, +300, +304, +308, +312, +319, +323, +327, +331, +335, +343, +348, +352, +356, +361, +369, +374, +378, +383, +392, +397, +401, +406, +410, +420, +424, +429, +433, +438, +447, +452, +457, +462, +467, +477, +482, +487, +493, +504, +509, +515, +520, +525, +538, +544, +550, +556, +562, +574, +580, +587, +594, +601, +614, +621, +627, +636, +644, +660, +669, +677, +685, +703, +713, +723, +733, +742, +762, +772, +783, +795, +806, +828, +840, +851, +862, +875, +901, +913, +926, +939, +952, +978, +992, +1005, +1019, +1047, +1060, +1074, +1088, +1102, +1130, +1144, +1158, +1172, +1186, +1213, +1226, +1240, +1253, +1267, +1294, +1307, +1319, +1332, +1358, +1371, +1383, +1396, +1408, +1432, +1443, +1455, +1467, +1479, +1501, +1512, +1523, +1533, +1544, +1565, +1576, +1586, +1595, +1605, +1624, +1634, +1643, +1653, +1670, +1679, +1688, +1696, +1705, +1722, +1730, +1738, +1746, +1754, +1770, +1778, +1786, +1792, +1799, +1813, +1820, +1827, +1834, +1841, +1853, +1859, +1865, +1871, +1884, +1890, +1895, +1900, +1906, +1916, +1921, +1927, +1932, +1936, +1945, +1950, +1954, +1959, +1964, +1972, +1976, +1979, +1983, +1990, +1994, +1998, +2001, +2004, +2010, +2013, +2016, +2020, +2023, +2027, +2029, +2031, +2033, +2035, +2039, +2040, +2041, +2042, +2042, +2044, +2044, +2045, +2045, +2044, +2043, +2043, +2043, +2042, +2041, +2039, +2038, +2037, +2036, +2034, +2032, +2030, +2028, +2025, +2021, +2019, +2016, +2014, +2010, +2003, +1999, +1995, +1992, +1984, +1979, +1974, +1969, +1964, +1954, +1949, +1944, +1937, +1931, +1918, +1912, +1906, +1899, +1893, +1877, +1869, +1861, +1853, +1838, +1830, +1820, +1811, +1802, +1783, +1774, +1764, +1755, +1744, +1723, +1712, +1701, +1691, +1680, +1657, +1645, +1633, +1621, +1609, +1584, +1572, +1559, +1545, +1519, +1505, +1492, +1478, +1465, +1437, +1422, +1408, +1394, +1380, +1352, +1337, +1322, +1307, +1292, +1261, +1246, +1231, +1215, +1184, +1168, +1152, +1136, +1120, +1088, +1071, +1055, +1038, +1022, +989, +972, +955, +938, +921, +887, +871, +854, +837, +819, +785, +767, +750, +733, +698, +680, +662, +645, +627, +592, +574, +556, +538, +520, +484, +466, +448, +430, +412, +376, +357, +339, +321, +302, +266, +248, +229, +211, +175, +156, +138, +120, +102, +66, +48, +30, +12, +-6, +-42, +-59, +-77, +-95, +-113, +-148, +-166, +-184, +-202, +-236, +-254, +-272, +-289, +-306, +-341, +-358, +-376, +-393, +-410, +-444, +-461, +-478, +-495, +-511, +-545, +-562, +-578, +-595, +-611, +-645, +-661, +-678, +-694, +-726, +-742, +-758, +-774, +-790, +-821, +-836, +-852, +-867, +-882, +-913, +-929, +-943, +-958, +-973, +-1003, +-1018, +-1032, +-1047, +-1061, +-1089, +-1103, +-1118, +-1132, +-1160, +-1173, +-1186, +-1199, +-1213, +-1239, +-1252, +-1266, +-1278, +-1290, +-1315, +-1328, +-1340, +-1352, +-1365, +-1388, +-1399, +-1411, +-1422, +-1445, +-1456, +-1467, +-1477, +-1487, +-1508, +-1518, +-1529, +-1539, +-1548, +-1567, +-1576, +-1586, +-1595, +-1605, +-1623, +-1631, +-1640, +-1648, +-1657, +-1674, +-1683, +-1691, +-1698, +-1714, +-1722, +-1729, +-1737, +-1745, +-1759, +-1767, +-1774, +-1781, +-1788, +-1802, +-1809, +-1815, +-1822, +-1828, +-1841, +-1847, +-1854, +-1859, +-1865, +-1876, +-1882, +-1887, +-1893, +-1903, +-1908, +-1913, +-1918, +-1923, +-1933, +-1938, +-1942, +-1946, +-1950, +-1959, +-1963, +-1967, +-1971, +-1975, +-1981, +-1985, +-1988, +-1991, +-1998, +-2000, +-2003, +-2005, +-2008, +-2013, +-2015, +-2018, +-2020, +-2022, +-2026, +-2028, +-2030, +-2031, +-2033, +-2036, +-2037, +-2038, +-2039, +-2040, +-2043, +-2043, +-2043, +-2044, +-2045, +-2045, +-2045, +-2046, +-2046, +-2045, +-2045, +-2045, +-2045, +-2045, +-2045, +-2044, +-2044, +-2044, +-2043, +-2042, +-2042, +-2041, +-2040, +-2039, +-2037, +-2036, +-2035, +-2034, +-2032, +-2030, +-2029, +-2027, +-2026, +-2023, +-2021, +-2019, +-2018, +-2016, +-2012, +-2011, +-2009, +-2007, +-2005, +-2000, +-1998, +-1996, +-1994, +-1989, +-1987, +-1984, +-1982, +-1979, +-1974, +-1972, +-1969, +-1967, +-1965, +-1960, +-1957, +-1955, +-1953, +-1951, +-1946, +-1944, +-1942, +-1940, +-1938, +-1934, +-1932, +-1930, +-1929, +-1925, +-1923, +-1922, +-1920, +-1919, +-1916, +-1915, +-1914, +-1912, +-1911, +-1909, +-1908, +-1907, +-1906, +-1905, +-1903, +-1902, +-1901, +-1901, +-1900, +-1898, +-1897, +-1896, +-1896, +-1894, +-1893, +-1892, +-1891, +-1890, +-1888, +-1887, +-1885, +-1884, +-1882, +-1880, +-1878, +-1876, +-1873, +-1870, +-1865, +-1863, +-1860, +-1857, +-1850, +-1846, +-1843, +-1839, +-1835, +-1828, +-1823, +-1819, +-1814, +-1810, +-1801, +-1797, +-1792, +-1787, +-1782, +-1773, +-1768, +-1763, +-1758, +-1753, +-1742, +-1737, +-1732, +-1726, +-1716, +-1711, +-1705, +-1699, +-1694, +-1683, +-1677, +-1672, +-1666, +-1661, +-1649, +-1644, +-1638, +-1633, +-1627, +-1616, +-1610, +-1605, +-1599, +-1594, +-1583, +-1577, +-1572, +-1566, +-1554, +-1549, +-1543, +-1537, +-1531, +-1518, +-1511, +-1504, +-1497, +-1490, +-1477, +-1468, +-1460, +-1452, +-1443, +-1426, +-1418, +-1410, +-1400, +-1381, +-1371, +-1361, +-1351, +-1342, +-1321, +-1311, +-1300, +-1290, +-1279, +-1258, +-1247, +-1237, +-1226, +-1215, +-1194, +-1183, +-1173, +-1162, +-1151, +-1130, +-1120, +-1109, +-1099, +-1078, +-1067, +-1057, +-1047, +-1037, +-1016, +-1006, +-996, +-987, +-977, +-958, +-948, +-939, +-929, +-919, +-902, +-893, +-884, +-876, +-867, +-849, +-841, +-833, +-825, +-809, +-801, +-793, +-784, +-777, +-762, +-755, +-747, +-740, +-732, +-718, +-711, +-704, +-697, +-690, +-676, +-669, +-663, +-656, +-643, +-637, +-630, +-624, +-617, +-606, +-600, +-594, +-588, +-582, +-570, +-565, +-559, +-554, +-549, +-538, +-533, +-528, +-522, +-517, +-507, +-502, +-497, +-492, +-482, +-477, +-472, +-467, +-462, +-452, +-447, +-442, +-437, +-433, +-423, +-418, +-414, +-409, +-405, +-396, +-392, +-387, +-383, +-379, +-371, +-367, +-363, +-359, +-351, +-347, +-344, +-340, +-336, +-329, +-326, +-322, +-319, +-315, +-309, +-305, +-302, +-299, +-296, +-289, +-286, +-283, +-280, +-273, +-270, +-267, +-264, +-261, +-254, +-251, +-248, +-245, +-242, +-236, +-233, +-230, +-226, +-223, +-217, +-214, +-211, +-208, +-206, +-200, +-197, +-194, +-191, +-184, +-181, +-178, +-175, +-172, +-166, +-163, +-160, +-157, +-154, +-148, +-145, +-142, +-139, +-137, +-131, +-129, +-126, +-124, +-119, +-116, +-114, +-111, +-109, +-104, +-102, +-99, +-97, +-95, +-90, +-87, +-85, +-83, +-80, +-76, +-74, +-71, +-69, +-67, +-63, +-61, +-59, +-57, +-52, +-50, +-48, +-46, +-44, +-40, +-38, +-37, +-35, +-33, +-29, +-27, +-25, +-23, +-21, +-18, +-16, +-14, +-13, +-11, +-8, +-6, +-5, +-3 +}; + + diff --git a/Open_Theremin_V3/theremin_sintable3.c b/Open_Theremin_V3/theremin_sintable3.c new file mode 100644 index 0000000..e4a243a --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable3.c @@ -0,0 +1,1032 @@ +/* Theremin WAVE Table "Sinus" - 1024 entries full table, amplitude -2048.,*/ + +#include + +const int16_t sine_table3[1024] PROGMEM = {\ +9, +13, +15, +15, +18, +20, +22, +26, +30, +34, +38, +42, +46, +50, +54, +58, +62, +66, +70, +74, +78, +82, +86, +90, +92, +95, +97, +101, +105, +109, +113, +120, +124, +128, +131, +135, +135, +135, +143, +150, +158, +162, +165, +173, +180, +188, +192, +196, +203, +211, +214, +218, +226, +233, +248, +252, +256, +271, +286, +290, +294, +301, +324, +331, +335, +339, +354, +361, +369, +373, +377, +384, +399, +403, +407, +414, +422, +437, +441, +444, +452, +467, +467, +471, +482, +490, +505, +505, +512, +512, +520, +527, +527, +527, +535, +535, +535, +535, +535, +535, +535, +539, +543, +543, +543, +543, +543, +550, +550, +543, +543, +543, +543, +543, +543, +543, +543, +535, +535, +535, +535, +535, +535, +535, +535, +535, +535, +535, +543, +543, +543, +543, +543, +543, +546, +550, +550, +558, +558, +561, +565, +565, +573, +573, +573, +580, +580, +588, +588, +588, +588, +595, +599, +603, +603, +610, +618, +618, +618, +625, +633, +641, +644, +648, +656, +671, +671, +678, +693, +701, +708, +712, +724, +739, +754, +769, +773, +776, +791, +814, +818, +829, +844, +859, +874, +878, +882, +897, +905, +912, +916, +920, +942, +950, +954, +957, +965, +988, +995, +999, +1003, +1018, +1025, +1033, +1037, +1040, +1048, +1055, +1063, +1071, +1078, +1078, +1086, +1089, +1093, +1101, +1108, +1116, +1116, +1116, +1123, +1123, +1127, +1131, +1131, +1138, +1146, +1146, +1146, +1146, +1154, +1154, +1157, +1161, +1161, +1161, +1165, +1169, +1169, +1169, +1176, +1176, +1176, +1176, +1176, +1180, +1184, +1191, +1206, +1206, +1210, +1214, +1221, +1229, +1244, +1248, +1259, +1274, +1289, +1289, +1304, +1312, +1327, +1342, +1346, +1365, +1387, +1410, +1425, +1429, +1448, +1470, +1485, +1485, +1501, +1516, +1531, +1538, +1538, +1553, +1561, +1576, +1584, +1587, +1591, +1606, +1614, +1617, +1621, +1629, +1636, +1644, +1648, +1659, +1666, +1666, +1674, +1678, +1682, +1682, +1689, +1689, +1697, +1697, +1697, +1704, +1704, +1704, +1704, +1704, +1712, +1712, +1712, +1712, +1719, +1719, +1719, +1719, +1727, +1727, +1727, +1727, +1727, +1734, +1734, +1734, +1734, +1734, +1734, +1734, +1742, +1742, +1742, +1742, +1742, +1742, +1742, +1742, +1742, +1742, +1742, +1742, +1734, +1734, +1734, +1734, +1734, +1727, +1727, +1727, +1727, +1727, +1723, +1719, +1719, +1719, +1712, +1712, +1712, +1704, +1704, +1697, +1697, +1689, +1689, +1682, +1678, +1674, +1666, +1659, +1651, +1648, +1644, +1636, +1629, +1621, +1617, +1606, +1599, +1584, +1584, +1576, +1561, +1553, +1538, +1538, +1531, +1516, +1508, +1493, +1493, +1485, +1478, +1470, +1470, +1455, +1448, +1440, +1433, +1429, +1425, +1418, +1410, +1402, +1402, +1402, +1395, +1395, +1391, +1387, +1387, +1380, +1380, +1376, +1372, +1372, +1365, +1365, +1361, +1357, +1357, +1350, +1350, +1350, +1342, +1342, +1342, +1342, +1342, +1335, +1335, +1335, +1327, +1327, +1327, +1327, +1323, +1319, +1319, +1312, +1304, +1304, +1304, +1297, +1297, +1293, +1282, +1274, +1267, +1259, +1259, +1252, +1237, +1229, +1214, +1214, +1206, +1199, +1191, +1191, +1176, +1169, +1161, +1154, +1150, +1138, +1123, +1116, +1108, +1105, +1093, +1078, +1055, +1055, +1040, +1025, +1010, +988, +988, +972, +950, +927, +905, +901, +882, +859, +837, +833, +822, +807, +791, +776, +773, +761, +754, +739, +731, +731, +724, +716, +708, +708, +701, +693, +686, +678, +675, +663, +663, +648, +641, +641, +633, +618, +595, +592, +580, +558, +543, +520, +516, +497, +475, +460, +456, +444, +429, +414, +399, +395, +384, +361, +339, +316, +312, +271, +218, +158, +154, +113, +75, +52, +30, +26, +-0, +-15, +-22, +-30, +-34, +-45, +-52, +-67, +-71, +-75, +-83, +-90, +-105, +-105, +-113, +-120, +-128, +-135, +-135, +-143, +-143, +-150, +-154, +-158, +-166, +-166, +-173, +-177, +-181, +-188, +-196, +-203, +-207, +-211, +-218, +-226, +-230, +-233, +-241, +-249, +-256, +-260, +-271, +-279, +-286, +-301, +-305, +-316, +-339, +-369, +-369, +-392, +-430, +-475, +-505, +-509, +-535, +-558, +-588, +-603, +-607, +-626, +-626, +-641, +-641, +-641, +-656, +-656, +-663, +-667, +-671, +-679, +-686, +-686, +-694, +-694, +-701, +-701, +-705, +-709, +-709, +-716, +-716, +-720, +-724, +-724, +-731, +-731, +-731, +-731, +-739, +-739, +-743, +-746, +-754, +-761, +-761, +-765, +-769, +-777, +-777, +-777, +-777, +-784, +-792, +-792, +-795, +-799, +-807, +-814, +-814, +-818, +-822, +-829, +-837, +-837, +-837, +-844, +-852, +-852, +-856, +-860, +-867, +-875, +-875, +-878, +-882, +-890, +-897, +-901, +-905, +-920, +-927, +-935, +-939, +-943, +-958, +-965, +-980, +-984, +-988, +-1003, +-1010, +-1014, +-1018, +-1033, +-1056, +-1078, +-1078, +-1093, +-1116, +-1131, +-1146, +-1150, +-1161, +-1176, +-1191, +-1195, +-1207, +-1214, +-1229, +-1229, +-1233, +-1237, +-1244, +-1244, +-1244, +-1244, +-1252, +-1252, +-1259, +-1259, +-1259, +-1259, +-1267, +-1267, +-1267, +-1274, +-1274, +-1282, +-1282, +-1282, +-1282, +-1282, +-1290, +-1290, +-1290, +-1297, +-1297, +-1305, +-1305, +-1305, +-1305, +-1312, +-1312, +-1312, +-1320, +-1327, +-1327, +-1327, +-1327, +-1335, +-1342, +-1342, +-1346, +-1350, +-1357, +-1357, +-1361, +-1365, +-1372, +-1380, +-1388, +-1388, +-1395, +-1403, +-1410, +-1418, +-1418, +-1418, +-1425, +-1433, +-1433, +-1440, +-1448, +-1455, +-1463, +-1467, +-1478, +-1486, +-1501, +-1516, +-1516, +-1516, +-1531, +-1546, +-1546, +-1554, +-1561, +-1576, +-1584, +-1587, +-1599, +-1606, +-1621, +-1629, +-1633, +-1637, +-1652, +-1667, +-1670, +-1682, +-1704, +-1719, +-1742, +-1742, +-1757, +-1772, +-1787, +-1787, +-1802, +-1810, +-1825, +-1825, +-1829, +-1840, +-1855, +-1863, +-1870, +-1874, +-1878, +-1878, +-1885, +-1885, +-1893, +-1893, +-1893, +-1893, +-1893, +-1893, +-1893, +-1893, +-1893, +-1889, +-1885, +-1885, +-1885, +-1882, +-1878, +-1870, +-1870, +-1870, +-1867, +-1863, +-1855, +-1855, +-1848, +-1848, +-1840, +-1840, +-1833, +-1833, +-1833, +-1825, +-1818, +-1818, +-1814, +-1802, +-1802, +-1795, +-1787, +-1784, +-1780, +-1780, +-1772, +-1769, +-1765, +-1757, +-1750, +-1750, +-1746, +-1742, +-1735, +-1727, +-1719, +-1716, +-1712, +-1704, +-1697, +-1693, +-1689, +-1682, +-1674, +-1667, +-1659, +-1644, +-1637, +-1621, +-1619, +-1616, +-1614, +-1606, +-1591, +-1587, +-1584, +-1569, +-1561, +-1546, +-1542, +-1538, +-1523, +-1516, +-1508, +-1501, +-1493, +-1486, +-1471, +-1467, +-1463, +-1448, +-1440, +-1425, +-1422, +-1418, +-1410, +-1395, +-1391, +-1380, +-1372, +-1357, +-1350, +-1346, +-1335, +-1327, +-1312, +-1290, +-1286, +-1282, +-1259, +-1237, +-1233, +-1229, +-1207, +-1184, +-1161, +-1158, +-1131, +-1108, +-1078, +-1056, +-1048, +-1003, +-950, +-897, +-890, +-844, +-784, +-724, +-686, +-679, +-656, +-626, +-596, +-580, +-573, +-550, +-520, +-490, +-482, +-467, +-452, +-422, +-392, +-384, +-377, +-362, +-347, +-332, +-324, +-316, +-301, +-286, +-279, +-271, +-256, +-241, +-226, +-218, +-211, +-196, +-181, +-173, +-166, +-158, +-150, +-135, +-124, +-113, +-105, +-98, +-83, +-78, +-73, +-67, +-52, +-47, +-42, +-37, +-22, +-15, +-7, +-0, +14, +22, +30, +37, +45, +52, +60, +65, +70, +75, +90, +95, +100, +105, +120, +128, +135, +140, +145, +150, +153, +155, +158, +165, +173, +178, +183, +286, +}; + + diff --git a/Open_Theremin_V3/theremin_sintable4.c b/Open_Theremin_V3/theremin_sintable4.c new file mode 100644 index 0000000..0fe85c8 --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable4.c @@ -0,0 +1,1033 @@ +/* Theremin WAVE Table "Sinus" - 1024 entries full table, amplitude -2048.,*/ + +#include + +const int16_t sine_table4[1024] PROGMEM = {\ + +0, +3, +8, +16, +24, +32, +43, +47, +47, +47, +54, +54, +54, +58, +62, +69, +69, +69, +77, +77, +81, +84, +92, +92, +92, +92, +100, +100, +107, +111, +115, +115, +130, +134, +137, +137, +152, +160, +160, +175, +183, +186, +190, +198, +213, +213, +220, +220, +235, +250, +250, +250, +266, +281, +288, +315, +318, +326, +333, +348, +348, +364, +379, +386, +416, +424, +424, +454, +480, +484, +507, +530, +560, +563, +567, +590, +597, +620, +620, +650, +658, +669, +673, +688, +695, +718, +733, +733, +741, +756, +778, +786, +794, +809, +816, +843, +846, +846, +869, +877, +877, +892, +907, +914, +926, +929, +944, +952, +959, +959, +967, +975, +982, +990, +990, +997, +997, +997, +997, +1005, +1005, +1012, +1012, +1012, +1012, +1020, +1020, +1020, +1020, +1027, +1027, +1027, +1027, +1027, +1027, +1031, +1035, +1035, +1035, +1042, +1042, +1042, +1042, +1042, +1042, +1042, +1042, +1042, +1050, +1050, +1050, +1050, +1050, +1054, +1058, +1058, +1058, +1058, +1058, +1058, +1058, +1058, +1058, +1058, +1058, +1065, +1065, +1065, +1065, +1065, +1065, +1065, +1065, +1065, +1065, +1073, +1073, +1073, +1073, +1073, +1073, +1073, +1073, +1075, +1078, +1080, +1080, +1080, +1088, +1088, +1088, +1095, +1095, +1099, +1103, +1103, +1103, +1103, +1103, +1107, +1110, +1110, +1114, +1118, +1118, +1118, +1122, +1125, +1125, +1125, +1125, +1125, +1133, +1141, +1141, +1141, +1141, +1148, +1156, +1156, +1156, +1163, +1171, +1171, +1174, +1178, +1186, +1191, +1196, +1201, +1201, +1208, +1213, +1218, +1224, +1231, +1231, +1235, +1239, +1246, +1250, +1254, +1271, +1274, +1276, +1284, +1288, +1291, +1291, +1299, +1306, +1306, +1314, +1314, +1322, +1329, +1329, +1337, +1344, +1348, +1352, +1352, +1367, +1374, +1378, +1382, +1389, +1389, +1397, +1397, +1412, +1412, +1420, +1431, +1435, +1442, +1450, +1454, +1457, +1472, +1488, +1495, +1495, +1495, +1503, +1508, +1513, +1518, +1533, +1543, +1545, +1548, +1563, +1578, +1578, +1586, +1593, +1597, +1601, +1618, +1621, +1623, +1638, +1646, +1650, +1653, +1661, +1671, +1674, +1676, +1691, +1695, +1699, +1710, +1714, +1721, +1729, +1733, +1736, +1752, +1759, +1774, +1779, +1784, +1789, +1797, +1812, +1812, +1819, +1827, +1835, +1842, +1842, +1850, +1857, +1861, +1865, +1868, +1872, +1877, +1882, +1887, +1887, +1908, +1912, +1924, +1927, +1934, +1937, +1939, +1941, +1943, +1945, +1946, +1948, +1948, +1950, +1951, +1951, +1952, +1952, +1954, +1955, +1957, +1957, +1958, +1958, +1958, +1958, +1958, +1958, +1958, +1958, +1957, +1956, +1955, +1954, +1952, +1952, +1951, +1949, +1948, +1947, +1946, +1944, +1944, +1943, +1941, +1940, +1937, +1935, +1930, +1927, +1921, +1914, +1910, +1903, +1899, +1897, +1892, +1880, +1865, +1865, +1865, +1857, +1850, +1835, +1835, +1835, +1827, +1819, +1804, +1804, +1797, +1789, +1774, +1774, +1767, +1759, +1752, +1736, +1736, +1729, +1721, +1706, +1706, +1706, +1699, +1695, +1684, +1681, +1679, +1676, +1669, +1665, +1653, +1653, +1646, +1631, +1631, +1623, +1623, +1608, +1608, +1601, +1593, +1586, +1578, +1574, +1563, +1555, +1563, +1540, +1538, +1535, +1533, +1510, +1495, +1491, +1488, +1472, +1450, +1446, +1442, +1427, +1405, +1400, +1394, +1374, +1363, +1352, +1344, +1337, +1322, +1306, +1295, +1284, +1261, +1254, +1239, +1231, +1224, +1186, +1181, +1176, +1171, +1148, +1103, +1103, +1092, +1080, +1050, +1045, +1040, +1020, +997, +975, +937, +926, +914, +899, +889, +879, +846, +824, +801, +778, +763, +726, +718, +711, +699, +665, +643, +613, +601, +590, +579, +537, +514, +503, +492, +454, +424, +416, +409, +371, +356, +341, +330, +318, +281, +266, +254, +243, +198, +175, +152, +145, +137, +84, +69, +58, +47, +1, +-20, +-35, +-43, +-73, +-111, +-133, +-141, +-171, +-171, +-209, +-216, +-224, +-262, +-307, +-322, +-329, +-337, +-382, +-397, +-409, +-420, +-450, +-480, +-495, +-503, +-541, +-541, +-578, +-586, +-601, +-616, +-639, +-654, +-665, +-676, +-691, +-722, +-729, +-737, +-759, +-774, +-797, +-805, +-812, +-835, +-850, +-857, +-865, +-910, +-918, +-925, +-933, +-963, +-978, +-981, +-983, +-1008, +-1023, +-1038, +-1046, +-1076, +-1080, +-1084, +-1121, +-1125, +-1137, +-1152, +-1174, +-1177, +-1179, +-1197, +-1220, +-1225, +-1230, +-1250, +-1257, +-1272, +-1276, +-1280, +-1295, +-1318, +-1325, +-1330, +-1335, +-1363, +-1365, +-1368, +-1385, +-1397, +-1408, +-1416, +-1423, +-1431, +-1442, +-1461, +-1466, +-1471, +-1476, +-1484, +-1491, +-1499, +-1514, +-1521, +-1529, +-1533, +-1570, +-1589, +-1593, +-1608, +-1608, +-1623, +-1638, +-1638, +-1653, +-1661, +-1668, +-1676, +-1676, +-1683, +-1695, +-1699, +-1706, +-1714, +-1729, +-1736, +-1736, +-1744, +-1751, +-1770, +-1774, +-1774, +-1797, +-1797, +-1812, +-1812, +-1812, +-1834, +-1834, +-1834, +-1849, +-1857, +-1864, +-1864, +-1864, +-1872, +-1872, +-1875, +-1877, +-1880, +-1880, +-1880, +-1880, +-1880, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1895, +-1895, +-1895, +-1897, +-1900, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1902, +-1895, +-1895, +-1895, +-1895, +-1895, +-1891, +-1887, +-1887, +-1887, +-1885, +-1882, +-1880, +-1880, +-1872, +-1872, +-1872, +-1868, +-1864, +-1864, +-1864, +-1864, +-1864, +-1854, +-1852, +-1849, +-1842, +-1842, +-1827, +-1825, +-1823, +-1821, +-1819, +-1812, +-1804, +-1798, +-1793, +-1787, +-1782, +-1759, +-1755, +-1751, +-1748, +-1744, +-1729, +-1726, +-1724, +-1721, +-1706, +-1699, +-1691, +-1680, +-1668, +-1661, +-1642, +-1634, +-1634, +-1631, +-1619, +-1619, +-1612, +-1604, +-1599, +-1594, +-1589, +-1584, +-1579, +-1574, +-1559, +-1551, +-1536, +-1536, +-1529, +-1521, +-1514, +-1510, +-1506, +-1499, +-1484, +-1476, +-1476, +-1468, +-1461, +-1453, +-1446, +-1438, +-1423, +-1416, +-1408, +-1404, +-1393, +-1385, +-1363, +-1359, +-1355, +-1348, +-1340, +-1336, +-1318, +-1310, +-1295, +-1287, +-1284, +-1280, +-1265, +-1250, +-1246, +-1242, +-1235, +-1220, +-1204, +-1201, +-1182, +-1182, +-1167, +-1163, +-1159, +-1152, +-1144, +-1139, +-1134, +-1121, +-1106, +-1091, +-1091, +-1084, +-1076, +-1061, +-1054, +-1050, +-1046, +-1038, +-1031, +-1031, +-1031, +-1016, +-1016, +-1016, +-1008, +-1001, +-1001, +-993, +-989, +-986, +-978, +-976, +-973, +-971, +-971, +-971, +-956, +-956, +-956, +-948, +-940, +-940, +-940, +-940, +-933, +-933, +-930, +-928, +-918, +-918, +-918, +-918, +-910, +-910, +-905, +-900, +-895, +-888, +-888, +-888, +-880, +-873, +-865, +-865, +-857, +-857, +-857, +-857, +-857, +-857, +-850, +-850, +-850, +-850, +-850, +-850, +-842, +-835, +-835, +-831, +-820, +-805, +-797, +-797, +-797, +-782, +-774, +-759, +-759, +-752, +-737, +-702, +-695, +-687, +-672, +-642, +-627, +-623, +-596, +-581, +-551, +-547, +-513, +-506, +-476, +-446, +-446, +-431, +-400, +-378, +-374, +-348, +-325, +-295, +-280, +-276, +-242, +-227, +-212, +-208, +-189, +-182, +-166, +-163, +-151, +-136, +-129, +-114, +-110, +-106, +-91, +-84, +-80, +-76, +-68, +-53, +-53, +-50, +-46, +-38, +-31, +-31, +-31, +-23, +-23, +-16, +-12, +-10, +-8, +-7, +-6, +-3, +2, +0 +}; + + diff --git a/Open_Theremin_V3/theremin_sintable5.c b/Open_Theremin_V3/theremin_sintable5.c new file mode 100644 index 0000000..35382e8 --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable5.c @@ -0,0 +1,1032 @@ +/* Theremin WAVE Table "Sinus" - 1024 entries full table, amplitude -2048,*/ + +#include + +const int16_t sine_table5[1024] PROGMEM = {\ +0, +76, +83, +83, +98, +98, +106, +110, +113, +128, +128, +144, +144, +144, +159, +166, +174, +181, +193, +196, +211, +219, +227, +234, +242, +249, +257, +257, +257, +279, +291, +294, +302, +310, +317, +325, +347, +352, +357, +362, +377, +385, +404, +408, +408, +430, +445, +449, +453, +460, +475, +491, +502, +506, +521, +589, +592, +596, +641, +641, +679, +687, +694, +732, +739, +758, +762, +792, +830, +853, +883, +890, +913, +936, +981, +1000, +1004, +1049, +1071, +1139, +1143, +1147, +1185, +1230, +1241, +1245, +1283, +1290, +1320, +1332, +1335, +1358, +1381, +1411, +1422, +1426, +1456, +1490, +1498, +1505, +1528, +1535, +1535, +1543, +1558, +1569, +1573, +1581, +1596, +1603, +1618, +1618, +1626, +1641, +1641, +1648, +1648, +1664, +1664, +1671, +1686, +1697, +1698, +1703, +1705, +1709, +1712, +1714, +1717, +1720, +1722, +1724, +1727, +1729, +1731, +1732, +1734, +1735, +1737, +1739, +1740, +1741, +1743, +1744, +1745, +1747, +1748, +1749, +1750, +1751, +1752, +1754, +1754, +1754, +1755, +1756, +1757, +1758, +1759, +1760, +1761, +1762, +1764, +1764, +1765, +1766, +1767, +1768, +1770, +1770, +1771, +1773, +1774, +1775, +1777, +1778, +1779, +1781, +1782, +1783, +1785, +1786, +1788, +1788, +1790, +1791, +1792, +1794, +1796, +1797, +1799, +1801, +1803, +1804, +1805, +1808, +1808, +1810, +1812, +1814, +1816, +1819, +1820, +1822, +1824, +1828, +1829, +1830, +1832, +1834, +1836, +1837, +1839, +1841, +1844, +1847, +1851, +1853, +1858, +1859, +1866, +1870, +1873, +1877, +1883, +1884, +1890, +1894, +1896, +1900, +1903, +1906, +1910, +1912, +1916, +1922, +1924, +1928, +1933, +1935, +1939, +1941, +1944, +1947, +1949, +1952, +1955, +1957, +1959, +1962, +1963, +1965, +1968, +1972, +1974, +1978, +1980, +1983, +1985, +1987, +1989, +1992, +1994, +1995, +1997, +1999, +1999, +2001, +2001, +2002, +2003, +2005, +2006, +2006, +2006, +2006, +2006, +2006, +2006, +2006, +2005, +2005, +2004, +2003, +2002, +2001, +2000, +1998, +1997, +1996, +1995, +1994, +1992, +1991, +1990, +1987, +1987, +1984, +1982, +1981, +1978, +1976, +1974, +1973, +1973, +1973, +1970, +1968, +1965, +1958, +1958, +1956, +1954, +1952, +1945, +1945, +1945, +1945, +1937, +1929, +1929, +1929, +1926, +1914, +1914, +1914, +1901, +1897, +1896, +1890, +1890, +1881, +1880, +1873, +1872, +1870, +1865, +1863, +1857, +1852, +1848, +1845, +1840, +1837, +1833, +1830, +1828, +1825, +1825, +1820, +1818, +1816, +1814, +1812, +1810, +1806, +1805, +1803, +1801, +1800, +1797, +1795, +1794, +1790, +1787, +1787, +1784, +1783, +1779, +1776, +1773, +1773, +1771, +1768, +1765, +1763, +1761, +1759, +1758, +1755, +1753, +1752, +1749, +1746, +1745, +1743, +1741, +1739, +1736, +1733, +1732, +1729, +1726, +1724, +1722, +1720, +1718, +1715, +1715, +1711, +1709, +1708, +1705, +1703, +1701, +1698, +1694, +1694, +1688, +1673, +1673, +1658, +1658, +1650, +1650, +1635, +1628, +1624, +1620, +1613, +1605, +1598, +1594, +1590, +1575, +1560, +1560, +1552, +1552, +1545, +1530, +1526, +1522, +1515, +1499, +1492, +1492, +1477, +1462, +1447, +1424, +1424, +1417, +1401, +1379, +1379, +1371, +1356, +1334, +1326, +1311, +1307, +1288, +1288, +1266, +1258, +1243, +1228, +1205, +1218, +1158, +1151, +1120, +1090, +1053, +1015, +1011, +947, +917, +879, +871, +864, +834, +789, +773, +766, +728, +713, +668, +653, +645, +638, +592, +585, +555, +547, +524, +502, +472, +449, +442, +419, +404, +359, +351, +343, +321, +283, +276, +272, +230, +215, +200, +170, +162, +155, +117, +102, +57, +53, +49, +34, +-10, +-55, +-86, +-93, +-116, +-138, +-153, +-161, +-165, +-184, +-191, +-206, +-229, +-236, +-251, +-259, +-282, +-312, +-312, +-327, +-342, +-350, +-372, +-380, +-387, +-417, +-433, +-440, +-448, +-470, +-478, +-485, +-493, +-523, +-531, +-553, +-553, +-561, +-576, +-591, +-606, +-636, +-644, +-651, +-666, +-697, +-704, +-712, +-719, +-734, +-749, +-764, +-772, +-795, +-802, +-810, +-821, +-832, +-847, +-870, +-885, +-890, +-895, +-900, +-923, +-953, +-957, +-961, +-976, +-987, +-998, +-1010, +-1021, +-1036, +-1051, +-1061, +-1071, +-1081, +-1096, +-1111, +-1119, +-1130, +-1142, +-1157, +-1172, +-1179, +-1187, +-1194, +-1209, +-1225, +-1232, +-1240, +-1247, +-1270, +-1275, +-1280, +-1285, +-1308, +-1315, +-1323, +-1330, +-1338, +-1353, +-1364, +-1391, +-1396, +-1451, +-1458, +-1462, +-1474, +-1485, +-1503, +-1520, +-1527, +-1532, +-1546, +-1554, +-1558, +-1564, +-1568, +-1570, +-1577, +-1580, +-1586, +-1590, +-1597, +-1600, +-1609, +-1615, +-1625, +-1635, +-1642, +-1663, +-1673, +-1685, +-1689, +-1696, +-1703, +-1708, +-1714, +-1720, +-1723, +-1727, +-1733, +-1735, +-1740, +-1744, +-1746, +-1752, +-1755, +-1750, +-1759, +-1760, +-1768, +-1761, +-1763, +-1768, +-1770, +-1772, +-1781, +-1784, +-1789, +-1792, +-1794, +-1797, +-1799, +-1802, +-1804, +-1807, +-1808, +-1814, +-1819, +-1821, +-1824, +-1825, +-1827, +-1829, +-1830, +-1831, +-1833, +-1835, +-1836, +-1838, +-1839, +-1840, +-1841, +-1843, +-1844, +-1848, +-1850, +-1851, +-1853, +-1855, +-1857, +-1859, +-1862, +-1864, +-1866, +-1868, +-1870, +-1873, +-1874, +-1875, +-1876, +-1876, +-1879, +-1880, +-1882, +-1882, +-1883, +-1884, +-1885, +-1885, +-1886, +-1886, +-1886, +-1887, +-1888, +-1889, +-1889, +-1890, +-1891, +-1891, +-1892, +-1892, +-1892, +-1893, +-1893, +-1893, +-1893, +-1893, +-1893, +-1892, +-1892, +-1892, +-1892, +-1892, +-1892, +-1892, +-1892, +-1891, +-1891, +-1891, +-1891, +-1890, +-1889, +-1889, +-1889, +-1889, +-1888, +-1887, +-1887, +-1887, +-1886, +-1886, +-1885, +-1885, +-1884, +-1883, +-1883, +-1881, +-1881, +-1880, +-1879, +-1878, +-1877, +-1875, +-1873, +-1872, +-1870, +-1869, +-1867, +-1864, +-1863, +-1861, +-1858, +-1857, +-1856, +-1853, +-1850, +-1848, +-1846, +-1843, +-1840, +-1838, +-1834, +-1832, +-1829, +-1826, +-1824, +-1820, +-1817, +-1815, +-1812, +-1808, +-1805, +-1801, +-1799, +-1797, +-1795, +-1790, +-1789, +-1788, +-1782, +-1780, +-1778, +-1773, +-1770, +-1768, +-1765, +-1763, +-1758, +-1753, +-1752, +-1750, +-1744, +-1742, +-1740, +-1732, +-1729, +-1727, +-1722, +-1719, +-1714, +-1712, +-1704, +-1702, +-1697, +-1692, +-1687, +-1684, +-1679, +-1673, +-1668, +-1664, +-1659, +-1651, +-1646, +-1640, +-1632, +-1628, +-1623, +-1620, +-1606, +-1600, +-1590, +-1588, +-1584, +-1582, +-1578, +-1572, +-1567, +-1565, +-1562, +-1561, +-1557, +-1556, +-1553, +-1552, +-1549, +-1548, +-1545, +-1542, +-1542, +-1539, +-1537, +-1535, +-1533, +-1529, +-1528, +-1526, +-1525, +-1524, +-1523, +-1522, +-1521, +-1518, +-1517, +-1514, +-1513, +-1510, +-1509, +-1508, +-1507, +-1505, +-1503, +-1500, +-1499, +-1498, +-1496, +-1494, +-1492, +-1491, +-1488, +-1487, +-1485, +-1484, +-1482, +-1480, +-1479, +-1477, +-1476, +-1474, +-1473, +-1471, +-1469, +-1467, +-1466, +-1462, +-1461, +-1460, +-1458, +-1456, +-1455, +-1453, +-1452, +-1450, +-1449, +-1447, +-1447, +-1445, +-1444, +-1442, +-1441, +-1440, +-1438, +-1435, +-1434, +-1430, +-1429, +-1425, +-1423, +-1418, +-1415, +-1412, +-1409, +-1401, +-1397, +-1395, +-1392, +-1389, +-1387, +-1382, +-1379, +-1379, +-1372, +-1372, +-1372, +-1364, +-1357, +-1357, +-1353, +-1349, +-1341, +-1334, +-1319, +-1319, +-1311, +-1311, +-1296, +-1281, +-1279, +-1276, +-1266, +-1251, +-1251, +-1243, +-1221, +-1221, +-1206, +-1198, +-1191, +-1176, +-1160, +-1138, +-1130, +-1123, +-1108, +-1085, +-1070, +-1066, +-1025, +-1010, +-979, +-964, +-949, +-904, +-881, +-859, +-821, +-813, +-791, +-776, +-746, +-734, +-700, +-678, +-655, +-565, +-553, +-497, +-459, +-451, +-383, +-361, +-331, +-270, +-160, +-80, +-40, +-15, +0 +}; + + diff --git a/Open_Theremin_V3/theremin_sintable6.c b/Open_Theremin_V3/theremin_sintable6.c new file mode 100644 index 0000000..1208422 --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable6.c @@ -0,0 +1,1032 @@ +/* Theremin WAVE Table "Sinus" - 1024 entries full table, amplitude -2048.,*/ + +#include + +const int16_t sine_table6[1024] PROGMEM = {\ +0, +5, +10, +20, +25, +27, +33, +36, +37, +43, +46, +47, +52, +56, +59, +62, +64, +67, +71, +74, +77, +80, +82, +88, +92, +94, +98, +104, +107, +112, +115, +117, +120, +122, +126, +129, +131, +134, +138, +141, +144, +147, +149, +155, +161, +167, +173, +176, +179, +185, +195, +198, +202, +205, +213, +214, +220, +223, +226, +228, +237, +238, +244, +248, +251, +258, +277, +277, +277, +292, +307, +322, +322, +322, +330, +345, +352, +364, +367, +375, +382, +398, +398, +405, +431, +443, +447, +450, +473, +480, +496, +503, +511, +518, +533, +556, +563, +574, +585, +589, +604, +611, +626, +634, +634, +649, +664, +679, +679, +679, +694, +709, +724, +728, +732, +732, +747, +762, +770, +777, +785, +807, +811, +815, +822, +822, +845, +845, +845, +868, +875, +898, +909, +921, +921, +936, +951, +954, +958, +981, +988, +996, +1004, +1011, +1026, +1034, +1037, +1041, +1056, +1064, +1079, +1079, +1079, +1094, +1109, +1109, +1117, +1124, +1132, +1139, +1147, +1151, +1154, +1162, +1166, +1169, +1180, +1182, +1185, +1200, +1207, +1211, +1215, +1222, +1234, +1237, +1243, +1249, +1254, +1260, +1275, +1279, +1283, +1286, +1290, +1313, +1317, +1320, +1324, +1328, +1333, +1338, +1343, +1354, +1366, +1371, +1376, +1381, +1388, +1396, +1403, +1411, +1418, +1426, +1433, +1439, +1444, +1449, +1456, +1464, +1471, +1479, +1486, +1498, +1509, +1514, +1519, +1524, +1532, +1539, +1547, +1554, +1562, +1567, +1573, +1579, +1584, +1592, +1599, +1604, +1609, +1615, +1622, +1630, +1635, +1640, +1645, +1652, +1660, +1665, +1670, +1675, +1690, +1695, +1700, +1705, +1713, +1720, +1725, +1730, +1735, +1743, +1748, +1753, +1758, +1765, +1780, +1780, +1788, +1796, +1803, +1811, +1826, +1829, +1832, +1835, +1839, +1840, +1844, +1847, +1852, +1854, +1859, +1861, +1865, +1866, +1868, +1870, +1870, +1872, +1873, +1873, +1874, +1875, +1875, +1875, +1875, +1875, +1875, +1874, +1874, +1870, +1867, +1859, +1852, +1852, +1848, +1844, +1844, +1844, +1829, +1829, +1829, +1821, +1821, +1814, +1814, +1806, +1799, +1799, +1791, +1787, +1784, +1769, +1769, +1753, +1753, +1746, +1746, +1731, +1731, +1727, +1723, +1716, +1708, +1708, +1705, +1697, +1690, +1675, +1670, +1665, +1660, +1648, +1637, +1632, +1627, +1622, +1611, +1599, +1588, +1577, +1569, +1562, +1557, +1552, +1547, +1539, +1532, +1509, +1504, +1499, +1494, +1479, +1464, +1459, +1454, +1449, +1444, +1439, +1433, +1423, +1413, +1403, +1396, +1388, +1381, +1373, +1363, +1353, +1343, +1335, +1328, +1323, +1318, +1313, +1303, +1293, +1283, +1278, +1273, +1268, +1256, +1245, +1237, +1230, +1222, +1217, +1212, +1207, +1192, +1177, +1172, +1167, +1162, +1151, +1139, +1132, +1124, +1117, +1105, +1094, +1090, +1086, +1083, +1079, +1056, +1051, +1046, +1041, +1036, +1031, +1026, +1011, +996, +992, +988, +985, +981, +966, +951, +946, +941, +936, +921, +913, +905, +898, +890, +883, +875, +868, +860, +853, +838, +834, +830, +826, +822, +807, +792, +787, +782, +777, +770, +762, +752, +742, +732, +724, +717, +713, +709, +706, +702, +692, +682, +672, +667, +662, +657, +649, +641, +634, +626, +621, +616, +611, +600, +589, +584, +579, +574, +566, +558, +551, +543, +536, +528, +521, +516, +511, +498, +491, +485, +479, +474, +468, +460, +445, +440, +435, +430, +415, +409, +404, +398, +392, +377, +375, +372, +370, +347, +345, +342, +340, +325, +317, +310, +302, +294, +287, +272, +269, +267, +264, +249, +244, +238, +232, +227, +211, +204, +196, +189, +181, +174, +169, +164, +159, +144, +132, +121, +116, +111, +106, +100, +95, +89, +83, +68, +53, +48, +43, +38, +27, +15, +15, +4, +-6, +-14, +-21, +-29, +-36, +-44, +-52, +-59, +-67, +-74, +-82, +-93, +-104, +-108, +-112, +-119, +-127, +-135, +-142, +-150, +-157, +-165, +-187, +-193, +-199, +-204, +-210, +-225, +-231, +-236, +-242, +-248, +-255, +-263, +-270, +-278, +-285, +-297, +-308, +-312, +-316, +-323, +-331, +-338, +-350, +-361, +-368, +-376, +-383, +-391, +-406, +-414, +-421, +-429, +-440, +-451, +-456, +-461, +-466, +-474, +-482, +-489, +-497, +-504, +-515, +-527, +-529, +-532, +-534, +-557, +-562, +-567, +-572, +-583, +-595, +-602, +-610, +-617, +-629, +-640, +-644, +-647, +-651, +-655, +-678, +-683, +-689, +-695, +-700, +-708, +-715, +-723, +-746, +-753, +-761, +-768, +-776, +-783, +-798, +-813, +-818, +-824, +-829, +-844, +-859, +-866, +-874, +-881, +-889, +-896, +-906, +-917, +-927, +-942, +-949, +-957, +-964, +-972, +-979, +-987, +-994, +-1002, +-1017, +-1027, +-1037, +-1047, +-1062, +-1068, +-1074, +-1079, +-1085, +-1096, +-1108, +-1115, +-1123, +-1130, +-1138, +-1145, +-1155, +-1165, +-1176, +-1183, +-1191, +-1198, +-1206, +-1213, +-1225, +-1236, +-1243, +-1251, +-1259, +-1266, +-1274, +-1284, +-1294, +-1304, +-1311, +-1319, +-1326, +-1334, +-1341, +-1353, +-1364, +-1372, +-1379, +-1387, +-1398, +-1409, +-1417, +-1424, +-1432, +-1440, +-1447, +-1455, +-1462, +-1477, +-1485, +-1492, +-1500, +-1511, +-1523, +-1533, +-1543, +-1553, +-1560, +-1568, +-1575, +-1583, +-1590, +-1606, +-1621, +-1628, +-1636, +-1643, +-1651, +-1658, +-1666, +-1673, +-1681, +-1696, +-1704, +-1711, +-1719, +-1726, +-1741, +-1749, +-1756, +-1764, +-1779, +-1794, +-1799, +-1804, +-1809, +-1824, +-1836, +-1847, +-1851, +-1854, +-1877, +-1885, +-1892, +-1897, +-1902, +-1907, +-1940, +-1940, +-1940, +-1947, +-1963, +-1970, +-1985, +-1988, +-1990, +-1993, +-2000, +-2003, +-2026, +-2026, +-2030, +-2033, +-2034, +-2036, +-2037, +-2037, +-2038, +-2039, +-2039, +-2039, +-2039, +-2039, +-2039, +-2039, +-2039, +-2039, +-2038, +-2035, +-2034, +-2031, +-2028, +-2025, +-2023, +-2023, +-2008, +-2000, +-1995, +-1993, +-1990, +-1968, +-1963, +-1958, +-1952, +-1930, +-1924, +-1919, +-1913, +-1907, +-1892, +-1885, +-1877, +-1867, +-1857, +-1847, +-1842, +-1837, +-1832, +-1820, +-1809, +-1794, +-1789, +-1784, +-1779, +-1771, +-1764, +-1760, +-1756, +-1749, +-1741, +-1731, +-1721, +-1711, +-1704, +-1692, +-1681, +-1666, +-1651, +-1646, +-1641, +-1621, +-1616, +-1611, +-1605, +-1590, +-1587, +-1583, +-1579, +-1575, +-1553, +-1545, +-1538, +-1530, +-1523, +-1515, +-1504, +-1492, +-1481, +-1470, +-1465, +-1460, +-1455, +-1440, +-1428, +-1417, +-1413, +-1409, +-1406, +-1387, +-1382, +-1377, +-1372, +-1360, +-1349, +-1344, +-1339, +-1334, +-1323, +-1311, +-1308, +-1304, +-1289, +-1281, +-1274, +-1266, +-1259, +-1236, +-1228, +-1225, +-1213, +-1198, +-1191, +-1168, +-1164, +-1160, +-1138, +-1130, +-1123, +-1115, +-1108, +-1093, +-1085, +-1062, +-1057, +-1052, +-1047, +-1032, +-1025, +-1021, +-1010, +-1002, +-972, +-969, +-967, +-949, +-949, +-912, +-909, +-906, +-896, +-881, +-866, +-862, +-844, +-829, +-813, +-806, +-795, +-783, +-761, +-753, +-748, +-743, +-723, +-708, +-700, +-685, +-680, +-675, +-670, +-663, +-651, +-640, +-632, +-625, +-610, +-606, +-602, +-580, +-572, +-557, +-552, +-547, +-527, +-519, +-504, +-497, +-489, +-482, +-466, +-459, +-451, +-444, +-429, +-421, +-406, +-402, +-399, +-383, +-368, +-361, +-353, +-346, +-323, +-316, +-312, +-308, +-293, +-285, +-278, +-265, +-263, +-256, +-253, +-249, +-241, +-235, +-220, +-213, +-204, +-183, +-165, +-154, +-151, +-144, +-133, +-127, +-121, +-109, +-106, +-102, +-98, +-80, +-40, +-20, +-10, +-5, +-3 +}; + + diff --git a/Open_Theremin_V3/theremin_sintable7.c b/Open_Theremin_V3/theremin_sintable7.c new file mode 100644 index 0000000..4e72e93 --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable7.c @@ -0,0 +1,1033 @@ +/* Theremin WAVE Table "Sinus" - 1024 entries full table, amplitude -2048.,*/ + +#include + +const int16_t sine_table7[1024] PROGMEM = {\ +11, +42, +47, +51, +56, +62, +68, +73, +79, +106, +220, +235, +258, +269, +281, +296, +326, +341, +356, +371, +379, +386, +409, +416, +424, +439, +462, +467, +472, +477, +499, +511, +522, +537, +545, +552, +560, +571, +582, +605, +610, +615, +620, +643, +654, +665, +680, +703, +711, +718, +726, +741, +763, +775, +786, +793, +801, +824, +839, +846, +854, +876, +882, +887, +892, +914, +926, +937, +952, +959, +967, +975, +997, +1008, +1020, +1035, +1046, +1058, +1073, +1080, +1088, +1110, +1125, +1133, +1140, +1156, +1163, +1178, +1193, +1208, +1216, +1223, +1239, +1254, +1261, +1269, +1284, +1288, +1291, +1306, +1310, +1314, +1329, +1337, +1342, +1347, +1352, +1359, +1374, +1378, +1382, +1389, +1397, +1405, +1412, +1427, +1431, +1435, +1438, +1442, +1450, +1465, +1472, +1480, +1487, +1491, +1495, +1503, +1506, +1510, +1518, +1525, +1528, +1530, +1533, +1537, +1540, +1548, +1550, +1553, +1555, +1559, +1563, +1570, +1574, +1578, +1581, +1583, +1586, +1593, +1597, +1601, +1603, +1606, +1608, +1616, +1619, +1623, +1627, +1631, +1635, +1638, +1642, +1646, +1650, +1653, +1661, +1663, +1666, +1669, +1676, +1680, +1684, +1691, +1691, +1691, +1691, +1699, +1706, +1706, +1706, +1706, +1714, +1714, +1718, +1721, +1729, +1729, +1729, +1736, +1736, +1736, +1744, +1752, +1752, +1752, +1752, +1759, +1767, +1767, +1769, +1772, +1774, +1774, +1774, +1782, +1782, +1782, +1782, +1782, +1789, +1789, +1789, +1789, +1789, +1789, +1789, +1789, +1797, +1797, +1797, +1797, +1797, +1797, +1797, +1797, +1797, +1797, +1797, +1797, +1804, +1804, +1804, +1804, +1804, +1804, +1808, +1812, +1812, +1812, +1812, +1812, +1812, +1812, +1812, +1819, +1819, +1819, +1819, +1819, +1819, +1819, +1819, +1827, +1827, +1827, +1827, +1827, +1834, +1834, +1834, +1834, +1842, +1842, +1842, +1842, +1842, +1850, +1850, +1850, +1857, +1857, +1857, +1865, +1865, +1865, +1872, +1872, +1876, +1880, +1880, +1880, +1880, +1880, +1880, +1884, +1887, +1887, +1887, +1887, +1887, +1887, +1887, +1887, +1887, +1887, +1880, +1880, +1880, +1880, +1880, +1872, +1872, +1872, +1872, +1872, +1868, +1865, +1865, +1865, +1865, +1865, +1857, +1857, +1857, +1857, +1857, +1857, +1850, +1850, +1850, +1850, +1850, +1850, +1850, +1842, +1842, +1842, +1842, +1842, +1842, +1834, +1834, +1834, +1834, +1834, +1827, +1827, +1827, +1819, +1819, +1819, +1812, +1812, +1804, +1797, +1797, +1793, +1789, +1782, +1782, +1774, +1767, +1759, +1759, +1759, +1752, +1744, +1736, +1721, +1721, +1721, +1714, +1706, +1699, +1691, +1684, +1684, +1680, +1676, +1669, +1661, +1653, +1653, +1646, +1646, +1638, +1631, +1623, +1616, +1616, +1608, +1608, +1601, +1593, +1586, +1578, +1578, +1563, +1563, +1555, +1548, +1540, +1533, +1525, +1510, +1510, +1503, +1495, +1480, +1465, +1457, +1435, +1435, +1427, +1412, +1397, +1389, +1374, +1367, +1363, +1352, +1337, +1329, +1306, +1299, +1284, +1280, +1269, +1254, +1239, +1223, +1208, +1186, +1182, +1171, +1148, +1133, +1118, +1110, +1088, +1084, +1073, +1058, +1042, +1020, +1012, +997, +993, +975, +959, +944, +922, +907, +884, +880, +869, +854, +839, +809, +786, +756, +752, +733, +703, +680, +658, +628, +605, +601, +582, +545, +514, +477, +439, +401, +397, +364, +318, +273, +220, +182, +137, +133, +107, +77, +39, +9, +-28, +-65, +-69, +-96, +-148, +-186, +-224, +-277, +-345, +-348, +-412, +-465, +-526, +-563, +-601, +-646, +-654, +-707, +-805, +-910, +-971, +-1023, +-1069, +-1072, +-1114, +-1159, +-1204, +-1242, +-1272, +-1303, +-1306, +-1333, +-1370, +-1401, +-1423, +-1446, +-1453, +-1476, +-1521, +-1551, +-1582, +-1604, +-1634, +-1638, +-1657, +-1687, +-1710, +-1740, +-1755, +-1770, +-1774, +-1793, +-1808, +-1831, +-1838, +-1853, +-1868, +-1872, +-1876, +-1891, +-1898, +-1921, +-1929, +-1936, +-1940, +-1951, +-1959, +-1966, +-1974, +-1981, +-1989, +-1989, +-1997, +-1997, +-2004, +-2004, +-2004, +-2012, +-2012, +-2012, +-2012, +-2019, +-2019, +-2019, +-2019, +-2023, +-2027, +-2027, +-2027, +-2027, +-2027, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2034, +-2027, +-2027, +-2027, +-2027, +-2027, +-2027, +-2019, +-2019, +-2019, +-2019, +-2012, +-2012, +-2004, +-2004, +-1997, +-1997, +-1997, +-1989, +-1981, +-1974, +-1966, +-1959, +-1959, +-1951, +-1944, +-1936, +-1929, +-1921, +-1914, +-1910, +-1898, +-1891, +-1876, +-1861, +-1846, +-1838, +-1834, +-1823, +-1808, +-1793, +-1770, +-1755, +-1733, +-1729, +-1717, +-1687, +-1665, +-1634, +-1589, +-1536, +-1533, +-1484, +-1423, +-1340, +-1197, +-1046, +-639, +-631, +-443, +-337, +-269, +-209, +-133, +-81,2 +-73, +-28, +17, +54, +84, +122, +145, +152, +167, +190, +220, +235, +250, +258, +262, +273, +281, +296, +303, +311, +318, +318, +318, +326, +326, +326, +329, +331, +333, +334, +334, +336, +336, +337, +337, +337, +338, +339, +340, +340, +340, +340, +340, +340, +340, +340, +340, +339, +339, +338, +337, +336, +335, +335, +333, +332, +332, +331, +330, +329, +328, +327, +326, +324, +322, +319, +317, +318, +311, +311, +303, +296, +296, +288, +281, +273, +269, +265, +258, +243, +235, +220, +205, +201, +198, +182, +167, +160, +145, +130, +122, +107, +92, +69, +47, +24, +-5, +-9, +-35,2 +-58, +-88, +-1333, +-1416, +-1476, +-1476, +-1521, +-1559, +-1597, +-1627, +-1650, +-1672, +-1672, +-1687, +-1702, +-1717, +-1733, +-1740, +-1755, +-1759, +-1770, +-1778, +-1785, +-1793, +-1800, +-1808, +-1812, +-1816, +-1823, +-1831, +-1838, +-1846, +-1846, +-1849, +-1853, +-1861, +-1861, +-1868, +-1876, +-1876, +-1880, +-1883, +-1883, +-1891, +-1891, +-1898, +-1898, +-1898, +-1898, +-1906, +-1906, +-1906, +-1906, +-1906, +-1906, +-1914, +-1914, +-1914, +-1914, +-1914, +-1914, +-1914, +-1914, +-1914, +-1914, +-1914, +-1906, +-1906, +-1906, +-1906, +-1906, +-1906, +-1906, +-1898, +-1898, +-1898, +-1898, +-1891, +-1891, +-1891, +-1891, +-1883, +-1883, +-1883, +-1883, +-1883, +-1876, +-1876, +-1868, +-1868, +-1868, +-1861, +-1861, +-1853, +-1853, +-1846, +-1846, +-1846, +-1838, +-1831, +-1831, +-1823, +-1816, +-1812, +-1800, +-1800, +-1785, +-1778, +-1770, +-1755, +-1755, +-1748, +-1740, +-1725, +-1710, +-1702, +-1699, +-1687, +-1672, +-1650, +-1619, +-1597, +-1567, +-1563, +-1529, +-1491, +-1453, +-1423, +-1378, +-1340, +-1337, +-1310, +-1265, +-1227, +-1197, +-1159, +-1137, +-1129, +-1106, +-1076, +-1046, +-1016, +-986, +-956, +-952, +-933, +-903, +-873, +-842, +-805, +-759, +-756, +-722, +-676, +-639, +-609, +-578, +-548, +-548, +-526, +-503, +-480, +-465, +-443, +-428, +-428, +-420, +-405, +-390, +-382, +-367, +-352, +-352, +-337, +-329, +-314, +-307, +-299, +-292, +-288, +-277, +-269, +-262, +-254, +-254, +-246, +-243, +-239, +-231, +-231, +-224, +-216, +-209, +-209, +-201, +-194, +-194, +-186, +-179, +-179, +-175, +-171, +-164, +-156, +-148, +-148, +-141, +-141, +-141, +-141, +-133, +-130, +-126, +-122, +-119, +-116, +-113, +-111, +-107, +-104, +-101, +-98, +-96, +-94, +-92, +-89, +-86, +-83, +-80, +-78, +-76, +-74, +-72, +-71, +-69, +-68, +-66, +-64, +-62, +-60, +-59, +-57, +-55, +-53, +-51, +-49, +-47, +-46, +-44, +-42, +-39, +-37, +-35, +-33, +-32, +-31, +-28, +-27, +-25, +-23, +-21, +-19, +-17, +-16, +-14, +-13, +-12, +-11, +-9, +-9, +-7, +-6, +-5, +-4, +-3, +-2, +-1, +3, + +}; + + diff --git a/Open_Theremin_V3/theremin_sintable8.c b/Open_Theremin_V3/theremin_sintable8.c new file mode 100644 index 0000000..bb65b71 --- /dev/null +++ b/Open_Theremin_V3/theremin_sintable8.c @@ -0,0 +1,1032 @@ +/* Theremin WAVE Table "Sinus" - 1024 entries full table, amplitude -2048.,*/ + +#include + +const int16_t sine_table8[1024] PROGMEM = {\ +11, +42, +47, +51, +56, +69, +80, +91, +102, +112, +123, +130, +138, +145, +152, +159, +166, +174, +181, +188, +195, +202, +210, +217, +224, +231, +238, +246, +253, +260, +267, +274, +282, +289, +297, +304, +312, +327, +334, +342, +349, +355, +360, +365, +380, +387, +391, +395, +402, +410, +414, +417, +425, +429, +432, +436, +440, +448, +451, +455, +463, +465, +468, +470, +478, +482, +485, +493, +500, +504, +508, +515, +523, +523, +531, +538, +542, +546, +561, +568, +568, +576, +583, +587, +591, +598, +602, +606, +614, +621, +625, +629, +636, +644, +651, +655, +659, +663, +666, +674, +678, +681, +689, +696, +699, +702, +704, +704, +712, +715, +719, +723, +727, +742, +749, +753, +757, +764, +768, +772, +779, +787, +795, +802, +805, +807, +810, +817, +821, +825, +832, +837, +842, +847, +855, +859, +862, +866, +870, +874, +878, +881, +885, +893, +900, +908, +910, +913, +915, +930, +938, +942, +945, +949, +953, +961, +968, +976, +983, +988, +993, +998, +1006, +1010, +1013, +1028, +1031, +1033, +1036, +1043, +1051, +1059, +1062, +1066, +1069, +1071, +1074, +1089, +1093, +1096, +1104, +1106, +1109, +1111, +1126, +1130, +1134, +1138, +1142, +1157, +1160, +1164, +1172, +1179, +1184, +1189, +1194, +1202, +1209, +1217, +1225, +1228, +1232, +1240, +1243, +1247, +1255, +1257, +1260, +1262, +1277, +1285, +1289, +1292, +1300, +1304, +1308, +1315, +1319, +1323, +1323, +1330, +1334, +1338, +1345, +1353, +1353, +1360, +1368, +1372, +1375, +1383, +1383, +1390, +1398, +1406, +1406, +1406, +1413, +1417, +1421, +1428, +1436, +1440, +1443, +1447, +1451, +1458, +1466, +1473, +1476, +1478, +1481, +1496, +1500, +1504, +1511, +1515, +1519, +1522, +1526, +1534, +1541, +1544, +1546, +1549, +1556, +1564, +1568, +1572, +1579, +1583, +1587, +1590, +1594, +1602, +1602, +1602, +1605, +1609, +1617, +1621, +1624, +1632, +1632, +1636, +1639, +1643, +1647, +1647, +1654, +1662, +1666, +1670, +1677, +1677, +1685, +1692, +1700, +1704, +1707, +1715, +1715, +1722, +1730, +1730, +1734, +1737, +1745, +1745, +1753, +1753, +1760, +1764, +1768, +1768, +1775, +1775, +1783, +1783, +1787, +1790, +1790, +1798, +1798, +1798, +1805, +1805, +1805, +1813, +1813, +1820, +1828, +1828, +1832, +1836, +1836, +1843, +1843, +1843, +1851, +1851, +1851, +1858, +1858, +1866, +1866, +1873, +1873, +1873, +1873, +1881, +1881, +1888, +1888, +1888, +1888, +1888, +1896, +1896, +1896, +1896, +1896, +1896, +1903, +1903, +1903, +1903, +1907, +1911, +1911, +1911, +1911, +1911, +1911, +1911, +1911, +1903, +1903, +1903, +1896, +1896, +1892, +1888, +1881, +1881, +1873, +1866, +1866, +1862, +1858, +1858, +1851, +1851, +1843, +1843, +1839, +1836, +1828, +1828, +1820, +1813, +1805, +1802, +1798, +1790, +1783, +1768, +1760, +1753, +1753, +1745, +1737, +1722, +1715, +1707, +1692, +1688, +1677, +1670, +1654, +1647, +1639, +1624, +1621, +1617, +1609, +1594, +1587, +1572, +1556, +1553, +1549, +1534, +1526, +1511, +1489, +1466, +1462, +1451, +1428, +1406, +1383, +1360, +1338, +1334, +1308, +1285, +1240, +1202, +1172, +1142, +1134, +1096, +1066, +1043, +1013, +991, +953, +949, +930, +908, +893, +870, +847, +832, +825, +810, +787, +764, +742, +712, +681, +678, +659, +629, +591, +531, +493, +455, +448, +425, +395, +372, +334, +297, +267, +263, +229, +199, +168, +131, +101, +70, +63, +33, +2, +-27, +-49, +-72, +-87, +-91, +-110, +-132, +-155, +-170, +-193, +-223, +-227, +-253, +-276, +-298, +-321, +-343, +-374, +-377, +-396, +-419, +-442, +-457, +-479, +-483, +-509, +-547, +-577, +-608, +-638, +-675, +-675, +-706, +-728, +-751, +-766, +-789, +-819, +-819, +-834, +-849, +-872, +-887, +-902, +-909, +-913, +-924, +-932, +-947, +-962, +-977, +-992, +-996, +-1007, +-1030, +-1045, +-1060, +-1075, +-1098, +-1098, +-1113, +-1136, +-1151, +-1166, +-1181, +-1211, +-1211, +-1226, +-1241, +-1256, +-1271, +-1286, +-1302, +-1305, +-1317, +-1332, +-1347, +-1354, +-1369, +-1384, +-1384, +-1392, +-1407, +-1415, +-1430, +-1445, +-1452, +-1452, +-1467, +-1475, +-1490, +-1505, +-1513, +-1520, +-1524, +-1528, +-1535, +-1550, +-1558, +-1573, +-1573, +-1577, +-1588, +-1596, +-1603, +-1611, +-1618, +-1626, +-1630, +-1633, +-1641, +-1648, +-1656, +-1664, +-1664, +-1667, +-1671, +-1679, +-1679, +-1686, +-1694, +-1694, +-1698, +-1701, +-1709, +-1709, +-1716, +-1731, +-1739, +-1739, +-1739, +-1747, +-1754, +-1762, +-1769, +-1777, +-1777, +-1777, +-1784, +-1792, +-1799, +-1807, +-1807, +-1811, +-1814, +-1822, +-1830, +-1830, +-1837, +-1837, +-1841, +-1859, +-1860, +-1862, +-1863, +-1866, +-1868, +-1870, +-1873, +-1874, +-1875, +-1876, +-1878, +-1880, +-1880, +-1882, +-1883, +-1884, +-1884, +-1885, +-1886, +-1886, +-1886, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1887, +-1886, +-1886, +-1886, +-1886, +-1885, +-1885, +-1883, +-1882, +-1881, +-1880, +-1879, +-1878, +-1876, +-1875, +-1873, +-1871, +-1870, +-1867, +-1864, +-1862, +-1859, +-1858, +-1852, +-1848, +-1846, +-1839, +-1836, +-1834, +-1826, +-1823, +-1819, +-1812, +-1810, +-1809, +-1802, +-1799, +-1796, +-1794, +-1791, +-1788, +-1785, +-1783, +-1781, +-1778, +-1776, +-1775, +-1773, +-1771, +-1770, +-1768, +-1766, +-1765, +-1764, +-1763, +-1760, +-1760, +-1759, +-1758, +-1756, +-1754, +-1754, +-1753, +-1751, +-1750, +-1749, +-1748, +-1746, +-1745, +-1745, +-1744, +-1743, +-1742, +-1741, +-1740, +-1739, +-1737, +-1737, +-1736, +-1734, +-1734, +-1734, +-1732, +-1732, +-1730, +-1730, +-1729, +-1728, +-1727, +-1726, +-1726, +-1725, +-1723, +-1722, +-1722, +-1721, +-1720, +-1719, +-1719, +-1718, +-1717, +-1717, +-1715, +-1715, +-1714, +-1714, +-1713, +-1712, +-1712, +-1711, +-1711, +-1709, +-1709, +-1708, +-1708, +-1707, +-1706, +-1705, +-1705, +-1704, +-1703, +-1703, +-1701, +-1701, +-1700, +-1699, +-1698, +-1698, +-1697, +-1696, +-1696, +-1695, +-1693, +-1692, +-1691, +-1690, +-1688, +-1687, +-1687, +-1684, +-1682, +-1682, +-1679, +-1677, +-1676, +-1673, +-1671, +-1668, +-1665, +-1661, +-1659, +-1656, +-1654, +-1647, +-1644, +-1639, +-1631, +-1629, +-1624, +-1618, +-1613, +-1612, +-1608, +-1606, +-1604, +-1604, +-1604, +-1601, +-1597, +-1589, +-1589, +-1582, +-1574, +-1574, +-1570, +-1567, +-1567, +-1559, +-1552, +-1544, +-1544, +-1540, +-1536, +-1529, +-1521, +-1521, +-1514, +-1506, +-1506, +-1499, +-1499, +-1491, +-1484, +-1476, +-1469, +-1469, +-1469, +-1461, +-1453, +-1446, +-1446, +-1438, +-1438, +-1431, +-1423, +-1416, +-1408, +-1401, +-1401, +-1401, +-1393, +-1393, +-1386, +-1378, +-1370, +-1367, +-1363, +-1355, +-1355, +-1348, +-1348, +-1355, +-1295, +-1280, +-1257, +-1220, +-1197, +-1167, +-1163, +-1129, +-1099, +-1061, +-1039, +-1008, +-978, +-974, +-940, +-918, +-888, +-850, +-820, +-797, +-790, +-767, +-744, +-729, +-707, +-684, +-654, +-654, +-639, +-616, +-594, +-571, +-556, +-533, +-533, +-518, +-503, +-488, +-473, +-465, +-450, +-446, +-443, +-428, +-420, +-405, +-397, +-390, +-386, +-375, +-367, +-360, +-352, +-337, +-337, +-333, +-322, +-314, +-299, +-292, +-284, +-277, +-277, +-269, +-262, +-254, +-247, +-247, +-231, +-231, +-231, +-216, +-209, +-194, +-194, +-186, +-182, +-179, +-171, +-164, +-156, +-148, +-148, +-145, +-141, +-133, +-126, +-122, +-118, +-115 +-111, +-107, +-103, +-99, +-96, +-92, +-88, +-86, +-83, +-81, +-77, +-73, +-69, +-65, +-63, +-60, +-58, +-54, +-50, +-47, +-43, +-41, +-39, +-37, +-35, +-32, +-28, +-25, +-23, +-20, +-18, +-15, +-13, +0 +}; + + diff --git a/Open_Theremin_V3/timer.cpp b/Open_Theremin_V3/timer.cpp new file mode 100644 index 0000000..77a95cc --- /dev/null +++ b/Open_Theremin_V3/timer.cpp @@ -0,0 +1,17 @@ +#include "Arduino.h" + +#include "timer.h" + +volatile uint16_t timer = 0; + +void ticktimer (uint16_t ticks) { + resetTimer(); + while (timerUnexpired(ticks)) + ; // NOP +}; + +void millitimer (uint16_t milliseconds) { + ticktimer(millisToTicks(milliseconds)); +} + + diff --git a/Open_Theremin_V3/timer.h b/Open_Theremin_V3/timer.h new file mode 100644 index 0000000..f7dd397 --- /dev/null +++ b/Open_Theremin_V3/timer.h @@ -0,0 +1,39 @@ +#ifndef _TIMER_H +#define _TIMER_H + +extern volatile uint16_t timer; + +inline uint16_t millisToTicks(uint16_t milliseconds) { + return milliseconds * (1000.0f/32); +} + +inline void resetTimer() { + timer = 0; +} + +inline void incrementTimer() { + timer++; +} + +inline bool timerExpired(uint16_t ticks) { + return timer >= ticks; +} + +inline bool timerUnexpired(uint16_t ticks) { + return timer < ticks; +} + +inline bool timerExpiredMillis(uint16_t milliseconds) { + return timerExpired(millisToTicks(milliseconds)); +} + +inline bool timerUnexpiredMillis(uint16_t milliseconds) { + return timerUnexpired(millisToTicks(milliseconds)); +} + +void ticktimer (uint16_t ticks); +void millitimer (uint16_t milliseconds); + +const uint16_t TICKS_100_MILLIS = millisToTicks(100); + +#endif // _TIMER_H