Fixed volume code.

pull/4/head
Holger Wirtz 6 years ago
parent 493240126f
commit 44e21b8777
  1. 17
      MicroDexed.ino
  2. 2
      config.h
  3. 3
      dexed.cpp

@ -65,7 +65,6 @@ AudioConnection patchCord5(amp2, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=1055,398 AudioControlSGTL5000 sgtl5000_1; //xy=1055,398
// GUItool: end automatically generated code // GUItool: end automatically generated code
Dexed* dexed = new Dexed(SAMPLE_RATE); Dexed* dexed = new Dexed(SAMPLE_RATE);
bool sd_card_available = false; bool sd_card_available = false;
uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR); uint8_t bank = EEPROM.read(EEPROM_BANK_ADDR);
@ -133,10 +132,13 @@ void setup()
// start audio card // start audio card
AudioMemory(AUDIO_MEM); AudioMemory(AUDIO_MEM);
sgtl5000_1.enable();
sgtl5000_1.volume(VOLUME);
amp1.gain(1.0); // normal audio amp1.gain(1.0); // normal audio
amp2.gain(1.0); // normal audio amp2.gain(1.0); // normal audio
sgtl5000_1.enable();
sgtl5000_1.unmuteHeadphone();
sgtl5000_1.autoVolumeDisable(); // turn off AGC
sgtl5000_1.volume(1.0,1.0);
sgtl5000_1.dacVolume(VOLUME,VOLUME);
// start SD card // start SD card
SPI.setMOSI(SDCARD_MOSI_PIN); SPI.setMOSI(SDCARD_MOSI_PIN);
@ -170,7 +172,7 @@ void setup()
Serial.print(F("AUDIO_BLOCK_SAMPLES=")); Serial.print(F("AUDIO_BLOCK_SAMPLES="));
Serial.print(AUDIO_BLOCK_SAMPLES); Serial.print(AUDIO_BLOCK_SAMPLES);
Serial.print(F(" (Time per block=")); Serial.print(F(" (Time per block="));
Serial.print(1000000/(SAMPLE_RATE/AUDIO_BLOCK_SAMPLES)); Serial.print(1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES));
Serial.println(F("ms)")); Serial.println(F("ms)"));
#ifdef TEST_NOTE #ifdef TEST_NOTE
@ -202,8 +204,8 @@ void setup()
void loop() void loop()
{ {
int16_t* audio_buffer; // pointer to 128 * int16_t (=256 bytes!) int16_t* audio_buffer; // pointer to AUDIO_BLOCK_SAMPLES * int16_t
const uint16_t audio_block_time_ms=1000000/(SAMPLE_RATE/AUDIO_BLOCK_SAMPLES); const uint16_t audio_block_time_ms = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES);
while (42 == 42) // DON'T PANIC! while (42 == 42) // DON'T PANIC!
{ {
@ -395,7 +397,8 @@ bool handle_master_key(uint8_t data)
num = abs(num); num = abs(num);
if (num <= 10) if (num <= 10)
{ {
sgtl5000_1.volume(num * 0.1); //sgtl5000_1.volume(num * 0.1, num * 0.1);
sgtl5000_1.dacVolume(num * 0.1, num * 0.1);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Volume changed to: ")); Serial.print(F("Volume changed to: "));
Serial.println(num * 0.1, DEC); Serial.println(num * 0.1, DEC);

@ -31,7 +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 VOLUME 0.8 #define VOLUME 0.5
#define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI
#define DEFAULT_SYSEXBANK 0 #define DEFAULT_SYSEXBANK 0
#define DEFAULT_SYSEXSOUND 0 #define DEFAULT_SYSEXSOUND 0

@ -220,7 +220,8 @@ bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2)
controllers.refresh(); controllers.refresh();
break; break;
case 7: // Volume case 7: // Volume
sgtl5000_1.volume(float(value) / 0x7f); //sgtl5000_1.volume(value / 0x7f, value / 0x7f);
sgtl5000_1.dacVolume(value / 0x7f, value / 0x7f);
break; break;
case 10: // Pan case 10: // Pan
if (value < 64) if (value < 64)

Loading…
Cancel
Save