Difference between revisions of "FluidSynth"

From ArchWiki
Jump to: navigation, search
(ALSA daemon mode: Adding disclaimer for pulseaudio)
 
(19 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[Category:Audio/Video]]
+
[[Category:Multimedia]]
[http://www.fluidsynth.org/ FluidSynth] is a real-time software synthesizer based on the SoundFont 2 specifications.
+
[[ja:FluidSynth]]
 +
[http://www.fluidsynth.org/ FluidSynth] is a real-time software synthesizer based on the SoundFont 2 specifications. It is required by {{Pkg|gst-plugins-bad}}, and thus is installed as a dependency of the {{Grp|gnome}} group.
  
==Installing FluidSynth==
+
== Installing FluidSynth ==
The first step is to [[pacman|install]] {{pkg|fluidsynth}} from the [[Official Repositories]].
+
  
'''However, fluidsynth will not produce any sound yet'''. This is because fluidsynth does not include any instrument samples. To produce sound, instrument patches and/or soundfonts need to be installed and fluidsynth configured so it knows where to find them. You can install [[Timidity#Soundfonts|Soundfont sample]].
+
The first step is to [[install]] the {{Pkg|fluidsynth}} package.
  
==How to use fluidsynth==
+
'''However, FluidSynth will not produce any sound yet'''. This is because FluidSynth does not include any instrument samples. To produce sound, instrument patches and/or soundfonts need to be installed and fluidsynth configured so it knows where to find them. You can install [[Timidity#SoundFonts|SoundFont sample]].
There are two ways to use fluidsynth. Either as MIDI player or as daemon adding MIDI support to ALSA.
+
 
 +
== How to use FluidSynth ==
 +
 
 +
There are two ways to use FluidSynth. Either as MIDI player or as daemon adding MIDI support to ALSA.
 +
 
 +
=== Standalone mode ===
  
===Standalone mode===
 
 
You can simply use fluidsynth to play MIDI files:
 
You can simply use fluidsynth to play MIDI files:
  $ fluidsynth -a alsa -m alsa_seq -l -i /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 example.midi
+
  $ fluidsynth -a alsa -m alsa_seq -l -i /usr/share/soundfonts/FluidR3_GM2-2.sf2 example.midi
Assuming than you installed fluidr3.
+
assuming than you installed {{Pkg|soundfont-fluid}}.
  
 
There are many other options to fluidsynth; see manpage or use -h to get help.
 
There are many other options to fluidsynth; see manpage or use -h to get help.
  
===Alsa daemon mode===
+
One may wish to use pulseaudio instead of alsa as the argument to the -a option.
If you want fluidsynth to run as ALSA daemon, edit /etc/conf.d/fluidsynth and modify FSYNTH_SOUNDFONT with de sound sample you want to use, for fluidr3:
+
FSYNTH_SOUNDFONT="/usr/share/soundfonts/fluidr3/FluidR3GM.SF2"
+
  
After that, you can start fluidsynth with:
+
=== ALSA daemon mode ===
+
# /etc/rc.d/fluidsynth start
+
  
If you want to have permanent MIDI support, add fluidsynth to your daemon list in /etc/rc.conf:
+
If you want fluidsynth to run as ALSA daemon, edit {{ic|/etc/conf.d/fluidsynth}} and add your soundfont along with any other changes you would like to make. For e.g., fluidr3:
DAEMONS=(... fluidsynth ...)
+
  
This will give you an output software MIDI port (in addition of hardware MIDI ports on your system, if any):
+
SOUND_FONT=/usr/share/soundfonts/FluidR3_GM2-2.sf2
 +
AUDIO_DRIVER=alsa
 +
OTHER_OPTS='-is -m alsa_seq -r 48000'
  
$ aconnect -o
+
After that, you can [[start/enable]] the fluidsynth service. Be aware of bug https://bugs.archlinux.org/task/50122 when using pulseaudio driver
client 128: 'FLUID Synth (5117)' [type=user]
+
 
    0 'Synth input port (5117:0)'
+
The following will give you an output software MIDI port (in addition of hardware MIDI ports on your system, if any):
 +
 
 +
{{hc|$ aconnect -o|2=
 +
client 128: 'FLUID Synth (5117)' [type=user]
 +
  0 'Synth input port (5117:0)'
 +
}}
  
 
An example of usage for this is aplaymidi:
 
An example of usage for this is aplaymidi:
  
  aplaymidi -p128:0 example.midi
+
  $ aplaymidi -p128:0 example.midi
  
 
== How to convert MIDI to OGG ==
 
== How to convert MIDI to OGG ==
 +
 
Simple command lines to convert midi to ogg:
 
Simple command lines to convert midi to ogg:
  
  # fluidsynth -nli -r 48000 -o synth.cpu-cores=2 -F /dev/shm/midi_temp.raw /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 example.MID
+
  $ fluidsynth -nli -r 48000 -o synth.cpu-cores=2 -T oga -F example.ogg /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 example.MID
# oggenc -r -B 16 -C 2 -R 48000 /dev/shm/midi_temp.raw -o example.ogg
+
  
 
Here's a little script to convert multiple midi files to ogg in parallel:
 
Here's a little script to convert multiple midi files to ogg in parallel:
  
 
  #!/bin/bash
 
  #!/bin/bash
  maxjobs=$(cat /proc/cpuinfo | grep processor | wc -l)
+
  maxjobs=$(grep processor /proc/cpuinfo | wc -l)
 
  midi2ogg() {
 
  midi2ogg() {
  name=`echo $@ | sed -r s/[.][mM][iI][dD][iI]?$//g | sed s/^[.][/]//g`
+
  name=$(echo $@ | sed -r s/[.][mM][iI][dD][iI]?$//g | sed s/^[.][/]//g)
 
  for arg; do  
 
  for arg; do  
 
  fluidsynth -nli -r 48000 -o synth.cpu-cores=$maxjobs -F "/dev/shm/$name.raw" /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 "$@"
 
  fluidsynth -nli -r 48000 -o synth.cpu-cores=$maxjobs -F "/dev/shm/$name.raw" /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 "$@"

Latest revision as of 22:33, 21 July 2016

FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications. It is required by gst-plugins-bad, and thus is installed as a dependency of the gnome group.

Installing FluidSynth

The first step is to install the fluidsynth package.

However, FluidSynth will not produce any sound yet. This is because FluidSynth does not include any instrument samples. To produce sound, instrument patches and/or soundfonts need to be installed and fluidsynth configured so it knows where to find them. You can install SoundFont sample.

How to use FluidSynth

There are two ways to use FluidSynth. Either as MIDI player or as daemon adding MIDI support to ALSA.

Standalone mode

You can simply use fluidsynth to play MIDI files:

$ fluidsynth -a alsa -m alsa_seq -l -i /usr/share/soundfonts/FluidR3_GM2-2.sf2 example.midi

assuming than you installed soundfont-fluid.

There are many other options to fluidsynth; see manpage or use -h to get help.

One may wish to use pulseaudio instead of alsa as the argument to the -a option.

ALSA daemon mode

If you want fluidsynth to run as ALSA daemon, edit /etc/conf.d/fluidsynth and add your soundfont along with any other changes you would like to make. For e.g., fluidr3:

SOUND_FONT=/usr/share/soundfonts/FluidR3_GM2-2.sf2
AUDIO_DRIVER=alsa
OTHER_OPTS='-is -m alsa_seq -r 48000'

After that, you can start/enable the fluidsynth service. Be aware of bug https://bugs.archlinux.org/task/50122 when using pulseaudio driver

The following will give you an output software MIDI port (in addition of hardware MIDI ports on your system, if any):

$ aconnect -o
client 128: 'FLUID Synth (5117)' [type=user]
   0 'Synth input port (5117:0)'

An example of usage for this is aplaymidi:

$ aplaymidi -p128:0 example.midi

How to convert MIDI to OGG

Simple command lines to convert midi to ogg:

$ fluidsynth -nli -r 48000 -o synth.cpu-cores=2 -T oga -F example.ogg /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 example.MID

Here's a little script to convert multiple midi files to ogg in parallel:

#!/bin/bash
maxjobs=$(grep processor /proc/cpuinfo | wc -l)
midi2ogg() {
	name=$(echo $@ | sed -r s/[.][mM][iI][dD][iI]?$//g | sed s/^[.][/]//g)
	for arg; do 
	fluidsynth -nli -r 48000 -o synth.cpu-cores=$maxjobs -F "/dev/shm/$name.raw" /usr/share/soundfonts/fluidr3/FluidR3GM.SF2 "$@"
	oggenc -r -B 16 -C 2 -R 48000 "/dev/shm/$name.raw" -o "$name.ogg"
	rm "/dev/shm/$name.raw"
	## Uncomment for replaygain tagging
	#vorbisgain -f "$name.ogg" 
	done
}
export -f midi2ogg
find . -regex '.*[.][mM][iI][dD][iI]?$' -print0 | xargs -0 -n 1 -P $maxjobs bash -c 'midi2ogg "$@"' --