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 MIDI HELPER
******************************************************************************/ ******************************************************************************/
bool checkMidiChannel(byte inChannel) bool checkMidiChannel(byte inChannel)
{ {
// check for MIDI channel // 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 // 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 // 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 #ifdef DEBUG
Serial.print(F("Setting volume: VOL=")); Serial.print(F("Setting volume: VOL="));
@ -1020,23 +1018,23 @@ void set_volume(uint8_t v, int8_t p, uint8_t m)
switch (m) switch (m)
{ {
case 0: case 0:
volume_r.gain(1.0); volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(1.0); volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(true); stereomono1.stereo(true);
break; break;
case 1: case 1:
volume_r.gain(1.0); volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(1.0); volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(false); stereomono1.stereo(false);
break; break;
case 2: case 2:
volume_r.gain(1.0); volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(0.0); volume_l.gain(0.0);
stereomono1.stereo(false); stereomono1.stereo(false);
break; break;
case 3: case 3:
volume_r.gain(0.0); volume_r.gain(0.0);
volume_l.gain(1.0); volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
stereomono1.stereo(false); stereomono1.stereo(false);
break; break;
} }

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

Loading…
Cancel
Save