1
0
Fork 0
mirror of https://github.com/kastdeur/pipeband-music.git synced 2024-11-01 01:53:31 +01:00

Compare commits

...

6 commits

30 changed files with 171 additions and 118 deletions

View file

@ -2,10 +2,11 @@
%% Globals %% Globals
global = { global = {
\time 6/8 \time 6/8
} key d \major
}
confTempo = { confTempo = {
\tempo 4. = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace {s4} s8 } part = { \partial 8 \grace {s4} s8 }
measure = { \grace { s4 } s1. | } measure = { \grace { s4 } s1. | }

View file

@ -2,10 +2,11 @@
%% Globals %% Globals
global = { global = {
\time 6/8 \time 6/8
} \key d \major
}
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 4 \grace{s1}s4 } part = { \partial 4 \grace{s1}s4 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -3,10 +3,10 @@
global = { global = {
\key a \mixolydian \key a \mixolydian
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -3,10 +3,10 @@
global = { global = {
\key d \major \key d \major
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4. = 100 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 2. = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace { s4 } s8 } part = { \partial 8 \grace { s4 } s8 }

View file

@ -3,10 +3,10 @@
global = { global = {
\key b \minor \key b \minor
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 s8 } part = { \partial 8 s8 }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace { s4 } s8 } part = { \partial 8 \grace { s4 } s8 }

View file

@ -3,10 +3,10 @@
global = { global = {
\key a \mixolydian \key a \mixolydian
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4. = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s1 | } measure = { \grace {s1} s1 | }

View file

@ -3,10 +3,10 @@
global = { global = {
\key d \major \key d \major
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4 = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -5,7 +5,7 @@ global = {
\key d \major \key d \major
} }
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace {s4} s8 } part = { \partial 8 \grace {s4} s8 }

View file

@ -3,10 +3,10 @@
global = { global = {
\key a \mixolydian \key a \mixolydian
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4. = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -3,10 +3,10 @@
global = { global = {
\key a \mixolydian \key a \mixolydian
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4 = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s32} s8 } part = { \partial 8 \grace{s32} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -3,10 +3,10 @@
global = { global = {
\key d \major \key d \major
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4 = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace {s4.} s8 } part = { \partial 8 \grace {s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 4 = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 s8 } part = { \partial 8 s8 }

View file

@ -3,10 +3,10 @@
global = { global = {
\key a \mixolydian \key a \mixolydian
\time 6/8 \time 6/8
} }
confTempo = { confTempo = {
\tempo 4. = 90 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 \grace{s4.} s8 } part = { \partial 8 \grace{s4.} s8 }
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 4 = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 s8 } part = { \partial 8 s8 }

View file

@ -2,10 +2,11 @@
%% Globals %% Globals
global = { global = {
\time 9/8 \time 9/8
} \key d \major
}
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 s8 } part = { \partial 8 s8 }
measure = { \grace {s1} s4.*3 | } measure = { \grace {s1} s4.*3 | }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 2. = 80 \tempo 4. = 90
} }
%% Format %% Format
measure = { \grace {s1} s4.*3 | } measure = { \grace {s1} s4.*3 | }

View file

@ -5,7 +5,7 @@ global = {
\key a \mixolydian \key a \mixolydian
} }
confTempo = { confTempo = {
\tempo 4. = 80 \tempo 4. = 90
} }
%% Format %% Format
part = { \partial 8 s8 } part = { \partial 8 s8 }

View file

@ -2,15 +2,16 @@
%% Globals %% Globals
global = { global = {
\time 3/4 \time 3/4
} \key d \major
}
confTempo = { confTempo = {
\tempo 4 = 60 \tempo 4 = 60
} }
%% Format %% Format
measure = { \grace {s1} s2. | } measure = { \grace {s1} s2. | }
halfline = { \repeat unfold 2 \measure } halfline = { \repeat unfold 2 \measure }
line = { \repeat unfold 2 { \halfline } } line = { \repeat unfold 2 { \halfline } }
%% Headers %% Headers
title = "God Save The Queen" title = "God Save The King"
meter = "British National Anthem" meter = "British National Anthem"

View file

@ -3,13 +3,14 @@
\include "bagpipe.ly" \include "bagpipe.ly"
\include "./config.ily" \include "./config.ily"
%\include "./notes.pipes.ily" \include "./notes.pipes.ily"
\include "./notes.lyrics.ily" \include "./notes.lyrics.ily"
\score { \score {
\new Staff { \new Staff {
\global \global
\lyricsglobal \lyricsglobal
\pipeglobal
<< <<
\new NullVoice = "format"{ \new NullVoice = "format"{
\line \halfline \line \halfline
@ -20,10 +21,14 @@
\bar "|." \bar "|."
}%Format }%Format
\new Voice = "tune" { \new NullVoice = "tune" {
\songA \songA
} }
\new Voice = "pipes" {
\pipesA
\pipesB
\pipesC
}
\new Lyrics = "lyrics" { \new Lyrics = "lyrics" {
\lyricsto "tune" { \lyricsto "tune" {
\lyricsA \lyricsA
@ -49,18 +54,20 @@
} }
} }
\markup { \markup {
\line{ \combine \null \vspace #0.5
\fill-line {
\column { \column {
\verseA \verseB
\combine \null \vspace #0.5 \combine \null \vspace #0.5
\verseC \verseC
}
\column {
\verseD
\combine \null \vspace #0.5 \combine \null \vspace #0.5
\verseE \verseE
} }
\column { \column {
\verseB \verseF
\combine \null \vspace #0.5
\verseD
} }
} }
} }

View file

@ -1,4 +1,4 @@
% 3/4 God Save the Queen % 3/4 God Save the King
% Lyrics (From Wikipedia) % Lyrics (From Wikipedia)
\version "2.18.2" \version "2.18.2"
composerLyrics = "" composerLyrics = ""
@ -24,28 +24,28 @@ songA = {
} }
lyricsA = \lyricmode { lyricsA = \lyricmode {
\set stanza = #"1." \set stanza = #"1."
God save our grac- ious Queen, God save our grac- ious King,
Long live our no- ble Queen, Long live our no- ble King,
God save the Queen: God save the King:
Send her vic- tor- i- ous, Send him vic- tor- i- ous,
Hap- py and glor- i- ous, Hap- py and glor- i- ous,
Long to reign ov- er us: Long to reign ov- er us:
God save the Queen. God save the King.
} }
verseA = \markup \column { verseA = \markup \column {
\line \bold {1.} \line \bold {1.}
\line { God save our gracious Queen,} \line { God save our gracious King,}
\line { Long live our noble Queen,} \line { Long live our noble King,}
\line { God save the Queen:} \line { God save the King:}
\line { Send her victorious,} \line { Send him victorious,}
\line { Happy and glorious,} \line { Happy and glorious,}
\line { Long to reign over us:} \line { Long to reign over us:}
\line { God save the Queen.} \line { God save the King.}
} }
verseB = \markup \column { verseB = \markup \column {
\line \bold {2.} \line \bold {2.}
\line { O Lord, our God, arise,} \line { O Lord, our God, arise,}
\line { Scatter her enemies,} \line { Scatter him enemies,}
\line { And make them fall:} \line { And make them fall:}
\line { Confound their politics,} \line { Confound their politics,}
\line { Frustrate their knavish tricks,} \line { Frustrate their knavish tricks,}
@ -55,12 +55,12 @@ verseB = \markup \column {
verseC = \markup \column { verseC = \markup \column {
\line \bold {3.} \line \bold {3.}
\line { Thy choicest gifts in store,} \line { Thy choicest gifts in store,}
\line { On her be pleased to pour;} \line { On him be pleased to pour;}
\line { Long may she reign:} \line { Long may she reign:}
\line { May she defend our laws,} \line { May she defend our laws,}
\line { And ever give us cause} \line { And ever give us cause}
\line { To sing with heart and voice} \line { To sing with heart and voice}
\line { God save the Queen.} \line { God save the King.}
} }
verseD = \markup \column { verseD = \markup \column {
\line \bold {4.} \line \bold {4.}
@ -76,19 +76,19 @@ verseE = \markup \column {
\line \bold {5.} \line \bold {5.}
\line { From every latent foe,} \line { From every latent foe,}
\line { From the assassins blow,} \line { From the assassins blow,}
\line { God save the Queen!} \line { God save the King!}
\line { O'er her thine arm extend,} \line { O'er him thine arm extend,}
\line { For Britain's sake defend,} \line { For Britain's sake defend,}
\line { Our mother, prince, and friend,} \line { Our father, prince, and friend,}
\line { God save the Queen!} \line { God save the King!}
} }
verseF = \markup \column { verseF = \markup \column {
\line \bold {During the Jacobite Risings} \line \bold {During the Jacobite Risings:}
\line { Lord grant that Marshall Wade} \line { Lord grant that Marshall Wade}
\line { May by thy mighty aid} \line { May by thy mighty aid}
\line { Victory bring.} \line { Victory bring.}
\line { May he sedition hush,} \line { May he sedition hush,}
\line { And like a torrent rush,} \line { And like a torrent rush,}
\line { Rebellious Scots to crush.} \line { Rebellious Scots to crush.}
\line { God save the Queen!} \line { God save the King!}
} }

View file

@ -1,4 +1,4 @@
% 3/4 God Save The Queen % 3/4 God Save The King
% Pipes % Pipes
\version "2.18.2" \version "2.18.2"
composerPipes = "" composerPipes = ""

View file

@ -6,9 +6,17 @@
#{{{ Functions #{{{ Functions
import os import os
import re
def walk_through_files(path, file_extension='.ly'): def walk_through_files(path, file_extension='.ly', exclude_dirs=[]):
for (dirpath, dirnames, filenames) in os.walk(path): for (dirpath, dirnames, filenames) in os.walk(path):
if os.path.basename(dirpath) in exclude_dirs:
continue
if '.ignore_scores2json' in filenames:
dirnames = []
continue
if file_extension: if file_extension:
for filename in filenames: for filename in filenames:
if filename.endswith(file_extension): if filename.endswith(file_extension):
@ -21,13 +29,9 @@ def rreplace(s, old, new, occurrence):
return new.join(li) return new.join(li)
def read_config(config_path): def search_file_for_tuneinfo(fname, textsearches = [], keywords = []):
''' return a dict created from the configfile ''' data = {}
import re with open(fname, 'r') as fh:
config = {}
textsearches = ['title', 'meter']
with open(config_path, 'r') as fh:
for line in fh: for line in fh:
if line.startswith('\\version'): if line.startswith('\\version'):
continue continue
@ -36,50 +40,92 @@ def read_config(config_path):
continue continue
for t in textsearches: for t in textsearches:
if not t in config: if not t in data:
result = re.search(t +' = (?P<quote>[\'\"])(.*?)(?P=quote)', line) result = re.search(t +'\s*=\s*(?P<quote>[\'\"])(.*?)(?P=quote)', line)
if result: if result:
config[t] = result.group(2) data[t] = result.group(2)
for keyword in ['\\\\tempo', '\\\\time', '\\\\partial']: for keyword in keywords:
if not keyword in config: if not keyword in data:
result = re.search(keyword+'\s*(.*)', line) result = re.search(keyword+'\s*(.*)', line)
if result: if result:
config[keyword.replace('\\','')] = result.group(1).strip() data[keyword.replace('\\','')] = result.group(1).strip().replace('\\', '')
return config return data
def read_config(config_path):
''' return a dict created from the configfile '''
tuneinfo = search_file_for_tuneinfo(
config_path,
textsearches = ['title', 'meter', 'instrument'],
keywords = ['\\\\tempo', '\\\\time', '\\\\partial', '\\\\key'],
)
if 'partial' in tuneinfo:
tuneinfo['partial'] = tuneinfo['partial'].split(' ')[0]
if 'time' in tuneinfo:
tuneinfo['time'] = tuneinfo['time'].split(' ')[0]
return tuneinfo
def read_lilypond(fname):
''' return a dict from file'''
data = read_config(fname)
return data
def analyse_tune_ly(tune_file): def analyse_tune_ly(tune_file):
''' return a dict created from the tune file''' ''' return a dict created from the tune file'''
data = read_lilypond(tune_file) data = read_lilypond(tune_file)
if 'instrument' not in data:
data['instrument'] = os.path.splitext(os.path.basename(tune_file))[0]
elif data['instrument']:
candidate = os.path.splitext(os.path.basename(tune_file))[0]
if data['instrument'].lower() in candidate.lower():
low_candidate = candidate.lower().split(sep=data['instrument'].lower(), maxsplit=1)
if len(low_candidate) > 1:
data['instrument'] += candidate[len(low_candidate[0]) + len(data['instrument']):]
data['instrument'] = data['instrument'].lower()
data['path'] = tune_file data['path'] = tune_file
return data return data
def read_lilypond(fname):
''' return a dict from file'''
data = {}
if not os.path.exists(fname): def merge_data_and_config(data={}, config={}):
return data """
Merge two dictionaries.
data is from the file itself, config is from the configfile
return data replaces data['title'] = 'My \\title' with 'My '+config['title']
"""
def merge_data_and_config(data, config): for k in config.keys():
if 'title' in data and '\\title' in data['title'] and 'title' in config: if k in data and '\\'+k in data[k]:
data['title'].replace('\\title',config['title']) data[k].replace('\\'+k, config[k])
# overwrite config values with data
newdata = { **config, **data } newdata = { **config, **data }
return newdata return newdata
def config_from_lypath(lypath): def config_from_lypath(lypath, default_name='config.ily'):
''' return the configpath belonging to the lypath ''' ''' return the configpath belonging to the lypath '''
li = lypath.rsplit("/", 1)[0] li = lypath.rsplit("/", 1)[0]
return os.path.join(li,"config.ily")
def read_path(music_paths): if False:
# determine config path from file
pass
else:
configpath = os.path.join(li, default_name)
return configpath
def read_path(music_paths, exclude_dirs=[]):
"""
Return a dictionary of tunes with tune info from music_paths
"""
tunes = {} tunes = {}
# Music Directory to work on # Music Directory to work on
@ -87,9 +133,7 @@ def read_path(music_paths):
music_paths = [music_paths] music_paths = [music_paths]
for path in music_paths: for path in music_paths:
for f in walk_through_files(path, '.ly'): for f in walk_through_files(path, '.ly', exclude_dirs=exclude_dirs):
if os.path.basename(os.path.dirname(f)) == 'template':
continue;
data = analyse_tune_ly(f) data = analyse_tune_ly(f)
config_path = config_from_lypath(f) config_path = config_from_lypath(f)
@ -99,7 +143,6 @@ def read_path(music_paths):
# merge them # merge them
data = merge_data_and_config(data, config) data = merge_data_and_config(data, config)
data['instrument'] = os.path.splitext(os.path.basename(f))[0]
data['files'] = {} data['files'] = {}
data['files']['lilypond'] = f.replace(path,'',1) data['files']['lilypond'] = f.replace(path,'',1)
for ext in ['pdf', 'midi', 'preview.pdf', 'preview.png']: for ext in ['pdf', 'midi', 'preview.pdf', 'preview.png']:
@ -126,7 +169,6 @@ def read_path(music_paths):
# ================================================================ # ================================================================
if __name__ == "__main__": if __name__ == "__main__":
import argparse import argparse
import json import json
parser = argparse.ArgumentParser(description="Read a music directory into a JSON file") parser = argparse.ArgumentParser(description="Read a music directory into a JSON file")
@ -134,4 +176,4 @@ if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
print(json.dumps(read_path( args.music_paths ))) print(json.dumps(read_path( args.music_paths, exclude_dirs=['template'] ), indent=0))

View file

@ -19,12 +19,12 @@
shortInstrumentName = \markup{ \shortInstrumentPipes } shortInstrumentName = \markup{ \shortInstrumentPipes }
} { } {
\global \global
\pipeglobal
<< <<
\new NullVoice = "format" { \new NullVoice = "format" {
% \line % \line
}%Format }%Format
\new Voice = "pipes" { \new Voice = "pipes" {
\pipeglobal
\repeat unfold 4 { \pipesA | \break } % Remove me \repeat unfold 4 { \pipesA | \break } % Remove me
}%Pipes }%Pipes
>> >>

View file

@ -8,12 +8,12 @@
\score { \score {
\new Staff { \new Staff {
\global \global
\pipeglobal
<< <<
\new NullVoice = "format" { \new NullVoice = "format" {
% \line % \line
}%Format }%Format
\new Voice = "pipes" { \new Voice = "pipes" {
\pipeglobal
\repeat unfold 8 { \pipesA | \break } % Remove me \repeat unfold 8 { \pipesA | \break } % Remove me
}%Pipes }%Pipes
>> >>

View file

@ -8,12 +8,12 @@
\score { \score {
\new Staff { \new Staff {
\global \global
\pipessecndglobal
<< <<
\new NullVoice = "format" { \new NullVoice = "format" {
% \line % \line
}%Format }%Format
\new Voice = "seconds" { \new Voice = "seconds" {
\pipessecndglobal
\repeat unfold 8 { \pipessecndA | \break } % Remove me \repeat unfold 8 { \pipessecndA | \break } % Remove me
}%Pipes }%Pipes
>> >>

View file

@ -8,12 +8,12 @@
\score { \score {
\new Staff { \new Staff {
\global \global
\pipesthrdglobal
<< <<
\new NullVoice = "format" { \new NullVoice = "format" {
% \line % \line
}%Format }%Format
\new Voice = "thirds" { \new Voice = "thirds" {
\pipesthrdglobal
\repeat unfold 8 { \pipesthrdA | \break } % Remove me \repeat unfold 8 { \pipesthrdA | \break } % Remove me
}%Pipes }%Pipes
>> >>