API#

Synthesizer#

class midistream.synthesizer.Synthesizer[source]#

MIDI Synthesizer.

close()[source]#

Stop MIDI rendering and playback.

property config: dict#

Synthesizer configuration dictionary.

property reverb: ReverbPreset#

Reverb effect preset.

Getter

Returns curently used ReverbPreset.

Setter

Set ReverbPreset to use.

property volume: int#

Master volume in dB, 100 is max.

Getter

Returns the volume for the mix engine.

Setter

Set the master volume for the mix engine.

write(data: AnyStr)[source]#

Write MIDI commands to synhtesizer stream.

class midistream.synthesizer.ReverbPreset(value)[source]#

Parameter settings for reverb effect.

CHAMBER = 2#

Chamber preset

HALL = 1#

Hall preset

LARGE_HALL = 0#

Large hall preset

OFF = -1#

Reverb effect off

ROOM = 3#

Room preset

exception midistream.synthesizer.MIDIException[source]#

MIDI error.

Helpers#

class midistream.helpers.Note[source]#

Note number.

>>> Note.A0
21
>>> Note.As0
22
>>> Note.Ab0
20
>>> Note.G9
127
class midistream.helpers.Control(value)[source]#

Control function number for Control Change messages.

See: https://midi.org/midi-1-0-control-change-messages

all_sound_off = 120#

All Sound Off

modulation = 1#

Modulation Wheel

pan = 10#

Pan

volume = 7#

Channel Volume

midistream.helpers.midi_note_on(note: int, channel: int = 0, velocity: int = 64) List[int][source]#

MIDI 9nH message - note on.

>>> midi_note_on(70)
[144, 70, 64]
>>> midi_note_on(70, velocity=127, channel=15)
[159, 70, 127]
midistream.helpers.midi_note_off(note: int, channel: int = 0, velocity: int = 0) List[int][source]#

MIDI 8nH message - note off.

>>> midi_note_off(70)
[128, 70, 0]
>>> midi_note_off(70, channel=15)
[143, 70, 0]
midistream.helpers.midi_program_change(program: int, channel: int = 0) List[int][source]#

MIDI CnH message - program change.

>>> midi_program_change(80, 1)
[193, 80]
midistream.helpers.midi_control_change(controller: int, value: int = 0, channel: int = 0) List[int][source]#

MIDI BnH message - control change.

>>> midi_control_change(7, value=127, channel=1)
[177, 7, 127]
midistream.helpers.midi_command_increase_channel(command: List[int], inc: int) List[int][source]#

Increase channel number of a given command.

>>> command = [177, 7, 127]
>>> midi_command_increase_channel(command, -7)
[170, 7, 127]
>>> command
[177, 7, 127]
midistream.helpers.midi_channels() Generator[int, None, None][source]#

Generator of MIDI channels numbers, with percussion (9) channel omited.

>>> list(midi_channels())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]
midistream.helpers.note_name(note: int) str[source]#

Returns name with accidental and octave number for a given note number.

>>> note_name(60)
'C4'
>>> note_name(90)
'Fs6'
midistream.helpers.parse_note(text: str) int[source]#

Parse note number from text.

Parameters

text – [Note name](optional: “s” - sharp, “b” - flat)[octave number]

Raises

ValueError

>>> parse_note("C4")
60
>>> parse_note("Cs4")
61
>>> parse_note("Cb4")
59