greeegouar
New member
Hi everyone, i’m a social worker and i’m doing music creation workshops for persons with special needs.
I have an Ipad with a bunch of apps, a cheap audio interface, some piezos and we are jamming and recording with that.
I’d like them to be able to record samples, to make their own beats live, and to control some effects
but the center i’m working for don’t have any budget for that, so i have to go D.I.Y.
I already had a Teensy ++2.0 and some cigar boxes, i bought another Teensy 3.5 some arcade buttons and knobs and here is the result.
https://photos.app.goo.gl/qujKW2ST2joHimFR9
Now i’m trying to write the code.
Disclaimer: i’m kind of a noob. My first attempt with Teensy is a midi foot controller that works well but the code was totally borrowed from the examples. I just adapted it to my switch number and so they give CCs instead of notes.
So i took the Many_Buttons_Knobs from the examples and tried it with the Teensy 3.5 with just one button and one knob to see i could get it work like that at first.
And it doesn’t.
The button is not recognized by my app and when i’m assigning the knobs, the value 'floats' and gives glitchy readings like in this thread:
https://forum.pjrc.com/threads/48200-Teensy-3-5-Exemple-AnalogControlChange-Problems
Here is the code*:
Here are my connections on breadboard:
https://photos.app.goo.gl/AFBu59C7C8tHgCmu7
I don’t get what i’m doing wrong.
Also i would like the digital pins to "give" CCs as the analog pins and not Notes and i really don't have a clue on how to do that. I tried to move things in the code that seems to be logical to me without really understanding it but all i got was a bunch of errors .
Thanks a lot in advance for your patience and your help.
I have an Ipad with a bunch of apps, a cheap audio interface, some piezos and we are jamming and recording with that.
I’d like them to be able to record samples, to make their own beats live, and to control some effects
but the center i’m working for don’t have any budget for that, so i have to go D.I.Y.
I already had a Teensy ++2.0 and some cigar boxes, i bought another Teensy 3.5 some arcade buttons and knobs and here is the result.
https://photos.app.goo.gl/qujKW2ST2joHimFR9
Now i’m trying to write the code.
Disclaimer: i’m kind of a noob. My first attempt with Teensy is a midi foot controller that works well but the code was totally borrowed from the examples. I just adapted it to my switch number and so they give CCs instead of notes.
So i took the Many_Buttons_Knobs from the examples and tried it with the Teensy 3.5 with just one button and one knob to see i could get it work like that at first.
And it doesn’t.
The button is not recognized by my app and when i’m assigning the knobs, the value 'floats' and gives glitchy readings like in this thread:
https://forum.pjrc.com/threads/48200-Teensy-3-5-Exemple-AnalogControlChange-Problems
Here is the code*:
Code:
//************LIBRARIES USED**************
// include the ResponsiveAnalogRead library for analog smoothing
#include <ResponsiveAnalogRead.h>
// include the Bounce library for 'de-bouncing' switches -- removing electrical chatter as contacts settle
#include <Bounce.h>
//usbMIDI.h library is added automatically when code is compiled as a MIDI device
// ******CONSTANT VALUES********
// customize code behaviour here!
const int channel = 1; // MIDI channel
const int A_PINS = 1; // number of Analog PINS
const int D_PINS = 1; // number of Digital PINS
const int ON_VELOCITY = 99; // note-one velocity sent from buttons (should be 65 to 127)
// define the pins you want to use and the CC ID numbers on which to send them..
const int ANALOG_PINS[A_PINS] = {A14};
const int CCID[A_PINS] = {21};
// define the pins and notes for digital events
const int DIGITAL_PINS[D_PINS] = {0};
const int note[D_PINS] = {60};
const int BOUNCE_TIME = 7; // 5 ms is usually sufficient
const boolean toggled = true;
//******VARIABLES***********
// a data array and a lagged copy to tell when MIDI changes are required
byte data[A_PINS];
byte dataLag[A_PINS]; // when lag and new are not the same then update MIDI CC value
//************INITIALIZE LIBRARY OBJECTS**************
// not sure if there is a better way... some way run a setup loop on global array??
// use comment tags to comment out unused portions of array definitions
// initialize the ReponsiveAnalogRead objects
ResponsiveAnalogRead analog[]{
{ANALOG_PINS[14],true}/*,
{ANALOG_PINS[1],true},
{ANALOG_PINS[2],true},
{ANALOG_PINS[3],true},
{ANALOG_PINS[4],true},
{ANALOG_PINS[5],true},
{ANALOG_PINS[6],true},
{ANALOG_PINS[7],true},*/
};
// initialize the bounce objects
Bounce digital[] = {
Bounce(DIGITAL_PINS[0],BOUNCE_TIME)/*,
Bounce(DIGITAL_PINS[1], BOUNCE_TIME),
Bounce(DIGITAL_PINS[2], BOUNCE_TIME),
Bounce(DIGITAL_PINS[3], BOUNCE_TIME),
Bounce(DIGITAL_PINS[4], BOUNCE_TIME),
Bounce(DIGITAL_PINS[5], BOUNCE_TIME),
Bounce(DIGITAL_PINS[6], BOUNCE_TIME),
Bounce(DIGITAL_PINS[7], BOUNCE_TIME),*/
};
//************SETUP**************
void setup() {
// loop to configure input pins and internal pullup resisters for digital section
for (int i=0;i<D_PINS;i++){
pinMode(DIGITAL_PINS[i], INPUT_PULLUP);
}
}
//************LOOP**************
void loop() {
getAnalogData();
getDigitalData();
while (usbMIDI.read()) {
// controllers must call .read() to keep the queue clear even if they are not responding to MIDI
}
}
//************ANALOG SECTION**************
void getAnalogData(){
for (int i=0;i<A_PINS;i++){
// update the ResponsiveAnalogRead object every loop
analog[i].update();
// if the repsonsive value has change, print out 'changed'
if(analog[i].hasChanged()) {
data[i] = analog[i].getValue()>>3;
if (data[i] != dataLag[i]){
dataLag[i] = data[i];
usbMIDI.sendControlChange(CCID[i], data[i], channel);
}
}
}
}
//************DIGITAL SECTION**************
void getDigitalData(){
for (int i=0;i<D_PINS;i++){
digital[i].update();
if (digital[i].fallingEdge()) {
usbMIDI.sendNoteOn(note[i], ON_VELOCITY, channel);
}
// Note Off messages when each button is released
if (digital[i].risingEdge()) {
usbMIDI.sendNoteOff(note[i], 0, channel);
}
}
}
Here are my connections on breadboard:
https://photos.app.goo.gl/AFBu59C7C8tHgCmu7
I don’t get what i’m doing wrong.
Also i would like the digital pins to "give" CCs as the analog pins and not Notes and i really don't have a clue on how to do that. I tried to move things in the code that seems to be logical to me without really understanding it but all i got was a bunch of errors .
Thanks a lot in advance for your patience and your help.