Pārlūkot izejas kodu

Update more examples

dds
PaulStoffregen pirms 10 gadiem
vecāks
revīzija
c1f34a4b18
5 mainītis faili ar 60 papildinājumiem un 44 dzēšanām
  1. +15
    -2
      examples/Analysis/FFT/FFT.ino
  2. +0
    -42
      examples/Analysis/MonoPeakMeterAnalog/MonoPeakMeterAnalog.ino
  3. +45
    -0
      examples/Analysis/PeakMeterMono/PeakMeterMono.ino
  4. +0
    -0
      examples/Analysis/PeakMeterStereo/PeakMeterStereo.ino
  5. +0
    -0
      examples/Analysis/SpectrumAnalyzerBasic/SpectrumAnalyzerBasic.ino

+ 15
- 2
examples/Analysis/FFT/FFT.ino Parādīt failu

@@ -1,3 +1,16 @@
// FFT Test
//
// Compute a 1024 point Fast Fourier Transform (spectrum analysis)
// on audio connected to the Left Line-In pin. By changing code,
// a synthetic sine wave can be input instead.
//
// The first 40 (of 512) frequency analysis bins are printed to
// the Arduino Serial Monitor. Viewing the raw data can help you
// understand how the FFT works and what results to expect when
// using the data to control LEDs, motors, or other fun things!
//
// This example code is in the public domain.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
@@ -28,7 +41,7 @@ void setup() {
// Enable the audio shield and set the output volume.
audioShield.enable();
audioShield.inputSelect(myInput);
audioShield.volume(0.6);
audioShield.volume(0.5);

// Configure the window algorithm to use
myFFT.windowFunction(AudioWindowHanning1024);
@@ -54,7 +67,7 @@ void loop() {
Serial.print(n);
Serial.print(" ");
} else {
Serial.print(" - ");
Serial.print(" - "); // don't print "0.00"
}
}
Serial.println();

+ 0
- 42
examples/Analysis/MonoPeakMeterAnalog/MonoPeakMeterAnalog.ino Parādīt failu

@@ -1,42 +0,0 @@
/* Mono peak meter example using Analog objects. Assumes Teensy 3.1

At a minimum DC decouple audio signals to/from Teensy pins with capacitors in the signal paths both in and out, 10uF is often used.
Possibly worthwhile to set up virtual ground at 3v3/2 for both, or if changing DAC REF to 1.2V then 1.2V/2 for output side.

This example code is in the public domain
*/

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

AudioInputAnalog audioInput(A0); // A0 is pin 14, feel free to change.
AudioAnalyzePeak peak;
AudioOutputAnalog audioOutput; // DAC pin.

AudioConnection c1(audioInput,peak);
AudioConnection c2(audioInput,audioOutput);

void setup() {
AudioMemory(4);
Serial.begin(9600);
}

// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.

elapsedMillis fps;

void loop() {
if (fps > 24) {
if (peak.available()) {
fps = 0;
uint8_t monoPeak = peak.read() * 30.0;
Serial.print("|");
for (uint8_t cnt=0;cnt<monoPeak;cnt++) {
Serial.print(">");
}
Serial.println();
}
}
}

+ 45
- 0
examples/Analysis/PeakMeterMono/PeakMeterMono.ino Parādīt failu

@@ -0,0 +1,45 @@
/* Mono Peak Meter

Scrolling peak audio level meter in the Arduino Serial Monitor

Audio input needs to connect to pin 16 (A2). The signal range is 0 to 1.2V.
See the documentation in the Audio System Design Tool for the recommended
circuit to connect an analog signal.

This example code is in the public domain
*/

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

// GUItool: begin automatically generated code
AudioInputAnalog adc1; //xy=164,95
AudioAnalyzePeak peak1; //xy=317,123
AudioConnection patchCord1(adc1, peak1);
// GUItool: end automatically generated code


void setup() {
AudioMemory(4);
Serial.begin(9600);
}

// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.

elapsedMillis fps;

void loop() {
if (fps > 24) {
if (peak1.available()) {
fps = 0;
int monoPeak = peak1.read() * 30.0;
Serial.print("|");
for (int cnt=0; cnt<monoPeak; cnt++) {
Serial.print(">");
}
Serial.println();
}
}
}

examples/Analysis/StereoPeakMeter/StereoPeakMeter.ino → examples/Analysis/PeakMeterStereo/PeakMeterStereo.ino Parādīt failu


examples/Analysis/SpectrumAnalyzer/SpectrumAnalyzer.ino → examples/Analysis/SpectrumAnalyzerBasic/SpectrumAnalyzerBasic.ino Parādīt failu


Notiek ielāde…
Atcelt
Saglabāt