barahlo
Member
Hi!
I'm working on my teensy synthesizer project and ran into a problem.
I use teensy 3.6, without an audio shield. And want the synth interface to be displayed on a ILI9341.
Every time the display updates with new text or any other graphic it produces short high pitch noise, changing SPI speed inside tft.begin() changes the pitch of that noise and at low speeds, it almost disappears but the screen updates become extremely slow, encoders and buttons unusable.
I tried hard to find anything about this issue and possible fixes but failed. Hope someone can help me with this issue
Here is a code example:
I'm working on my teensy synthesizer project and ran into a problem.
I use teensy 3.6, without an audio shield. And want the synth interface to be displayed on a ILI9341.
Every time the display updates with new text or any other graphic it produces short high pitch noise, changing SPI speed inside tft.begin() changes the pitch of that noise and at low speeds, it almost disappears but the screen updates become extremely slow, encoders and buttons unusable.
I tried hard to find anything about this issue and possible fixes but failed. Hope someone can help me with this issue
Here is a code example:
Code:
#include <Arduino.h>
#include <Audio.h>
#include <Wire.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Keypad.h>
#include "SPI.h"
#include "ILI9341_t3n.h"
#include <ili9341_t3n_font_Arial.h>
#include "EncButton2.h"
#include <vector>
#include <TimerMs.h>
using namespace std;
int mydelay=500;
TimerMs tmr(mydelay, 1, 0);
AudioSynthWaveformDc dc; //xy=189.1428985595703,1161.2859554290771
AudioSynthWaveform waveform; //xy=192.57142639160156,1116.0000247955322
AudioEffectEnvelope filter_envelope; //xy=339.14287185668945,1161.285846710205
AudioFilterStateVariable filter; //xy=706,1130
AudioMixer4 mixer; //xy=919,1136
AudioEffectEnvelope envelope; //xy=1084,1135
AudioOutputAnalogStereo dacs1; //xy=1349.4287490844727,1139.4285583496094
AudioConnection patchCord1(dc, filter_envelope);
AudioConnection patchCord2(waveform, 0, filter, 0);
AudioConnection patchCord3(filter_envelope, 0, filter, 1);
AudioConnection patchCord4(filter, 0, mixer, 0);
AudioConnection patchCord5(filter, 1, mixer, 1);
AudioConnection patchCord6(filter, 2, mixer, 2);
AudioConnection patchCord7(mixer, envelope);
AudioConnection patchCord8(envelope, 0, dacs1, 0);
AudioConnection patchCord9(envelope, 0, dacs1, 1);
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#define TFT_MOSI 11
#define TFT_MISO 12
#define TFT_SCK 14
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCK, TFT_MISO);
EncButton2<EB_ENCBTN> enc1(INPUT, 29, 30, 23);
EncButton2<EB_ENCBTN> enc(INPUT, 27, 28, 22);
EncButton2<EB_ENCBTN> enc2 (INPUT, 25, 26, 21);
EncButton2<EB_BTN> btn(INPUT, 2); // просто кнопка
int currentWF = 0;
const byte ROWS = 6; //four rows
const byte COLS = 2; //three columns
int activekeys=0;
int randomness=1;
char keys[ROWS][COLS] = {
{'c','C'},
{'e','D'},
{'f','E'},
{'g','F'},
{'b','G'},
{'B','A'}
};
byte rowPins[ROWS] = {2, 3, 4, 5, 6, 7}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {0,1}; //connect to the column pinouts of the kpd
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
double freq[]={16.35, 17.32, 18.35, 19.45, 20.60, 21.83, 23.12, 24.50, 25.96, 27.50, 29.14, 30.87};
double octaves[]={1, 2, 4, 8, 16, 32, 64, 128, 256};
int octave=4;
void cfreq(char y);
void setup() {
SPI.begin();
SPI.setSCK(14);
tft.begin(20000000);
tft.setRotation(3);
tft.useFrameBuffer(true);
tft.updateChangedAreasOnly(true);
tft.setTextSize(1);
tft.fillScreen(ILI9341_BLACK);
Serial.begin(1000000);
AudioMemory(10);
waveform.begin(0.2,500, currentWF);
waveform.phase(50);
mixer.gain(0, 0.5);
mixer.gain(1, 0.0);
mixer.gain(1, 0.0);
dc.amplitude(1.0,500);
filter_envelope.attack(250);
filter_envelope.decay(200);
filter_envelope.sustain(0.5);
filter_envelope.release(10);
filter.frequency(200);
filter.resonance(5.0);
filter.octaveControl(5);
envelope.attack(250);
envelope.decay(200);
envelope.sustain(0.5);
envelope.release(10);
Serial.begin(9600);
}
void loop() {
tft.drawCircle(50,40,10,ILI9341_BLUE);
tft.updateScreen();
}