15 декабря 2009 г.

lilypond-book: Интеграция музыки и текста

Получил желаемое, может кому пригодится: обвернем партитуру lilypond'a в текст при помощи latex
Спасибо документации lilypond'a  и Олегу Шмелеву который еще раз подтолкнул к мучениям с ним. И я таки разобрался со своей проблемой. Она оказалась в том, что в пути не должно быть рус. каталогов и тогда все генерится! lilypond-book не понимает русский и из за этого не создавался example.tex
~/партитуры/example.lytex - не будет работать
~/scores/example.lytex - сработает! = example.tex
Создать файл example.lytex
lilypond-book --output=out --pdf example.lytex
cd out
latex example.tex
dvipdf example.dvi и получаем example.pdf
N.B. pdflatex example.tex действительно убивает кир. текст!!!

Продемонстрирую метод включения в текстовый документ нотных вставок на примере файла example.lytex следующего содержания:

\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[T2A]{fontenc}
\usepackage[ukrainian,russian,english]{babel}
\pagestyle{empty}

\setlength{\parindent}{0mm}
\setlength{\textwidth}{170mm}
\setlength{\textheight}{260mm}
\setlength{\topmargin}{-25mm}
\setlength{\oddsidemargin}{-1mm}

\begin{document}
\begin{flushleft}
Церковний рік\hspace{\stretch{1}}Вознесіння
\end{flushleft}

\begin{center}
{\Large\bf 43. Не сумуйте, Божі діти}\\
\end{center}

\begin{flushleft}
Український Євангельський співаник\hspace{\stretch{1}}STUTTGART\\
Станиславів, 1933\hspace{\stretch{1}}C.F. Witt, 1660-1716
\end{flushleft}

\begin{lilypond}
% This document was generated by Canorus, version 0.7
\version "2.12.2"

% Staff1Voice1
ContextZeroVoiceZero = \relative c' {
\clef "treble" \key f \major \time 4/4 c4 c f f | g g a f | c' c d bes | g c a2 | a4 a g a | f g f e | f d c f | f e f2 \bar "|."
}

% Staff1Voice2
ContextZeroVoiceOne = \relative c' {
\clef "treble" \key f \major \time 4/4 c4 c a c | d c c c | g' f f f | f e f2 | f4 f e e | d d c c | c bes a a8( bes) | c4 c c2
}

% Staff2Voice1
ContextOneVoiceZero = \relative c' {
\clef "bass" \key f \major \time 4/4 a4 g f f | f e f a | c a bes d | c c c2 | d4 a bes a | a bes a g | f f f f | g8( a) bes4 a2 \bar "|."
}

% Staff2Voice2
ContextOneVoiceOne = \relative c {
\clef "bass" \key f \major \time 4/4 f4 e d c | bes c e f | e f bes, bes | c c f2 | d4 d d c | d bes c d | a bes f' d | c c f2
}

\score {
<<
\new Staff {
<<
% Staff1Voice1
\new Voice = "ContextZeroVoiceZeroVirtual" { \voiceOne \ContextZeroVoiceZero }
\addlyrics { Не су- муй- те, Бо- жі ді- ти, і не лий- те в_смут- ку сльоз,
Що воз- ніс- ся у бла- ки- ті з_Є- ле- о- ну Спас Хрис- тос, }
\addlyrics { Не су- муй- те, а бод- ріть- ся: Зі- шле Спас із Не- ба вам
Ду- ха прав- ди, тож крі- піть- ся, жнив ба- га- тих жде ваш лан. }
% Staff1Voice2
\new Voice = "ContextZeroVoiceOneVirtual" { \voiceTwo \ContextZeroVoiceOne }
>>
}
\new Staff {
<<
% Staff2Voice1
\new Voice = "ContextOneVoiceZeroVirtual" { \voiceOne \ContextOneVoiceZero }
% Staff2Voice2
\new Voice = "ContextOneVoiceOneVirtual" { \voiceTwo \ContextOneVoiceOne }
>>
}

% Voice assignment:
\set Score.melismaBusyProperties = #'()
>>
}
\end{lilypond}

\begin{enumerate}
\item[3]Не сумуйте ж, Божі діти,\\
І не бійтесь бур, погроз.\\
Бо з Небес --- з висот, з блакиті,\\
Стереже вас Бог Христос.
\end{enumerate}

\vspace{\stretch{1}}\dag Павло Богмат
\hspace{\stretch{1}}\emph{Lilypond+}\LaTeX

\end{document}


P.S. Осталось подогнать шрифт, чтобы в нотах и стихах внизу он был одного размера. Но все же MusiXTeX лучше Lilypond'a, сразу создает ноты и обрамляется текстом в LaTeX без проблме, а не вставляет графику с заморочками lilypond'a, хотя синтаксис сложный. IMHO.
P.P.S. Я знаю что \usepackage[T2A]{fontenc} для UTF-8 не нужен, но иначе не получалось...


Комментариев нет: