lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Set the sequence name in MIDI using title information from \header block


From: ht . lilypond . development
Subject: Set the sequence name in MIDI using title information from \header block (issue 256230045 by address@hidden)
Date: Tue, 04 Aug 2015 22:35:22 +0000

Reviewers: ,

Message:
This patch adds support for setting the MIDI sequence name for MIDI
output files using the value of the "midititle" field from a relevant
\header block, and falling back to using the "title" field if
"midititle"
has not been defined.  (This should be analogous to how "pdftitle" and
"title" work for customizing PDF metadata.)

The purpose of the change is to improve the previous behavior where the
name of every MIDI sequence created by LilyPond used to be shown by MIDI
synthesizers as "control track" (previously, this string was hard-coded
as the name of every initial track of MIDI files created by LilyPond by
Control_track_performer).

The patch
  * extends every Performance instance with a reference to a \header
block associated with the performance, adds Scheme library routines for
getting and setting the associated \header (modeled after corresponding
routines available for the Score class), and updates the
Book::process_score function to initialize the header information of
Performance objects attached to a score;
  * adds a "name" parameter to the Performance output routines, used for
updating the track name in the performance's first Audio_staff (assumed
to represent the control track) before outputting MIDI; and
  * changes the write-performances-midis function (in scm/midi.scm) to
query the MIDI sequence name for a performance from the performance's
\header block (adapted from the handle-metadata function in
scm/framework-ps.scm).


For testing, I used the following LilyPond code:

----

\version "2.19.25"

\header {
  title = "Top-level title"
}

% Book A without a title defined in a \header block
\book {
  \bookOutputName "A"

  % A: score without a title in Book A -- will get the top-level title
  \score {
    \new Staff { c1 }
    \midi { }
  }

  % A-1: score with a title defined in a nested \header block (in Book
A) --
  %      will get the title in this \header block
  \score {
    \new Staff { c1 }
    \header { title = "Score in Book A" }
    \midi { }
  }

  % A-2: score with a title and a separate MIDI title defined in a
nested
  % \header block (in Book A) -- will get the MIDI title in this \header
block
  \score {
    \new Staff { c1 }
    \header {
      title = "Another score in Book A"
      midititle = "MIDI title"
    }
    \midi { }
  }
}

% Book B with a title defined in a \header block
\book {
  \bookOutputName "B"
  \header { title = "Book B" }

  % B: score without a title in Book B -- will get the title of Book B
  \score {
    \new Staff { c1 }
    \midi { }
  }

  % B-1: score with a \header block (and title) of its own (in Book B)
-- will
  %      get the title in this \header block
  \score {
    \new Staff { c1 }
    \header { title = "Score in Book B" }
    \midi { }
  }
}

% Book C: book with a title defined in a \header block with book parts
\book {
  \bookOutputName "C"
  \header { title = "Book C" }

  % Book part in Book C with a title of its own
  \bookpart {
    \header { title = "Part 1 in Book C" }

    % C: score without a title (in Part 1 of Book C) -- will get the
title of
    %    its enclosing book part
    \score {
      \new Staff { c1 }
      \midi { }
    }

    % C-1: score with a \header (and a title) of its own (in Part 1 of
Book C)
    %      -- will get this title
    \score {
      \new Staff { c1 }
      \header { title = "Score in Part 1 of Book C" }
      \midi { }
    }
  }

  % C-2: score without a title outside any book part of Book C -- will
get the
  % title of Book C
  \score {
    \new Staff { c1 }
    \midi { }
  }

  % Book part in Book C with no \header block
  \bookpart {

    % C-3: score without a \header block (in Part 2 of Book C) -- will
get the
    % title of Book C
    \score {
      \new Staff { c1 }
      \midi { }
    }

    % C-4: score with an explicit title (in Part 2 of Book C) -- will
get this
    % title
    \score {
      \new Staff { c1 }
      \header { title = "Score in Part 2 of Book C" }
      \midi { }
    }
  }
}

----


Description:
Set the sequence name in MIDI using title information from \header block

Please review this at https://codereview.appspot.com/256230045/

Affected files (+92, -14 lines):
  M lily/book.cc
  M lily/control-track-performer.cc
  M lily/include/performance.hh
  M lily/performance.cc
  M lily/performance-scheme.cc
  M scm/midi.scm





reply via email to

[Prev in Thread] Current Thread [Next in Thread]