hey everyone,
i have been stuck on this for around a week now!!
im having a issue trying to send midi over usb
the code i am using is this
i keep getting errors with the lines that are ******************************
error that i keep getting are
error: request for member 'fallingEdge' in 'v', which is of non-class type 'int'
error: request for member 'risingEdge' in 'v', which is of non-class type 'int'
error: request for member 'fallingEdge' in 'v', which is of non-class type 'int'
error: request for member 'risingEdge' in 'v', which is of non-class type 'int'
when i changed this bit of code to the one below i can get it to output midi but keeps sending it every loop
to be like this
it works but with out the note off when i let go. but i cant work out how to add it with out errors
i had also tryed useing the bounce lib but couldnt work it out ether but im not sure if i even need it when useing mux
if any one can point me where to look or even show me how to fix this would be much liked!!!
sorry i no this is posted eles where on this forum but no 1 has replyed to it so im asking again fresh
thanks
nick
i have been stuck on this for around a week now!!
im having a issue trying to send midi over usb
the code i am using is this
Code:
#include <Encoder.h>
#include <Bounce.h>
const byte sensor0 = 14;
const byte sensor1 = 15;
const byte fader0 = A8;
const byte touch0 = 0;
const byte transmitA = 2;
const byte transmitB = 3;
const byte transmitC = 4;
const byte reciverA = 5;
const byte reciverB = 6;
const byte reciverC = 7;
Encoder myEnc0 (8,9);
const int motorDown = 18;
const int motorUp = 19;
int led = 13;
int v = 0;
int w = 0;
int t[8] = {0};
int f[8] = {0};
double faderMax = 1023;
double faderMin = 1;
volatile bool touched = false;
void setup() {
Serial.begin(115200);
pinMode(reciverA,OUTPUT);
pinMode(reciverB,OUTPUT);
pinMode(reciverC,OUTPUT);
pinMode(transmitA,OUTPUT);
pinMode(transmitB,OUTPUT);
pinMode(transmitC,OUTPUT);
pinMode(sensor0,INPUT);
pinMode(sensor1,INPUT);
pinMode(fader0,INPUT);
pinMode(touch0,INPUT);
pinMode(led,OUTPUT);
pinMode(motorUp,OUTPUT);
pinMode(motorDown,OUTPUT);
digitalWrite (led,HIGH);
}
long oldEnc0 = -999;
int readKeyboard() {
int j,i,code;
code=0;
for(i=0;i<=7;i++) {
for(j=0;j<=7;j++) {
code++;
//col
{
digitalWrite (transmitA, (i & 1) ? HIGH : LOW);
digitalWrite (transmitB, (i & 2) ? HIGH : LOW);
digitalWrite (transmitC, (i & 4) ? HIGH : LOW);
}
//row
{
digitalWrite (reciverA, (j & 1) ? HIGH : LOW);
digitalWrite (reciverB, (j & 2) ? HIGH : LOW);
digitalWrite (reciverC, (j & 4) ? HIGH : LOW);
delayMicroseconds(20);
digitalRead(sensor0);
digitalRead(sensor1);
}
// Read the actual Value
v = digitalRead(sensor0);
w = digitalRead(sensor1);
/*
Serial.print("Col: ");
Serial.print(i);
Serial.print(",Row: ");
Serial.print(j);
Serial.print("),IC1: ");
Serial.print(v);
Serial.print(" ,IC2: ");
Serial.println(w);
*/
if(v==HIGH)
{return code;}
if(w==HIGH)
{return (code+64);}
}
}
}
int readfader0 (const byte i)
{
{
// select correct MUX channel
digitalWrite (transmitA, (i & 1) ? HIGH : LOW);
digitalWrite (transmitB, (i & 2) ? HIGH : LOW);
digitalWrite (transmitC, (i & 4) ? HIGH : LOW);
// now read the sensor
return analogRead (fader0);
}
f[i] = analogRead (fader0);
}
int readtouch0 (const byte i)
{
{
// select correct MUX channel
digitalWrite (transmitA, (i & 1) ? HIGH : LOW);
digitalWrite (transmitB, (i & 2) ? HIGH : LOW);
digitalWrite (transmitC, (i & 4) ? HIGH : LOW);
// now read the sensor
return touchRead (touch0);
}
t[i] = touchRead (touch0);
}
void loop(){
{
v = readKeyboard();
if(v >= 1 && v <= 128){
Serial.println(v);
if (v.fallingEdge()) { **********************************
usbMIDI.sendNoteOn(v-1, 127, 1);
}
if (v.risingEdge()){ **********************************
usbMIDI.sendNoteOff(v-1, 0, 1);
}
}
if (v >= 129 && v <= 254){
Serial.println(v);
if (v.fallingEdge()) { **********************************
usbMIDI.sendNoteOn(v-1, 127, 2);
}
if (v.risingEdge()){ **********************************
usbMIDI.sendNoteOff(v-1, 0, 2);
}}
}
{
long newEnc0;
newEnc0= myEnc0.read();
if (newEnc0 != oldEnc0) {
Serial.print("Enc0 = ");
Serial.println(newEnc0/4);
oldEnc0 = newEnc0;
}
}
{
// show all 8 sensor readings
for (byte i = 0; i <=7; i++)
{
if(readfader0(i)>2){
Serial.print ("fader ");
Serial.print (i);
Serial.print (" reads: ");
Serial.println (readfader0(i));
}
if (readtouch0(i) > 3600){
Serial.print("touch0 ");
Serial.print(i);
Serial.println(" is touched");
}
}
}
}
i keep getting errors with the lines that are ******************************
error that i keep getting are
error: request for member 'fallingEdge' in 'v', which is of non-class type 'int'
error: request for member 'risingEdge' in 'v', which is of non-class type 'int'
error: request for member 'fallingEdge' in 'v', which is of non-class type 'int'
error: request for member 'risingEdge' in 'v', which is of non-class type 'int'
when i changed this bit of code to the one below i can get it to output midi but keeps sending it every loop
Code:
void loop(){
{
v = readKeyboard();
if(v >= 1 && v <= 128){
Serial.println(v);
if (v.fallingEdge()) {
usbMIDI.sendNoteOn(v-1, 127, 1);
}
if (v.risingEdge()){
usbMIDI.sendNoteOff(v-1, 0, 1);
}
}
if (v >= 129 && v <= 254){
Serial.println(v);
if (v.fallingEdge()) {
usbMIDI.sendNoteOn(v-1, 127, 2);
}
if (v.risingEdge()){
usbMIDI.sendNoteOff(v-1, 0, 2);
}}
}
to be like this
Code:
void loop(){
{
v = readKeyboard();
if(v >= 1 && v <= 128){
Serial.println(v);
usbMIDI.sendNoteOn(v-1, 127, 1);
}
if (v >= 129 && v <= 254){
Serial.println(v);
usbMIDI.sendNoteOn(v-1, 127, 2);
}
}
it works but with out the note off when i let go. but i cant work out how to add it with out errors
i had also tryed useing the bounce lib but couldnt work it out ether but im not sure if i even need it when useing mux
if any one can point me where to look or even show me how to fix this would be much liked!!!
sorry i no this is posted eles where on this forum but no 1 has replyed to it so im asking again fresh
thanks
nick