Added Hysteresis to Pots

master
Gaudi 8 years ago
parent 89ad1a5bb9
commit d1b5051f5e
  1. 17
      Open_Theremin_V3/application.cpp
  2. 24
      README.md
  3. 2
      README.md~

@ -12,6 +12,7 @@ const AppMode AppModeValues[] = {MUTE,NORMAL};
const int16_t CalibrationTolerance = 15; const int16_t CalibrationTolerance = 15;
const int16_t PitchFreqOffset = 700; const int16_t PitchFreqOffset = 700;
const int16_t VolumeFreqOffset = 700; const int16_t VolumeFreqOffset = 700;
const int8_t HYST_VAL = 40;
static int32_t pitchCalibrationBase = 0; static int32_t pitchCalibrationBase = 0;
static int32_t pitchCalibrationBaseFreq = 0; static int32_t pitchCalibrationBaseFreq = 0;
@ -162,7 +163,9 @@ void Application::loop() {
uint16_t volumePotValue = 0; uint16_t volumePotValue = 0;
uint16_t pitchPotValue = 0; uint16_t pitchPotValue = 0;
uint16_t registerPotValue = 0; int registerPotValue,registerPotValueL = 0;
int wavePotValue,wavePotValueL = 0;
uint8_t registerValue = 0;
@ -170,10 +173,14 @@ void Application::loop() {
pitchPotValue = analogRead(PITCH_POT); pitchPotValue = analogRead(PITCH_POT);
volumePotValue = analogRead(VOLUME_POT); volumePotValue = analogRead(VOLUME_POT);
registerPotValue = (analogRead(REGISTER_SELECT_POT)>>8)+1; registerPotValue = analogRead(REGISTER_SELECT_POT);
wavePotValue = analogRead(WAVE_SELECT_POT);
vWavetableSelector = analogRead(WAVE_SELECT_POT) >> 7; if ((registerPotValue-registerPotValueL) >= HYST_VAL || (registerPotValueL-registerPotValue) >= HYST_VAL) registerPotValueL=registerPotValue;
if (((wavePotValue-wavePotValueL) >= HYST_VAL) || ((wavePotValueL-wavePotValue) >= HYST_VAL)) wavePotValueL=wavePotValue;
vWavetableSelector=wavePotValueL>>7;
registerValue=4-(registerPotValueL>>8);
if (_state == PLAYING && HW_BUTTON_PRESSED) { if (_state == PLAYING && HW_BUTTON_PRESSED) {
_state = CALIBRATING; _state = CALIBRATING;
@ -224,7 +231,7 @@ void Application::loop() {
OCR0A = pitch & 0xff; OCR0A = pitch & 0xff;
#endif #endif
#if SERIAL_ENABLED #if L_ENABLED
if (timerExpired(TICKS_100_MILLIS)) { if (timerExpired(TICKS_100_MILLIS)) {
resetTimer(); resetTimer();
Serial.write(pitch & 0xff); // Send char on serial (if used) Serial.write(pitch & 0xff); // Send char on serial (if used)
@ -246,7 +253,7 @@ void Application::loop() {
// set wave frequency for each mode // set wave frequency for each mode
switch (_mode) { switch (_mode) {
case MUTE : /* NOTHING! */; break; case MUTE : /* NOTHING! */; break;
case NORMAL : setWavetableSampleAdvance((pitchCalibrationBase-pitch_v)/registerPotValue+2048-(pitchPotValue<<2)); break; case NORMAL : setWavetableSampleAdvance((pitchCalibrationBase-pitch_v)/registerValue+2048-(pitchPotValue<<2)); break;
}; };
// HW_LED2_OFF; // HW_LED2_OFF;

@ -1,2 +1,22 @@
# OpenTheremin_V3 ## Open.Theremin V3 control software
Open Source Theremin Instrument, Arudino Codes
Arduino UNO Software for the Open.Theremin
### Don't click on the files!
Click on the "Download ZIP" Button to the right or [Click here](https://github.com/GaudiLabs/OpenTheremin_V3/archive/master.zip)
Then unpack the archive.
### Open Source Theremin based on the Arduino Platform
Open.Theremin is an arduino shield to build the legendary music instrument invented by Leon Theremin back in 1920. The theremin is played with two antennas, one to control the pitch and one for volume. The electronic shield with two ports to connect those antennas comprises two heterodyne oscillators to measure the distance of the hand to the antenna when playing the instrument. The resulting signal is fed into the arduino. After linearization and filtering the arduino generates the instruments sound that is then played through a high quality digital analog audio converter on the board. The characteristics of the sound can be determined by a wave table on the arduino.
For more info on the open source project and on availability of ready made shield see:
http://www.gaudi.ch/OpenTheremin/
### Installation
1. Open up the Arduino IDE
2. Open the File "Open_Theremin_V3.ino"
3. Selecting the correct usb port on Tools -> Serial Port
4. Select the correct arduino board from Tools -> Board
5. Upload the code by clicking on the upload button.

@ -0,0 +1,2 @@
# OpenTheremin_V3
Open Source Theremin Instrument, Arudino Codes
Loading…
Cancel
Save