MidiFile
Declaration
public sealed class Strawberry.Sound.Midi.MidiFile
Parses a standard MIDI file (SMF) into a sorted list of MidiEvents with absolute tick positions and computed time-in-seconds.
Remarks: Supports Format 0 (single track) and Format 1 (multiple concurrent tracks). Format 2 (sequential tracks) is not supported and will throw. The parser is 100% managed C# with zero native dependencies, making it safe for WebAssembly / AOT environments.
Constructors
MidiFile
void MidiFile(Stream stream)
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
System.IO.Stream |
Properties
Format
MIDI file format (0 = single track, 1 = multi track).
int Format { get }
TrackCount
Number of tracks in the file.
int TrackCount { get }
TicksPerQuarterNote
Ticks per quarter note (PPQN resolution).
int TicksPerQuarterNote { get }
Events
All MIDI events merged from all tracks, sorted by absolute ticks (and in original order for same-tick events).
List<MidiEvent> Events { get }
DurationSeconds
Total duration of the MIDI file in seconds.
double DurationSeconds { get }
Methods
SecondsToTicks
Converts a time in seconds back to an absolute tick position, respecting the tempo map.
long SecondsToTicks(double seconds)
Parameters:
| Name | Type | Description |
|---|---|---|
seconds |
System.Double |