diff --git a/src/main_testtone.cc b/src/main_testtone.cc new file mode 100644 index 0000000..bf30ed2 --- /dev/null +++ b/src/main_testtone.cc @@ -0,0 +1,51 @@ +#include "daisy_seed.h" +#include "daisysp.h" + +// Use the daisy namespace to prevent having to type +// daisy:: before all libdaisy functions +using namespace daisy; +using namespace daisysp; + +// Declare a DaisySeed object called hardware +DaisySeed hardware; +Oscillator osc; + +void AudioCallback( + AudioHandle::InterleavingInputBuffer in, + AudioHandle::InterleavingOutputBuffer out, + size_t size) +{ + float osc_out; + + //Convert floating point knob to midi (0-127) + //Then convert midi to freq. in Hz + osc.SetFreq(1000); + + //Fill the block with samples + for (size_t i = 0; i < size; i += 2) { + osc.SetAmp(1.0); + osc_out = osc.Process(); + //Set the left and right outputs + out[i] = osc_out; + out[i + 1] = osc_out; + } +} + + +int main(void) +{ + hardware.Configure(); + hardware.Init(); + hardware.SetAudioBlockSize(4); + + float samplerate = hardware.AudioSampleRate(); + + osc.Init(samplerate); + osc.SetWaveform(osc.WAVE_SIN); + osc.SetAmp(1.f); + osc.SetFreq(1000); + + hardware.StartAudio(AudioCallback); + + for (;;) {} +}