Arduino + MIDI + FLStudio
hey guys,
absolute newbie here. use arduino schoolproject, , want make myself midi controller, basically. has communicate fruityloops. that's working (i use s2midi, since prototype, definitive machine have better midi interface). works, got analog inputs working too. but, want use digital inputs well, of them pushbuttons, others switches, have same basic action: on/off
and can't work. i've tried anything, means i'm looking in wrong places.
// arduino multi midi cc script
//arrays analog
int inputsanalog[] = {0, 1, 2, 3, 4, 5};
int channelsanalog[] = {9, 10, 11, 12, 13, 14};
int lastanalogs[]= {0, 0, 0, 0, 0, 0};
//arrays digital
int inputsdigital[] = {3, 4, 5, 6, 7, 8};
int channelsdigital[] = {15, 16, 17, 18, 19, 20};
int lastdigital[]= {low, low, low, low, low, low};
//analog smoothing
int analogsmooth = 2;
void setup()
{
serial.begin(9600);
}
void loop()
{
for (int i=0; i<2; i++)
{
doreadanalog(i, inputsanalog, channelsanalog, lastanalogs);
}
for (int i=0; i<2; i++)
{
doreaddigital(i, inputsdigital, channelsdigital);
}
}
void doreadanalog(int i, int input, int channel, int lastanalog)
{
int readinganalog = 0;
readinganalog = analogread(input)/8;
if (abs(readinganalog-lastanalog) > analogsmooth)
{
lastanalogs = readinganalog;
controlchange(channel, 10, readinganalog);
}
}
void doreaddigital(int i, int input, int channel)
{
int readingdigital = 0;
readingdigital = digitalread(input);
if(lastdigital != readingdigital)
{
if(readingdigital == 'high')
{
controlchange(channel, 10, 0);
}else{
controlchange(channel, 10, 127);
}
lastdigital = readingdigital;
}
}
// send midi control change
void controlchange(byte channel, byte controller, byte value)
{
midimsg(channel+0xb0, controller, value);
}
// send general midi message
void midimsg(byte cmd, byte data1, byte data2)
{
serial.print(cmd, byte);
serial.print(data1, byte);
serial.print(data2, byte);
}
anyway, that's code got...when use analog works, recognizes digital input, midi message isn't right sends same value high , low. please me this, deadlines approaching..
thanks in advance..
absolute newbie here. use arduino schoolproject, , want make myself midi controller, basically. has communicate fruityloops. that's working (i use s2midi, since prototype, definitive machine have better midi interface). works, got analog inputs working too. but, want use digital inputs well, of them pushbuttons, others switches, have same basic action: on/off
and can't work. i've tried anything, means i'm looking in wrong places.
// arduino multi midi cc script
//arrays analog
int inputsanalog[] = {0, 1, 2, 3, 4, 5};
int channelsanalog[] = {9, 10, 11, 12, 13, 14};
int lastanalogs[]= {0, 0, 0, 0, 0, 0};
//arrays digital
int inputsdigital[] = {3, 4, 5, 6, 7, 8};
int channelsdigital[] = {15, 16, 17, 18, 19, 20};
int lastdigital[]= {low, low, low, low, low, low};
//analog smoothing
int analogsmooth = 2;
void setup()
{
serial.begin(9600);
}
void loop()
{
for (int i=0; i<2; i++)
{
doreadanalog(i, inputsanalog, channelsanalog, lastanalogs);
}
for (int i=0; i<2; i++)
{
doreaddigital(i, inputsdigital, channelsdigital);
}
}
void doreadanalog(int i, int input, int channel, int lastanalog)
{
int readinganalog = 0;
readinganalog = analogread(input)/8;
if (abs(readinganalog-lastanalog) > analogsmooth)
{
lastanalogs = readinganalog;
controlchange(channel, 10, readinganalog);
}
}
void doreaddigital(int i, int input, int channel)
{
int readingdigital = 0;
readingdigital = digitalread(input);
if(lastdigital != readingdigital)
{
if(readingdigital == 'high')
{
controlchange(channel, 10, 0);
}else{
controlchange(channel, 10, 127);
}
lastdigital = readingdigital;
}
}
// send midi control change
void controlchange(byte channel, byte controller, byte value)
{
midimsg(channel+0xb0, controller, value);
}
// send general midi message
void midimsg(byte cmd, byte data1, byte data2)
{
serial.print(cmd, byte);
serial.print(data1, byte);
serial.print(data2, byte);
}
anyway, that's code got...when use analog works, recognizes digital input, midi message isn't right sends same value high , low. please me this, deadlines approaching..
thanks in advance..
ps. i'm not trying send noteon/noteoff, @ least don't think am. want button activate or mute effect or channel. i know there different types of controlchange messages, down that.
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Arduino + MIDI + FLStudio
arduino
Comments
Post a Comment