Added PT8211 output driver option.

pull/4/head
Holger Wirtz 6 years ago
parent 5cee620f4a
commit 836af67646
  1. 45
      MicroDexed.ino
  2. 14
      config.h
  3. 2
      dexed.h
  4. 1
      synth.h

@ -53,13 +53,25 @@ Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
#endif #endif
// GUItool: begin automatically generated code // GUItool: begin automatically generated code
AudioPlayQueue queue1; //xy=708,349 AudioPlayQueue queue1; //xy=494,404
AudioAnalyzePeak peak1; //xy=909,436 AudioAmplifier volume_master; //xy=678,393
AudioOutputI2S i2s1; //xy=1055,343 AudioAnalyzePeak peak1; //xy=695,491
AudioAmplifier volume_r; //xy=818,370
AudioAmplifier volume_l; //xy=818,411
#ifdef TEENSY_AUDIO_BOARD
AudioOutputI2S i2s1; //xy=1072,364
AudioConnection patchCord5(volume_r, 0, i2s1, 0);
AudioConnection patchCord7(volume_l, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=700,536
#else
AudioOutputPT8211 pt8211_1; //xy=1079,320
AudioConnection patchCord5(volume_r, 0, pt8211_1, 0);
AudioConnection patchCord7(volume_l, 0, pt8211_1, 1);
#endif
AudioConnection patchCord1(queue1, peak1); AudioConnection patchCord1(queue1, peak1);
AudioConnection patchCord2(queue1, 0, i2s1, 0); AudioConnection patchCord2(queue1, volume_master);
AudioConnection patchCord3(queue1, 0, i2s1, 1); AudioConnection patchCord3(volume_master, volume_r);
AudioControlSGTL5000 sgtl5000_1; //xy=1055,398 AudioConnection patchCord4(volume_master, volume_l);
// GUItool: end automatically generated code // GUItool: end automatically generated code
Dexed* dexed = new Dexed(SAMPLE_RATE); Dexed* dexed = new Dexed(SAMPLE_RATE);
@ -135,12 +147,14 @@ void setup()
// start audio card // start audio card
AudioMemory(AUDIO_MEM); AudioMemory(AUDIO_MEM);
#ifdef TEENSY_AUDIO_BOARD
sgtl5000_1.enable(); sgtl5000_1.enable();
//sgtl5000_1.dacVolumeRamp(); //sgtl5000_1.dacVolumeRamp();
sgtl5000_1.dacVolumeRampLinear(); sgtl5000_1.dacVolumeRampLinear();
sgtl5000_1.unmuteHeadphone(); sgtl5000_1.unmuteHeadphone();
sgtl5000_1.autoVolumeDisable(); // turn off AGC sgtl5000_1.autoVolumeDisable(); // turn off AGC
sgtl5000_1.volume(1.0, 1.0); sgtl5000_1.volume(1.0, 1.0);
#endif
set_volume(vol, vol_left, vol_right); set_volume(vol, vol_left, vol_right);
// start SD card // start SD card
@ -246,6 +260,10 @@ void loop()
if (peak1.read() > 0.99) if (peak1.read() > 0.99)
peak++; peak++;
} }
#ifndef TEENSY_AUDIO_BOARD
for (uint8_t i = 0; i <= AUDIO_BLOCK_SAMPLES; i++)
audio_buffer[i] *= vol;
#endif
queue1.playBuffer(); queue1.playBuffer();
} }
} }
@ -489,9 +507,9 @@ int8_t num_key_base_c(uint8_t midi_note)
void set_volume(float v, float vr, float vl) void set_volume(float v, float vr, float vl)
{ {
vol=v; vol = v;
vol_right=vr; vol_right = vr;
vol_left=vl; vol_left = vl;
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX));
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX));
@ -524,7 +542,16 @@ void set_volume(float v, float vr, float vl)
Serial.println(F("]")); Serial.println(F("]"));
#endif #endif
#ifdef TEENSY_AUDIO_BOARD
volume_master.gain(1.0);
volume_r.gain(1.0);
volume_l.gain(1.0);
sgtl5000_1.dacVolume(vol * vol_left, vol * vol_right); sgtl5000_1.dacVolume(vol * vol_left, vol * vol_right);
#else
volume_master.gain(vol);
volume_r.gain(vr);
volume_l.gain(vl);
#endif
} }
void handle_sysex_parameter(const uint8_t* sysex, uint8_t len) void handle_sysex_parameter(const uint8_t* sysex, uint8_t len)

