MIDISynth.Keyboard (midi_synth v0.4.2)

Copy Markdown View Source

Simple keyboard functions for sending MIDI commands to the synthesizer

Summary

Functions

Change the current program (e.g., the current instrument)

Functions

change_program(server, prog, channel \\ 0)

Change the current program (e.g., the current instrument)

The soundfont that's supplied to MIDISynth.start_link/2 determines the mapping from program numbers to instruments. The default is to use a general MIDI soundfont, and instrument mappings for those can be found by looking at the General MIDI 1 and General MIDI 2 specifications.

Example

# Play a violin iex> {:ok, synth} = MIDISynth.start_link([]) iex> MIDISynth.Keyboard.change_program(synth, 41) :ok iex> MIDISynth.Keyboard.play(synth, 60, 100) :ok

play(server, note, duration, velocity \\ 127, channel \\ 0)

Play a note

This is a utility method for pressing a note down and then releasing it after a duration.

Example

iex> {:ok, synth} = MIDISynth.start_link([]) iex> MIDISynth.Keyboard.play(synth, 60, 100) :ok iex> MIDISynth.Keyboard.play(synth, 60, 100, 80) :ok