23
2015
Play Midi Sounds with midi-dot-net dll

Instructions:
– Download midi-dot-net from https://code.google.com/p/midi-dot-net/ (from downloads section, midi-dot-net_1.1.0.zip)
– Unzip and copy “Midi.dll” into your unity project folder, Assets/Plugins/
– Create c# script and use the source below for testing
– Attach the script to gameobject in scene and hit play, should hear 1 note sound
– See the midi-dot-net examples & API for more info
Note:
– This library doesn’t support loading MIDI files!
– (probably works in Windows only)
Source:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // usage: copy Midi.dll to Assets/Plugins/ folder | |
| // Get it from https://code.google.com/p/midi-dot-net/ | |
| using UnityEngine; | |
| using System.Collections; | |
| using Midi; // needs this | |
| public class MidiSound : MonoBehaviour | |
| { | |
| OutputDevice outputDevice; | |
| void Start () | |
| { | |
| outputDevice = OutputDevice.InstalledDevices[0]; | |
| if (outputDevice.IsOpen) outputDevice.Close(); | |
| if (!outputDevice.IsOpen) outputDevice.Open(); | |
| // play note | |
| outputDevice.SendNoteOn(Channel.Channel1, Pitch.C4, 80); // Middle C, velocity 80 | |
| outputDevice.SendPitchBend(Channel.Channel1, 7000); // 8192 is centered, so 7000 is bent down | |
| } | |
| void OnDestroy () | |
| { | |
| if (outputDevice != null && outputDevice.IsOpen) outputDevice.Close(); | |
| } | |
| void OnDisable () | |
| { | |
| if (outputDevice != null && outputDevice.IsOpen) outputDevice.Close(); | |
| } | |
| } |
Related Posts
Leave a comment
Recent posts
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
Recent Comments
- on Sprite Sheet Flip Book Shader
- on Sprite Sheet Flip Book Shader
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by











