Quellcode durchsuchen

Fix up synth_tonesweep and the example to conform (more closely) to the naming conventions

dds
Pete (El Supremo) vor 10 Jahren
Ursprung
Commit
456a59dc0c
3 geänderte Dateien mit 12 neuen und 14 gelöschten Zeilen
  1. +5
    -5
      examples/ToneSweep/ToneSweep.ino
  2. +5
    -7
      synth_tonesweep.cpp
  3. +2
    -2
      synth_tonesweep.h

+ 5
- 5
examples/ToneSweep/ToneSweep.ino Datei anzeigen

@@ -40,7 +40,7 @@ AudioConnection c2(myEffect, 0, audioOutput, 1);
AudioControlSGTL5000 audioShield;


int t_ampx = 20000;
float t_ampx = 0.8;
int t_lox = 10;
int t_hix = 22000;
// Length of time for the sweep in seconds
@@ -63,20 +63,20 @@ void setup(void)

Serial.println("setup done");

if(!myEffect.begin(t_ampx,t_lox,t_hix,t_timex)) {
if(!myEffect.play(t_ampx,t_lox,t_hix,t_timex)) {
Serial.println("AudioSynthToneSweep - begin failed");
while(1);
}
// wait for the sweep to end
while(myEffect.busy());
while(myEffect.isPlaying());

// and now reverse the sweep
if(!myEffect.begin(t_ampx,t_hix,t_lox,t_timex)) {
if(!myEffect.play(t_ampx,t_hix,t_lox,t_timex)) {
Serial.println("AudioSynthToneSweep - begin failed");
while(1);
}
// wait for the sweep to end
while(myEffect.busy());
while(myEffect.isPlaying());
Serial.println("Done");
}


+ 5
- 7
synth_tonesweep.cpp Datei anzeigen

@@ -32,7 +32,7 @@
// Written by Pete (El Supremo) Feb 2014


boolean AudioSynthToneSweep::begin(short t_amp,int t_lo,int t_hi,float t_time)
boolean AudioSynthToneSweep::play(float t_amp,int t_lo,int t_hi,float t_time)
{
double tone_tmp;
@@ -49,6 +49,7 @@ if(0) {
}
tone_amp = 0;
if(t_amp < 0)return false;
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;
@@ -58,11 +59,8 @@ if(0) {
tone_hi = t_hi;
tone_phase = 0;

tone_amp = t_amp;
// Limit the output amplitude to prevent aliasing
// until I can figure out why this "overtops"
// above 29000.
if(tone_amp > 29000)tone_amp = 29000;
tone_amp = t_amp * 32767.0;

tone_tmp = tone_hi - tone_lo;
tone_sign = 1;
tone_freq = tone_lo*0x100000000LL;
@@ -78,7 +76,7 @@ if(0) {



unsigned char AudioSynthToneSweep::busy(void)
unsigned char AudioSynthToneSweep::isPlaying(void)
{
return(sweep_busy);
}

+ 2
- 2
synth_tonesweep.h Datei anzeigen

@@ -35,9 +35,9 @@ public:
AudioStream(0,NULL), sweep_busy(0)
{ }

boolean begin(short t_amp,int t_lo,int t_hi,float t_time);
boolean play(float t_amp,int t_lo,int t_hi,float t_time);
virtual void update(void);
unsigned char busy(void);
unsigned char isPlaying(void);

private:
short tone_amp;

Laden…
Abbrechen
Speichern