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
global = {
\time 6/8
}
key d \major
}
confTempo = {
\tempo 4. = 90
}
}
%% Format
part = { \partial 8 \grace {s4} s8 }
measure = { \grace { s4 } s1. | }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,13 +3,14 @@
\include "bagpipe.ly"
\include "./config.ily"
%\include "./notes.pipes.ily"
\include "./notes.pipes.ily"
\include "./notes.lyrics.ily"
\score {
\new Staff {
\global
\lyricsglobal
\pipeglobal
<<
\new NullVoice = "format"{
\line \halfline
@ -20,10 +21,14 @@
\bar "|."
}%Format
\new Voice = "tune" {
\new NullVoice = "tune" {
\songA
}
\new Voice = "pipes" {
\pipesA
\pipesB
\pipesC
}
\new Lyrics = "lyrics" {
\lyricsto "tune" {
\lyricsA
@ -49,18 +54,20 @@
}
}
\markup {
\line{
\column {
\verseA
\combine \null \vspace #0.5
\verseC
\combine \null \vspace #0.5
\verseE
\combine \null \vspace #0.5
\fill-line {
\column {
\verseB
\combine \null \vspace #0.5
\verseC
}
\column {
\verseD
\combine \null \vspace #0.5
\verseE
}
\column {
\verseF
}
}
\column {
\verseB
\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)
\version "2.18.2"
composerLyrics = ""
@ -24,28 +24,28 @@ songA = {
}
lyricsA = \lyricmode {
\set stanza = #"1."
God save our grac- ious Queen,
Long live our no- ble Queen,
God save the Queen:
Send her vic- tor- i- ous,
God save our grac- ious King,
Long live our no- ble King,
God save the King:
Send him vic- tor- i- ous,
Hap- py and glor- i- ous,
Long to reign ov- er us:
God save the Queen.
God save the King.
}
verseA = \markup \column {
\line \bold {1.}
\line { God save our gracious Queen,}
\line { Long live our noble Queen,}
\line { God save the Queen:}
\line { Send her victorious,}
\line { God save our gracious King,}
\line { Long live our noble King,}
\line { God save the King:}
\line { Send him victorious,}
\line { Happy and glorious,}
\line { Long to reign over us:}
\line { God save the Queen.}
\line { God save the King.}
}
verseB = \markup \column {
\line \bold {2.}
\line { O Lord, our God, arise,}
\line { Scatter her enemies,}
\line { Scatter him enemies,}
\line { And make them fall:}
\line { Confound their politics,}
\line { Frustrate their knavish tricks,}
@ -55,12 +55,12 @@ verseB = \markup \column {
verseC = \markup \column {
\line \bold {3.}
\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 { May she defend our laws,}
\line { And ever give us cause}
\line { To sing with heart and voice}
\line { God save the Queen.}
\line { God save the King.}
}
verseD = \markup \column {
\line \bold {4.}
@ -76,19 +76,19 @@ verseE = \markup \column {
\line \bold {5.}
\line { From every latent foe,}
\line { From the assassins blow,}
\line { God save the Queen!}
\line { O'er her thine arm extend,}
\line { God save the King!}
\line { O'er him thine arm extend,}
\line { For Britain's sake defend,}
\line { Our mother, prince, and friend,}
\line { God save the Queen!}
\line { Our father, prince, and friend,}
\line { God save the King!}
}
verseF = \markup \column {
\line \bold {During the Jacobite Risings}
\line \bold {During the Jacobite Risings:}
\line { Lord grant that Marshall Wade}
\line { May by thy mighty aid}
\line { Victory bring.}
\line { May he sedition hush,}
\line { And like a torrent rush,}
\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
\version "2.18.2"
composerPipes = ""

View file

@ -6,9 +6,17 @@
#{{{ Functions
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):
if os.path.basename(dirpath) in exclude_dirs:
continue
if '.ignore_scores2json' in filenames:
dirnames = []
continue
if file_extension:
for filename in filenames:
if filename.endswith(file_extension):
@ -21,13 +29,9 @@ def rreplace(s, old, new, occurrence):
return new.join(li)
def read_config(config_path):
''' return a dict created from the configfile '''
import re
config = {}
textsearches = ['title', 'meter']
with open(config_path, 'r') as fh:
def search_file_for_tuneinfo(fname, textsearches = [], keywords = []):
data = {}
with open(fname, 'r') as fh:
for line in fh:
if line.startswith('\\version'):
continue
@ -36,50 +40,92 @@ def read_config(config_path):
continue
for t in textsearches:
if not t in config:
result = re.search(t +' = (?P<quote>[\'\"])(.*?)(?P=quote)', line)
if not t in data:
result = re.search(t +'\s*=\s*(?P<quote>[\'\"])(.*?)(?P=quote)', line)
if result:
config[t] = result.group(2)
data[t] = result.group(2)
for keyword in ['\\\\tempo', '\\\\time', '\\\\partial']:
if not keyword in config:
for keyword in keywords:
if not keyword in data:
result = re.search(keyword+'\s*(.*)', line)
if result:
config[keyword.replace('\\','')] = result.group(1).strip()
return config
data[keyword.replace('\\','')] = result.group(1).strip().replace('\\', '')
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):
''' return a dict created from the 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
return data
def read_lilypond(fname):
''' return a dict from file'''
data = {}
if not os.path.exists(fname):
return data
def merge_data_and_config(data={}, config={}):
"""
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):
if 'title' in data and '\\title' in data['title'] and 'title' in config:
data['title'].replace('\\title',config['title'])
for k in config.keys():
if k in data and '\\'+k in data[k]:
data[k].replace('\\'+k, config[k])
# overwrite config values with data
newdata = { **config, **data }
return newdata
def config_from_lypath(lypath):
def config_from_lypath(lypath, default_name='config.ily'):
''' return the configpath belonging to the lypath '''
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 = {}
# Music Directory to work on
@ -87,19 +133,16 @@ def read_path(music_paths):
music_paths = [music_paths]
for path in music_paths:
for f in walk_through_files(path, '.ly'):
if os.path.basename(os.path.dirname(f)) == 'template':
continue;
for f in walk_through_files(path, '.ly', exclude_dirs=exclude_dirs):
data = analyse_tune_ly(f)
config_path = config_from_lypath(f)
if os.path.exists(config_path):
config = read_config(config_path)
# merge them
# merge them
data = merge_data_and_config(data, config)
data['instrument'] = os.path.splitext(os.path.basename(f))[0]
data['files'] = {}
data['files']['lilypond'] = f.replace(path,'',1)
for ext in ['pdf', 'midi', 'preview.pdf', 'preview.png']:
@ -126,7 +169,6 @@ def read_path(music_paths):
# ================================================================
if __name__ == "__main__":
import argparse
import json
parser = argparse.ArgumentParser(description="Read a music directory into a JSON file")
@ -134,4 +176,4 @@ if __name__ == "__main__":
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 }
} {
\global
\pipeglobal
<<
\new NullVoice = "format" {
% \line
}%Format
\new Voice = "pipes" {
\pipeglobal
\repeat unfold 4 { \pipesA | \break } % Remove me
}%Pipes
>>

View file

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

View file

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

View file

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