PaulStoffregen 7 years ago
parent
commit
88535e1164
3 changed files with 14 additions and 3 deletions
  1. +3
    -0
      gui/index.html
  2. +3
    -3
      synth_tonesweep.cpp
  3. +8
    -0
      synth_tonesweep.h

+ 3
- 0
gui/index.html View File

@@ -2082,6 +2082,9 @@ The actual packets are taken
<p class=func><span class=keyword>isPlaying</span>();</p>
<p class=desc>Returns true (non-zero) while the output is active.
</p>
<p class=func><span class=keyword>read</span>();</p>
<p class=desc>Returns the current frequency, or zero if the output is not active.
</p>
<h3>Examples</h3>
<p class=exam>File &gt; Examples &gt; Audio &gt; HardwareTesting &gt; ToneSweep
</p>

+ 3
- 3
synth_tonesweep.cpp View File

@@ -54,7 +54,7 @@ if(0) {
if(t_hi < 1)return false;
if(t_hi >= (int) AUDIO_SAMPLE_RATE_EXACT / 2)return false;
if(t_lo >= (int) AUDIO_SAMPLE_RATE_EXACT / 2)return false;
if(t_time < 0)return false;
if(t_time <= 0)return false;
tone_lo = t_lo;
tone_hi = t_hi;
tone_phase = 0;
@@ -99,7 +99,7 @@ void AudioSynthToneSweep::update(void)
uint64_t tone_tmp = (0x400000000000LL * (int)(tmp&0x7fffffff)) / (int) AUDIO_SAMPLE_RATE_EXACT;
// Generate the sweep
for(i = 0;i < AUDIO_BLOCK_SAMPLES;i++) {
*bp++ = (short)(( (short)(arm_sin_q31((uint32_t)((tone_phase >> 15)&0x7fffffff))>>16) *tone_amp) >> 16);
*bp++ = (short)(( (short)(arm_sin_q31((uint32_t)((tone_phase >> 15)&0x7fffffff))>>16) *tone_amp) >> 15);

tone_phase += tone_tmp;
if(tone_phase & 0x800000000000LL)tone_phase &= 0x7fffffffffffLL;
@@ -111,7 +111,7 @@ void AudioSynthToneSweep::update(void)
}
tone_freq += tone_incr;
} else {
if(tmp < tone_hi) {
if(tmp < tone_hi || tone_freq < tone_incr) {
sweep_busy = 0;

break;

+ 8
- 0
synth_tonesweep.h View File

@@ -39,6 +39,14 @@ public:
boolean play(float t_amp,int t_lo,int t_hi,float t_time);
virtual void update(void);
unsigned char isPlaying(void);
float read(void) {
__disable_irq();
uint64_t freq = tone_freq;
unsigned char busy = sweep_busy;
__enable_irq();
if (!busy) return 0.0f;
return (float)(freq >> 32);
}

private:
short tone_amp;

Loading…
Cancel
Save