Go Down

Topic: Music project (Read 4458 times) previous topic - next topic

PieterP

#105
Feb 23, 2018, 03:11 pm Last Edit: Feb 23, 2018, 03:14 pm by PieterP
Code:
// Create 2 instances of 'AnalogMultiplex' with the output pins of the multiplexers connected to
// analog input pin A0 and A1 respectively, and the address pins connected to pins 2, 3 and 4.
AnalogMultiplex multiplexers[] = {
  {A0, { 2, 3, 4 } },
  {A1, { 2, 3, 4 } },
};

// Create 16 new instances of the class 'Analog', on the 16 pins of the multiplexers,
// that send MIDI messages with controller 7 (channel volume) on channels 1 - 16
Analog potentiometers[] = {
  {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},
  {multiplexers[0].pin(1), MIDI_CC::Channel_Volume, 2},
  {multiplexers[0].pin(2), MIDI_CC::Channel_Volume, 3},
  {multiplexers[0].pin(3), MIDI_CC::Channel_Volume, 4},
  {multiplexers[0].pin(4), MIDI_CC::Channel_Volume, 5},
  {multiplexers[0].pin(5), MIDI_CC::Channel_Volume, 6},
  {multiplexers[0].pin(6), MIDI_CC::Channel_Volume, 7},
  {multiplexers[0].pin(7), MIDI_CC::Channel_Volume, 8},
  {multiplexers[1].pin(0), MIDI_CC::Channel_Volume, 9},
  {multiplexers[1].pin(1), MIDI_CC::Channel_Volume, 10},
  {multiplexers[1].pin(2), MIDI_CC::Channel_Volume, 11},
  {multiplexers[1].pin(3), MIDI_CC::Channel_Volume, 12},
  {multiplexers[1].pin(4), MIDI_CC::Channel_Volume, 13},
  {multiplexers[1].pin(5), MIDI_CC::Channel_Volume, 14},
  {multiplexers[1].pin(6), MIDI_CC::Channel_Volume, 15},
  {multiplexers[1].pin(7), MIDI_CC::Channel_Volume, 16},
};

As you can see, this is quite cumbersome (and inefficient) for large numbers of potentiometers. I'm improving it at the moment.

ciabio

thank youu..

it give me this errors :

multiplexer:3: error: 'AnalogMultiplex' does not name a type
 AnalogMultiplex multiplexers[] = {

 ^

multiplexer:10: error: 'Analog' does not name a type
 Analog potentiometers[] = {

 ^

'AnalogMultiplex' does not name a type




Code:
// Create 2 instances of 'AnalogMultiplex' with the output pins of the multiplexers connected to
// analog input pin A0 and A1 respectively, and the address pins connected to pins 2, 3 and 4.
AnalogMultiplex multiplexers[] = {
  {A0, { 2, 3, 4 } },
  {A1, { 2, 3, 4 } },
};

// Create 16 new instances of the class 'Analog', on the 16 pins of the multiplexers,
// that send MIDI messages with controller 7 (channel volume) on channels 1 - 16
Analog potentiometers[] = {
  {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},
  {multiplexers[0].pin(1), MIDI_CC::Channel_Volume, 2},
  {multiplexers[0].pin(2), MIDI_CC::Channel_Volume, 3},
  {multiplexers[0].pin(3), MIDI_CC::Channel_Volume, 4},
  {multiplexers[0].pin(4), MIDI_CC::Channel_Volume, 5},
  {multiplexers[0].pin(5), MIDI_CC::Channel_Volume, 6},
  {multiplexers[0].pin(6), MIDI_CC::Channel_Volume, 7},
  {multiplexers[0].pin(7), MIDI_CC::Channel_Volume, 8},
  {multiplexers[1].pin(0), MIDI_CC::Channel_Volume, 9},
  {multiplexers[1].pin(1), MIDI_CC::Channel_Volume, 10},
  {multiplexers[1].pin(2), MIDI_CC::Channel_Volume, 11},
  {multiplexers[1].pin(3), MIDI_CC::Channel_Volume, 12},
  {multiplexers[1].pin(4), MIDI_CC::Channel_Volume, 13},
  {multiplexers[1].pin(5), MIDI_CC::Channel_Volume, 14},
  {multiplexers[1].pin(6), MIDI_CC::Channel_Volume, 15},
  {multiplexers[1].pin(7), MIDI_CC::Channel_Volume, 16},
};

As you can see, this is quite cumbersome (and inefficient) for large numbers of potentiometers. I'm improving it at the moment.

Grumpy_Mike

Quote
'AnalogMultiplex' does not name a type
This means you have not installed the libiary correctly.

ciabio

This means you have not installed the libiary correctly.
thanks..

I copied the code and then pressed verify ... but the error is always the same ..

i tried another code and it works without errors but in ableton it does not detect any potentiometer..

this is the code:

int s0 = 2;
int s1 = 3;
int s2 = 4;
int s3 = 5;

//Mux in "SIG" pin
int SIG_pin = A0;

void setup(){
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);

  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);

  Serial.begin(9600);
}

