浏览代码

declare tone_incr to be volatile to prevent the compiler optimizing frequency() out of existence

dds
Pete (El Supremo) 10 年前
父节点
当前提交
a2682bac25
共有 2 个文件被更改,包括 7 次插入5 次删除
  1. +1
    -0
      synth_waveform.cpp
  2. +6
    -5
      synth_waveform.h

+ 1
- 0
synth_waveform.cpp 查看文件

@@ -46,6 +46,7 @@ void AudioSynthWaveform::set_ramp_length(int16_t r_length)
ramp_length = r_length;
}


boolean AudioSynthWaveform::begin(float t_amp,int t_hi,short type)
{
tone_type = type;

+ 6
- 5
synth_waveform.h 查看文件

@@ -50,13 +50,12 @@ public:
ramp_down(0), ramp_up(0), ramp_length(0)
{
}
// Change the frequency on-the-fly to permit a phase-continuous
// change between two frequencies.
void frequency(int t_hi)
{
// tone_incr = (0x100000000LL*t_hi)/AUDIO_SAMPLE_RATE_EXACT;
tone_incr = (0x80000000LL*t_hi)/AUDIO_SAMPLE_RATE_EXACT;
}
// If ramp_length is non-zero this will set up
// either a rmap up or a ramp down when a wave
// first starts or when the amplitude is set
@@ -85,16 +84,18 @@ public:
// set new magnitude
tone_amp = n * 32767.0;
}
boolean begin(float t_amp,int t_hi,short t_type);
virtual void update(void);
void set_ramp_length(int16_t r_length);
private:
short tone_amp;
short last_tone_amp;
short tone_freq;
uint32_t tone_phase;
uint32_t tone_incr;
// volatile prevents the compiler optimizing out the frequency function
volatile uint32_t tone_incr;
short tone_type;

uint32_t ramp_down;

正在加载...
取消
保存