fbpx
Skip to main content

MIDI Forum

Setting up a channe...
 
Notifications
Clear all

Setting up a channel for legato

9 Posts
4 Users
0 Reactions
9,089 Views
Michael
Posts: 3
Active Member
Topic starter
 

I'm making a MIDI instrument with an Arduino that spits out MIDI notes based on inputs. One of the things I really need is the ability to slur notes, which legato ought to allow me to do.

However, it appears there is more to do this than sending the legato foot pedal on/off, and I'm not sure what I am missing here, other than there needs to be some set-up for the channel.

In case it matters, I am using FluidSynth (v2.1.1) on a Raspberry Pi as the voice part of this project. Between the walls I'm running into with their documentation and the MIDI standard, I'm beginning to think I have a big hole in my MIDI education.

 
Posted : 11/10/2021 8:40 am
Geoff
Posts: 1039
Noble Member
 

You could experiment with the use of Controller 68 (Hex 44) if your device supports that controller. That may be what the actual foot pedal does. However, I assume that the way you play will be important too. If you release the first key before you press the new key then there may be a gap that the legato 'effect' cannot cover. Maybe you need to try to press the new key before you release the first key, then maybe the legato effect will determine the amount of slurring? Of course, this may depend on the type of instrument, both in terms of the actual instrument (i.e. piano or organ) and as in maker (i.e. Roland or Yamaha, for example).

Experiment to get the effect you want, then we can see how to do that with midi.

Geoff

 
Posted : 11/10/2021 10:19 am
Pedro Lopez-Cabanillas
Posts: 154
Estimable Member
 

The FluidSynth library has a "legato mode" feature: https://www.fluidsynth.org/api/group__channel__setup.html
MIDI CC68 triggers this function: https://github.com/FluidSynth/fluidsynth/wiki/FluidFeatures#midi-control-change-implementation-chart
You may also be interested in this design document: https://raw.githubusercontent.com/FluidSynth/fluidsynth/master/doc/polymono/FluidPolyMono-0004.pdf

Like Geoff has pointed out, you may be missing the piece of a human musician who has to play legato to leverage all that technology. If the musician plays staccato, the synth output will sound staccato. The Soundfont loaded in the synth and the selected program may have influence in the results too. If your doubt is about something else, please ask.

 
Posted : 11/10/2021 10:48 am
Michael
Posts: 3
Active Member
Topic starter
 

I've been sending the CC68 On/Off signals, but that doesn't seem to work - at least on its own.. I've also read a good chunk of the FluidPolyMono document (along with the other FluidSynth docs), but I'm not sure if I understand it.

From what I've read there and elsewhere it seems to imply the channel needs to be set to mono mode, which I think I'm setting, but I'm a little fuzzy on just how the "basic channel" part works. From what I understand by default FluidSynth comes up with that being set to channel 0 (1 as normally thought of) and the rest of the channels following the mode settings sent to it. I send Omni-on and Mono-on commands on channel 1, which (as I understand it) should set all 16 channels to omni-mono mode. But I'm not sure if it does.

As for the human factor, I'm the only one playing it at this point, and the code is definitely turning the second note on before the first one is tuned off, so I don't think that is an issue (yet).

 
Posted : 12/10/2021 11:47 am
Pedro Lopez-Cabanillas
Posts: 154
Estimable Member
 

There is a lot more to read. Please browse and try the tutorials in https://github.com/FluidSynth/fluidsynth/tree/master/doc/polymono
Also, you may be interested in the MIDI Specification document. Channel Modes are described in the PDF pages 38-40.

You cannot configure (and supervise) the basic channel using MIDI messages, but fluidsynth has a shell that accepts its own commands where you can configure and see modes and basic channels. You can access the shell running the fluidsynth command line client on a terminal, or by network.

 
Posted : 12/10/2021 1:04 pm
JohnG
Posts: 225
Estimable Member
 

If you want to achieve a slur between two notes, i.e. to cut off the attack portion of the second (and any subsequent) notes under the slur, then the first note needs to overlap the second note (and so on),
That is, the note off for the 1st note occurs after the note on of the 2nd, etc.

The CC68 is placed after the note on of the 1st note and released before the note off of the last note under the slur.

The CC68 on should temporarily (according to the MIDI specification) place the channel into monophonic mode.

This technique works perfectly in many orchestral VSTi's for woodwind, brass and bowed strings although, sometimes (for the VSTi player) CC64 is used for simple convenience instead of CC68.

 
Posted : 13/10/2021 4:10 am
Pedro Lopez-Cabanillas
Posts: 154
Estimable Member
 

sometimes CC64 is used for simple convenience instead of CC68.

Using the sustain pedal of the piano to play legato is like cheating! 😉

Sorry, I'm joking... Sort of. But many pianists may say something like that, in a very serious tone.

The point is that some instruments, like the acoustic piano, are not really melodic instruments. Each key is attached to a hammer and when you press it down it strokes one or several metallic strings, producing an audible "bang" with percussive quality. It doesn't matter that the hammers are made of wood, and covered with felt. It could be worse, but still... Playing legato on the piano is quite difficult.

Compare to the violin. Legato is performed by keeping the bow movement on the same direction during the legato phrase. When the bow movement direction changes, there is a distinctive rubbing sound that a violinist wants to avoid when playing legato. Wind instruments also have artifacts at the sound attack, produced by the player's mouth.

Synthesizers create the notes using an envelope generator, usually with four stages: attack, decay, sustain and release (ADSR). In legato mode, the notes do not perform the whole attack and release phases, which are overlapped with the adjacent notes. In Fluidsynth, you can choose among two legato modes using the "setlegatomode" shell command, and it accepts CC68 as the on/off switch. But it also depends on the soundfont, and each program within the soundfont. The tutorials on the "polymono" directory suggest the General User GS soundfont, and its (beautiful) flute program to illustrate the legato modes, which are quite convincing. But you may use the program 0 instead (acoustic grand piano) that sounds quite unnatural in the default legato mode, because sometimes the hammer blow is almost removed from the sound. If you use another soundfont and other programs, the results will be different.

 
Posted : 13/10/2021 4:14 pm
JohnG
Posts: 225
Estimable Member
 

Yes, agreed, use of the sustain pedal could be considered cheating, but for most non hammer action keyboards (much easier to achieve the desired result when playing bowed strings or wind) they will usually arrive with a pedal that implements CC64 not CC68.

Many orchestral libraries (the few I've used) can use CC00, the modulation wheel, (instead of CC11) for expression.
So controlling dynamics and legato whilst playing in phrases can be achieved by using the mod wheel and the sustain pedal ... very useful.

Some libraries use CC64 for the play program and CC68 for entry from a notation program, e.g. Finale.

 
Posted : 14/10/2021 3:34 am
Michael
Posts: 3
Active Member
Topic starter
 

Well, I think I'm seeing a couple mistakes I've been making, and a couple that should have worked but don't. Maybe. Got to try some code changes to test where I think I went wrong. I'll update when I know if I figured it out.

Hopefully I can give the next poor sap that needs to figure this out a better answer than RTFM.

 
Posted : 26/10/2021 12:28 pm
Share: