Hello i'm trying to make presonus faderport with arduino i'm receiving fader position data from Studio One but i can't assing to integer value how i assign to integer rx.byte3 value
Here is my code
#include <MIDIUSB.h>
#include <MIDIUSB_Defs.h>
#include <frequencyToNote.h>
#include <pitchToFrequency.h>
#include <pitchToNote.h>
int byte3;
/*
*Fevzi Kutay Sarigul FaderPort Test
*/
/*
* MIDIUSB_test.ino
*
* Created: 4/6/2015 10:47:08 AM
* Author: gurbrinder grewal
* Modified by Arduino LLC (2015)
*/
// First parameter is the event type (0x09 = note on, 0x08 = note off).
// Second parameter is note-on/note-off, combined with the channel.
// Channel can be anything between 0-15. Typically reported to the user as 1-16.
// Third parameter is the note number (48 = middle C).
// Fourth parameter is the velocity (64 = normal, 127 = fastest).
void noteOn(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
}
void noteOff(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOff);
}
void setup() {
Serial.begin(115200);
}
// First parameter is the event type (0x0B = control change).
// Second parameter is the event type, combined with the channel.
// Third parameter is the control number number (0-119).
// Fourth parameter is the control value (0-127).
void controlChange(byte channel, byte control, byte value) {
midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
MidiUSB.sendMIDI(event);
}
void midiCommand(byte cmd, byte data1, byte data2) {
// First parameter is the event type (top 4 bits of the command byte).
// Second parameter is command byte combined with the channel.
// Third parameter is the first data byte
// Fourth parameter second data byte
midiEventPacket_t midiMsg = {cmd >> 4, cmd, data1, data2};
MidiUSB.sendMIDI(midiMsg);
}
void loop() {
//noteOn(0, 94, 127); // Channel 0, 5. La# , tam velocity
// Veri alma bolumu
midiEventPacket_t rx;
do {
rx = MidiUSB.read();
if (rx.header != 0) {
Serial.print("Received: ");
Serial.print(rx.byte1, HEX);
Serial.print("-");
Serial.print(rx.byte2, DEC);//Default olarak hex studio one da hex gonderiyor fakat midicommand icin ilk hane hex ikinci ve ucuncu hane decimal
Serial.print("-");
Serial.println(rx.byte3, DEC);//Default olarak hex studio one da hex gonderiyor fakat midicommand icin ilk hane hex ikinci ve ucuncu hane decimal
}
} while (rx.header != 0);
// Veri gonderme bolumu
//MidiUSB.flush();
delay(1000);
midiCommand(0xE0,127,127); // Secili kanalin faderini son seviyeye getir
midiCommand(0x90,94,127); // Play tusu Channel 0 94Numaralı Nota 127 velocity
//MIDI command icin flush kullanmaya gerek yok direkt olarak gonderiliyor triggerlanmali
}