cycfi / q

C++ Library for Audio Digital Signal Processing
MIT License
1.17k stars 151 forks source link

use with raw audio stream pointers (int16_t * audio) #23

Closed mgood7123 closed 3 years ago

mgood7123 commented 3 years ago

could an example be provided to show how this can be used with audio buffer stream pointers?

for example

class Delay {
public:
    /**
     * return true if we still have data to write, otherwise false
     */
    bool write(PortUtils2 * in, PortUtils2 * out, unsigned int samples) {
        //
        // called as delay.write(mixerPortA, tmpPort);
        //
        // the value of samples is dependant on the audio engine, but is always equal to the samples
        // remaining in the audio block
        // it is one of two values:
        //
        // value 1: mixerPortA->ports.samples - i
        // value 2: mixerPortA->ports.samples
        //
        // example code to produce silence
        for (int i = 0; i < out->ports.samples; i += 2) {
            reinterpret_cast<int16_t *>(out->ports.outputStereo->l->buf)[i] = 0;
            reinterpret_cast<int16_t *>(out->ports.outputStereo->r->buf)[i] = 0;
        }
        return true;
    }
};
djowel commented 3 years ago

If you can provide an MVCE (no dependencies) with a pass-through write block, I can make one for you.

mgood7123 commented 3 years ago

If you can provide an MVCE (no dependencies) with a pass-through write block, I can make one for you.

what is a MVCE

djowel commented 3 years ago

what is a MVCE

minimal, complete and verifiable example https://stackoverflow.com/help/minimal-reproducible-example