Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no response when change banks and instruments #102

Open
xtramo opened this issue Jan 20, 2020 · 11 comments
Open

no response when change banks and instruments #102

xtramo opened this issue Jan 20, 2020 · 11 comments

Comments

@xtramo
Copy link

xtramo commented Jan 20, 2020

Description of the problem or question

Using Arduino leonrado connected via usb to pi rasberry 4 to play the yoshimi synth.
Im using your library and have successfully used the arduino to play on the yoshimi synth.
However I cant seem to get the midi to change the instruments on yoshimi?
Im using your code to test and nothing happens?
Ex.07.BankSelectors

Steps to reproduce the problem

Hardware

Arduino board: ? , Arduino Leonardo, pi rasberry 4
Schematic: ? using your example

Software versions: pi rasbery rasbian latest , arduino 1.8.10

MIDI Controller library: ? 3.1.1
Arduino IDE: ?1.8.10
Operating System: ? Windows, , ?
Operating System version: ? 10, and rasbian, arduino

(Encoder library): ? 1.4.1 ?
(MIDIUSB library): ? 1.0.3 ?

Settings in the IDE

Full code

// Your code here
/*
  This is an example of the "Bank" class of the MIDI_controller library.
  Connect two potentiometers to analog pins A0 and A1,
  and two pushbuttons to pins 2 and 3.

  Connect push buttons to pins 11 and 12, and 4 LEDs (+ current limiting resitors) to pins 4, 5, 6 and 7).

  When bank 1 is selected:
    Potentiometer A is channel volume of track 1      (Controller number 0x07, MIDI channel 1)
    Potentiometer B is channel volume of track 2      (Controller number 0x07, MIDI channel 2)
    Mute button A is the mute button for track 1      (Note number 0x10, MIDI channel 1)
    Mute button B is the mute button for track 2      (Note number 0x11, MIDI channel 1)
    The LED on pin 4 lights up.

  When bank 2 is selected:
    Potentiometer A is channel volume of track 3      (Controller number 0x07, MIDI channel 3)
    Potentiometer B is channel volume of track 4      (Controller number 0x07, MIDI channel 4)
    Mute button A is the mute button for track 3      (Note number 0x12, MIDI channel 1)
    Mute button B is the mute button for track 4      (Note number 0x13, MIDI channel 1)
    The LED on pin 5 lights up.

  When bank 3 is selected:
    Potentiometer A is channel volume of track 5      (Controller number 0x07, MIDI channel 5)
    Potentiometer B is channel volume of track 6      (Controller number 0x07, MIDI channel 6)
    Mute button A is the mute button for track 5      (Note number 0x14, MIDI channel 1)
    Mute button B is the mute button for track 6      (Note number 0x15, MIDI channel 1)
    The LED on pin 6 lights up.

  When bank 4 is selected:
    Potentiometer A is channel volume of track 7      (Controller number 0x07, MIDI channel 7)
    Potentiometer B is channel volume of track 8      (Controller number 0x07, MIDI channel 8)
    Mute button A is the mute button for track 7      (Note number 0x16, MIDI channel 1)
    Mute button B is the mute button for track 8      (Note number 0x17, MIDI channel 1)
    The LED on pin 7 lights up.

  This allows you to control multiple tracks with only a limited amount of physical potentiometers and buttons

  Map accordingly in your DAW or DJ software.

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

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

// Create a two new instances of the class 'Analog', on pins A0 and A1,
// that send MIDI messages with controller 7 (channel volume) on channels 1 and 2
Analog potentiometer_A(A0, MIDI_CC::Channel_Volume, 1);
Analog potentiometer_B(A1, MIDI_CC::Channel_Volume, 2);

// Create a two new instances of the class 'Digital', on pins 2 and 3,
// that send MIDI messages with note numbers 0x10 and 0x11 on MIDI channel 1
Digital muteButton_A(2, 0x10, 1);
Digital muteButton_B(3, 0x11, 1);

// Create a new bank that has two tracks per bank
Bank bank(2);

// Create a new bank selector that changes the bank setting of the bank we just created
// It has pushbuttons connected to pins 11 and 12 that increment or decrement the bank setting,
// and 4 LEDs to pins 4, 5, 6 and 7 that display the current bank setting.
BankSelector bankSelector(bank, { 11, 12 }, { 4, 5, 6, 7 } );

/* Alternatively, you can use arrays for the pin numbers:

   const pin_t buttonPins[] = { 11, 12 };
   const pin_t ledPins[] = { 4, 5, 6, 7 };

   BankSelector bankSelector(bank, buttonPins, ledPins);
*/

/*_______________________________________________________________________________________________________________________________________*/

