Skip to content

Commit

Permalink
Add example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellmattryan committed Oct 16, 2024
1 parent 7549cc5 commit 664b76b
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
## Overview

Welcome to Flora! This is a collection of C++ patches for the Electrosmith Daisy platform. It uses an underlying DSP library, [Cortex](https://github.com/blackboxdsp/cortex), for constructing
the processing chains for different patches.
Welcome to Flora! This is a collection of C++ patches for the Electrosmith Daisy platform.

It uses an underlying DSP library, [Cortex](https://github.com/blackboxdsp/cortex), for constructing
the processing chains for different patches.

## Getting Started

Expand Down Expand Up @@ -38,3 +40,51 @@ make program-dfu
```

:warning: Be sure to run `make clean` when compiling source code!

## Writing Patches

To write your own patch, you can simply modify an example or copy an example folder and re-write the code as necessary.

Here is an example of a simple oscillator patch:
```c++
#include "daisy_seed.h"
#include "cortex.h"

using namespace daisy;
using namespace cortex;

DaisySeed hardware;

Context context {
(size_t)hardware.AudioSampleRate(),
2,
hardware.AudioBlockSize(),
};

Oscillator oscillator(context, 110.0f);

void AudioCallback(
AudioHandle::InterleavingInputBuffer in,
AudioHandle::InterleavingOutputBuffer out,
size_t size
) {
for(size_t idx = 0; idx < size; idx += 2)
{
auto sample = (float)oscillator.Generate();
out[idx] = sample;
out[idx + 1] = sample;
}
}


int main(void) {
hardware.Configure();
hardware.Init();
hardware.SetAudioBlockSize(4);

hardware.adc.Start();
hardware.StartAudio(AudioCallback);

while(1) { }
}
```

0 comments on commit 664b76b

Please sign in to comment.