Ronan Keryell a6fa0d6b8a abc2midi: fix -PMAR perturbing note timing and end-of-track time (#26)
Emitting a Marker meta-event from the PART case wrote the event with
delta_time_track0 (correct, since that's the conductor-track accumulator)
but did not also reset delta_time. On track 0 in multi-track mode,
delta_time also accumulates via timestep() and is what writetrack()
returns to the MIDI library as the end-of-track delta — so each marker
left a stale delta_time that pushed the end-of-track event past the end
of the music. In single-track mode (ntracks == 1), markers were written
with delta_time_track0 too, but delta_time is the only relevant counter
in that mode, so notes following each marker were shifted later.

Fix: mirror the TEMPO handler — on ntracks == 1 use delta_time and reset
it; on ntracks != 1 keep using delta_time_track0 for the event delta but
also zero delta_time so the end-of-track is not inflated.

Reported by James Allwright with the partdemo.abc test case (now in
samples/), which exercises the parts != -1 path (header P:BACDBAC plus
body P: labels A/B/C/D). James independently fixed the same bug in his
abc2midiu fork in r32 (commit 34b7c32, "Add -PMAR option for part
markers"), where the equivalent reset is on the single delta_time
counter — his fork having retired delta_time_track0 in an earlier
refactor. Verified that mftext output of the generated MIDI is now
byte-identical to the non-PMAR output except for the added Marker
events, on both partdemo.abc (single-track) and samples/demo.abc tune 5
with P:(AB)3 (multi-track).

Add a CMake/CTest regression test (abc2midi_pmar_partdemo) that locks in
the post-fix mftext output. To support it, add_golden_test() gains an
optional NAME (to register multiple tests against the same TYPE+SAMPLE
pair) and an optional ABC2MIDI_ARGS (forwarded to the abc2midi
invocation in run_via_mid). Reverting the genmidi.c fix makes the new
test fail; reapplying it makes it pass.
2026-05-01 09:09:46 -04:00
2020-10-20 11:52:56 -04:00
2020-07-12 12:40:01 -04:00
2022-06-14 14:46:35 -04:00
2025-10-02 15:54:33 +02:00
2020-10-20 11:52:56 -04:00
2020-07-12 12:40:01 -04:00
2022-12-07 16:50:19 -05:00
2022-12-07 16:50:19 -05:00
2020-07-12 12:40:01 -04:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2020-11-07 19:32:23 -05:00
2020-07-12 12:40:01 -04:00
2020-07-12 12:40:01 -04:00
2022-12-07 16:50:19 -05:00
2022-12-07 16:50:19 -05:00
2020-10-20 11:52:56 -04:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2024-02-25 07:53:27 -05:00
2022-07-31 12:16:26 -04:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2020-07-12 12:40:01 -04:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2025-10-02 15:54:33 +02:00
2020-07-12 12:40:01 -04:00
2020-07-12 12:40:01 -04:00
2020-10-04 06:39:45 -04:00
2022-06-14 14:46:35 -04:00
2025-10-02 15:54:33 +02:00
2026-04-26 17:06:50 -04:00
2025-10-02 15:54:33 +02:00

abcMIDI package

Tests

abcMIDI is a package of programs written in C for handling abc music notation files. The software was created by James Allwright in the early 1990 and presently maintained by Seymour Shlien. It initially included the following programs:

  1. abc2midi for converting an abc file to a midi file,
  2. abc2abc for transposing abc notation to another key signature,
  3. midi2abc for creating an abc file from a midi file,
  4. yaps for producing a PostScript file displaying the abc file in common music notation and,
  5. mftext for creating a text representation of a midi file.

Seymour added two more programs:

  1. abcmatch for finding common elements in a collection of abc tunes and,
  2. midicopy for copying parts of a midi file to a new midi file.

Yaps has been superceded by Jef Moine abcm2ps and abc2svg programs. Midi2abc has been expanded to include mftext and various other features for supporting the runabc application. Abc2midi has numerous new features that are described in its own web page abc2midi guide.

Components of the abcMIDI package are parts of numerous applications for creating and editing abc files. Compilations of these components for various operating systems can be found on The ABC Plus Project web page.

The latest version of the abcMIDI package supported by James Allwright can be found can be found here. More recent versions can be found on sourceforge and on the runabc web page.

Building

Autoconf (legacy)

The traditional build uses autoconf:

./configure
make
sudo make install

CMake (modern)

A CMake build system is available alongside the legacy one, with presets for common configurations:

# Configure and build (pick a preset: default, debug, sanitize)
cmake --preset default
cmake --build --preset default

# Install
cmake --install build/default

Available presets:

Preset Build type Description
default Release Optimized build
debug Debug Debug symbols, no optimization
sanitize Debug Debug + AddressSanitizer + UndefinedBehaviorSanitizer

The CMake build generates compile_commands.json for use with clangd and other LSP-based editors.

Testing

The CMake build includes a test suite covering all 8 programs:

  • Smoke tests verify each binary runs cleanly with -ver.
  • Golden-file tests run each program on a sample input and compare the (normalized) output to a checked-in reference. Binary MIDI outputs are piped through mftext to produce diffable text. Volatile lines (version banners, dates, temporary paths) are stripped before comparison.
# Run all tests
ctest --preset debug

# Run only golden-file tests / only smoke tests
ctest --preset debug -L golden
ctest --preset debug -L smoke

To regenerate the golden files after an intentional behavioural change, review the diff, then commit:

cmake --build build/debug --target update-golden
git diff tests/golden/

Maintainers / releasing

The package release date in the VERSION file is the single source of truth for the package version. It is read by CMakeLists.txt (into ABCMIDI_VERSION) and spliced into configure.ac's AC_INIT via m4_esyscmd_s at autoreconf time. Each individual program also keeps its own #define VERSION "<n.nn> <date> <toolname>" in its .c file (e.g. store.c for abc2midi); these are bumped per-tool when that tool's behaviour changes.

To cut a release:

  1. Update the VERSION file (e.g. April 25 2026).
  2. For each tool whose behaviour changed since the last release, bump its #define VERSION string in the corresponding source file.
  3. Run autoreconf -f so the committed configure picks up the new AC_INIT arguments. The CMake build does not need this step — it reads VERSION directly at configure time.
  4. Run ctest --preset debug and, if a golden-file test fails because of an intentional output change, regenerate with cmake --build build/debug --target update-golden and review the diff.
  5. Append an entry to doc/CHANGES and update the per-tool version listing at the top of doc/readme.txt.
  6. Commit and tag.
Description
No description provided
Readme 21 MiB
Languages
C 92.8%
Shell 3.6%
Makefile 1.8%
CMake 1.3%
WebAssembly 0.4%
Other 0.1%