void setup() {
  // Add the created objects to the bank
  bank.add(potentiometer_A, Bank::CHANGE_CHANNEL); // When the bank setting is changed, change the channel of the potentiometer
  bank.add(potentiometer_B, Bank::CHANGE_CHANNEL);
  bank.add(muteButton_A, Bank::CHANGE_ADDRESS); // When the bank setting is changed, change the address (note number) of the mute button
  bank.add(muteButton_B, Bank::CHANGE_ADDRESS);
}

/*_______________________________________________________________________________________________________________________________________*/

void loop() {
  // Refresh the MIDI controller (check whether the inputs have changed since last time, if so, send the new value over MIDI)
  // It also refreshes the bank selector
  MIDI_Controller.refresh();
}

/*
Different Bank Select modes:

- One toggle switch (latching switch)

    When the switch is in the 'off' position, bankSetting 1 is selected
    When the switch is in the 'on' position, bankSetting 2 is selected

    BankSelector(bank, switch pin, BankSelector::TOGGLE);


- One toggle switch (latching switch) and one LED

    When the switch is in the 'off' position, bankSetting 1 is selected and the LED is off
    When the switch is in the 'on' position, bankSetting 2 is selected and the LED is on

        Note: this mode is pretty useless, you can just connect the LED to the switch directly,
            without wasting a digital output pin on it.

    BankSelector(bank, switch pin, led pin, BankSelector::TOGGLE);


- One momentary switch (push button)

    Pressing the button switches the bankSetting:
    When starting the program, bankSetting 1 is selected,
    When the button is pressed, bankSetting 2 is selected,
    When the button is pressed again, bankSetting 1 is selected, 
    and so on.

    BankSelector(bank, button pin);
    BankSelector(bank, button pin, BankSelector::MOMENTARY);


- One momentary switch (push button) and one LED

    Pressing the button switches the bankSetting and toggles the LED:
    When starting the program, bankSetting 1 is selected and the LED is off,
    When the button is pressed, bankSetting 2 is selected and the LED turns on,
    When the button is pressed again, bankSetting 1 is selected and the LED is turned off,
    and so on.

    BankSelector(bank, button pin, led pin);
    BankSelector(bank, button pin, led pin, BankSelector::MOMENTARY);


- Multiple momentary switches (push buttons)

    Pressing one of the buttons selects the respective output:
    When starting the program, bankSetting 1 is selected,
    When the second button is pressed, bankSetting 2 is selected,
    When the n-th button is pressed, bankSetting n is selected.

    BankSelector(bank, { button 1 pin, button 2 pin, ... , button n pin } );


- Multiple momentary switches (push buttons) and multiple LEDs

    Pressing one of the buttons selects the respective output and enables the respective LED:
    When starting the program, bankSetting 1 is selected and LED 1 is on,
    When the second button is pressed, bankSetting 2 is selected, LED 1 turns off and LED 2 turns on,
    When the n-th button is pressed, bankSetting n is selected, LED n turns on, and all other LEDs are off.

    BankSelector(bank, { button 1 pin, button 2 pin, ... , button n pin }, { led 1 pin, led 2 pin, ... , led n pin } );

    
- Two momentary switches (push buttons)

    Pressing the first button increments the bankSetting number,
    pressing the second button decrements the bankSetting number: 
    When starting the program, bankSetting 1 is selected,
    When the first button is pressed, bankSetting 2 is selected, 
    When the first button is pressed again, bankSetting 3 is selected,
    When the last bankSetting is selected, and the first button is pressed again,
    bankSetting 1 is selected.
    When the second button is pressed, the last bankSetting (n) is selected,
    When the second button is pressed again, bankSetting (n-1) is selected,
    and so on.

    BankSelector(bank, { button increment pin, button decrement pin }, number of bankSettings);


- Two momentary switches (push buttons) and multiple LEDs

    Pressing the first button increments the bankSetting number and turns on the respective LED,
    pressing the second button decrements the bankSetting number and turns on the respective LED: 
    When starting the program, bankSetting 1 is selected and LED 1 is on,
    When the first button is pressed, bankSetting 2 is selected, LED 1 turns off and LED 2 turns on,
    When the first button is pressed again, bankSetting 3 is selected, LED 2 turns off and LED 3 turns on.
    When the last bankSetting is selected, and the first button is pressed,
    bankSetting 1 is selected, the last LED turns off and LED 1 turns on.
    When the second button is pressed, the last bankSetting (n) is selected, LED 1 turns off and LED n turns on,
    When the second button is pressed again, bankSetting (n-1) is selected, LED n turns off and LED n-1 turns on,
    and so on.

    BankSelector(bank, { button increment pin, button decrement pin }, { led 1 pin, led 2 pin, ... , led n pin });


- One momentary switch (push button)

    Pressing the button increments the bankSetting number,
    When starting the program, bankSetting 1 is selected,
    When the button is pressed, bankSetting 2 is selected, 
    When the button is pressed again, bankSetting 3 is selected,
    When the last bankSetting is selected, and the button is pressed again,
    bankSetting 1 is selected.

    BankSelector(bank, { button increment pin }, number of bankSettings);


- One momentary switch (push button) and multiple LEDs

    Pressing the button increments the bankSetting number and turns on the respective LED,
    When starting the program, bankSetting 1 is selected and LED 1 is on,
    When the button is pressed, bankSetting 2 is selected, LED 1 turns off and LED 2 turns on,
    When the button is pressed again, bankSetting 3 is selected, LED 2 turns off and LED 3 turns on.
    When the last bankSetting is selected, and the button is pressed,
    bankSetting 1 is selected, the last LED turns off and LED 1 turns on.
    
    BankSelector(bank, { button increment pin }, { led 1 pin, led 2 pin, ... , led n pin });


Note: a switch is 'off' or 'released' when it doesn't conduct. The digital value 
on the input will therefore be HIGH (because of the pull-up resistor)
*/

