how can i get the value from sine1 at any time?

Status
Not open for further replies.

Lukashuk

Well-known member
Hello! I know how to create an audio object, for example

#include <Audio.h>
AudioSynthWaveformSine sine1;
//AudioOutputAnalog dac1;
//AudioConnection patchCord1(sine1, dac1);
void setup()
{
AudioMemory(10);
sine1.frequency(100);
sine1.phase(0);
sine1.amplitude(1.0);
}
void loop()
{
}

I do not want to use the design
AudioOutputAnalog dac1;
AudioConnection patchCord1(sine1, dac1);

I want to use
analogWrite(A14,value);

how can i get the value from sine1 at any time?
 
The audio library is designed to always create 128 samples in one batch which are written into a buffer. The AudioAnalogOutput object is the DAC on A14 which gets fed a value from that buffer in regular intervals via DMA, triggered by the PDB to output 44117 samples per second.

It makes absolutely no sense to use analogwrite instead, timing will not be precise (and you‘ll get a lot of phase jitter) and the sine object will not be aware of the amount of data consumed from the buffer, so it won‘t know when to start generating the next batch of 128 samples.
 
Status
Not open for further replies.
Back
Top