void loop(){

  //Loop through and read all 16 values
  //Reports back Value at channel 6 is: 346
  for(int i = 0; i < 16; i ++){
    Serial.print("Value at channel ");
    Serial.print(i);
    Serial.print("is : ");
    Serial.println(readMux(i));
    delay(1000);
  }

}

int readMux(int channel){
  int controlPin[] = {s0, s1, s2, s3};

  int muxChannel[16][4]={
    {0,0,0,0}, //channel 0
    {1,0,0,0}, //channel 1
    {0,1,0,0}, //channel 2
    {1,1,0,0}, //channel 3
    {0,0,1,0}, //channel 4
    {1,0,1,0}, //channel 5
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
    {0,1,0,1}, //channel 10
    {1,1,0,1}, //channel 11
    {0,0,1,1}, //channel 12
    {1,0,1,1}, //channel 13
    {0,1,1,1}, //channel 14
    {1,1,1,1}  //channel 15
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin, muxChannel[channel]);
  }

  //read the value at the SIG pin
  int val = analogRead(SIG_pin);

  //return the value
  return val;
}

Thanks

PieterP

I copied the code and then pressed verify ... but the error is always the same ..
No, like Mike said, you didn't install the library correctly. Did you follow the instructions in the Readme? Tell us exactly what you did, and post the exact code you're trying to use.

ciabio

thanks..


I downloaded the source code from the website:

https: //github.com/tttapa/MIDI_controller/releases/tag/3.0.1

then i went to tools, include library from zip and then i copy your code.

/*
  This is an example of the "AnalogMultiplex" class of the MIDI_controller library.
  Connect an analog multiplexer to analog pin A0. Connect the address lines to pins 2, 3 and 4.
  Connect 8 potentiometers to the inputs of the multiplexer. These will be the channel volumes
  of MIDI channels 1 through 8.
  Map accordingly in your DAW or DJ software.

  Written by Pieter P, 20-09-2017
  https://github.com/tttapa/MIDI_controller
*/

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

// Create 2 instances of 'AnalogMultiplex' with the output pins of the multiplexers connected to
// analog input pin A0 and A1 respectively, and the address pins connected to pins 2, 3 and 4.
AnalogMultiplex multiplexers[0] = {
  {A0, { 2, 3, 4, 5 } },
  {A1, { 2, 3, 4, 5 } },
};

// Create 16 new instances of the class 'Analog', on the 16 pins of the multiplexers,
// that send MIDI messages with controller 7 (channel volume) on channels 1 - 16
Analog potentiometers[] = {
  {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},
  {multiplexers[0].pin(1), MIDI_CC::Channel_Volume, 2},
  {multiplexers[0].pin(2), MIDI_CC::Channel_Volume, 3},
  {multiplexers[0].pin(3), MIDI_CC::Channel_Volume, 4},
  {multiplexers[0].pin(4), MIDI_CC::Channel_Volume, 5},
  {multiplexers[0].pin(5), MIDI_CC::Channel_Volume, 6},
  {multiplexers[0].pin(6), MIDI_CC::Channel_Volume, 7},
  {multiplexers[0].pin(7), MIDI_CC::Channel_Volume, 8},
  {multiplexers[1].pin(0), MIDI_CC::Channel_Volume, 9},
  {multiplexers[1].pin(1), MIDI_CC::Channel_Volume, 10},
  {multiplexers[1].pin(2), MIDI_CC::Channel_Volume, 11},
  {multiplexers[1].pin(3), MIDI_CC::Channel_Volume, 12},
  {multiplexers[1].pin(4), MIDI_CC::Channel_Volume, 13},
  {multiplexers[1].pin(5), MIDI_CC::Channel_Volume, 14},
  {multiplexers[1].pin(6), MIDI_CC::Channel_Volume, 15},
  {multiplexers[1].pin(7), MIDI_CC::Channel_Volume, 16},
};