Steps taken to try to diagnose or solve the problem

? Tried the MIDI debug mode, used a MIDI monitor, ... ? Im new to this how would I test as he usb is connected to the pi now and not the pc?

The goal of your project and aditional information

To play the Yoshimi via the arduino buttons and sensors.

@tttapa
Copy link
Owner

tttapa commented Jan 20, 2020

I haven't been able to reproduce this problem. I just tested the code you posted on an Arduino UNO, and it worked fine.
The bank only changes the channel or the note number (depending on whether you're using CHANGE_CHANNEL or CHANGE_ADDRESS). It doesn't change the instrument.

Changing instruments is usually done by changing patches or programs using MIDI program change events.
You could use something like this:

MIDI_Controller.MIDI()->send(PROGRAM_CHANGE, channel, program);
// channel [1, 16] and program [0, 127]

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020

Thanks for getting back to me.
Please explain as Im using a Leonardo? how did you verify that this works if you didnt duplicate my setup? the usb is connected to the rasberry?
How would I verify this if I wanted to test on a windows pc? I have fl studio on win 10.

@tttapa
Copy link
Owner

tttapa commented Jan 21, 2020

90% of the code is the same, only the MIDI backend is different on Leonardo. All code has been tested on a Leonardo before.

MIDI is platform independent. I haven't tried Yoshimi, but I did confirm that the bank selector correctly changes the channel or address of the MIDI messages in question. You can confirm this by using a MIDI monitor on your PC or RPi.
If it doesn't change the instrument in Yoshimi, this is most likely a problem with the configuration in Yoshimi.

Im using your code to test and nothing happens?

What does "nothing happens" mean?

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020 via email

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020 via email

@tttapa
Copy link
Owner

tttapa commented Jan 21, 2020

MIDI_Controller.MIDI()->send(PROGRAM_CHANGE, [1, 16], [0, 127]);
.07.BankSelectors:58:1: error: 'MIDI_Controller' does not name a type

You have to use that code inside of a function. By [1, 16], I meant "any number from 1 to 16", it's not actual code.

Now Im trying to 1. change the "bank"? if that swhat it is from default to
say chorus, and then to change the instrument to a human voice and be able
to use a button to increment through different banks and instruments , so
when i use my arduino keypad it will then play those sounds.

I don't think using a "MIDI Controller Bank" is what you're looking for.
The voices and instruments are determined by the settings in Yoshimi, not by the notes sent by the MIDI Controller library.

You'll have to look through the documentation for Yoshimi to check if there are specific MIDI commands you can send to instruct it to change the instrument. Usually this is program change (see previous message) if there are less than 128 instruments, and a combination of MIDI bank select and program change if there are more instruments.
MIDI bank select is different from the banking features of the MIDI Controller library.

A MIDI Bank Select event selects one of 16,384 different banks. Each bank has 128 patches/programs/instruments that can be selected using a MIDI Program Change event.

The MIDI Controller banking feature changes the address or channel of the MIDI control elements. For example, if you have four volume potentiometers, they send on MIDI channels 1-4 if the first bank is selected, on channels 5-8 if the second bank is selected, channels 9-12 if the third bank is selected, and so on.

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020 via email

@tttapa
Copy link
Owner

tttapa commented Jan 21, 2020

I have exams right now, I don't have time.

I already posted the code you need to change the program. Changing the banks is similar, but you'll have to do some research first, you can find a lot of information in the MIDI specs and probably in the Yoshimi documentation.

You'll then have to write code that decides when to change the instrument.

The Control Surface library has some of this built-in, like the Program Changer.

https://tttapa.github.io/Control-Surface-doc/Doxygen/d9/d7f/Program-Changer_8ino-example.html

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020 via email

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020 via email

@xtramo
Copy link
Author

xtramo commented Jan 21, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants