Go Down

Topic: Send MIDI messages to a synthesizer (Read 229 times) previous topic - next topic

Pedropepe

Hello, I'm a novice with little knowledge of programming and I'm trying to build a simple digital flute with an Arduino Uno board and some sensors connected to its digital pins. The goal is to send the signal from the sensors to a MIDI synthesizer on the PC.
With the code that is attached, when executing it, it gives not errors, but notes are executed randomly, without any pulsation in the sensors. Would you be so kind to guide me to correct my mistakes? Thank you

Code:

slipstick

That code is really difficult to read with loads of statements all on a single line. Why do you define all those global b2,b3 etc.variables and then define new versions of them all inside loop()?

Some idea of what hardware you're using would be helpful. But if you're using Serial to write the MIDI via a standard MIDI Out circuit and 5-pin DIN cable to a synth or similar then it should be Serial.begin(31250). That's the standard rate that MIDI always works at.

I have no idea if the button combinations are correct but it looks as if it should do something. Since you don't have any equivalent of breath control presumably it is permanently playing one note or another. I guess this is just an early test is it?

Steve

Grumpy_Mike

Quote
but notes are executed randomly,
Sounds like a floating input to me.
How are the switches wired up?

The correct way to wire up a switch / push button is between the input and ground. The enable the internal pull up resistors with a
Code: [Select]
pinMode(pin,INPUT_PULLUP);
call in the setup function.

Pedropepe

That code is really difficult to read with loads of statements all on a single line. Why do you define all those global b2,b3 etc.variables and then define new versions of them all inside loop()?

Some idea of what hardware you're using would be helpful. But if you're using Serial to write the MIDI via a standard MIDI Out circuit and 5-pin DIN cable to a synth or similar then it should be Serial.begin(31250). That's the standard rate that MIDI always works at.

I have no idea if the button combinations are correct but it looks as if it should do something. Since you don't have any equivalent of breath control presumably it is permanently playing one note or another. I guess this is just an early test is it?

Steve
Hi, thanks for the answer,
slipstick: I modified the code a little, I attached the new one.
I am using Arduino Uno R3 with cables with one end connected to a pin and the other connected directly to the digital pins (according to some comments I have read, activating the internal resistance of the pins, it is not necessary to connect an additional resistor). I follow the recommendation of the echanter.com page, but my intention is to connect the Arduino to the PC via USB, without MIDI cable, and execute the MIDI messages with a virtual synthesizer on the PC (Windows).
When executing the code, it continuously sends me the MIDI message corresponding to the continuous note 72, with speed 127. It does not detect the pulsation of any other pin.
I don't know how to program or connect a breathing control, as you've told me.

Pedropepe

Sounds like a floating input to me.
How are the switches wired up?

The correct way to wire up a switch / push button is between the input and ground. The enable the internal pull up resistors with a
Code: [Select]
pinMode(pin,INPUT_PULLUP);
call in the setup function.
Hi, thanks for the answer,
I've enabled the internal pull up resistors with a pinMode (pin, INPUT_PULLUP); in the setup function.
I am using Arduino Uno R3 with cables with one end connected to a pin and another connected directly to the digital pins: I follow the model of the echanter.com page.

Thanks for your help.

Grumpy_Mike

#5
Jan 11, 2018, 10:49 pm Last Edit: Jan 11, 2018, 10:50 pm by Grumpy_Mike
Quote
I follow the model of the echanter.com page.
You should have said, that changes everything with your switches.
This is the circuit of your tone hole sensors.

In effect it is using a 5M pull up and enabling the internal pull ups will kill the effect you are trying to achieve. So put those pinMode calls back to just INPUT.

However what is not clear on the only diagram on the page is that the metal on your tube needs to be connected to the ground of the Arduino in order for the high resistance from your fingers pull down the input. If grounding the tube does not fix it the 5M might be too high and I would try 2.7M and then 1M.

Pedropepe

Sorry, I forgot the new code.

Go Up