@ -31,6 +31,7 @@
// Initial values // Initial values
#define MIDI_DEVICE Serial1 #define MIDI_DEVICE Serial1
#define USE_ONBOARD_USB_HOST 1 #define USE_ONBOARD_USB_HOST 1
#define TEENSY_AUDIO_BOARD 1
#define VOLUME 0.6 #define VOLUME 0.6
#define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI
#define DEFAULT_SYSEXBANK 0 #define DEFAULT_SYSEXBANK 0
@ -41,6 +42,7 @@
#if !defined(__MK66FX1M0__) // check for Teensy-3.6 #if !defined(__MK66FX1M0__) // check for Teensy-3.6
#define MAX_NOTES 11 // No? #define MAX_NOTES 11 // No?
#undef USE_ONBOARD_USB_HOST
#else #else
#define MAX_NOTES 16 // Yes #define MAX_NOTES 16 // Yes
#endif #endif
@ -67,13 +69,13 @@
#define TEST_VEL_MAX 110 #define TEST_VEL_MAX 110
// Use these with the Teensy Audio Shield // Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN 10 //#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7 //#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14 //#define SDCARD_SCK_PIN 14
// Use these with the Teensy 3.5 & 3.6 SD card // Use these with the Teensy 3.5 & 3.6 SD card
//#define SDCARD_CS_PIN BUILTIN_SDCARD #define SDCARD_CS_PIN BUILTIN_SDCARD
//#define SDCARD_MOSI_PIN 11 // not actually used #define SDCARD_MOSI_PIN 11 // not actually used
//#define SDCARD_SCK_PIN 13 // not actually used #define SDCARD_SCK_PIN 13 // not actually used
// Encoder with button // Encoder with button
#define ENC1_PIN_A 14 #define ENC1_PIN_A 14

@ -169,7 +169,7 @@ class Dexed
04, 06, 00, // algorithm, feedback, osc sync 04, 06, 00, // algorithm, feedback, osc sync
34, 33, 00, 00, 00, 04, // lfo speed, lfo delay, lfo pitch_mod_depth, lfo_amp_mod_depth, lfo_sync, lfo_waveform 34, 33, 00, 00, 00, 04, // lfo speed, lfo delay, lfo pitch_mod_depth, lfo_amp_mod_depth, lfo_sync, lfo_waveform
03, 24, // pitch_mod_sensitivity, transpose 03, 24, // pitch_mod_sensitivity, transpose
00, 00, 00, 00, 00, 00, 00, 00, 00, 00, // 10 * char for name 69, 68, 80, 56, 85 , 76, 84, 00, 00, 00, // 10 * char for name ("DEFAULT ")
01, 00, 99, 00, 99, 00, 99, 00, 99, 00, // pitch_bend_range, pitch_bend_step, mod_wheel_range, mod_wheel_assign, foot_ctrl_range, foot_ctrl_assign, breath_ctrl_range, breath_ctrl_assign, aftertouch_range, aftertouch_assign 01, 00, 99, 00, 99, 00, 99, 00, 99, 00, // pitch_bend_range, pitch_bend_step, mod_wheel_range, mod_wheel_assign, foot_ctrl_range, foot_ctrl_assign, breath_ctrl_range, breath_ctrl_assign, aftertouch_range, aftertouch_assign
00, // master tune 00, // master tune
01, 01, 01, 01, 01, 01, // OP1-6 enable 01, 01, 01, 01, 01, 01, // OP1-6 enable

@ -19,6 +19,7 @@
//#include <Arduino.h> //#include <Arduino.h>
//#define SUPER_PRECISE //#define SUPER_PRECISE
#include <Audio.h>
// This IS not be present on MSVC. // This IS not be present on MSVC.
// See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio // See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio

Loading…
Cancel
Save