The BIG Arduino MIDI controller thread - Page 7
Page 7 of 16 FirstFirst ... 34567891011 ... LastLast
Results 61 to 70 of 155
  1. #61
    Tech Mentor
    Join Date
    Sep 2010
    Posts
    444

    Default

    Quote Originally Posted by DjNecro View Post
    You realize that that is the same product that I linked you to originally...
    It is? well arent i slow lol thanks
    Equipment------
    --HP Dv6T Select Editon. i5 6gb DDR3, backlit keys and touchscreen.

  2. #62
    Tech Guru MiL0's Avatar
    Join Date
    May 2009
    Location
    Brighton / Bangkok
    Posts
    1,386

    Default

    Quote Originally Posted by DjNecro View Post
    You realize that that is the same product that I linked you to originally...
    Quote Originally Posted by DjNecro View Post
    You would be much better off using something like this: http://lividinstruments.com/hardware_builder.php instead of an arduino.
    These are different products by different companies... Livid DIY Builder is much more expensive than Highly Liquid Midi CPU.

  3. #63
    Tech Mentor
    Join Date
    Feb 2011
    Location
    Southern Ontario, Canada
    Posts
    244

    Default

    oops my bad.. i am 100% incorrect.. I have no idea why I thought you referred to the midi brain...

  4. #64
    Tech Wizard Siytek's Avatar
    Join Date
    Apr 2011
    Location
    UK
    Posts
    36

    Default

    Quote Originally Posted by MiL0 View Post
    Ideally, what would be perfect, is if someone could write some Arduino code that will allow x number of potentiometers/buttons and that everyone can use on their controllers (without having to go the HID/midi route or hack a joypad to pieces!)
    There is a minor problem with achieving this with regards to the analog inputs for faders and knobs, and I had to solve it when developing my 64 I/O dedicated ArduinoMIDI board. The problem is making the code versatile, so one bit of code works no matter how many inputs are used.

    As you repeatedly scan the analog inputs, you check the value to see if it has changed since the last time the input was read ie has the POT moved? That way if the POT has moved the MIDI is outputted, if the POT hasn't moved no MIDI is sent. If this system is not implemented and you just output a MIDI value when the POT is read then a) bombarding the other device with lots of unnecessary MIDI may cause latency and b) 'MIDI learn' functions of programs like Traktor and Ableton will not work properly.

    ...so here's the problem. It would be quite easy to write a bit of code that scanned all the analog inputs on an Arduino, checked to see if they were different to the last time and if so, output the MIDI data on a different CC number for each analog input. The problem is getting the code to work with different combinations of POTS connected... for example if I wrote the code to read all 6 analog inputs of the Arduino UNO board and you only connected 4 POTS there would be random MIDI messages flying about for the disconnected inputs.... why? ...if you read an analog input that is 'floating' (nothing connected) you will find the analog values fluctuate all over the place. As this is seen by the code as 'a changing value' it will fire out MIDI messages of random values which is not what you want!

    So the code has to take in to account which inputs are connected and which inputs are not. The user can then adjust a variable in the code to state which inputs are used and which are not before uploading to their Arduino.

    Here is some code that should work with any Arduino with 1 - 6 analog inputs connected. If anyone finds this useful or anyone thinks it would be worth me adding digital intputs to the code, let me know and ill make some time to add it! To suit your needs, just change the very bit at the top...

    This bit needs to be changed to how many POTs you have connected to the Arduino, entering 6 means all 6 inputs will be scanned for POTs. If you only want to use 3 POTs, change this number to 3. NOTE: Consecutive inputs must be used from the first analog pin, for 3 POTs, use A0, A1, A2.
    number_of_analog_connections = 6;

    This bit can be changed if you want specific CC numbers for each POT. The numbers 50 .. 55 correspond to the CC numbers for analog inputs 1 - 6 on the Arduino. If you want the second input to be CC07, change '51' to '7' as shown below
    control_change_numbers[6] = { 50, 7, 52, 53, 54, 55 };

    You can also change the MIDI channel the CC data is outputted on with this line..
    midi_channel = x;

    ..and the LED pin if you are using a custom Arduino board...
    led_pin = 13;

    Be warned I have thrown this code together pretty quickly and have only tested it a little bit!! So apologies if there is a prob with it, let me know and ill fix

    PHP Code:
    // BASIC ANALOG INPUTS --> MIDI OUT CODE - SIYTEK - siy@btinternet.com

    // YOU MUST USE CONSECUTIVE ANALOG PINS AND BEGIN FROM A0!!!
    // IF YOU WANT TO CONNECT 3 POTS, CONNECT TO A0, A1, A2 AND SET 'number_of_analog_connections' to '3'

    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////
    ////// USER EDITS THESE VARIABLES

    int number_of_analog_connections 6;                           //NUMBER OF ANALOG INPUTS USED FROM 1 to 6               
    int control_change_numbers[6] = { 505152535455 };     //CONTROL CHANGE NUMBERS FOR ANALOG OUTPUTS A0, A1, A2, A3, A4, A5 - SO 'A1' WILL OUTPUT TO 'CC51' etc...  
    int midi_channel 1;                                           //MIDI CHANNEL 
    int led_pin 13;                                               //ARDUINO BOARDS USUALLY USE PIN 13, SO MOST LIKELY NO NEED TO CHANGE

    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////
    //////////////////////////////////////////////////////



    int MIDIReading;
    int last_analog_reading[6] = { 0,0,0,0,0,};
    int current_analog_reading[6] = { 0,0,0,0,0,};

    void setup() {                  
      
      
    pinMode(led_pinOUTPUT);    //INITIALIZE LED PIN
      
    digitalWrite(led_pinHIGH);  
      
      
    Serial.begin(31250);  // INITIALIZE SERIAL PORT, 31,250 bps FOR MIDI         
      
    Serial.flush();           
      
    }


    void loop(){                      

      for (
    int x=0number_of_analog_connectionsx++){  //CREATES A LOOP THAT SCANS A0 - A6 DEPENDING ON NUMBER OF INPUTS SELECTED
      
        
    current_analog_reading[x] = analogRead(x);    //READS ANALOG INPUT PIN
        
    if (current_analog_reading[x] != last_analog_reading[x]){    //CHECKS TO SEE IF ITS THE SAME AS THE PREVIOUS READING (IF ITS THE SAME, NO MIDI IS TRANSMITTED)
          
    MIDIReading current_analog_reading[x] >> 3;            //CONVERTS THE 10-BIT READING FROM ARDUINOS ADC TO 7-BIT FOR MIDI
          
    transmit_MIDI(MIDIReadingcontrol_change_numbers[x]);  //TRANSMITS THE VALUE OF THE ANALOG READING TO THE CC NUMBER FOR THE RELEVANT INPUT

        
    }
        
    last_analog_reading[x] = current_analog_reading[x];      //STORES THE READING AS A PREVIOUS VALUE REFERENCE FOR NEXT TIME INPUT IS SCANNED
      
      
    }


    }


    void transmit_MIDI(byte the_out_valuebyte cc_output){    //TRANSMIT MIDI ROUTINE
      
      
    digitalWrite(led_pinLOW);                              //BLINKS LED TO SHOW MIDI IS BEING SENT
      
    Serial.print((0xB0 midi_channel) , BYTE);              //SENDS MIDI CC MESSAGE AND CHANNEL NUMBER
      
    Serial.print((cc_output 0x7F), BYTE);                  //SENDS THE CC NUMBER RELEVANT TO THE ANALOG INPUT
      
    Serial.print((the_out_value 0x7F), BYTE);              //SENDS THE ACTUAL VALUE OF THE ANALOG INPUT
      
    digitalWrite(led_pinHIGH);                             //SWITCH LED BACK ON AFTER TRANSMISSION
      
      

    ...dreams in binary

  5. #65
    Tech Guru MiL0's Avatar
    Join Date
    May 2009
    Location
    Brighton / Bangkok
    Posts
    1,386

    Default

    interesting

    so what about designing the hardware so that there are physical jumpers on the board? depending on which jumper is enabled, the Arduino will know what pots/buttons are connected.

    or, connecting all the unused inputs directly to ground... would this stop the 'floating' values?

  6. #66
    Tech Wizard Siytek's Avatar
    Join Date
    Apr 2011
    Location
    UK
    Posts
    36

    Default

    Quote Originally Posted by MiL0 View Post
    interesting

    so what about designing the hardware so that there are physical jumpers on the board? depending on which jumper is enabled, the Arduino will know what pots/buttons are connected.

    or, connecting all the unused inputs directly to ground... would this stop the 'floating' values?
    On my custom board its bit like you said with the 'tying' of unused pins to ground, only with a resistor and not a direct connection. There is a very high value pull down resistor on all the inputs of the multiplexers, ... this value of resistor is high enough so as not to influence the voltage on the input when using common POT sizes. I have tested 10K, 50K and 100K with no problems. Many POTs are 10K, I have found some DJ x-faders (the Vestax one I use in my MIDI scratch mixer) are about 50K, all working fine.

    The pull down resistor is strong enough to limit the analog value to less than 300 when a floating pin suffers interference from the other used analog inputs. That means the unused pin values still fluctuate, but never above about 300 (out of a possible 1023 of the 10-bit analog scale).

    What this allows me to do is give the user a 'calibration' option which will automatically run on first power up, there will also be a menu option to re-calibrate too should you want to change the design and add or remove any controls.

    When in calibration mode, the board listens to all the pins. All the user has to do is turn all the POTs up to max and press all the buttons at least once in order for the board to detect the inputs used. The LCD informs the user of every successfully detected input and the board saves this to EEPROM and only reads these inputs when in MIDI mode. To change the amount of inputs, all the user needs to do is select 'calibrate' from the menu to change the config ...at least thats how it will work when I finish the code!

    This is possible because floating pins cannot cross an analog value in Arduino of about 300, even when suffering maximum interference from used inputs, as the pull-down resistors limit the noise. The MCU is then able to detect what is connected by seeing which inputs significantly cross the 300 boundary. Turning a POT fully up or pressing a button should give you a maximum reading of 1023, indicating to the MCU there must be something connected to this input.

    ...dreams in binary

  7. #67
    Tech Student
    Join Date
    May 2010
    Location
    Stuttgart, Germany
    Posts
    4

    Default

    Great Idea Siytek!!

    I´ve tried your code with my arduino mega clone and a linear Pot.. It works perfect for me with one pot!

    I really like your idea, because i´ve had a lot of problems during on week "self learning" of programming my arduiono (..no "real" results).

    If its possible for you i would really thank you for a code with adjustable "user" bits for analogue an digital inputs of an arduino (+Outputs? ).

    I would like to implement the arduino into my DIY controller with 41 Buttons and 4 Pots. At the moment my brains are an old gamepad and a usb keypad.

    Great Regards!
    Last edited by manou; 04-20-2011 at 02:05 PM.

  8. #68
    Tech Wizard Siytek's Avatar
    Join Date
    Apr 2011
    Location
    UK
    Posts
    36

    Default

    Quote Originally Posted by manou View Post
    Great Idea Siytek!!

    I´ve tried your code with my arduino mega clone and a linear Pot.. It works perfect for me with one pot!

    I really like your idea, because i´ve had a lot of problems during on week "self learning" of programming my arduiono (..no "real" results).

    If its possible for you i would really thank you for a code with adjustable "user" bits for analogue an digital inputs of an arduino (+Outputs? ).

    I would like to implement the arduino into my DIY controller with 41 Buttons and 4 Pots. At the moment my brains are an old gamepad and a usb keypad.

    Great Regards!
    Thats great news manou, glad it worked for you I tried to comment the code as much as possible to help show whats going on. If you got any questions just give me a shout.

    Yeh I may add support for outputs too and ill almost certainly add digital inputs if the code is working for people! handling the MIDI in code is quite a bit more complex, I have it working fine in my own projects but it will make the code quite a bit longer and more complex! Im not sure if there is a library for handling MIDI though, I wasnt aware of one when I first started using the Arduino programming environment, so programmed my own routines for it and have used those ever since.

    Keep me posted on the progress
    ...dreams in binary

  9. #69
    Tech Mentor michaeldunne109's Avatar
    Join Date
    Nov 2009
    Location
    The land of the leprechaun
    Posts
    456

    Default

    Hi lads decided to post this in here rather than make a new thread. I want to start to learn Arduino for college projects and of course eventually build my own midi controller but i want to learn the ins and outs so to speak and im just wondering were i should start?? I have a good chomp of change left over from my grant after recently shelling out for a mac

    I was thinking this >
    http://www.coolcomponents.co.uk/cata...FQRP4QodQREMHg

    Or would i be better off buying the arduino mega and just start off from their as i have some components/ breadboard ect laying around here at home from college??
    I play everything Indie/ Rock/ HipHop/ Cheese/ Electro/ Dubstep and anything that sounds good

    Tsp 1.7/ Tsp 2/ Sony vaio Win 7 4gb Ram / Macbook Pro 13 inch (Main machine) /vci 100 se/ mixdeck/ audio 8/ technics rph headphones/ Custom xBox Controller/ Akai Lpd8

  10. #70
    Tech Mentor
    Join Date
    Feb 2011
    Location
    Southern Ontario, Canada
    Posts
    244

    Default

    Quote Originally Posted by Siytek View Post
    Im not sure if there is a library for handling MIDI though...
    Ask and ye shall receive
    http://timothytwillman.com/itp_blog/?page_id=240

Page 7 of 16 FirstFirst ... 34567891011 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •