Expérimentations avec fluidsynth

Fluidsynth est un synthétiseur temps-réel qui utilise des échantillons sonores stockés dans des SoundFonts (SoundFont(R) 2). Le site LinuxMAO le classe dans la catégorie des lecteurs d'échantillons

On l'utilise pour générer des sons depuis un périphérique MIDI (tel qu'un clavier) ou partir d'un fichier au format MIDI.

Qsynth est une interface graphique qui facilite l'accès au logiciel.


Consulter en ligne :

Sur le site Linux MAO

Lire en local :

tagadan@aeiouyz:~$ apropos fluidsynth
fluidsynth (1) - a SoundFont synthesizer
qsynth (1) - A fluidsynth Qt GUI Interface

tagadan@aeiouyz:~$ man fluidsynth
NAME
FluidSynth - a SoundFont synthesizer
SYNOPSIS
fluidsynth [options] [ SoundFonts ] [ midifiles ]

Page rédigée en février 2011

Mise en oeuvre

Pour simplifier la rédaction (noms plus courts), créons un lien vers la "soundfont" utilisée :

alain@aeiouyz:~$ ln -s /usr/share/sounds/sf2/FluidR3_GM.sf2 soundfont.sf2

fluidsynth soundfont.sf2 Lance l'éxécution en associant une soundfont. Attention ne fonctionnera que si jackd est en fonctionnement.
fluidsynth -l -a alsa soundfont.sf2 Idem mais sans jackd (paramètre -l) en définissant alsa (paramètre -a) comme pilote son. Le périphérique d'entrée (clavier...) est actif.
fluidsynth -n -l -a alsa soundfont.sf2 Pas de périphérique d'entrée (paramètre -l)
fluidsynth -n -l -a alsa soundfont.sf2 fichier.mid On a remplacé le clavier par un fichier MIDI

Connecter un clavier MIDI USB

Le branchement doit être fait avant de lancer fluidsynth.

Pour que le clavier ait un effet, il faut établir une relation logique entre lui et le programme fluidsynth quand celui-ci sera "en service". Cette relation se fait par ce qu'on appelle des ports MIDI.
Pour établir la connexion on utilise le logiciel aconnect (ALSA Connect).

aconnect -i Liste les ports d'entrée disponibles
aconnect -o Liste les ports de sortie disponibles
aconnect -l Liste les connexions établies. Ne marche pas !!!
aconnect -x Supprime toutes les connexions
aconnect 64:0 65:0 Etablit la connexion du port 64:0 VERS le port 65:0
aconnect -d 64:0 65:0 Rompt la connexion des port 64:0 et 65:0

Expérimentation

1. On branche le clavier.

2. On vérifie si le clavier est reconnu :
tagadan@aeiouyz:~$aconnect -i
tagadan@aeiouyz:~$client 24 : 'USB MIDI keyboard' [type=noyau] 0 'USB MIDI keyboard MIDI 1'

3. On vérifie s'il existe un port MIDI en sortie
tagadan@aeiouyz:~$aconnect -o
On ne trouvera pas fluidsynth.

4. Lancement de fluidsynth
tagadan@aeiouyz:~$fluidsynth -l -a alsa soundfont.sf2
>
Fluidsynth se met en attente

5. Dans un autre terminal, vérifier si un port MIDI a été ouvert pour fluidsynth.
tagadan@aeiouyz:~$aconnect -o
tagadan@aeiouyz:~$client 129 : 'FLUID Synth (2548)' [type=utilisateur] 0 'Synth input port (2548:0)'

6. Connexion
tagadan@aeiouyz:~$aconnect 24:0 129:0

7. On joue...

8. On déconnecte clavier et fluidsynth.
tagadan@aeiouyz:~$aconnect -x


A suivre

A suivre

Once fluidsynth is running, it reads commands from the stdin. There are commands to send MIDI events manually, to load or unload SoundFonts, andsoforth. All the available commands are discussed below. fluidsynth can also be used to play a list of MIDI files. Simply run fluidsynth with the SoundFont and the list of MIDI files to play. In this case you might not want to open the MIDI device to read external events. Use the -n option to deactivate MIDI input. If you also want to deactivate the use of the shell, start fluidsynth with the -i option: 'fluidsynth -ni soundfont.sf2 midifile1.mid midifile2.mid'. fluidsynth -n /usr/share/sounds/sf2/FluidR3_GM.sf2 air.mid générera des messages d'erreur de type : lash_open_socket: could not connect to host 'localhost', service '14541' lash_comm_connect_to_server: could not create server connection Pour éviter les messages, il faut lancer sans lash et utiliser alsa de façon à ce que Jack n'essaie pas de se lancer fluidsynth -n -l -a alsa FluidR3_GM.sf2 air.mid Mettre en attente le synthétiseur : fluidsynth -l -s -i -aalsa -o audio.alsa.device=default /usr/share/sounds/sf2/FluidR3_GM.sf2 Lister les ports MIDI ouverts pmidi -l 24:0 USB MIDI keyboard USB MIDI keyboard MIDI 1 .... 129:0 FLUID Synth (2325) Synth input port (2325:0) Connecter par : aconnect 24:0 129:0 Message du 7/02/2011: -------------------- Objectif : associer le synthétiseur et un clavier MIDI. 1.D'après le man de FS : -s, --server démarre fluidsynth en mode serveur -l, --disable-lash n'active pas lash (évite jack) -i, --no-shell pas de shell (interaction avec l'utilisateur) [default = yes] -o Define a setting, -o name=value ("-o help" to dump current values) audio.alsa.device default ALSA audio driver output device. 2. On lance la commande résultante : fluidsynth -l -s -i -aalsa -o audio.alsa.device=default /usr/share/sounds/sf2/FluidR3_GM.sf2 (pour info : /usr/share/sounds/sf2/FluidR3_GM.sf2 est l'adresse de la "soundfont" utilisée) 3. On branche le clavier MIDI USB 4. On teste les ports midi ouverts pmidi -l qui donne (extrait) : 24:0 USB MIDI keyboard USB MIDI keyboard MIDI 1 .... 129:0 FLUID Synth (2325) Synth input port (2325:0) 5. On connecte le clavier sur le synthétiseur : aconnect 24:0 129:0 Et cela marche. On peut faire la manip avec timidity (autre synthé) mais c'est moins bon. Critiques, incertitudes : ------------------------ On ne sort que le son d'un piano. Comment choisir la fonte dans la commande ? Que se passe-t-il si l'on joue vite ? Faut-il jack dans ce cas ? Remarque : choisir l'instrument : synth.audio-channels INT [min=1, max=128, def=1] Number of audio channels (DOCME!).