From e90059648cde8a9ebc7082bff973bc5ca268d7b0 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Fri, 21 Aug 2015 01:05:14 +0200 Subject: [PATCH] Created script to easily compile a score. Should be further extended for compiling a full drumscore, however, this will lead to a change in file structure of the 'music' files modified: TODO modified: lilydrum.ly new file: makedrum --- .gitignore | 1 + 4-4_marches/the_old_rustic_bridge.tenor.ly | 30 ++++ 5-4_marches/cullen_bay.bass.ly | 18 +++ 5-4_marches/cullen_bay.tenor.ly | 28 ++++ README.md | 4 + TODO | 39 +++-- airs/farewell_to_camraw.tenor.ly | 27 ++++ airs/the_mist_covered_mountains.tenor.ly | 37 +++++ lilydrum.ly | 89 ++++++++--- makedrum | 174 +++++++++++++++++++++ 10 files changed, 411 insertions(+), 36 deletions(-) create mode 100755 4-4_marches/the_old_rustic_bridge.tenor.ly create mode 100755 5-4_marches/cullen_bay.bass.ly create mode 100755 5-4_marches/cullen_bay.tenor.ly create mode 100755 airs/farewell_to_camraw.tenor.ly create mode 100755 airs/the_mist_covered_mountains.tenor.ly create mode 100755 makedrum diff --git a/.gitignore b/.gitignore index b7f1aa7..0bc45fd 100755 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *tmp* bwwtolily.py _output/ +pdf/ diff --git a/4-4_marches/the_old_rustic_bridge.tenor.ly b/4-4_marches/the_old_rustic_bridge.tenor.ly new file mode 100755 index 0000000..d0b0e3c --- /dev/null +++ b/4-4_marches/the_old_rustic_bridge.tenor.ly @@ -0,0 +1,30 @@ +\version "2.18.2" + +\include "lilydrum.ly" + +\score { + \new DrumStaff { + \drummode { + \time 4/4 + + \repeat volta 2 { + \partial 16 g16 | + d4 g8 d g4 d8. g16 | + d8 g d4 g r | + d4 g8 d g d g d | + g4 r4 d4 r4 | + + d4 g8 d g4 d8. g16 | + d8 g d4 g r | + d4 g8 d g d g d | + g4 r4 d4 r4 + } + } + } + + \header { + title = "The Old Rustic Bridge" + meter = "March" + instrument = "Tenor" + } +} \ No newline at end of file diff --git a/5-4_marches/cullen_bay.bass.ly b/5-4_marches/cullen_bay.bass.ly new file mode 100755 index 0000000..76b6148 --- /dev/null +++ b/5-4_marches/cullen_bay.bass.ly @@ -0,0 +1,18 @@ +\version "2.18.2" + +\include "lilydrum.ly" + +\score { + \new DrumStaff { + \time 5/4 + \repeat volta 2 { + \repeat unfold 8 { d4-^ g d-> g d | } + } + } + + \header { + title = "Cullen Bay" + meter = "March" + instrument = "Bass" + } +} \ No newline at end of file diff --git a/5-4_marches/cullen_bay.tenor.ly b/5-4_marches/cullen_bay.tenor.ly new file mode 100755 index 0000000..e926c63 --- /dev/null +++ b/5-4_marches/cullen_bay.tenor.ly @@ -0,0 +1,28 @@ +\version "2.18.2" + +\include "lilydrum.ly" + +\score { + \new DrumStaff { + \drummode { + \time 5/4 + \repeat volta 4 { + d8-> g d g d-> g d4 d4 | + d8. g16 d8-> g8-> r8 g8 d4 d4 | + d8-> g d g d-> g d8.-> g16-> r8 d8-> | + d4 d4 d8 g8 d4 d4 | + + d4 g4 d4 g4 d4 | + d8. g16 d8-> g8-> r8 g8 d4 d4 | + d4 g4 d8-> g8 d8.-> g16-> r8 d8-> + d4 d4 d8 g8 d4 d4 | + } + } + } + + \header { + title = "Cullen Bay" + meter = "March" + instrument = "Tenor" + } +} \ No newline at end of file diff --git a/README.md b/README.md index 10d34a9..ac83937 100755 --- a/README.md +++ b/README.md @@ -7,3 +7,7 @@ There has been a lilypond include file earlier made by Simon Froger (which inclu This is meant to extend or translate some parts. The original file can still be found at http://lsr.di.unimi.it/LSR/Snippet?id=970 + + +Currently, the most advanced score is MacKenzie Highlanders in 2-4_marches/mackenzie_highlanders.side.ly +This score is used for most of the layout. \ No newline at end of file diff --git a/TODO b/TODO index d7791cc..c577211 100755 --- a/TODO +++ b/TODO @@ -1,15 +1,30 @@ TODO - * flam function : detect whether left flam or right flam. This depends on the note, whether it is right or left respectively * show 8th and 16th beats in beaming, currently only 8ths - * include EUSPBA flourishing symbols, maybe a sprite file ?!? - * spanners (traditional and regimental spanners) - * symbols - * Very special beats (backsticking, crosssticking and the like..) - * Macros for tutti's (unisons), "Part 2 of $n", + * Macro for tutti's (unisons) + * Macro for "Part 2 of $n" + * If 8/16/32/..th notes come before a flam, they have a flag instead of a beam (fixable by explicit beaming, but rather have a good autobeaming) + * A tuplet beginning with a flam has a strange tuplet beam (slanted) + * It's custormary to have 4 bars per line for portrait and 8 for landscape... - * Find a nice filing system for easy saving, editing, generation of the scores - *** script to easily generate the scores - should be able to generate single instrument scores aswell as full drumscores, - and possibly fullscores (with the pipetune) - from referenced files - *** templates \ No newline at end of file + * TEMPLATING + Find a nice filing system for easy saving, editing, generation of the scores + *** script to easily generate the scores + should be able to generate single instrument scores aswell as full drumscores, + and possibly fullscores (with the pipetune) + from referenced files + *** templates + + * SIDE sticking (lookup swiss notation) + regular default + cross-stick cross + rimshot default + cross + backstick white triangle pointing down + + + * FLOURISHING short note above-note + regular flourish \fl cross + ups \up arrow-up + scoop \scoop arrow-right-(diag-up\diag-down) + split the feather \stf xcircle + cartwheel \cart + (EUSPBA symbols) \ No newline at end of file diff --git a/airs/farewell_to_camraw.tenor.ly b/airs/farewell_to_camraw.tenor.ly new file mode 100755 index 0000000..d9c5dca --- /dev/null +++ b/airs/farewell_to_camraw.tenor.ly @@ -0,0 +1,27 @@ +\version "2.18.2" + +\include "lilydrum.ly" + +\score { + \new DrumStaff { + \drummode { + \time 4/4 + \repeat volta 2 { + R1 + r8 g d16 g d g d8 g d16 g d g | + d8 g d16 g d g d4 d16 g d g | + d4 g16 d g d d4 r4 | + d4 d8 g d4 r4 | + d4 d8 g d4 r4 | + d8 g d g d4 d8 g | + d8 g r4 r2 | + } + } + } + + \header { + title = "Farewell to Camraw" + meter = "Slow Air" + instrument = "Tenor" + } +} \ No newline at end of file diff --git a/airs/the_mist_covered_mountains.tenor.ly b/airs/the_mist_covered_mountains.tenor.ly new file mode 100755 index 0000000..8b4cc50 --- /dev/null +++ b/airs/the_mist_covered_mountains.tenor.ly @@ -0,0 +1,37 @@ +\version "2.18.2" + +\include "lilydrum.ly" + +\score { + \new DrumStaff { + \drummode { + \time 6/8 + \repeat volta 2 { + d4. g | + d4. g8 r8 g8 | + d4. g8. d16 g8 | + d8. g16 d8 g8 r8 g8 | + d4. g | + d4. g8 r8 g8 | + d4. g8. d16 g8 | + d8 g8 d8 g8 r4 + } + \repeat volta 2 { + d4. g | + d4. g8 r8 g8 | + d4. g | + d4. g8 r8 g8 | + d4. g | + d4. g8 r8 g8 | + r8. g16 d8 r8. d16 g8 | + d8 g8 d8 g8 r4 + } + } + } + + \header { + title = "The Mist Covered Mountains" + meter = "Slow Air" + instrument = "Tenor" + } +} \ No newline at end of file diff --git a/lilydrum.ly b/lilydrum.ly index 20a0acf..6372fae 100755 --- a/lilydrum.ly +++ b/lilydrum.ly @@ -85,8 +85,6 @@ drumPitchNames = % dynamics up \dynamicUp - - % slurs below rolls number %\override TextScript.outside-staff-priority = ##f %\override TextScript.side-axis = #0 @@ -103,10 +101,10 @@ drumPitchNames = %\override StemTremolo.Y-offset = #-2.8 % repeat brackets - %\consists "Horizontal_bracket_engraver" - %\override HorizontalBracket.staff-padding = #6.5 % staff-padding - %\override HorizontalBracket.direction = #DOWN % brackets under thr staff - %\override HorizontalBracket.bracket-flare = #'(0 . 0) % vertical brackets + \consists "Horizontal_bracket_engraver" + \override HorizontalBracket.staff-padding = #3.5 % staff-padding + \override HorizontalBracket.direction = #UP % brackets under thr staff + \override HorizontalBracket.bracket-flare = #'(0 . 0) % vertical brackets } \context { @@ -147,10 +145,43 @@ sixteenthBeaming = { subdivideBeams = ##t strictBeatBeaming = ##t - \override TupletBracket.bracket-visibility = ##f + \override TupletBracket.bracket-visibility = #'if-no-beams } } +% ================================================= % +% Side Sticking (modifies note, or adds mark) % +% ================================================= % +backstick = #(define-music-function (parser location notes) (ly:music?) + #{ + \temporary \override Staff.NoteHead.style = #'triangle + $notes + \revert Staff.NoteHead.style + #}) +crossstick = #(define-music-function (parser location notes) (ly:music?) + #{ + \temporary \override Staff.NoteHead.style = #'xcircle + $notes + \revert Staff.NoteHead.style + #}) +rimshot = #(define-music-function (parser location notes) (ly:music?) + #{ + $notes + \once \override Staff.NoteHead.style = #'cross + \once \hide Stem + d + #}) + +% ================================================= % +% Tenor Flourishing % +% ================================================= % +flourish = #(define-music-function (parser location notes) (ly:music?) + #{ + \temporary \override Staff.NoteHead.style = #'cross + $notes + \revert Staff.NoteHead.style + #}) + % ================================================= % % Functions % % ================================================= % @@ -183,6 +214,13 @@ dynLine = #(define-music-function \once \override TextSpanner.bound-details.right.text = \markup { \draw-line #'(0 . -1) } #}) +tutti = #(define-event-function (parser location notes) (ly:music?) #{ + \startGroup + % still to add: a little 'u' + $notes + \stopGroup + #}) + % ================================================= % % Flams, Drags & the sort % % ================================================= % @@ -206,30 +244,33 @@ drumgrace = #(define-music-function (parser location notes) (ly:music?) #{ % Flams -flamd = \drummode { \drumgrace { g8 } } % right Flam, actually flam(left) note(right) -flamddr = \drummode { \drumgrace { g8\startGroup } } % with start repeat -flamg = \drummode { \drumgrace { d8 } } % left Flam -flamgdr = \drummode { \drumgrace { d8\startGroup } } % with start repeat +flamd = \drummode { \drumgrace { g8 } } % Flam right +flamg = \drummode { \drumgrace { d8 } } % Flam left +flamddr = \drummode { \drumgrace { g8\startGroup } } % Flam right with start repeat +flamgdr = \drummode { \drumgrace { d8\startGroup } } % Flam left with start repeat % Drags -dragd = \drummode { \drumgrace { g16[ g] }} % right Drag -dragddr = \drummode { \drumgrace { g16[\startGroup g] }} % with start repeat -dragg = \drummode { \drumgrace { d16[ d] }} % left Drag -draggdr = \drummode { \drumgrace { d16[\startGroup d] }} % with start repeat +dragd = \drummode { \drumgrace { g16[ g] }} % Drag right +dragg = \drummode { \drumgrace { d16[ d] }} % Drag left +dragddr = \drummode { \drumgrace { g16[\startGroup g] }} % Drag right with start repeat +draggdr = \drummode { \drumgrace { d16[\startGroup d] }} % Drag left with start repeat % Ruff -ruffg = \drummode { \drumgrace { g16[ d g] }} % left Ruff -ruffgdr = \drummode { \drumgrace { g16[\startGroup d g] }} % with start repeat -ruffd = \drummode { \drumgrace { d16[ g d] }} % right Ruff -ruffddr = \drummode { \drumgrace { d16[\startGroup g d] }} % with start repeat +ruffg = \drummode { \drumgrace { g16[ d g] }} % Ruff right +ruffd = \drummode { \drumgrace { d16[ g d] }} % Ruff left +ruffgdr = \drummode { \drumgrace { g16[\startGroup d g] }} % Ruff right with start repeat +ruffddr = \drummode { \drumgrace { d16[\startGroup g d] }} % Ruff left with start repeat % Swiss Ruff -sruffg = \drummode { \drumgrace { g16[ d d] }} % left Swiss Ruff -sruffgdr = \drummode { \drumgrace { g16[\startGroup d d] }} % with start repeat -sruffd = \drummode { \drumgrace { d16[ g g] }} % right Swiss Ruff -sruffddr = \drummode { \drumgrace { d16[\startGroup g g] }} % with start repeat +sruffg = \drummode { \drumgrace { g16[ d d] }} % Swiss Ruff right +sruffd = \drummode { \drumgrace { d16[ g g] }} % Swiss Ruff left +sruffgdr = \drummode { \drumgrace { g16[\startGroup d d] }} % Swiss Ruff right with start repeat +sruffddr = \drummode { \drumgrace { d16[\startGroup g g] }} % Swiss Ruff left with start repeat + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Embellishment functions, automatic left or right %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Embellishment functions, automatic left or right % Flam flam = #(define-music-function (parser location note) (ly:music?) #{ % is note right-handed? then \flamd diff --git a/makedrum b/makedrum new file mode 100755 index 0000000..72a5d13 --- /dev/null +++ b/makedrum @@ -0,0 +1,174 @@ +#!/usr/bin/python3.4 + +## Generate pdf form lilypond file +## by using standard command +## +## Most of programming was done by Sven Axelsson, http://svenax.net/ + +import codecs, os +from argparse import ArgumentParser + +class MakeDrum: + LILYPOND = 'lilypond' + VERSION = '0.7' + TMP_DIR = './tmp' + TMP_PREFIX = 'tmp_' + + def __init__(self): + # Gather options and create the template file + + usage = __file__ + parser = ArgumentParser(usage) + + parser.add_argument('--version', + action='store_true', dest='show_version', default=False, + help='show makeDrum version and exit') + parser.add_argument('--lilyversion', + action='store_true', dest='show_lilyversion', default=False, + help='show Lilypond version and exit') + + parser.add_argument('-p', '--paper-size', + dest='papersize', default='a4', + help='Paper size. Default: A4') + parser.add_argument('-o', '--orientation', + dest='orientation', default='landscape', + help='Paper orientation. Default: landscape') + parser.add_argument('-s', '--staff-size', + dest='staffsize', default='16', + help='Staff size. Default: 16pt.') + parser.add_argument('-f', '--format', + dest='format', default=None, + help='Use header format file "header_{format}". Default: "header_default"') + parser.add_argument('-w', '--view-spacing', + action='store_true', dest='view_spacing', default=False, + help='Turn on "Paper.annotatespacing".') + + parser.add_argument('--no-log', + action='store_false', dest='log', default=True, + help='Do not generate log files.') + parser.add_argument('--no-cleanup', + action='store_false', dest='clean', default=True, + help='Leave all temporary files in place') + parser.add_argument('music_file', + default='', nargs='+', + help='file to process') + parser.add_argument('-@', '--list_file', + dest='list_file', default='', + help='list of files to process') + + self.args = parser.parse_args() + + if self.args.show_version: + print(__name__, ' ', self.VERSION) + return + + if self.args.show_lilyversion: + print(os.system(self.LILYPOND+' --version')) + return + + if self.args.view_spacing: + self.args.view_spacing = "##t" + else: + self.args.view_spacing = "##f" + + # Input files + if self.args.list_file != '': + self.args.music_file.append(open(self.args.list_file, 'r').readlines()) + close(self.args.list_file) + + # Clean up of files + self.remove_tmp_dir = self.args.clean + + if not os.path.exists(os.path.join(os.path.curdir, self.TMP_DIR)): + try: os.makedirs(os.path.join(os.path.curdir, self.TMP_DIR)) + except: + print('Seems like no temporary directory can be created') + return + + + for file_path in self.args.music_file: + self.processit(self.TMP_DIR, file_path) + + #if not + #os.rmdir(self.TMP_DIR) + + def processit(self, tmp_dir, file): + if self.args.log: + logfile = os.path.join(self.TMP_DIR, file.strip('.ly').replace('/', '-')+'.log') + log = ' > '+logfile+' 2>&1' + else: + log = '' + + if self.args.format is None: + if file.endswith(".book"): + header_format = "header_book" + else: + header_format = "header_default" + + tmp_file = self.maketemplate(tmp_dir, file, header_format) + + print ('Compiling ', file, end=' ', flush=True) + + lilycmd = self.LILYPOND+' --pdf --output=./pdf/'+os.path.basename(tmp_file).strip(self.TMP_PREFIX).strip('ly')+' '+tmp_file+log + + if os.system(lilycmd) != 0: + self.remove_tmp_dir = False + print ('[Error]') + print (' ! Did not compile, please see the log at ', logfile) + else : + print ('[OK]') + os.remove(logfile) + os.remove(tmp_file) + + + def maketemplate(self, tmp_dir, file, header_format): + # set up a tmp file with template and file combined + tmp_file = os.path.join(tmp_dir, self.TMP_PREFIX + file.replace('/', '-')) + + out_file = codecs.open(tmp_file, 'w+', 'utf8') + out_file.write(u'\ufeff') + + out_file.write(u""" +% Generated from """+file+""" by """+__file__+""" + +\\version "2.18.0" + +#(ly:set-option 'point-and-click #f) + +#(set-global-staff-size """+self.args.staffsize+""") +#(set-default-paper-size \""""+self.args.papersize+"""\" '"""+self.args.orientation+""") + +\\include "../"""+header_format+""".ily" +\\include "lilydrum.ly" + +% Local tweaks +\\paper { + ragged-bottom = ##t +} +\layout { + \context { + \Score + % We only permit explicit line breaks + \override NonMusicalPaperColumn #'line-break-permission = ##f + } +} + +% The tune to generate. + """) + + # Read lily file into tmp file + music = codecs.open(file, 'r', 'utf8').read() + if music.startswith(u'\ufeff'): music = music[1:] + music = music.split(u'\n') + printit = 1 + for line in music: + if line.strip().startswith(u'\\include "lilydrum.ly"'): continue + if printit: + out_file.write(line.replace('\r', '')+'\n') + out_file.close() + + # Return tmp_file_path + return tmp_file + + +MakeDrum(); \ No newline at end of file