Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Elixir bindings to the portmidi library

License

NotificationsYou must be signed in to change notification settings

lucidstack/ex-portmidi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Need to catch up? Have a look at thechangelog! 🚀

ex-portmidi is a wrapper for thePortMidi C library,that provides some nice abstractions to (write to|listen on) MIDI devices.

Installation

Add portmidi to your list of dependencies inmix.exs, and ensurethatportmidi is started before your application:

def deps do  [{:portmidi, "~> 5.0"}]enddef application do  [applications: [:portmidi]]end

Configuration

If needed, the input buffer size can be set, in yourconfig.exs:

  config :portmidi, buffer_size: 1024

By default, this value is 256.

Usage

To send MIDI events to a MIDI device:

iex(1)> {:ok, output} = PortMidi.open(:output, "Launchpad Mini"){:ok, #PID<0.172.0>}iex(2)> PortMidi.write(output, {176, 0, 127}):okiex(3)> PortMidi.write(output, {{176, 0, 127}, 123}) # with timestamp:okiex(4)> PortMidi.write(output, [iex(5)>   {{176, 0, 127}, 123},iex(6)>   {{178, 0, 127}, 128}iex(7)> ]) # as a sequence of events (more efficient):okiex(8)> PortMidi.close(:output, output):ok

To listen for MIDI events from a MIDI device:

iex(1)> {:ok, input} = PortMidi.open(:input, "Launchpad Mini"){:ok, #PID<0.103.0>}ex(2)> PortMidi.listen(input, self):okiex(3)> receive do...(3)>   {^input, event} -> IO.inspect(event)...(3)> end{144, 112, 127}iex(4)> PortMidi.close(:input, input):ok

To list all connected devices:

ex(1)> PortMidi.devices%{input: [%PortMidi.Device{input: 1, interf: "CoreMIDI", name: "Launchpad Mini",    opened: 0, output: 0}],  output: [%PortMidi.Device{input: 0, interf: "CoreMIDI",    name: "Launchpad Mini", opened: 0, output: 1}]}

For more details,check out the Hexdocs.

About

Elixir bindings to the portmidi library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp