libMidi 2.0.0

dotnet add package libMidi --version 2.0.0
                    
NuGet\Install-Package libMidi -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="libMidi" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="libMidi" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="libMidi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add libMidi --version 2.0.0
                    
#r "nuget: libMidi, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package libMidi@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=libMidi&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=libMidi&version=2.0.0
                    
Install as a Cake Tool

libMidi

License: MIT .NET

Standard MIDI File(SMF)を読み込み、解析・編集・変換・保存するための .NET ライブラリです。

現在のパッケージバージョンは 2.0.0、Target Frameworkは net10.0-windows7.0 です。v2.0.0では.NET 10専用となり、.NET 8は対象外です。

主な機能

  • SMF Format 0 / Format 1 の読み込みと書き出し
  • Format 0 / Format 1 間の変換
  • チャンネル別、音色別、マルチティンバー単位へのトラック分割
  • チャンネル、メタイベント、システムエクスクルーシブ(SysEx)のメッセージモデル
  • テンポマップ、拍子、使用チャンネル、音源規格(GM / GM2 / GS / XG)、ドラムチャンネルの解析
  • イベントの追加・削除・フィルタリング
  • ヤマハ XF のインフォメーションヘッダー、カラオケ、スタイル情報の解析
  • XF カラオケ歌詞の SRT / テキスト出力

動作環境

  • .NET 10 SDK
  • ターゲットフレームワーク: net10.0-windows7.0

ビルド

dotnet build libMidi.sln

別のプロジェクトから利用する場合は、libMidi.csproj へのプロジェクト参照を追加します。

dotnet add <利用側プロジェクト> reference <libMidi.csprojへのパス>

基本的な使い方

MIDI ファイルを読み込む

using libMidi.Messages;
using libMidi.SMF;

MidiData midi = SMFLoader.Load("input.mid");

Console.WriteLine(midi.Format);
Console.WriteLine($"Tracks: {midi.NumberOfTrack}");
Console.WriteLine($"Division: {midi.Division}");

foreach (MidiEvent<NoteOn> note in midi.GetAllEvents<NoteOn>())
{
    Console.WriteLine($"tick={note.AbsoluteTick}, ch={note.Channel}, note={note.Message.Pitch}");
}

変換して保存する

using libMidi.SMF;
using libMidi.SMF.enums;

MidiData source = SMFLoader.Load("input.mid");
var converted = new MidiData();

SMFConverter.Convert(ConvertType.Format0, source, converted);

converted.FilePath = "output.mid";
SMFConverter.SaveMidiData(converted, SMFEncode.UTF8, filter: false);

ConvertType には次の値があります。

  • Format0: 全トラックを統合して Format 0 に変換
  • Format1: Format 0 をチャンネル別トラックに分割(Format 1 はコピー)
  • Instrument: 音色単位でトラックを分割
  • MultiTimber: 複数チャンネルを含むトラックをチャンネル単位に分割

SaveMidiData は MidiData.FilePath に書き出します。既定では有効なフィルターを適用するため、全イベントをそのまま保存したい場合は filter: false を指定してください。文字列イベントの出力エンコーディングは SMFEncode.UTF8 または SMFEncode.SJIS から選択できます。

ライセンス

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 91 10/18/2026
1.0.7 156 7/13/2026
1.0.6 727 4/13/2026
1.0.5 722 4/9/2026
1.0.4 753 1/19/2026
1.0.3 948 11/12/2025
1.0.2 862 11/2/2025
1.0.1 846 10/7/2025
1.0.0 833 10/5/2025