You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, currently I am trying to generate a tempo map that starts at certain tempo map values, and then after a certain amount of ticks change to a new tempo and time signature. Using the ManageTempoMap api this work fine, except in the cases where the initial tempo and time signature are standard values (120bpm @ 4/4), which results in an exception being thrown.
---
System.ArgumentException : Collection of EventsCollection is empty.
Parameter name: eventsCollections
---
at Melanchall.DryWetMidi.Common.ThrowIfArgument.IsEmptyCollection[T] (System.String parameterName, System.Collections.Generic.IEnumerable`1[T] collection, System.String message) [0x00008] in <6afb839a39da48d6bfc3946fb9a5d8af>:0
at Melanchall.DryWetMidi.Interaction.TempoMapManager..ctor (Melanchall.DryWetMidi.Core.TimeDivision timeDivision, System.Collections.Generic.IEnumerable`1[T] eventsCollections) [0x0001c] in <6afb839a39da48d6bfc3946fb9a5d8af>:0
at Melanchall.DryWetMidi.Interaction.TempoMapManagingUtilities.ManageTempoMap (System.Collections.Generic.IEnumerable`1[T] eventsCollections, Melanchall.DryWetMidi.Core.TimeDivision timeDivision) [0x00016] in <6afb839a39da48d6bfc3946fb9a5d8af>:0
at Melanchall.DryWetMidi.Interaction.TempoMapManagingUtilities.ManageTempoMap (System.Collections.Generic.IEnumerable`1[T] trackChunks, Melanchall.DryWetMidi.Core.TimeDivision timeDivision) [0x0003b] in <6afb839a39da48d6bfc3946fb9a5d8af>:0
at Melanchall.DryWetMidi.Interaction.TempoMapManagingUtilities.ManageTempoMap (Melanchall.DryWetMidi.Core.MidiFile file) [0x00017] in <6afb839a39da48d6bfc3946fb9a5d8af>:0
This can be reproduced in the following ways-
Melanchall.DryWetMidi.Core.MidiFile midiFile = new();
var timeDivision = new Melanchall.DryWetMidi.Core.TicksPerQuarterNoteTimeDivision(192);
midiFile.TimeDivision = timeDivision;
midiFile.ReplaceTempoMap(TempoMap.Create(timeDivision, Tempo.FromBeatsPerMinute(120)));
using (var tempoMapManager = midiFile.ManageTempoMap())
{ ... }
or via
Melanchall.DryWetMidi.Core.MidiFile midiFile = new();
var timeDivision = new Melanchall.DryWetMidi.Core.TicksPerQuarterNoteTimeDivision(192);
midiFile.TimeDivision = timeDivision;
midiFile.ReplaceTempoMap(TempoMap.Create(timeDivision, new TimeSignature(4, 4)));
using (var tempoMapManager = midiFile.ManageTempoMap())
{ ... }
This does not occur if the tempo is not 120 (i.e. 121 or 119 are fine) or the time signature is not standard (i.e does not throw on anything other than 4/4). midiFile.ReplaceTempoMap(TempoMap.Create(timeDivision, Tempo.FromBeatsPerMinute(121))); midiFile.ReplaceTempoMap(TempoMap.Create(timeDivision, new TimeSignature(6, 4)));
The text was updated successfully, but these errors were encountered:
melanchall
changed the title
Exception using Melanchall.DryWetMidi.Interaction.TempoMapManagingUtilities.ManageTempoMap when initial tempo or time signature are default valuesManageTempoMap fails on empty MidiFileFeb 9, 2025
Thanks for the issue. The problem is not with tempo/time signature values. The root cause is calling ManageTempoMap on empty MidiFile. I'll fix the bug in the upcoming release.
Right now a workaround is constructing a MidiFile with one empty track chunk:
Hello, currently I am trying to generate a tempo map that starts at certain tempo map values, and then after a certain amount of ticks change to a new tempo and time signature. Using the ManageTempoMap api this work fine, except in the cases where the initial tempo and time signature are standard values (120bpm @ 4/4), which results in an exception being thrown.
This can be reproduced in the following ways-
or via
This does not occur if the tempo is not 120 (i.e. 121 or 119 are fine) or the time signature is not standard (i.e does not throw on anything other than 4/4).
midiFile.ReplaceTempoMap(TempoMap.Create(timeDivision, Tempo.FromBeatsPerMinute(121)));
midiFile.ReplaceTempoMap(TempoMap.Create(timeDivision, new TimeSignature(6, 4)));
The text was updated successfully, but these errors were encountered: