How to make a comfortable synthesizer with your own hands
As a child I had a piano, this is a real, Soviet, 300 kilo kilogram. I liked to strum on it, and even after graduating from music school, even play something. The piano is cool, authentic, but not at all practical. And in order to be completely straightforward for the soul, we also need a drum set, five lotions for an electric guitar, a clarinet, a sitar and sample loops ...
Of course, now you don’t need to make a garage studio with a stash of six wages from an apartment; you just need to install a free music editor on your PC. But, this is inconvenient.
The keyboard of a PC is not at all like a keyboard instrument, everything is different here. Moreover, it is not suitable for teaching a child. It seems there is no choice but to acquire a synthesizer. But still tearing at me doubts.
What is a synthesizer? A large device, with a music keyboard, which somewhere should take a decent place. In which the acoustics are built in, and in fact I already have a receiver with speakers. In which the bad PC is built, but I have a good PC.
It turns out that for 40 thousand I buy what I already have in the best quality, except for just the keyboard. It's just some kind of irrational spending.
Looking for a separate keyboard, I came across a class of devices like the USB MIDI Keyboard.
It always seemed to me that MIDI is from a professional music field.
But now all music is made on a PC, in any convenient place, which means that musicians need mobile music keyboards that fit easily into a backpack.
Here it is!
A plan immediately formed in my head. We connect the MIDI-keyboard to the home media center based on the Raspberry Pi 3, where the software synthesizer is spinning, allowing anyone who wants to play their next masterpiece at any time. On such MIDI-keyboards as a rule there is a set of knobs and additional buttons that are programmed for various effects or additional musical instruments. It looks and sounds very cool!
There are bigger and smaller devices, there is more expensive and slightly cheaper. I chose the option for about 5 sput. He has two octaves, the normal size of the key, the buttons for the percussion, the tuning knob, that is, everything that the novice electronic musician can dream of.
I am not an expert in creating music on a PC, so it was difficult to find ways to implement my ideas. Information had to be collected bit by bit. The puzzle gradually began to take shape and it turned out to collect a working solution, which I share with you. Oddly enough, but the standard distribution of Raspbian / Debian found everything you need, did not even have to connect external repositories.
Fluidsynth is used as a sequencer (an application that plays MIDI files).
A MIDI keyboard is immediately detected via ALSA and is available to connect to the sequencer.
To play the sounds of various instruments using an open base of samples in the format SoundFont2. First, install it all.
Here it is important for us to remember the numbers of the keyboard and sequencer clients, then to connect them with the command:
aconnect 20:0 128:0
Now we are ready to play the Yamaha Piano (this is the default instrument). Read the fluidsynth manual, there are many interesting commands there, for example, to change the instrument to percussion or wind instruments, set the amount of reverberation or chorus.
Let's make our software synthesizer convenient. In order not to manually connect the keyboard with the sequencer each time, we will write a simple demon that will do this when it starts automatically.
Note that now when starting the sequencer, the configuration file (/ home / osmc / midi-router) is sent, containing commands that turn our keyboard into a real synthesizer.
This is what it is. Each key and twist on the keyboard sends certain events with its own number. I understand there are no special standards, so each manufacturer creates what he wants. For example, I want the square keys to sound drums, the other keys sound the piano, the knobs control the volume, reverb and chorus.
So, I need to register event codes from the keyboard for different instruments, and codes from the knobs for codes that the sequencer understands. In fluidsynth, this is done using a router. These commands are contained in the configuration file.
Here is an example of my configuration file, with comments on what it does.
To find out which codes your device generates, you need to use this utility:
aseqdump -p 20:0
She listens and displays events from the MIDI keyboard to the console. Click the button or twist the knob and you will see the type, channel and event code. You can program your keyboard the way you want, not the way the engineers who designed the specific synthesizer came up with. For that many thanks to the developers of fluidsynth, alsa, SoundFont2, Raspberry and V-Mini.
By the way, this topic with DIY synthesizers is reflected in several inventions, I recommend to study: one and two .