Hi,
I am completely new to the Teensy, but I only need to figure out one more thing.
For a project I connected the pui audio board to a Teensy 3.6 and I am able to play sounds (e.g. a sine wave) via DAC using the Audio Library.
However, what I actually need, is that the Teensy plays a sine wave for a second and after that it should be silent again for some seconds (say 15s). The timing is very important, but I cannot use an IntervalTimer, because interrupts might happen. I can also not use the void loop() {} because many other things need to happen at the same time. The sound needs to play independently from anything else.
Does anyone have an idea how to do that?
I thought of the IntervalTimer, which is a no-go.
Then I thought, maybe I can multiply a square or pulse and a sine wave - but I cannot get it to work the way I want it to.
There should be an easy for this, right?
Thanks in advance for any help!
Here is an example of what I have tried:
EDIT: I actually just connected one DAC, so I think then this is already not right (0 and 1, should be 0 and 0, but also does not work)
AudioConnection patchCord1(sine, 0, multiply1, 0);
AudioConnection patchCord2(square, 0, multiply1, 1);
I am completely new to the Teensy, but I only need to figure out one more thing.
For a project I connected the pui audio board to a Teensy 3.6 and I am able to play sounds (e.g. a sine wave) via DAC using the Audio Library.
However, what I actually need, is that the Teensy plays a sine wave for a second and after that it should be silent again for some seconds (say 15s). The timing is very important, but I cannot use an IntervalTimer, because interrupts might happen. I can also not use the void loop() {} because many other things need to happen at the same time. The sound needs to play independently from anything else.
Does anyone have an idea how to do that?
I thought of the IntervalTimer, which is a no-go.
Then I thought, maybe I can multiply a square or pulse and a sine wave - but I cannot get it to work the way I want it to.
There should be an easy for this, right?
Thanks in advance for any help!
Here is an example of what I have tried:
EDIT: I actually just connected one DAC, so I think then this is already not right (0 and 1, should be 0 and 0, but also does not work)
AudioConnection patchCord1(sine, 0, multiply1, 0);
AudioConnection patchCord2(square, 0, multiply1, 1);
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform sine; //xy=390,155
AudioSynthWaveform square; //xy=391,230
AudioEffectMultiply multiply1; //xy=624,211
AudioOutputAnalog dac1; //xy=834,204
AudioConnection patchCord1(sine, 0, multiply1, 0);
AudioConnection patchCord2(square, 0, multiply1, 1);
AudioConnection patchCord3(multiply1, dac1);
AudioControlSGTL5000 sgtl5000_1; //xy=635,407
// GUItool: end automatically generated code
#define RESOLUTION 12
void setup() {
analogWriteResolution(RESOLUTION);
// Start audio
AudioMemory(20);
float freq = 440.0;
float angle = 90.0;
AudioMemory(15);
//AudioNoInterrupts();
sine.begin(WAVEFORM_SINE);
sine.frequency(freq);
sine.amplitude(1.0);
sine.phase(0);
square.begin(WAVEFORM_SQUARE);
square.frequency(0.5);
square.amplitude(1.0);
square.phase(angle);
//AudioInterrupts();
// End audio
//sine1.amplitude(0.05);
//sine1.frequency(8000);
}
void loop() {
}
Last edited: