New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove all notes example from the README not working #256
Comments
Hi, Thank you, I'll fix the example. You just need to use |
Thanks for your quick answer. I looked at the |
Where? What code? Please provide details. |
After going through the library I found a method to update the chords. I thought this would allow me to remove all notes from each chord but the first one, on all tracks. using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
var midiFile = MidiFile.Read("in.mid");
foreach (var trackChunk in midiFile.GetTrackChunks())
{
trackChunk.ProcessChords(TrimChord);
}
midiFile.Write("out.mid");
void TrimChord(Chord chord)
{
chord.Notes.RemoveAll(x => x != chord.Notes.First());
} But the output file is identical to the input one. I'm guessing the |
This worked. using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Interaction;
var midiFile = MidiFile.Read("in.mid");
foreach (var trackChunk in midiFile.GetTrackChunks())
{
var newChords = new List<Chord>();
foreach (var chord in trackChunk.GetChords())
{
var higherNote = FindHigherNote(chord.Notes);
chord.Notes.RemoveAll(x => x != higherNote);
newChords.Add(chord);
}
trackChunk.RemoveChords();
trackChunk.AddObjects(newChords);
}
Note? FindHigherNote(TimedObjectsCollection<Note> notes)
{
var higherNote = notes.First();
foreach (var note in notes)
{
if (higherNote.GetMusicTheoryNote().CompareTo(note.GetMusicTheoryNote()) < 0)
{
higherNote = note;
}
}
return higherNote;
}
midiFile.Write("out.mid"); |
That's correct. But the file should be updated. Hmm, it's probably a bug in the library. I'll check it. Please don't close the issue. |
Yes, that's the bug. I'll think how to support chord's notes collection changes within |
I've released DryWetMIDI 7.0.0-prerelease2 which introduces midiFile.ProcessChords(
chord =>
{
var higherNote = FindHigherNote(chord.Notes);
chord.Notes.RemoveAll(x => x != higherNote);
},
hint: ChordProcessingHint.NotesCollectionCanBeChanged); Thanks for the issue! |
🚀 7.0.0 version is released now! Prerelease NuGet packages will be unlisted soon, so please update the package references to the new version. |
I am looking to remove all the notes from each chords but the first one, for each track. To get started I tried the following example from the README that is supposed to remove absolutely all notes from the midi.
notesManager.Notes
does not exist.The text was updated successfully, but these errors were encountered: