Access to in/out buffers

I wrote a program I compile using a Makefile and make just by linking the code to libdaisy and DaisySP. In this code I use in[index_to_buf] for the left and in[index_to_buf + 1] for the right channel data, in a way similar to this bypass example:

for (size_t index_2_buf = 0; index_2_buf < size; index_2_buf += 2)
{
    // Get sample from left channel.
    xc = in[index_2_buf];
    // Get sample from right channel.
    xm = in[index_2_buf + 1];

    // Write sample to left output channel.
    out[index_2_buf] = xc;
    // Write sample to right output channel.
    out[index_2_buf + 1] = xm;
}

The compiled program works and the data on the left and right channel output is as expected. However, when I look alt examples for working with an arduino setup, I see

for (size_t index_2_buf = 0; index_2_buf < size; index_2_buf++)
{
    // Get sample from left channel.
    xc = in[0][index_2_buf];
    // Get sample from right channel.
    xm = in[1][index_2_buf];
    // some processing is done here

    // Write sample to left output channel.
    out[0][index_2_buf] = xc;
    // Write sample to right output channel.
    out[1][index_2_buf] = xm;
}

The in and out buffers apparently are 2 dimensional here.
The code compiles in the arduino ide, however, the output signal for the latter example is not the same as the former example. As far as I understand the examples it should. Am I missing something?

There are two different types of audio callback, with slightly different function prototypes.

The first type has L and R interleaved, and the buffer is one dimensional, with R indexed by L+1.

The second type can handle 2 or more channels, and uses a multidimensional array.

From libDaisy/src/daisy_seed.h:


    /** Begins the audio for the seeds builtin audio.
    the specified callback will get called whenever
    new data is ready to be prepared.
    */
    void StartAudio(dsy_audio_callback cb);

    /** Begins the audio for the seeds builtin audio.
    the specified callback will get called whenever
    new data is ready to be prepared.
    This will use the newer non-interleaved callback.
    */
    void StartAudio(dsy_audio_mc_callback cb);

See also: libDaisy/src/hid/audio.h

2 Likes