{"id":16012739,"url":"https://github.com/smacker/mid","last_synced_at":"2026-05-21T07:30:13.621Z","repository":{"id":141960215,"uuid":"149172319","full_name":"smacker/mid","owner":"smacker","description":"Easy reading and writing of MIDI and SMF","archived":false,"fork":false,"pushed_at":"2018-09-17T18:49:09.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T18:48:45.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smacker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-17T18:47:58.000Z","updated_at":"2022-08-26T07:23:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"130f6ec5-9914-49c8-858b-17e720ce1c53","html_url":"https://github.com/smacker/mid","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fmid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fmid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fmid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fmid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smacker","download_url":"https://codeload.github.com/smacker/mid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131773,"owners_count":19752725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T14:20:52.320Z","updated_at":"2026-05-21T07:30:13.538Z","avatar_url":"https://github.com/smacker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mid\nPorcelain library for reading and writing MIDI and SMF (Standard MIDI File) \n\nBased on https://github.com/gomidi/midi.\n\n[![Build Status Travis/Linux](https://travis-ci.org/gomidi/mid.svg?branch=master)](http://travis-ci.org/gomidi/mid) [![Coverage Status](https://coveralls.io/repos/github/gomidi/mid/badge.svg)](https://coveralls.io/github/gomidi/mid) [![Go Report](https://goreportcard.com/badge/github.com/gomidi/mid)](https://goreportcard.com/report/github.com/gomidi/mid) [![Documentation](http://godoc.org/github.com/gomidi/mid?status.png)](http://godoc.org/github.com/gomidi/mid)\n\n## Description\n\nPackage mid provides an easy abstraction for reading and writing of \"live\" `MIDI` and `SMF` \n(Standard MIDI File) data.\n\n`MIDI` data could be written the following ways:\n\n- `NewWriter` is used to write \"live\" MIDI to an `io.Writer`.\n- `NewSMF` is used to write SMF MIDI to an `io.Writer`.\n- `NewSMFFile` is used to write a complete SMF file.\n- `WriteTo` writes \"live\" MIDI to an `connect.Out`, aka MIDI out port\n\nTo read, create a `Reader` and attach callbacks to it.\nThen MIDI data could be read the following ways:\n\n- `Reader.Read` reads \"live\" MIDI from an `io.Reader`.\n- `Reader.ReadSMF` reads SMF MIDI from an `io.Reader`.\n- `Reader.ReadSMFFile` reads a complete SMF file.\n- `Reader.ReadFrom` reads \"live\" MIDI from an `connect.In`, aka MIDI in port\n\nFor a simple example with \"live\" MIDI and `io.Reader` and `io.Writer` see the example below.\n\nTo connect with the MIDI ports of your computer (via connect.In and connect.Out), use it with one of the \ndriver packages for `rtmidi` and `portaudio` at https://github.com/gomidi/connect.\n\nThere you can find a simple example how to do it.\n\n## Example\n\nWe use an `io.Writer` to write to and `io.Reader` to read from. They are connected by the same `io.Pipe`.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/gomidi/mid\"\n    \"io\"\n    \"time\"\n)\n\n// callback for note on messages\nfunc noteOn(p *mid.Position, channel, key, vel uint8) {\n    fmt.Printf(\"NoteOn (ch %v: key %v vel: %v)\\n\", channel, key, vel)\n}\n\n// callback for note off messages\nfunc noteOff(p *mid.Position, channel, key, vel uint8) {\n    fmt.Printf(\"NoteOff (ch %v: key %v)\\n\", channel, key)\n}\n\nfunc main() {\n    fmt.Println()\n\n    // to disable logging, pass mid.NoLogger() as option\n    rd := mid.NewReader()\n\n    // set the functions for the messages you are interested in\n    rd.Message.Channel.NoteOn = noteOn\n    rd.Message.Channel.NoteOff = noteOff\n\n    // to allow reading and writing concurrently in this example\n    // we need a pipe\n    piperd, pipewr := io.Pipe()\n\n    go func() {\n        wr := mid.NewWriter(pipewr)\n        wr.SetChannel(11) // sets the channel for the next messages\n        wr.NoteOn(120, 50)\n        time.Sleep(time.Second) // let the note ring for 1 sec\n        wr.NoteOff(120)\n        pipewr.Close() // finishes the writing\n    }()\n\n    for {\n        if rd.Read(piperd) == io.EOF {\n            piperd.Close() // finishes the reading\n            break\n        }\n    }\n\n    // Output:\n    // channel.NoteOn channel 11 key 120 velocity 50\n    // NoteOn (ch 11: key 120 vel: 50)\n    // channel.NoteOff channel 11 key 120\n    // NoteOff (ch 11: key 120)\n}\n```\n\n## Status\n\nAPI mostly stable and complete\n\n- Go version: \u003e= 1.10\n- OS/architectures: everywhere Go runs (tested on Linux and Windows).\n\n## Installation\n\nIt is recommended to use Go 1.11 with module support (`$GO111MODULE=on`).\n\n```\ngo get -d github.com/gomidi/mid/...\n```\n\n## License\n\nMIT (see LICENSE file) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fmid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmacker%2Fmid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fmid/lists"}