Cleaning up duplicate notes on LMMS

This post was written by eli on December 31, 2010
Posted Under: Linux,Software

Since certain keystrokes can copy notes on exactly the same position where there are already exactly the same notes, it so turned out, that I had some 6-7 identical notes overlapped in certain time slots. This condition is invisible in the GUI editor unless you try to move notes, just to find that there’s still another note underneath. And another one.

While this condition is not notable otherwise, it may cause some sporadic notes getting stuck forever (at least using ZynAddSubFX) which is problematic during playback, but even worse, when exporting to WAV. This is a result of a bug, of course, but this bug is waken up by this double note condition.

If the project is saved uncompressed (as .mpp and not .mppz), this condition is more evident. There are “pattern” tags in the XML file, which have “note” tags within. Each of these “note” tags represent a note (with the sensible attributes, such as volume, which key and length). If there are two identical such, we have a double note. Since the notes are given ordered by their position in time, double notes come in subsequent lines, so the following little Perl script does the cleanup nicely:

#!/usr/bin/perl
use warnings;
use strict;

my $line;
my $prevline = <>;

my $removed = 0;

print $prevline;

while (defined ($line = <>)) {
  if (($line eq $prevline) && ($line =~ /^[ \t]*<note/i)) {
    $removed++;
  } else {
    print $line;
  }

  $prevline = $line;
}

print STDERR "$removed lines removed\n";

Just go

./removedups.pl < original.mmp > fixed.mmp

And load the output file instead.

Add a Comment

required, use real name
required, will not be published
optional, your blog address