-
Notifications
You must be signed in to change notification settings - Fork 253
Expand file tree
/
Copy pathPassthruExample.cpp
More file actions
59 lines (54 loc) · 1.92 KB
/
PassthruExample.cpp
File metadata and controls
59 lines (54 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "daisy_patch_sm.h"
#include "daisysp.h"
/** These are namespaces for the daisy libraries.
* These lines allow us to omit the "daisy::" and "daisysp::" before
* referencing modules, and functions within the daisy libraries.
*/
using namespace daisy;
using namespace patch_sm;
using namespace daisysp;
/** Our hardware board class handles the interface to the actual DaisyPatchSM
* hardware. */
DaisyPatchSM patch;
/** Callback for processing and synthesizing audio
*
* The audio buffers are arranged as arrays of samples for each channel.
* For example, to access the left input you would use:
* in[0][n]
* where n is the specific sample.
* There are "size" samples in each array.
*
* The default size is 48 samples per channel. This means the
* callback is being called at 1kHz.
*
* You can change this size by calling patch.SetAudioBlockSize(desired_size).
* When running complex DSP it is more efficient to do the processing on larger chunks at a time.
*
*/
void AudioCallback(AudioHandle::InputBuffer in,
AudioHandle::OutputBuffer out,
size_t size)
{
/** The easiest way to do pass thru is to simply copy the input to the output
* In C++ the standard way of doing this is with std::copy. However, those
* familliar with C can use memcpy. A simple loop is also a good way to do
* this.
*
* Since you'll most likely want to be doing something between the input,
* and the output, and not just passing it through we'll demonstrate doing
* so with a for loop.
*/
for(size_t i = 0; i < size; i++)
{
out[0][i] = in[0][i]; /**< Copy the left input to the left output */
out[1][i] = in[1][i]; /**< Copy the right input to the right output */
}
}
int main(void)
{
/** Initialize the hardware */
patch.Init();
/** Start Processing the audio */
patch.StartAudio(AudioCallback);
while(1) {}
}