Login / Register 0 items | $0.00 New @ KVR
User avatar
melanchall
KVRer
 
1 post since 4 Aug, 2018, from Saint Petersburg, Russia

Postby melanchall; Sun Aug 05, 2018 7:49 am DryWetMIDI / .NET library to work with MIDI files

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),
                                                           tempoMap,
                                                           LengthedObjectPart.Entire);

  • 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)
        .SetNoteLength(MusicalTimeSpan.Eighth.Triplet())
        .SetOctave(5)
        .Note(NoteName.A)
        .Note(NoteName.B)
        .Note(NoteName.GSharp)
        .Build();

    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.
experimental.crow
KVRAF
 
5429 posts since 9 Mar, 2003, from The Druid Hills

Postby experimental.crow; Sun Aug 05, 2018 7:56 am Re: DryWetMIDI / .NET library to work with MIDI files

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

:hihi:
Image

Moderator: Moderators (Main)

Return to DSP and Plug-in Development