You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/08.mega/boards/giga-r1/tutorials/giga-audio/content.md
+65-2Lines changed: 65 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -639,7 +639,7 @@ void loop(){
639
639
640
640
### Playback with the GIGA R1 DACs
641
641
642
-
The GIGA R1 12-bit DAC channels can also be used to create a simple mono or stereo audio playback. In the following example, we will use a USB drive as our source for a .WAV audio files and output them using custom libraries to help us process these files. A 3.5mm audio jack-compatible speaker is also required for the audio playback output.
642
+
The GIGA R1 12-bit DAC channels can also be used to create a simple mono or stereo audio playback. In the following example, we will use a USB drive as our source for a .WAV audio files and output them using custom libraries to help us process them. A 3.5mm audio jack-compatible speaker is also required for the audio playback output.
643
643
644
644
The libraries we are going to use are the following:
645
645
@@ -748,4 +748,67 @@ void setup() {
748
748
void loop() {}
749
749
```
750
750
751
-
Once you have the setup and the code ready, you can upload it to the GIGA R1 board and play the audio file of your choice. The example can playback 3 to 4 seconds of an audio file.
751
+
Once you have the setup and the code ready, you can upload it to the GIGA R1 board and play the audio file of your choice. The example can playback 3 to 4 seconds of an audio file.
752
+
753
+
## Pulse Density Modulation Support
754
+
755
+
Pulse Density Support (PDM) is a form of modulation used to represent analog information into digital information; PDM uses a high-frequency stream of 1-bit digital samples. In PDM, a large cluster of ones represents a positive amplitude, while a large cluster of zeros represents a negative amplitude.
756
+
757
+
The GIGA R1 PDM support can be used with the [built-in PDM library](https://docs.arduino.cc/learn/built-in-libraries/pdm). Let's check an interesting example that shows of how to read a PDM microphone wwith the GIGA R1:
758
+
759
+
```arduino
760
+
#include <PDM.h>
761
+
762
+
// Default number of output channels
763
+
static const char channels = 1;
764
+
765
+
// Default PCM output frequency
766
+
static const int frequency = 16000;
767
+
768
+
// Buffer to read samples into, each sample is 16-bits
769
+
short sampleBuffer[128];
770
+
771
+
// Number of audio samples read
772
+
volatile int samplesRead;
773
+
774
+
void setup() {
775
+
Serial.begin(9600);
776
+
while (!Serial);
777
+
778
+
// Configure the callback function and gain
779
+
PDM.onReceive(onPDMdata);
780
+
PDM.setGain(30);
781
+
782
+
// Initialize PDM microphone in mono mode, and a 16 kHz sample rate:
0 commit comments