Skip to content

Commit

Permalink
Apply Unity package layout
Browse files Browse the repository at this point in the history
  • Loading branch information
kshoji committed May 7, 2022
1 parent 016480d commit 6967da8
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ sysinfo.txt
# Crashlytics generated file
crashlytics-build.properties

RTP-MIDI-for-.NET/bin
RTP-MIDI-for-.NET/obj
RTP-MIDI-for-.NET/bin.meta
RTP-MIDI-for-.NET/obj.meta
.idea
Runtime/bin
Runtime/obj
Runtime/bin.meta
Runtime/obj.meta
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog
All notable changes to this package will be documented in this file.

## [1.0.0] - 2022-05-08

### Initial release

* Initial release.
* Ported RTP MIDI features from [Arduino-AppleMIDI-Library](https://github.com/lathoub/Arduino-AppleMIDI-Library), to C#.
* No dependency with Unity, so it also runs on pure .NET environment.
7 changes: 7 additions & 0 deletions CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions Documentation~/jp.kshoji.rtpmidi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# How to use this library

## Use this library with Unity
At first, setup the library to Unity Project.
Open the `manifest.json` for your project and add the following entry to your list of dependencies.

```json
"jp.kshoji.rtpmidi": "https://github.com/kshoji/RTP-MIDI-for-.NET.git",
```

## Start RTP MIDI Listener
`Listener` can accept connection from the other RTP MIDI `Initiator` host.
```cs
// defines and create a instance of RTP MIDI connection listener.
class RtpMidiDeviceConnectionListenerImpl : IRtpMidiDeviceConnectionListener
{
void OnRtpMidiDeviceAttached(string deviceId)
{
Console.WriteLine($"device {deviceId} connected.");
}

void OnRtpMidiDeviceDetached(string deviceId)
{
Console.WriteLine($"device {deviceId} disconnected.");
}
}
var connectionListner = new RtpMidiDeviceConnectionListenerImpl();

// Create a server instance, listening UDP port 5004 (control port), and 5005 (data port)
var rtpMidiServer = new RtpMidiServer("My session name", 5004, connectionListener);
// Start the server. Now, the server can connect from the RTP MIDI Initiator host.
rtpMidiServer.Start();
```

## Start RTP MIDI Initiator
`Initiator` can connect to the another `Listener` hosts.
```cs
// Connect to another RTP MIDI listener
rtpMidiServer.ConnectToListener(new IPEndpoint(IPAddress.Parse("192.168.0.100"), 5004));
```

## Receive MIDI events
```cs
// defines and create a instance of RTP MIDI event listener.
class MidiEventHandler : IRtpMidiEventHandler
{
void OnMidiNoteOn(int channel, int note, int velocity)
{
Console.WriteLine($"Note on channel: {channel}, note: {note}, velocity: {velocity}");
}
...
}
var midiEventHandler = new MidiEventHandler();

// attach the RTP MIDI event listener.
rtpMidiServer.SetMidiEventListener(midiEventHandler);
```

## Send MIDI events
```cs
// Example: send note on event with channel 1, note 64, velocity 127
// deviceId can obtain from RtpMidiDeviceConnectionListenerImpl.OnRtpMidiDeviceAttached callback.
rtpMidiServer.SendMidiNoteOn(deviceId, 0, 64, 127);
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions Runtime/jp.kshoji.rtpmidi.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "jp.kshoji.rtpmidi",
"rootNamespace": "jp.kshoji.rtpmidi",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
}
7 changes: 7 additions & 0 deletions Runtime/jp.kshoji.rtpmidi.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "jp.kshoji.midisystem",
"displayName": "RTP-MIDI",
"description": "RTP-MIDI porting for .NET / Unity",
"version": "1.0.0",
"unity": "2018.4",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/kshoji/RTP-MIDI-for-.NET.git"
},
"author": "Kaoru Shoji <0x0badc0de@gmail.com> (https://github.com/kshoji)",
"changelogUrl": "https://github.com/kshoji/RTP-MIDI-for-.NET/blob/main/CHANGELOG.md",
"documentationUrl": "https://github.com/kshoji/RTP-MIDI-for-.NET/blob/main/Documentation~/jp.kshoji.rtpmidi.md",
"licensesUrl": "https://github.com/kshoji/RTP-MIDI-for-.NET/blob/main/LICENSE",
"keywords": [
"midi",
"rtp"
]
}
7 changes: 7 additions & 0 deletions package.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6967da8

Please sign in to comment.