Passer au contenu principal

Système USB / Micro / Casque

Introduction

Teensy permet de simuler une "carte son" USB, ce réglage permet:

  • D'avoir le son de l'ordinateur (pc) sur la sortie headphones du teensy
  • D'avoir le son du micro sur la sortie headphones (direct_mic) et en tant que micro USB (pc_mic)
  • D'ajouter des effets au son du micro (reverb/chorus)
  • D'ajouter des filtres / compression sur le micro
  • De paramétrer (en partie pour le moment) les réglages des effets en MIDI.

Prérequis

Ce système nécessite un:

  • Teensy (Testé sur 4.2)
  • Teensy Audio Board
  • Un PCB pour relier un micro jack
  • Un micro au format Jack (Ici : un micro cravate Rode NT1)
  • Un casque audio

Pour enregistrer le son du micro en direct sans latence, je vous conseille d'installer la demo de Fruity Loop pour avoir FL Studio Asio (bien meilleur que Asio4All)
https://www.image-line.com/

PCB Headphones

Paramétrages sur Audio System Design Tool

 

image-1620219275159.png

 

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

// GUItool: begin automatically generated code
AudioInputUSB            pc; //xy=62,74
AudioInputI2S            mic;           //xy=62,229
AudioEffectFreeverb      reverb;      //xy=206,161
AudioEffectChorus        chorus;        //xy=206,266
AudioMixer4              mic_effects;         //xy=397,229
AudioFilterBiquad        mic_post_filter;        //xy=598,244
AudioOutputUSB           pc_mic;           //xy=617,394
AudioMixer4              direct_mic;         //xy=758,160
AudioMixer4              left;         //xy=877,48
AudioMixer4              right;         //xy=892,115
AudioOutputI2S           headphones; //xy=1136,59
AudioConnection          patchCord1(pc, 0, left, 0);
AudioConnection          patchCord2(pc, 1, right, 0);
AudioConnection          patchCord3(mic, 0, reverb, 0);
AudioConnection          patchCord4(mic, 0, mic_effects, 1);
AudioConnection          patchCord5(mic, 1, chorus, 0);
AudioConnection          patchCord6(reverb, 0, mic_effects, 0);
AudioConnection          patchCord7(chorus, 0, mic_effects, 2);
AudioConnection          patchCord8(mic_effects, 0, pc_mic, 0);
AudioConnection          patchCord9(mic_effects, 0, pc_mic, 1);
AudioConnection          patchCord10(mic_effects, mic_post_filter);
AudioConnection          patchCord11(mic_post_filter, 0, direct_mic, 0);
AudioConnection          patchCord12(direct_mic, 0, left, 1);
AudioConnection          patchCord13(direct_mic, 0, right, 1);
AudioConnection          patchCord14(left, 0, headphones, 0);
AudioConnection          patchCord15(right, 0, headphones, 1);
AudioControlSGTL5000     audio; //xy=60,24
// GUItool: end automatically generated code

Programme

float bass_level = -0.3;
float mid_bass_level = 0.5;
float midrange_level = 1.0;
float mid_treble_level = 1.0;
float treble_level = 1.0;

void setup() {
  AudioMemory(100);

  audio.enable(); //Enable Audio board
  audio.audioPreProcessorEnable(); //Enable Preprocessor (eq/compressor)
  audio.volume(1); //Headphones Volume
  audio.inputSelect(AUDIO_INPUT_MIC); //Enable Analog Microphone
  audio.micGain(5); //Mic gain to +5db
  
  audio.eqBands(bass_level, mid_bass_level, midrange_level, mid_treble_level, treble_level); // Equalizer
  mic_effects.gain(0, 0.6); // Reverb
  mic_effects.gain(1, 0.3); // Dry
  mic_effects.gain(2, 0); // Chorus
  direct_mic.gain(1, 0.5); //Direct mic volume
  reverb.roomsize(1); //Reverb room size / damping
  reverb.damping(0.6);
  //audio.autoVolumeControl(1, 100, 1, -18, 100, 1000); // Compressor/Limiter
  //audio.autoVolumeEnable();
  mic_post_filter.setHighShelf(0, 15000 , -50, 1); // Remove high level frequency
  usbMIDI.setHandleControlChange(myControlChange); // Get Control Change Midi

  //chorus1.begin(delayline,CHORUS_DELAY_LENGTH,n_chorus);
  //chorus1.voices(n_chorus);
}

// Change int value to float value, useful for converting midi to 0.0/1.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}


void myControlChange(byte channel, byte control, byte value) {
  float floatvalue = mapfloat(value, 0, 127, 0.0, 1.0);
  Serial.println(control);

  if (control == 11) {
    int percent = map(value, 0, 127, 0, 63);
    audio.micGain(percent);
    Serial.print("Microphone Gain :" );
    Serial.println(percent);
  }

  switch (control) {
    case 7:
      mic_effects.gain(0, floatvalue);
      Serial.print("Reverb Mix :");
      Serial.println(floatvalue);
      break;
    case 8:
      mic_effects.gain(1, floatvalue);
      Serial.print("Dry Mix : ");
      Serial.println(floatvalue);
      break;
    case 9:
      reverb.damping(floatvalue);
      Serial.print("Reverb Damp : ");
      Serial.println(floatvalue);
      break;
    case 10:
      reverb.roomsize(floatvalue);
      Serial.println(floatvalue);
      Serial.print("Reverb Room Size : ");
      break;
    case 12:
      audio.volume(floatvalue);
      Serial.println("Headphones Mix :");
      Serial.println(floatvalue);
      break;
    case 13:
      bass_level = mapfloat(value, 0, 127, -1.0, 1.0);
      audio.eqBands(bass_level, mid_bass_level, midrange_level, mid_treble_level, treble_level);
      Serial.println("Bass : ");
      Serial.println(bass_level);
      break;
    case 14:
      mid_bass_level = mapfloat(value, 0, 127, -1.0, 1.0);
      audio.eqBands(bass_level, mid_bass_level, midrange_level, mid_treble_level, treble_level);
      Serial.println("Mid bass : ");
      Serial.println(mid_bass_level);
      break;
    case 15:
      midrange_level = mapfloat(value, 0, 127, -1.0, 1.0);
      audio.eqBands(bass_level, mid_bass_level, midrange_level, mid_treble_level, treble_level);
      Serial.println("Mid Range : ");
      Serial.println(midrange_level);
      break;
    case 16:
      mid_treble_level = mapfloat(value, 0, 127, -1.0, 1.0);
      audio.eqBands(bass_level, mid_bass_level, midrange_level, mid_treble_level, treble_level);
      Serial.println("Mid Treble : ");
      Serial.println(mid_treble_level);
      break;
    case 17:
      treble_level = mapfloat(value, 0, 127, -1.0, 1.0);
      audio.eqBands(bass_level, mid_bass_level, midrange_level, mid_treble_level, treble_level);
      Serial.println("Treble : ");
      Serial.println(treble_level);
      break;
    case 18:
      direct_mic.gain(0, floatvalue);
      Serial.println("Direct Mic :");
      Serial.println(floatvalue);
      break;
    default:
      Serial.print(control);
      Serial.print(" : ");
      Serial.println(value);
      break;
  }
}

void loop() {
  usbMIDI.read();
}

Open Stage Control

Lien de téléchargement : https://openstagecontrol.ammd.net/