this are the messages in red:

In file included from c:\users\fabio\documents\arduino\libraries\midi_controller-3.0.1\src\extendedinputoutput\extendedinputoutput.h:5:0,

                 from c:\users\fabio\documents\arduino\libraries\midi_controller-3.0.1\src\midi_outputs\analog.h:7,

                 from C:\Users\Fabio\Documents\Arduino\libraries\MIDI_controller-3.0.1\src/MIDI_Controller.h:14,

                 from C:\Users\Fabio\AppData\Local\Temp\arduino_modified_sketch_940190\Ex.12.AnalogMultiplex.ino:12:

c:\users\fabio\documents\arduino\libraries\midi_controller-3.0.1\src\extendedinputoutput\ExtendedIOElement.h: In member function 'virtual int ExtendedIOElement::digitalRead(pin_t)':

Error compiling for board Teensy 3.6.

thank you very much :)


PieterP

Please use [code][/code] tags around your code.

Start from the Ex.12.AnalogMultiplex example, see #103. The code in #105 is just the snippet needed to use the example with multiple multiplexers, as you requested in #104.

On top of that, you copied the code incorrectly:
Code: [Select]
AnalogMultiplex multiplexers[0] = {
That zero shouldn't be there.

Code: [Select]
#include <MIDI_Controller.h> // Include the library

// Create 2 instances of 'AnalogMultiplex' with the output pins of the multiplexers connected to
// analog input pin A0 and A1 respectively, and the address pins connected to pins 2, 3 and 4.
AnalogMultiplex multiplexers[] = {
  {A0, { 2, 3, 4, 5 } },
  {A1, { 2, 3, 4, 5 } },
};

// Create 16 new instances of the class 'Analog', on the 16 pins of the multiplexers,
// that send MIDI messages with controller 7 (channel volume) on channels 1 - 16
Analog potentiometers[] = {
  {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},
  {multiplexers[0].pin(1), MIDI_CC::Channel_Volume, 2},
  {multiplexers[0].pin(2), MIDI_CC::Channel_Volume, 3},
  {multiplexers[0].pin(3), MIDI_CC::Channel_Volume, 4},
  {multiplexers[0].pin(4), MIDI_CC::Channel_Volume, 5},
  {multiplexers[0].pin(5), MIDI_CC::Channel_Volume, 6},
  {multiplexers[0].pin(6), MIDI_CC::Channel_Volume, 7},
  {multiplexers[0].pin(7), MIDI_CC::Channel_Volume, 8},
  {multiplexers[1].pin(0), MIDI_CC::Channel_Volume, 9},
  {multiplexers[1].pin(1), MIDI_CC::Channel_Volume, 10},
  {multiplexers[1].pin(2), MIDI_CC::Channel_Volume, 11},
  {multiplexers[1].pin(3), MIDI_CC::Channel_Volume, 12},
  {multiplexers[1].pin(4), MIDI_CC::Channel_Volume, 13},
  {multiplexers[1].pin(5), MIDI_CC::Channel_Volume, 14},
  {multiplexers[1].pin(6), MIDI_CC::Channel_Volume, 15},
  {multiplexers[1].pin(7), MIDI_CC::Channel_Volume, 16},
};

void setup() {}

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();
}

ciabio

THANKS...

the code is working.. but i can only controll one potentiometer /cc 7

i think there is a problem in the code

thanks




Please use [code][/code] tags around your code.

Start from the Ex.12.AnalogMultiplex example, see #103. The code in #105 is just the snippet needed to use the example with multiple multiplexers, as you requested in #104.

