DryWetMIDI / .NET library to work with MIDI files

DSP, Plug-in and Host development discussion.
User avatar
1 posts since 4 Aug, 2018 from Saint Petersburg, Russia

Post Sun Aug 05, 2018 7:49 am

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
I'd like to present DryWetMIDI (https://github.com/melanchall/drywetmidi) – open-source .NET library to work with MIDI files. It may be useful for musicians who have programming experience and want to automate their tasks in field of MIDI files processing.

Features the library provides are:
  • reading (https://github.com/melanchall/drywetmidi/wiki/Reading-a-MIDI-file), writing (https://github.com/melanchall/drywetmidi/wiki/Writing-a-MIDI-file) and creating Standard MIDI Files;

    Code: Select all (#)

    var midiFile = MidiFile.Read("Some Great Song.mid");
    var newMidiFile = new MidiFile(
        new TrackChunk(
            new SetTempoEvent(500000)),
        new TrackChunk(
            new NoteOnEvent((SevenBitNumber)60, (SevenBitNumber)45),
            new NoteOffEvent((SevenBitNumber)60, (SevenBitNumber)0) { DeltaTime = 400 }));
    newMidiFile.Write("My Future Great Song.mid");
  • managing content of a MIDI file either with low-level objects, like event (https://github.com/melanchall/drywetmidi/wiki/Events), or high-level ones, like note (https://github.com/melanchall/drywetmidi/wiki/Notes);

    Code: Select all (#)

    var firstTrackChunk = midiFile.Chunks.OfType<TrackChunk>().First();
    var setTempoEvent = firstTrackChunk.Events.OfType<SetTempoEvent>().First();
    TempoMap tempoMap = midiFile.GetTempoMap();
    IEnumerable<Note> allNotes = midiFile.GetNotes();
    MetrciTimeSpan firstNoteLengthInSeconds = allNotes.First().LengthAs<MetricTimeSpan>(tempoMap);
    IEnumerable<Chord> chordsAt20seconds = midiFile.GetChords()
                                                   .AtTime(new MetricTimeSpan(0, 0, 20),
  • building musical compositions (https://github.com/melanchall/drywetmidi/wiki/Pattern) based on MIDI;

    Code: Select all (#)

    Pattern pattern = new PatternBuilder()
        .StepForward(new MetricTimeSpan(0, 0, 5))
        .Note(Octave.Get(4).CSharp, MusicalTimeSpan.Eighth)
    MidiFile midiFile = pattern.ToFile(TempoMap.Default);
  • performing complex tasks (https://github.com/melanchall/drywetmidi/wiki/Tools) like quantizing, notes splitting or converting MIDI file to CSV representation.

    Code: Select all (#)

    midiFile.QuantizeTimedEvents(new SteppedGrid(MusicalTimeSpan.Sixteenth));
    midiFile.MergeNotes(new NotesMergingSettings
                            Tolerance = new MetricTimeSpan(0, 0, 1)
                        n => n.NoteName == NoteName.CSharp);
See the library Wiki (https://github.com/melanchall/drywetmidi/wiki) to learn more.

5505 posts since 9 Mar, 2003 from The Druid Hills

Re: DryWetMIDI / .NET library to work with MIDI files

Post Sun Aug 05, 2018 7:56 am

oh boy ...
harry's going to have a field day ...


Return to “DSP and Plug-in Development”