Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

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

  1. #1
    Member
    Join Date
    Oct 2017
    Location
    Ukraine
    Posts
    33

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

    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?

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,385
    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.

  3. #3
    Member
    Join Date
    Oct 2017
    Location
    Ukraine
    Posts
    33
    @ Theremingenieur ! Thanks for your reply. He upset me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •