MIDISynth.Keyboard (midi_synth v0.4.1) View Source

Simple keyboard functions for sending MIDI commands to the synthesizer

Link to this section Summary

Functions

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

Link to this section Functions

Link to this function

change_program(server, prog, channel \\ 0)

View Source

Specs

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

Link to this function

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

View Source

Specs

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