Explorar el Código

Merge pull request #169 from FrankBoesing/patch-5

use AUDIO_SAMPLE_RATE_EXACT
dds
Paul Stoffregen hace 8 años
padre
commit
4e948f409a
Se han modificado 1 ficheros con 9 adiciones y 9 borrados
  1. +9
    -9
      synth_tonesweep.cpp

+ 9
- 9
synth_tonesweep.cpp Ver fichero

@@ -34,7 +34,7 @@

boolean AudioSynthToneSweep::play(float t_amp,int t_lo,int t_hi,float t_time)
{
double tone_tmp;
float tone_tmp;
if(0) {
Serial.print("AudioSynthToneSweep.begin(tone_amp = ");
@@ -52,8 +52,8 @@ if(0) {
if(t_amp > 1)return false;
if(t_lo < 1)return false;
if(t_hi < 1)return false;
if(t_hi >= 44100/2)return false;
if(t_lo >= 44100/2)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;
tone_lo = t_lo;
tone_hi = t_hi;
@@ -69,7 +69,7 @@ if(0) {
tone_sign = -1;
tone_tmp = tone_lo - tone_hi;
}
tone_tmp = tone_tmp/t_time/44100.;
tone_tmp = tone_tmp / t_time / AUDIO_SAMPLE_RATE_EXACT;
tone_incr = (tone_tmp * 0x100000000LL);
sweep_busy = 1;
return(true);
@@ -95,22 +95,23 @@ void AudioSynthToneSweep::update(void)
block = allocate();
if(block) {
bp = block->data;
uint32_t tmp = tone_freq >> 32;
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);
uint64_t tone_tmp = (0x400000000000LL * (int)((tone_freq >> 32)&0x7fffffff))/44100;

tone_phase += tone_tmp;
if(tone_phase & 0x800000000000LL)tone_phase &= 0x7fffffffffffLL;

if(tone_sign > 0) {
if((tone_freq >> 32) > tone_hi) {
if((tmp > tone_hi) {
sweep_busy = 0;
break;
}
tone_freq += tone_incr;
} else {
if((tone_freq >> 32) < tone_hi) {
if(tmp < tone_hi) {
sweep_busy = 0;

break;
@@ -121,8 +122,7 @@ void AudioSynthToneSweep::update(void)
while(i < AUDIO_BLOCK_SAMPLES) {
*bp++ = 0;
i++;
}
//b_count++;
}
// send the samples to the left channel
transmit(block,0);
release(block);

Cargando…
Cancelar
Guardar