FluidSynth support for mingus.

FluidSynth is a software MIDI synthesizer which allows you to play the containers in mingus.containers real-time. To work with this module, you’ll need fluidsynth and a nice instrument collection (look here: http://www.hammersound.net, go to Sounds → Soundfont Library → Collections).

To start using FluidSynth with mingus, do: >>> from mingus.midi import fluidsynth >>> fluidsynth.init(‘soundfontlocation.sf2’)

Now you are ready to play Notes, NoteContainers, etc.

class mingus.midi.fluidsynth.FluidSynthSequencer[source]

Attribute of type: int 2


Attribute of type: int 3


Attribute of type: int 9


Attribute of type: int 10


Attribute of type: int 13


Attribute of type: int 0


Attribute of type: int 7


Attribute of type: int 5


Attribute of type: int 11


Attribute of type: int 12


Attribute of type: int 4


Attribute of type: int 1


Attribute of type: int 8


Attribute of type: int 6

attach(self, listener)

Attach an object that should be notified of events.

The object should have a notify(msg_type, param_dict) function.

cc_event(self, channel, control, value)[source]
control_change(self, channel, control, value)

Send a control change message.

See the MIDI specification for more information.

detach(self, listener)

Detach a listening object so that it won’t receive any events anymore.

instr_event(self, channel, instr, bank)[source]
load_sound_font(self, sf2)[source]

Load a sound font.

Return True on success, False on failure.

This function should be called before your audio can be played, since the instruments are kept in the sf2 file.

main_volume(self, channel, value)

Set the main volume.

modulation(self, channel, value)

Set the modulation.

notify_listeners(self, msg_type, params)

Send a message to all the observers.


Attribute of type: NoneType None

pan(self, channel, value)

Set the panning.

play_Bar(self, bar, channel=1, bpm=120)

Play a Bar object.

Return a dictionary with the bpm lemma set on success, an empty dict on some kind of failure.

The tempo can be changed by setting the bpm attribute on a NoteContainer.

play_Bars(self, bars, channels, bpm=120)

Play several bars (a list of Bar objects) at the same time.

A list of channels should also be provided. The tempo can be changed by providing one or more of the NoteContainers with a bpm argument.

play_Composition(self, composition, channels=None, bpm=120)

Play a Composition object.

play_Note(self, note, channel=1, velocity=100)

Play a Note object on a channel with a velocity[0-127].

You can either specify the velocity and channel here as arguments or you can set the Note.velocity and Note.channel attributes, which will take presedence over the function arguments.

play_NoteContainer(self, nc, channel=1, velocity=100)

Play the Notes in the NoteContainer nc.

play_Track(self, track, channel=1, bpm=120)

Play a Track object.

play_Tracks(self, tracks, channels, bpm=120)

Play a list of Tracks.

If an instance of MidiInstrument is used then the instrument will be set automatically.

play_event(self, note, channel, velocity)[source]
set_instrument(self, channel, instr, bank=0)

Set the channel to the instrument _instr_.

sleep(self, seconds)[source]
start_audio_output(self, driver=None)[source]

Start the audio output.

The optional driver argument can be any of ‘alsa’, ‘oss’, ‘jack’, ‘portaudio’, ‘sndmgr’, ‘coreaudio’, ‘Direct Sound’, ‘dsound’, ‘pulseaudio’. Not all drivers will be available for every platform.

start_recording(self, file=mingus_dump.wav)[source]

Initialize a new wave file for recording.

stop_Note(self, note, channel=1)

Stop a note on a channel.

If Note.channel is set, it will take presedence over the channel argument given here.

stop_NoteContainer(self, nc, channel=1)

Stop playing the notes in NoteContainer nc.

stop_event(self, note, channel)[source]

Stop all the notes on all channels.


Attribute of type: bool False


Attribute of type: mingus.midi.fluidsynth.FluidSynthSequencer <mingus.midi.fluidsynth.FluidSynthSequencer object at 0x7f906636a890>

mingus.midi.fluidsynth.control_change(channel, control, value)[source]

Send a control change event on channel.

mingus.midi.fluidsynth.init(sf2, driver=None, file=None)[source]

Initialize the audio.

Return True on success, False on failure.

This function needs to be called before you can have any audio.

The sf2 argument should be the location of a valid soundfont file.

The optional driver argument can be any of ‘alsa’, ‘oss’, ‘jack’, ‘portaudio’, ‘sndmgr’, ‘coreaudio’ or ‘Direct Sound’.

If the file argument is not None, then instead of loading the driver, a new wave file will be initialized to store the audio data.

mingus.midi.fluidsynth.main_volume(channel, value)[source]

mingus.midi.fluidsynth.modulation(channel, value)[source]

mingus.midi.fluidsynth.pan(channel, value)[source]

mingus.midi.fluidsynth.play_Bar(bar, channel=1, bpm=120)[source]

Play a Bar object using play_NoteContainer and stop_NoteContainer.

Set a bpm attribute on a NoteContainer to change the tempo.

mingus.midi.fluidsynth.play_Bars(bars, channels, bpm=120)[source]

Play a list of bars on the given list of channels.

Set a bpm attribute on a NoteContainer to change the tempo.

mingus.midi.fluidsynth.play_Composition(composition, channels=None, bpm=120)[source]

Play a composition.

mingus.midi.fluidsynth.play_Note(note, channel=1, velocity=100)[source]

Convert a Note object to a ‘midi on’ command.

The channel and velocity can be set as Note attributes as well. If that’s the case those values take presedence over the ones given here as function arguments.


>>> n = Note('C', 4)
>>> n.channel = 9
>>> n.velocity = 50
>>> FluidSynth.play_Note(n)

mingus.midi.fluidsynth.play_NoteContainer(nc, channel=1, velocity=100)[source]

Use play_Note to play the Notes in the NoteContainer nc.

mingus.midi.fluidsynth.play_Track(track, channel=1, bpm=120)[source]

Use play_Bar to play a Track object.

mingus.midi.fluidsynth.play_Tracks(tracks, channels, bpm=120)[source]

Use play_Bars to play a list of Tracks on the given list of channels.

mingus.midi.fluidsynth.set_instrument(channel, instr, bank=0)[source]

mingus.midi.fluidsynth.stop_Note(note, channel=1)[source]

Stop the Note playing at channel.

If a channel attribute is set on the note, it will take presedence.

mingus.midi.fluidsynth.stop_NoteContainer(nc, channel=1)[source]

Use stop_Note to stop the notes in NoteContainer nc.


Stop all the playing notes on all channels.

Back to Index