On top of that, you copied the code incorrectly:
Code: [Select]
AnalogMultiplex multiplexers[0] = {
That zero shouldn't be there.

Code: [Select]
#include <MIDI_Controller.h> // Include the library

// Create 2 instances of 'AnalogMultiplex' with the output pins of the multiplexers connected to
// analog input pin A0 and A1 respectively, and the address pins connected to pins 2, 3 and 4.
AnalogMultiplex multiplexers[] = {
  {A0, { 2, 3, 4, 5 } },
  {A1, { 2, 3, 4, 5 } },
};

// Create 16 new instances of the class 'Analog', on the 16 pins of the multiplexers,
// that send MIDI messages with controller 7 (channel volume) on channels 1 - 16
Analog potentiometers[] = {
  {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},
  {multiplexers[0].pin(1), MIDI_CC::Channel_Volume, 2},
  {multiplexers[0].pin(2), MIDI_CC::Channel_Volume, 3},
  {multiplexers[0].pin(3), MIDI_CC::Channel_Volume, 4},
  {multiplexers[0].pin(4), MIDI_CC::Channel_Volume, 5},
  {multiplexers[0].pin(5), MIDI_CC::Channel_Volume, 6},
  {multiplexers[0].pin(6), MIDI_CC::Channel_Volume, 7},
  {multiplexers[0].pin(7), MIDI_CC::Channel_Volume, 8},
  {multiplexers[1].pin(0), MIDI_CC::Channel_Volume, 9},
  {multiplexers[1].pin(1), MIDI_CC::Channel_Volume, 10},
  {multiplexers[1].pin(2), MIDI_CC::Channel_Volume, 11},
  {multiplexers[1].pin(3), MIDI_CC::Channel_Volume, 12},
  {multiplexers[1].pin(4), MIDI_CC::Channel_Volume, 13},
  {multiplexers[1].pin(5), MIDI_CC::Channel_Volume, 14},
  {multiplexers[1].pin(6), MIDI_CC::Channel_Volume, 15},
  {multiplexers[1].pin(7), MIDI_CC::Channel_Volume, 16},
};

void setup() {}

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();
}


PieterP

the code is working.. but i can only controll one potentiometer /cc 7

i think there is a problem in the code
What does that mean?
Please elaborate.

ciabio

What does that mean?
Please elaborate.
i copy the code than i go to ableton and the only midi controll that is showing is cc7..

you write :

 {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},

in the datasheet of the multiplexer the first potentiometer is on pin 9... so i must write pin(9) ?

thanks


PieterP

#115
Feb 25, 2018, 01:53 pm Last Edit: Feb 25, 2018, 01:55 pm by PieterP
i copy the code than i go to ableton and the only midi controll that is showing is cc7..
Correct, that's normal, all potentiometers use the same control (MIDI_CC::Channel_Volume == CC7), but on different channels. You can change this in your code, of course.

you write :

 {multiplexers[0].pin(0), MIDI_CC::Channel_Volume, 1},

in the datasheet of the multiplexer the first potentiometer is on pin 9... so i must write pin(9) ?

thanks
pin(0) refers to the first input pin of the multiplexer, i.e. I0 in the datasheet.
multiplexers[0] is the first multiplexer, multiplexers[1] is the second multiplexer.

ciabio

Correct, that's normal, all potentiometers use the same control (MIDI_CC::Channel_Volume == CC7), but on different channels. You can change this in your code, of course.
pin(0) refers to the first input pin of the multiplexer, i.e. I0 in the datasheet.
multiplexers[0] is the first multiplexer, multiplexers[1] is the second multiplexer.
thanks

so if i want that the first 16 potentiometer on the first line , control the send/return knob can i use the midi cc channel volume code ?

PieterP

I'm not sure what you mean there. You can pick any controller number (0-119) on any channel (1-16). Just map it in Ableton accordingly.

ciabio

I'm not sure what you mean there. You can pick any controller number (0-119) on any channel (1-16). Just map it in Ableton accordingly.
thank youu..

I managed to map the first row of 16 potentiometers,

I have 4 send / return a b c and d, now I have mapped the D send / return

to be able to map the others , I can not use control_volume midi cc (code)because then it interferes with the map of the send / return D

how i can make it thanks

PieterP

Read the library documentation and change the controller number.

Go Up