Browse Source

types and testtone

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

43
src/main_testtone.cc

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