Hi,
I'm working on a project with the Teensy 3.2. I want to build a Midi controller with touchsensors using the internal touchpins and usbMidi. But I have two questions/problems.
I have started writing a code (see below) but have the problem that the note keeps on playing repeatedly when I keep my finger on the sensor. How do I make it play only once and in the rhythm I tap the sensor. My second question is, how would I implement variable velocity. So it reacts to the way I play (how hard/fast I touch the sensor). I thought of using the threshold for that, but I guess thats not the right way.
const int channel = 1;
void setup() {
Serial.begin(9600);
}
void loop() {
if (touchRead(1) > 1000) {
usbMIDI.sendNoteOn (40, 99, channel);
}
if (touchRead(1) < 1000) {
usbMIDI.sendNoteOff (40, 0, channel);
}
Serial.println(touchRead(1));
while (usbMIDI.read()){}
delay(5);
}
Appreciate any help or advice
I'm working on a project with the Teensy 3.2. I want to build a Midi controller with touchsensors using the internal touchpins and usbMidi. But I have two questions/problems.
I have started writing a code (see below) but have the problem that the note keeps on playing repeatedly when I keep my finger on the sensor. How do I make it play only once and in the rhythm I tap the sensor. My second question is, how would I implement variable velocity. So it reacts to the way I play (how hard/fast I touch the sensor). I thought of using the threshold for that, but I guess thats not the right way.
const int channel = 1;
void setup() {
Serial.begin(9600);
}
void loop() {
if (touchRead(1) > 1000) {
usbMIDI.sendNoteOn (40, 99, channel);
}
if (touchRead(1) < 1000) {
usbMIDI.sendNoteOff (40, 0, channel);
}
Serial.println(touchRead(1));
while (usbMIDI.read()){}
delay(5);
}
Appreciate any help or advice
Attachments
Last edited: