Browse Source

types and testtone

usb_midi_launchpad
heck 7 months ago
parent
commit
aa88142f8b
  1. 77
      src/main_testtone.cc
  2. 6
      src/types.hh

77
src/main_testtone.cc

@ -1,43 +1,54 @@
#include "daisy_seed.h" #include "types.hh"
#include "daisysp.h"
namespace ld = daisy; namespace Heck {
namespace dsp = daisysp; namespace Constants {
}
static ld::DaisySeed hardware;
static dsp::Oscillator osc;
void AudioCallback( ld::DaisySeed hw{};
ld::AudioHandle::InterleavingInputBuffer in, dsp::Oscillator osc{};
ld::AudioHandle::InterleavingOutputBuffer out,
size_t size) void AudioCallback(
{ ld::AudioHandle::InterleavingInputBuffer in,
float osc_out; ld::AudioHandle::InterleavingOutputBuffer out,
osc.SetFreq(1000); size_t size)
for (size_t i = 0; i < size; i += 2) { {
osc.SetAmp(1.0); float osc_out;
osc_out = osc.Process(); osc.SetFreq(1000);
osc_out *= 0.01;
out[i] = osc_out; for (size_t i = 0; i < size; i += 2) {
out[i + 1] = osc_out; osc.SetAmp(1.0);
osc_out = osc.Process();
osc_out *= 0.005;
out[i] = osc_out;
out[i + 1] = osc_out;
}
} }
}
void init()
{
hw.Configure();
hw.Init();
hw.SetAudioBlockSize(4);
float samplerate = hw.AudioSampleRate();
int main(void) osc.Init(samplerate);
{ osc.SetWaveform(osc.WAVE_SIN);
hardware.Configure(); osc.SetAmp(1.f);
hardware.Init(); osc.SetFreq(1000);
hardware.SetAudioBlockSize(4);
float samplerate = hardware.AudioSampleRate(); hw.StartAudio(AudioCallback);
}
osc.Init(samplerate); void mainloop()
osc.SetWaveform(osc.WAVE_SIN); {
osc.SetAmp(1.f); for (;;) {}
osc.SetFreq(1000); }
} // namespace Heck
hardware.StartAudio(AudioCallback);
while (true) {} int main(void)
{
Heck::init();
Heck::mainloop();
return 0;
} }

6
src/types.hh

@ -7,7 +7,7 @@
namespace Heck { namespace Heck {
// Types // fundamental types
using u8 = uint8_t; using u8 = uint8_t;
using u16 = uint16_t; using u16 = uint16_t;
using u32 = uint32_t; using u32 = uint32_t;
@ -24,6 +24,10 @@ namespace Heck {
// namespace aliases // namespace aliases
namespace ld = daisy; namespace ld = daisy;
namespace dsp = daisysp; namespace dsp = daisysp;
// type aliases from libs
using Samplerate = ld::SaiHandle::Config::SampleRate;
} // namespace Heck } // namespace Heck

Loading…
Cancel
Save