Giter VIP home page Giter VIP logo

nim-rtmidi's Introduction

nim-rtmidi

Work in progress, not ready for public consumption yet!

This is a Nim wrapper for the RtMidi cross-platform C++ MIDI library. RtMidi provides a common API for realtime MIDI input/output across the following operating systems:

  • Linux (ALSA, JACK)
  • Mac OS X (CoreMIDI, JACK)
  • Windows (Multimedia Library)

The wrapper provides a pleasant Nim interface to the functions provided by the C API.

For more information please refer to the official RtMidi tutorial and check out the Nim examples.

Versioning

Versioning follows the x.y.z.w scheme, where x.y.z corresponds to the RtMidi version being wrapped (e.g. 4.0.0) and w to the patch version of the Nim wrapper (e.g. 4.4.0.1).

Installation

The best way to install the latest version of the package is via nimble:

nimble install rtmidi

Examples

Compile and run any of the examples by running the following command in the examples directory:

nim c -r <example>

Alternatively, you can invoke the examples nimble task in the project root directory to compile all examples:

nimble examples

Selecting the target API

On Windows, the Windows Multimedia Library is always used so there's no need to configure anything.

On OS X, the symbols rtMidiCore or rtMidiJack need to be provided to indicate which API(s) to compile the library for (note that only CoreMIDI has been tested).

On Linux, the symbols rtMidiAlsa or rtMidiJack need to be provided to indicate which API(s) to compile the library for (note that Linux has not been tested at all).

Documentation

TODO

License

RtMidi is the copyright of Gary P. Scavone and is released under a modified MIT license, with the added feature that modifications be sent to the developer. This library is also released under the MIT license to avoid confusion.

nim-rtmidi's People

Contributors

johnnovak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

demetera

nim-rtmidi's Issues

Cannot read midi messages

The wrapper.getMessage API isn't called correctly, as the size of the buffer must be passed in. If this isn't done, the buffer isn't modified.
Here is how I patched it:

diff --git a/rtmidi.nim b/rtmidi.nim
index 16d4eb8..542ff10 100644
--- a/rtmidi.nim
+++ b/rtmidi.nim
@@ -99,10 +99,11 @@ proc ignoreTypes*(m: MidiIn, midiSysEx: bool = true, midiTime: bool = true,
   wrapper.ignoreTypes(m, midiSysEx, midiTime, midiSense)
 
 proc getNextMessage*(m: MidiIn,
-                     buffer: var openArray[byte]): tuple[length: Natural,
-                                                         eventDelta: float] =
+                     buffer: var openArray[byte],
+                     blen: csize): tuple[length: Natural,
+                                         eventDelta: float] =
   withHandleError(m):
-    var length: csize
+    var length: csize = blen
     var eventDelta = wrapper.getMessage(m, buffer[0].addr, length.addr)
     result = (length.Natural, eventDelta)

How to use?

I tried installing with nimble:

nimble install rtmidi

Prompt: rtmidi not found in any local packages.json, check internet for updated packages? [y/N]
    Answer: y
Downloading Official package list
    Success Package list downloaded.
       Tip: 3 messages have been suppressed, use --verbose to show them.
     Error: Package not found.
Intel Mac running OSX 13.0.1
nimble v0.13.1 compiled at 2022-11-21 01:04:21
Nim Compiler Version 1.6.10 [MacOSX: amd64], Compiled at 2022-11-21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.