{"id":23557106,"url":"https://github.com/bechstein/midi-toolkit","last_synced_at":"2025-05-15T23:08:58.342Z","repository":{"id":262237130,"uuid":"819359178","full_name":"bechstein/midi-toolkit","owner":"bechstein","description":"A MIDI message parser for simplified event handling","archived":false,"fork":false,"pushed_at":"2024-11-11T10:13:36.000Z","size":1493,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T14:29:16.947Z","etag":null,"topics":["midi","parser","toolkit"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bechstein.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-06-24T10:52:07.000Z","updated_at":"2024-11-11T10:13:38.000Z","dependencies_parsed_at":"2024-11-11T11:36:11.082Z","dependency_job_id":null,"html_url":"https://github.com/bechstein/midi-toolkit","commit_stats":null,"previous_names":["bechstein/midi-toolkit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bechstein%2Fmidi-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bechstein%2Fmidi-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bechstein%2Fmidi-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bechstein%2Fmidi-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bechstein","download_url":"https://codeload.github.com/bechstein/midi-toolkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436950,"owners_count":22070947,"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":["midi","parser","toolkit"],"created_at":"2024-12-26T14:19:39.025Z","updated_at":"2025-05-15T23:08:53.330Z","avatar_url":"https://github.com/bechstein.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# MIDI ToolKit Library\n\nThis library provides a set of utilities for parsing and working with MIDI message data. It offers functions to extract important details from MIDI messages, such as the message type, channel, and various control changes (e.g., sustain pedal, soft pedal), and also includes support for high-resolution velocity parsing.\n\n## Features\n\n- **Message Type Detection**: Identify different types of MIDI messages, such as \"Note On\", \"Note Off\", \"Control Change\", \"Pitch Bend\", and more.\n- **Channel and Status Byte Extraction**: Easily extract the channel number and status byte from the MIDI message.\n- **Control Change Handling**: Includes specialized functions to handle MIDI control change messages, such as sustain pedal, soft pedal, and sostenuto pedal.\n- **High-Resolution Velocity**: Support for high-resolution velocity, with methods for detecting and processing it.\n- **Message Splitting**: Split a raw MIDI data payload into individual messages for easy processing.\n\n## Installation\n\nYou can install the package via npm:\n\n```bash\nnpm install @bechstein/midi-toolkit\n```\n\n## Usage\n\n### Importing the Library\n\nYou can import the functions and types provided by the library as needed:\n\n```typescript\nimport { \n  getStatusByte, \n  getType, \n  getChannel, \n  isNoteOn, \n  isNoteOff, \n  getControllerNumber, \n  getControllerValue, \n  isControlChange, \n  isSustainPedal, \n  splitDataPayload \n} from '@bechstein/midi-toolkit';\n```\n\n### Parsing MIDI Messages\n\nThe library provides a simple way to parse MIDI messages, extract information, and handle specific message types:\n\n```typescript\nconst midiData = new Uint8Array([144, 60, 100]);  // Example MIDI \"Note On\" message\n\nconst statusByte = getStatusByte(midiData);       // 144\nconst messageType = getType(midiData);            // MessageType.NOTE_ON\nconst channel = getChannel(midiData);             // 1\n\nif (isNoteOn(midiData)) {\n  console.log('Note On message received');\n}\n```\n\n### Splitting a MIDI Payload\n\nYou can use `splitDataPayload` to split a batch of MIDI messages into individual messages:\n\n```typescript\nconst midiPayload = new Uint8Array([176, 64, 127, 144, 60, 100]);\nconst splitMessages = splitDataPayload(midiPayload);\n\nconsole.log(splitMessages);  // [[176, 64, 127], [144, 60, 100]]\n```\n\n### Control Change Messages\n\nThe library can help detect and handle various control change messages, including the sustain pedal:\n\n```typescript\nconst controlChangeMessage = new Uint8Array([176, 64, 127]);\n\nif (isControlChange(controlChangeMessage)) {\n  const controllerNumber = getControllerNumber(controlChangeMessage); // 64\n  const controllerValue = getControllerValue(controlChangeMessage);   // 127\n\n  if (isSustainPedal(controlChangeMessage)) {\n    console.log('Sustain pedal activated');\n  }\n}\n```\n\n## Available Functions\n\n- **getStatusByte(data: Uint8Array)**: Extract the status byte from a MIDI message.\n- **getType(data: Uint8Array)**: Get the type of the MIDI message (Note On, Note Off, etc.).\n- **getChannel(data: Uint8Array)**: Extract the MIDI channel from a message.\n- **isNoteOn(data: Uint8Array)**: Check if the message is a \"Note On\" message.\n- **isNoteOff(data: Uint8Array)**: Check if the message is a \"Note Off\" message.\n- **getNoteNumber(data: Uint8Array)**: Get the note number from \"Note On\" and \"Note off\" messages.\n- **getVelocity(data: Uint8Array)**: Get the velocity from \"Note On\" and \"Note off\" messages as well as pedal messages.\n- **getControllerNumber(data: Uint8Array)**: Get the controller number from a \"Control Change\" message.\n- **getControllerValue(data: Uint8Array)**: Get the controller value from a \"Control Change\" message.\n- **isControlChange(data: Uint8Array)**: Check if the message is a \"Control Change\".\n- **isPolyphonicAftertouch(data: Uint8Array)**: Check if the message is a polyphonic aftertouch.\n- **isPitchBend(data: Uint8Array)**: Check if the message is a pitch bend.\n- **isProgramChange(data: Uint8Array)**: Check if the message is a program change.\n- **isChannelAftertouch(data: Uint8Array)**: Check if the message is a channel aftertouch.\n- **isSustainPedal(data: Uint8Array)**: Detect if the control change message is for the sustain pedal.\n- **isSoftPedal(data: Uint8Array)**: Detect if the control change message is for the soft pedal.\n- **isSostenutoPedal(data: Uint8Array)**: Detect if the control change message is for the sostenuto pedal.\n- **isHighResVelocity(data: Uint8Array, lsb: number)**: Check if the message uses high-resolution velocity.\n- **getHighResVelocity(data: Uint8Array)**: Extract the high-resolution velocity.\n- **splitDataPayload(data: Uint8Array)**: Split a payload of MIDI data into individual messages.\n- **generateStatusByte(type: MessageType, channel: number)**: Generates the corresponding status byte given the type and channel.\n- **generateNoteOn(channel: number, note: number, velocity: number)**: Generate the payload for a \"Note On\" message.\n- **generateNoteOff(channel: number, note: number, velocity: number)**: Generates the payload for a \"Note Off\" message.\n\n## Types\n\nThe library includes the following types to help with handling MIDI messages:\n\n- **MessageType**: Enum representing different MIDI message types (e.g., `NOTE_ON`, `CONTROL_CHANGE`, etc.).\n- **ControlChangeMessageType**: Enum representing different control change message types (e.g., `SUSTAIN_PEDAL`, `SOFT_PEDAL`).\n- **MidiNoteOnMessage**: Type for \"Note On\" messages.\n- **MidiNoteOffMessage**: Type for \"Note Off\" messages.\n- **MidiControlChangeMessage**: Type for \"Control Change\" messages.\n- **MidiParserOptions**: Configuration options for the parser.\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Contribution\n\nFeel free to open issues or submit pull requests if you'd like to contribute or report any bugs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbechstein%2Fmidi-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbechstein%2Fmidi-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbechstein%2Fmidi-toolkit/lists"}