Coder Social home page Coder Social logo

saml98 / niprotocol Goto Github PK

View Code? Open in Web Editor NEW
23.0 6.0 3.0 256 KB

Applications for interacting with the Native Instruments Maschine 2 application (and Mikro MK2).

Makefile 4.72% C++ 58.71% C 11.40% Python 1.39% Objective-C 23.50% Shell 0.27%

niprotocol's Introduction

NIProtocol

This repository contains the code necessary to do two things:

  1. Read button/wheel input from the Native Instruments Maschine Mikro 2.
  2. Send button input from an iPhone to the Native Instruments Maschine 2 application.

For more information on the project, see the linked blog post: [https://medium.com/@lerner98/rage-against-the-maschine-3357be1abc48]

NOTE: All of the code is written for MacOS. Significant changes will be needed for this code to work on other operating systems.

Reading the MK2

The Maschine Mikro 2 (MK2) interfaces with your pc through the Native Instrument drivers. The drivers then forward the data to the NIHardwareAgent (at least on MacOS) which in turns forwards it to the Maschine 2 GUI.

The m2client program, which can be built by running make while inside the client directory, will act as the Maschine 2 GUI and interact with the NIHardwareAgent.

When m2client is run, it will perform the handshake with the hardware agent and create a CFMessagePortRef with name "SIHWMainHandler" for listening applications to send messages to the MK2 through.

Performing the handshake

To perform the handshake (and build the client), multiple modules first need to be built:

  1. niparser: This module will parse the wheel or button packets from the hardware agent into structs.
  2. nimessenger: This module sends the messages necessary for performing the handshake and interacting with the MK2 (such as setting button LED's) to the hardware agent.
  3. ninotifier: This module implements the functions necessary for program to register as a listener for incoming packets and for a program to broadcast a packet to any listening program.
  4. nihandshaker: This module contains the functionality to perform the handshake from the client side with the hardware agent. The previous three modules need to be built in order for this module to be built.

These can all be built using the make_libs.sh script or each can be built individually with the Makefile in its respective directory.

Note that when each library is built, its header and compiled dylib will be copied into the usr/local/include and usr/local/lib directories respectively so that they can be included through system paths.

After m2client performs the handshake, when a new packet is forwarded from the hardware agent, it will then be parsed into a structure and broadcast via a CFNotification to any listening program.

Listening to the notification

Any program can use the ninotifier module to listen to the broadcasted packets. There is an example application in the testapp directory that registers itself as a listener and prints the pressed button or wheel action when a new packet is received.

Writing to Maschine 2

The second part of this project is to act as the hardware agent and send packets to the Maschine 2 GUI. The m2server program (located in the server directory) will perform that task. The server program relies on the same four modules that the client is dependent on.

m2server will also set up a TCP socket on port 6969 to listen for button commands from the Maschine 2 iPhone application. It will then register a Bonjour service with name M2 on this port. The Maschine 2 application, when run, will connect to the published Bonjour service and connect to port 6969.

Currently, pressure sensitivity is not available in the Maschine 2 app since my phone does not support 3D Touch.

niprotocol's People

Contributors

saml98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

niprotocol's Issues

Contact request

Hi Sam,
dropping this fake issue as Iโ€™m reaching out for a job related contact on your research on NI protocol.
Cheers.

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.