Extensions and classes in Swift that make it easy to get an iOS device reading and processing MIDI data

Related tags

Audio morkandmidi
Overview

Swift Swift Badge SwiftPM compatible License Badge

MorkAndMIDI

A really thin Swift layer on top of CoreMIDI that opens a virtual MIDI destination and port and connects to any MIDI endpoints that appear on the network, no questions asked.

Currently just supports some MIDI v1 messages. However, it also provides enhancements to MIDIPacket and MIDIPacketList to support building new ones and to parse them.

Features

This package basically sets up MIDI and connects to all available inputs it finds. Connection state can be monitored by installing a Monitor instance, and actual MIDI commands can be observed by installing a Receiver instance. Everything else should be handle automatically by the package.

To Use

Create a new MIDI instance passing in a name to use for the endpoints that it will create, and a unique ID that will be assigned to the endpoints:

let midi = MorkAndMIDI.MIDI(clientName: "Na-Nu Na-Nu", uniqueId: 12_345)
midi.monitor = my_monitor
midi.receiver = my_receiver
midi.start()

Ideally, this uniqueId value will actually be unique to your MIDI network. However, there is no way to guarantee that so instead one should install a Monitor to observe the unique ID value that is passed to Monitor.initialized rouotine once initialization is complete. When there are no conflicts, this value will be the same as the one given in the MIDI constructor. If there was a conflict, you should be given a value provided by the system.

Processing MIDI Messages

The Receiver protocol defines functions that will be called for MIDI commands that arrive over USB or the network. Since they are all optional, you only need to implement the commands you want.

Note that at the moment, SysExc (0xF0) commands are not support and will be silently ignored. I have no need for them, but supporting them should not be too difficult a task -- you just need to buffer MIDI packets until it is complete.

Connectivity

The MIDI class listens for changes to the MIDI nework and creates / destroys connections to external devices when necessary. The Monitor protocol has methods you can implement to be notified when connections and/or devices change. There is also a way to track the MIDI channel being used by an external device.

MIDIPacket and MIDIPacketList Builders

I implemented my own version of the builders that are available for MIDIPacket and MIDIPacketList in iOS 14+. They are not 100% replacement, but they do what I need in a safe and performant manner, and they allow me to continue to support iOS 12 devices in my apps.

You might also like...
An app to get you the latest and the trending news based on your location.

Newsline Link to APK : http://bit.ly/newslineapp Newsline is an android application made with flutter which makes use of NewsAPI.org to fetch and serv

 A simple way to get a music pitch from a frequency.
A simple way to get a music pitch from a frequency.

Pitchy provides a simple way to get a music pitch from a frequency. Other than that it has a bunch of useful data structures, calculators and helper functions to work with notes, octaves and acoustic waves.

This app demonstrates how to use the Google Cloud Speech API and Apple on-device Speech library to recognize speech in live recorded audio.

SpeechRecognitionIOS This app demonstrates how to use Google Cloud Speech API and Apple on-device Speech library to recognize speech in live audio rec

KeyAudioManager - A swift package to make it a lot easier to play audio in your app

KeyAudioManager A swift package to make it a lot easier to play audio in your ap

Swift-music - swift-music is a swift package that provides an easy-to-use API for music related developments.

🎼 swift-music Introduction swift-music is a swift package that provides an easy-to-use API for music related developments. Currently available module

:musical_keyboard: A simple iOS synthesiser powered by Pure Data. Based on the Korg Monotron Delay.

Monotone Delay A simple iOS Synthesizer based on Pure Data. You can see a short demo of the app on youtube. If you want to buy the app you can find it

iOS framework for the Quiet Modem (data over sound)

QuietModemKit This is the iOS framework for https://github.com/quiet/quiet With this library, you can send data through sound. Live demo: https://quie

Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way

Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way. You can play

MusicTheoryKit: a swift module that provides an easy-to-use API for most commonly used music terms

MusicTheoryKit Introduction MusicTheoryKit is a Swift framework that provides an easy-to-use API for most commonly used music terms. Create notes, ass

Comments
  • You might be interested in my framework

    You might be interested in my framework

    Hey Brad, I came across this project and I thought that you might be interested in a framework I developed. https://github.com/adamnemecek/WebMIDIKit

    Sorry if this is uninvited.

    opened by adamnemecek 1
Owner
Brad Howes
I've typed more code than I can remember.
Brad Howes
A note source and a rhythm source to create a new virtual MIDI instrument

MidiCombiner for Mac Combines inputs from 2 different MIDI sources: A note source and a rhythm source to create a new virtual MIDI instrument. The not

null 2 Jul 6, 2022
I'm trying to make Flutter based Audio Unit Extensions possible.

Flutter AUv3 Audio Unit Error Demo Motivation We are the developers of Audanika, a professional MIDI Controller app written in Flutter. Many of our us

Gabriel Gatzsche 0 Jan 5, 2022
Swift audio synthesis, processing, & analysis platform for iOS, macOS and tvOS

AudioKit AudioKit is an audio synthesis, processing, and analysis platform for iOS, macOS (including Catalyst), and tvOS. Installation To add AudioKit

AudioKit 8.7k Sep 30, 2021
OSCKit - The OSCKit package provides the classes needed for your apps to communicate among computers, sound synthesizers

OSCKit The OSCKit package provides the classes needed for your apps to communica

Sammy Smallman 23 Nov 27, 2022
AudioKit is an audio synthesis, processing, and analysis platform for iOS, macOS, and tvOS.

AudioKit is an audio synthesis, processing, and analysis platform for iOS, macOS (including Catalyst), and tvOS. Installation To add AudioKit

AudioKit 9.5k Dec 31, 2022
An iOS and macOS audio visualization framework built upon Core Audio useful for anyone doing real-time, low-latency audio processing and visualizations.

A simple, intuitive audio framework for iOS and OSX. Deprecated EZAudio has recently been deprecated in favor of AudioKit. However, since some people

Syed Haris Ali 4.9k Jan 2, 2023
Beethoven is an audio processing Swift library

Beethoven is an audio processing Swift library that provides an easy-to-use interface to solve an age-old problem of pitch detection of musical signals.

Vadym Markov 735 Dec 24, 2022
TuningFork is a simple utility for processing microphone input and interpreting pitch, frequency, amplitude, etc.

Overview TuningFork is a simple utility for processing microphone input and interpreting pitch, frequency, amplitude, etc. TuningFork powers the Parti

Comyar Zaheri 419 Dec 23, 2022
📴 SoundModeManager 📳 Detect silent / ring mode on iOS device

?? SoundModeManager ?? Detect silent / ring mode on the device. Installation CocoaPods Usage Documentation License ?? Installation CocoaPods For usage

Yurii Lysytsia 4 Oct 4, 2022
Nobetci Eczacim is open-source App Store Application which users can get pharmacy information and location easily and safely.

Pharmacy-On-Duty Nobetci Eczacim Project Description This project designed for make it easier for people to search for a pharmacy on duty. App Store A

Mert Demirtas 5 Sep 19, 2022