You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
#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 (;;) {}
|
|
}
|
|
|