I need help with my project. I try get control over CC by amplitude from microphone audio signal. Maybe someone can help me with my code? Almost is done, but I can’t get midi to work. Unfortunately maths functions is not my best, still have some problems with understanding how to using it for good results .
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.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(8);
Serial.begin(115200);
}
// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.
elapsedMillis fps;
int mod;
void loop() {
if (fps > 48) {
if (peak1.available()) {
fps = 0;
int monoPeak = peak1.readPeakToPeak() * 80.0;
for
(int cnt=0; cnt<monoPeak; cnt++) {
mod = map(mod,0,1023,0,127);
}
usbMIDI.sendControlChange(1, mod, 0);
}
}
}
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.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(8);
Serial.begin(115200);
}
// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.
elapsedMillis fps;
int mod;
void loop() {
if (fps > 48) {
if (peak1.available()) {
fps = 0;
int monoPeak = peak1.readPeakToPeak() * 80.0;
for
(int cnt=0; cnt<monoPeak; cnt++) {
mod = map(mod,0,1023,0,127);
}
usbMIDI.sendControlChange(1, mod, 0);
}
}
}