Je travaille sur mon projet final pour mon diplôme de musique (l'idée est d'explorer d'autres méthodes de saisie pour interagir avec les instruments électroniques) et je mets en place un écran tactile synthé basé utilisant le Teensy 3.2 et l'Adafruit STMPE610. J'avais initialement prévu d'aller avec une configuration basée sur le matériel, mais après avoir lutté avec différents circuits, j'ai décidé d'aller avec un logiciel avec lequel je suis beaucoup plus à l'aise. Le problème que je rencontre, c'est que je n'arrive pas à lire le son via le DAC intégré ou via l'interface USB numérique transmise à l'ordinateur. Je peux voir que le programme passe à l'endroit où l'audio devrait être joué mais rien ne semble vouloir fonctionner. Après l'ajout de dac1.begin(), le programme se bloque et n'imprime que le titre du projet initial. Je ne pense pas que cette fonction soit requise, mais après avoir regardé le code source de la bibliothèque, je l'ai trouvé, alors j'ai pensé que j'essaierais. Je ne suis pas sûr s'il me manque quelque chose dans ma fonction de configuration ou si je dois spécifiquement produire l'audio dans la fonction de boucle.Pas de sortie audio Teensy 3.2 en utilisant le DAC ou le passthrough USB
Voici une copie de la sortie au moniteur série sans dac1.begin() avec moi en appuyant au hasard sur l'écran tactile (code source est sous):
=======================
Touch Synth
<name> - 2017
Music Major Project
=======================
Note on
Touch location (x,y,z) -> 1884 2371 49
Touch location (x,y,z) -> 1896 2365 37
Touch location (x,y,z) -> 1892 2365 34
Touch location (x,y,z) -> 1428 2152 37
Note off
Note on
Touch location (x,y,z) -> 1985 2440 55
Touch location (x,y,z) -> 1987 2420 39
Touch location (x,y,z) -> 2010 2381 36
Touch location (x,y,z) -> 2023 2327 34
Touch location (x,y,z) -> 2277 2552 34
Touch location (x,y,z) -> 2074 2648 40
Note off
Note on
Touch location (x,y,z) -> 2006 2575 35
Touch location (x,y,z) -> 2024 2568 35
Note off
Note on
Touch location (x,y,z) -> 1992 2522 34
Touch location (x,y,z) -> 2005 2525 31
Touch location (x,y,z) -> 2004 2523 31
Touch location (x,y,z) -> 2007 2514 33
Note off
Note on
Touch location (x,y,z) -> 2047 2409 36
Touch location (x,y,z) -> 2036 2410 32
Touch location (x,y,z) -> 2039 2405 31
Touch location (x,y,z) -> 2066 2399 37
Note off
Note on
Touch location (x,y,z) -> 2058 2367 36
Touch location (x,y,z) -> 2062 2372 34
Note off
Note on
Touch location (x,y,z) -> 2013 2398 34
Touch location (x,y,z) -> 2029 2399 32
Note off
Et le code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SerialFlash.h>
#include "Adafruit_STMPE610.h"
// ===== Audio GUI Tool code =====
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=97,100
AudioSynthWaveform waveform2; //xy=97,137
AudioMixer4 mixer1; //xy=349,119
AudioEffectEnvelope envelope1; //xy=514,104
AudioMixer4 mixer2; //xy=676,123
AudioOutputAnalog dac1; //xy=841,110
AudioConnection patchCord1(waveform1, 0, mixer1, 0);
AudioConnection patchCord2(waveform2, 0, mixer1, 1);
AudioConnection patchCord3(mixer1, envelope1);
AudioConnection patchCord4(envelope1, 0, mixer2, 0);
AudioConnection patchCord5(mixer2, 0, dac1, 0);
// GUItool: end automatically generated code
// ===== Pinout setup =====
const byte PWR_LED = 13;
const byte GATE_OUT = 6;
const byte SPI_SCK = 14;
const byte SPI_MOSI = 11;
const byte SPI_MISO = 12;
const byte STMPE_CS = 15; // Touch Screen Controller Chip Select
const byte aPot = 16;
const byte rPot = 17;
// ===== Touch Screen Object Declaration =====
// SDI to MOSI, SDO to MISO, and SCL to SPI CLOCK
// Tie MODE to 3.3V and POWER CYCLE the STMPE610 (there is no reset pin)
Adafruit_STMPE610 touch = Adafruit_STMPE610(STMPE_CS, SPI_MOSI, SPI_MISO, SPI_SCK);
// ===== Function Declarations =====
void error(int);
// ===== Global variables =====
int gTouchOn = 0;
int gNoteOn = 0;
void setup() {
Serial.begin(9600); // Setup serial
Serial.println("======================="); // ============================
Serial.println("Touch Synth"); //
Serial.println("Callum Blackmore - 2017"); // Print faux splash screen to
Serial.println("Music Major Project"); // serial output
Serial.println("======================="); //
//Serial.flush(); // ============================
pinMode(PWR_LED, OUTPUT); //Setup power LED
digitalWrite(PWR_LED, HIGH);
if (! touch.begin()) {
Serial.println("STMPE not found!");
error(1000);
}
AudioMemory(50);
//dac1.begin(); // <--- Code will hang here if uncommented
dac1.analogReference(INTERNAL);
waveform1.begin(WAVEFORM_SINE);
waveform2.begin(WAVEFORM_TRIANGLE);
mixer1.gain(0, 0.5);
mixer1.gain(1, 0.5);
mixer2.gain(0, 0.75);
envelope1.delay(0);
envelope1.attack(100);
envelope1.hold(0);
envelope1.decay(15);
envelope1.sustain(0.7);
envelope1.release(200);
}
void loop() {
// put your main code here, to run repeatedly:
uint16_t analogVal; // temp value for analog reads
uint16_t x, y; // Touch coordinates
uint8_t z; // ''
analogVal = analogRead(aPot); // =====
//Serial.print(analogVal); Serial.print(' ');
envelope1.attack(analogVal/10); // Read pots and update attack and release values
analogVal = analogRead(rPot); //
//Serial.print(analogVal); Serial.println(' ');
envelope1.release(analogVal/10); // =====
if(touch.touched())
{
gTouchOn = 1;
while (! touch.bufferEmpty())
{
touch.readData(&x, &y, &z);
waveform1.frequency((y*2)+100);
waveform2.frequency((y*2)+100);
Serial.print("Touch location (x,y,z) -> ");
Serial.print(x); Serial.print(' ');
Serial.print(y); Serial.print(' ');
Serial.print(z); Serial.println(' ');
}
touch.writeRegister8(STMPE_INT_STA, 0xFF); // reset all ints
if(gNoteOn == 0)
{
Serial.print("Note on"); Serial.println(' ');
gNoteOn = 1;
envelope1.noteOn();
}
}
else if(!touch.touched() && gNoteOn == 1)
{
Serial.print("Note off"); Serial.println(' ');
envelope1.noteOff();
gNoteOn = 0;
gTouchOn = 0;
}
}
void error(int len){
while(1) {
digitalWrite(PWR_LED, HIGH);
delay(len);
digitalWrite(PWR_LED, LOW);
delay(len);
}
}