Fixed Volume, tested USB_HOST on T4.0 OK

pull/7/head
Dirk Niggemann 5 years ago
parent 69cdb158fd
commit 075232c2dc
  1. 16
      MicroDexed.ino
  2. 14
      source_microdexed.h

@ -961,7 +961,6 @@ void handleSystemReset(void)
/******************************************************************************
MIDI HELPER
******************************************************************************/
bool checkMidiChannel(byte inChannel)
{
// check for MIDI channel
@ -999,8 +998,7 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
// float v = (float)(a * (a + 2))/(float)(1 << 20); // (pseudo-) logarithmic curve for volume control
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
#ifdef DEBUG
Serial.print(F("Setting volume: VOL="));
@ -1020,23 +1018,23 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
switch (m)
{
case 0:
volume_r.gain(1.0);
volume_l.gain(1.0);
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(true);
break;
case 1:
volume_r.gain(1.0);
volume_l.gain(1.0);
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(false);
break;
case 2:
volume_r.gain(1.0);
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(0.0);
stereomono1.stereo(false);
break;
case 3:
volume_r.gain(0.0);
volume_l.gain(1.0);
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(false);
break;
}

@ -12,10 +12,20 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed {
AudioSourceMicroDexed(int sample_rate) : AudioStream(0, NULL), Dexed(sample_rate) {
};
void update(void) {
if (in_update) {
xrun++;
return;
}
else in_update = true;
elapsedMicros render_time;
audio_block_t *lblock;
lblock = allocate();
if (!lblock) return;
if (!lblock) {
in_update = false;
return;
}
getSamples(AUDIO_BLOCK_SAMPLES, lblock->data);
if (render_time > audio_block_time_us) // everything greater 2.9ms is a buffer underrun!
xrun++;
@ -24,6 +34,8 @@ class AudioSourceMicroDexed : public AudioStream, public Dexed {
transmit(lblock, 0);
release(lblock);
in_update = false;
};
private:
volatile bool in_update = false;
};

Loading…
Cancel
Save