Giter VIP home page Giter VIP logo

Comments (12)

TechJA avatar TechJA commented on August 19, 2024 1

Another tip: could you connect just one pot to A3 and after to A4 to check these input ports? Maybe they are damaged

from midi_controller.

tttapa avatar tttapa commented on August 19, 2024

All inputs are independent objects in software, so that shouldn't be an issue.
Make sure all wires make good connection, even when wiggling them around. You could try soldering wires to everything, and use male header pins to plug them into the Arduino.
The outer terminals of the potentiometer go to ground and 5V respectively, the center pin (wiper) goes to the analog input. If you experience noise (values fluctuating up and down 1 or 2 values), you could try the master version, which has improved filtering.

Other than that, I don't know what could cause it. I would suspect a hardware issue, though.

from midi_controller.

rabbiccu avatar rabbiccu commented on August 19, 2024

The breadboard has an interupted power rail which I didn't realize was a thing. First project. Sadly though when I figured this out I was bridging them and the board fried. I had an external 12V power supply, which I the leonardo is supposed to handle.

There's no other way this could have fried using just the 5v, gnd, inputs and a bunch of pots and faders, right?

from midi_controller.

tttapa avatar tttapa commented on August 19, 2024

You could have shorted out 5V to ground, which would probably destroy the 5V regulator when powering it from a 12V source.

What exactly fried? The MCU or some other part?

from midi_controller.

rabbiccu avatar rabbiccu commented on August 19, 2024

The ATmega32u4 is incredibly hot now, so I think that burned asking with some other things.

I'm sure I sorted the 5v to gnd because I wasn't cautious to avoid that and tried a million configurations during troubleshooting. I guess I just thought the gnd could handle it. Oh well 10 bucks.

So my pots are linear but my faders are logarithmic but there is code for mapping log sliders IIRC.

from midi_controller.

tttapa avatar tttapa commented on August 19, 2024

You can use the map function, together with the formula discussed here: #43 (comment).

from midi_controller.

rabbiccu avatar rabbiccu commented on August 19, 2024

So would the

value = (value < y_knee) ? (value * x_knee / y_knee) : ((value - y_knee) * (1023 - x_knee) / (1023 - y_knee) + x_knee); 

come after the mapping function for that input? Will you do a sample code please?

from midi_controller.

tttapa avatar tttapa commented on August 19, 2024
#include <MIDI_Controller.h> // Include the library

// Create a new instance of the class 'Analog', called 'potentiometer', on pin A0, 
// that sends MIDI messages with controller 7 (channel volume) on channel 1
Analog potentiometer(A0, MIDI_CC::Channel_Volume, 1);

const int x_knee = 512;
const int y_knee = 102;

int mapCalibrated(int value) {
  value = (value < y_knee) ? (value * x_knee / y_knee) : ((value - y_knee) * (1023 - x_knee) / (1023 - y_knee) + x_knee); 
  return value;
}

void setup() {
  potentiometer.map(mapCalibrated); // apply the 'mapCalibrated' function on the analog input of 'potentiometer'
}

void loop() {
  // Refresh the MIDI controller (check whether the potentiometer's input has changed since last time, if so, send the new value over MIDI)
  MIDI_Controller.refresh();
}

from midi_controller.

rabbiccu avatar rabbiccu commented on August 19, 2024

And to add linear would they be added at the end of map calibration aka

#include <MIDI_Controller.h> // Include the library

// Create a new instance of the class 'Analog', called 'potentiometer', on pin A0, 
// that sends MIDI messages with controller 7 (channel volume) on channel 1
Analog potentiometer(A0, MIDI_CC::Channel_Volume, 1);
Analog potentiometer(A2, MIDI_CC::Channel_Volume, 3);

const int x_knee = 512;
const int y_knee = 102;

int mapCalibrated(int value) {
  value = (value < y_knee) ? (value * x_knee / y_knee) : ((value - y_knee) * (1023 - x_knee) / (1023 - y_knee) + x_knee); 
  return value;
}

Analog potentiometer(A1, MIDI_CC::Channel_Volume, 2);

void setup() {
  potentiometer.map(mapCalibrated); // apply the 'mapCalibrated' function on the analog input of 'potentiometer'
}

void loop() {
  // Refresh the MIDI controller (check whether the potentiometer's input has changed since last time, if so, send the new value over MIDI)
  MIDI_Controller.refresh();
}

Gives you log pots on 1 and 3 and linear on 2?

from midi_controller.

tttapa avatar tttapa commented on August 19, 2024

No, for the linear ones, you just don't use potentiometer.map(mapCalibrated) at all. The position in the code doesn't matter.

from midi_controller.

tttapa avatar tttapa commented on August 19, 2024

For example:

#include <MIDI_Controller.h> // Include the library

Analog linearPots[] = {
  {A0, MIDI_CC::Channel_Volume, 1},
  {A1, MIDI_CC::Channel_Volume, 2},
  {A2, MIDI_CC::Channel_Volume, 3},
  {A3, MIDI_CC::Channel_Volume, 4},
};

Analog logPots[] = {
  {A4, MIDI_CC::Channel_Volume, 5},
  {A5, MIDI_CC::Channel_Volume, 6},
  {A6, MIDI_CC::Channel_Volume, 7},
  {A7, MIDI_CC::Channel_Volume, 8},
};

const int x_knee = 512;
const int y_knee = 102;

int mapLog(int value) {
  value = (value < y_knee) ? (value * x_knee / y_knee) : ((value - y_knee) * (1023 - x_knee) / (1023 - y_knee) + x_knee); 
  return value;
}

void setup() {
  for (Analog &potentiometer : logPots)
    potentiometer.map(mapLog); // apply the 'mapLog' function on the analog input of this potentiometer
}

void loop() {
  // Refresh the MIDI controller (check whether the potentiometer's input has changed since last time, if so, send the new value over MIDI)
  MIDI_Controller.refresh();
}

from midi_controller.

rabbiccu avatar rabbiccu commented on August 19, 2024

Wow amazing, and it all makes sense.

from midi_controller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.