mirror of
https://github.com/kastdeur/pipeband-music.git
synced 2024-11-01 01:53:31 +01:00
Compare commits
No commits in common. "0a8b5ebe4b9503852dd2eda34327dc53b1ec0d58" and "e42f33373f6924bd1742a470b31d976e815abd77" have entirely different histories.
0a8b5ebe4b
...
e42f33373f
30 changed files with 118 additions and 171 deletions
|
@ -2,11 +2,10 @@
|
|||
%% Globals
|
||||
global = {
|
||||
\time 6/8
|
||||
key d \major
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace {s4} s8 }
|
||||
measure = { \grace { s4 } s1. | }
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
%% Globals
|
||||
global = {
|
||||
\time 6/8
|
||||
\key d \major
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 4 \grace{s1}s4 }
|
||||
measure = { \grace {s1} s2. | }
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
global = {
|
||||
\key a \mixolydian
|
||||
\time 6/8
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace{s4.} s8 }
|
||||
measure = { \grace {s1} s2. | }
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
global = {
|
||||
\key d \major
|
||||
\time 6/8
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4. = 100
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace{s4.} s8 }
|
||||
measure = { \grace {s1} s2. | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 2. = 90
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace { s4 } s8 }
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
global = {
|
||||
\key b \minor
|
||||
\time 6/8
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace{s4.} s8 }
|
||||
measure = { \grace {s1} s2. | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 s8 }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace { s4 } s8 }
|
||||
|
|
|
@ -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 | }
|
||||
|
|
|
@ -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. | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key d \major
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace {s4} s8 }
|
||||
|
|
|
@ -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. | }
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
global = {
|
||||
\key a \mixolydian
|
||||
\time 6/8
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4 = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace{s32} s8 }
|
||||
measure = { \grace {s1} s2. | }
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
global = {
|
||||
\key d \major
|
||||
\time 6/8
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4 = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 \grace {s4.} s8 }
|
||||
measure = { \grace {s1} s2. | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 4 = 90
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 s8 }
|
||||
|
|
|
@ -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. | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 4 = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 s8 }
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
%% Globals
|
||||
global = {
|
||||
\time 9/8
|
||||
\key d \major
|
||||
}
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
}
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 s8 }
|
||||
measure = { \grace {s1} s4.*3 | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 2. = 80
|
||||
}
|
||||
%% Format
|
||||
measure = { \grace {s1} s4.*3 | }
|
||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
|||
\key a \mixolydian
|
||||
}
|
||||
confTempo = {
|
||||
\tempo 4. = 90
|
||||
\tempo 4. = 80
|
||||
}
|
||||
%% Format
|
||||
part = { \partial 8 s8 }
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
%% 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 King"
|
||||
title = "God Save The Queen"
|
||||
meter = "British National Anthem"
|
|
@ -3,14 +3,13 @@
|
|||
\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
|
||||
|
@ -21,14 +20,10 @@
|
|||
\bar "|."
|
||||
}%Format
|
||||
|
||||
\new NullVoice = "tune" {
|
||||
\new Voice = "tune" {
|
||||
\songA
|
||||
}
|
||||
\new Voice = "pipes" {
|
||||
\pipesA
|
||||
\pipesB
|
||||
\pipesC
|
||||
}
|
||||
|
||||
\new Lyrics = "lyrics" {
|
||||
\lyricsto "tune" {
|
||||
\lyricsA
|
||||
|
@ -54,20 +49,18 @@
|
|||
}
|
||||
}
|
||||
\markup {
|
||||
\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
|
||||
}
|
||||
\line{
|
||||
\column {
|
||||
\verseA
|
||||
\combine \null \vspace #0.5
|
||||
\verseC
|
||||
\combine \null \vspace #0.5
|
||||
\verseE
|
||||
}
|
||||
\column {
|
||||
\verseB
|
||||
\combine \null \vspace #0.5
|
||||
\verseD
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
% 3/4 God Save the King
|
||||
% 3/4 God Save the Queen
|
||||
% Lyrics (From Wikipedia)
|
||||
\version "2.18.2"
|
||||
composerLyrics = ""
|
||||
|
@ -24,28 +24,28 @@ songA = {
|
|||
}
|
||||
lyricsA = \lyricmode {
|
||||
\set stanza = #"1."
|
||||
God save our grac- ious King,
|
||||
Long live our no- ble King,
|
||||
God save the King:
|
||||
Send him vic- tor- i- ous,
|
||||
God save our grac- ious Queen,
|
||||
Long live our no- ble Queen,
|
||||
God save the Queen:
|
||||
Send her vic- tor- i- ous,
|
||||
Hap- py and glor- i- ous,
|
||||
Long to reign ov- er us:
|
||||
God save the King.
|
||||
God save the Queen.
|
||||
}
|
||||
verseA = \markup \column {
|
||||
\line \bold {1.}
|
||||
\line { God save our gracious King,}
|
||||
\line { Long live our noble King,}
|
||||
\line { God save the King:}
|
||||
\line { Send him victorious,}
|
||||
\line { God save our gracious Queen,}
|
||||
\line { Long live our noble Queen,}
|
||||
\line { God save the Queen:}
|
||||
\line { Send her victorious,}
|
||||
\line { Happy and glorious,}
|
||||
\line { Long to reign over us:}
|
||||
\line { God save the King.}
|
||||
\line { God save the Queen.}
|
||||
}
|
||||
verseB = \markup \column {
|
||||
\line \bold {2.}
|
||||
\line { O Lord, our God, arise,}
|
||||
\line { Scatter him enemies,}
|
||||
\line { Scatter her 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 him be pleased to pour;}
|
||||
\line { On her 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 King.}
|
||||
\line { God save the Queen.}
|
||||
}
|
||||
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 King!}
|
||||
\line { O'er him thine arm extend,}
|
||||
\line { God save the Queen!}
|
||||
\line { O'er her thine arm extend,}
|
||||
\line { For Britain's sake defend,}
|
||||
\line { Our father, prince, and friend,}
|
||||
\line { God save the King!}
|
||||
\line { Our mother, prince, and friend,}
|
||||
\line { God save the Queen!}
|
||||
}
|
||||
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 King!}
|
||||
\line { God save the Queen!}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
% 3/4 God Save The King
|
||||
% 3/4 God Save The Queen
|
||||
% Pipes
|
||||
\version "2.18.2"
|
||||
composerPipes = ""
|
110
scores2json.py
110
scores2json.py
|
@ -6,17 +6,9 @@
|
|||
|
||||
#{{{ Functions
|
||||
import os
|
||||
import re
|
||||
|
||||
def walk_through_files(path, file_extension='.ly', exclude_dirs=[]):
|
||||
def walk_through_files(path, file_extension='.ly'):
|
||||
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):
|
||||
|
@ -29,9 +21,13 @@ def rreplace(s, old, new, occurrence):
|
|||
return new.join(li)
|
||||
|
||||
|
||||
def search_file_for_tuneinfo(fname, textsearches = [], keywords = []):
|
||||
data = {}
|
||||
with open(fname, 'r') as fh:
|
||||
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:
|
||||
for line in fh:
|
||||
if line.startswith('\\version'):
|
||||
continue
|
||||
|
@ -40,92 +36,50 @@ def search_file_for_tuneinfo(fname, textsearches = [], keywords = []):
|
|||
continue
|
||||
|
||||
for t in textsearches:
|
||||
if not t in data:
|
||||
result = re.search(t +'\s*=\s*(?P<quote>[\'\"])(.*?)(?P=quote)', line)
|
||||
if not t in config:
|
||||
result = re.search(t +' = (?P<quote>[\'\"])(.*?)(?P=quote)', line)
|
||||
if result:
|
||||
data[t] = result.group(2)
|
||||
config[t] = result.group(2)
|
||||
|
||||
for keyword in keywords:
|
||||
if not keyword in data:
|
||||
for keyword in ['\\\\tempo', '\\\\time', '\\\\partial']:
|
||||
if not keyword in config:
|
||||
result = re.search(keyword+'\s*(.*)', line)
|
||||
|
||||
if result:
|
||||
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
|
||||
config[keyword.replace('\\','')] = result.group(1).strip()
|
||||
return config
|
||||
|
||||
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 = {}
|
||||
|
||||
def merge_data_and_config(data={}, config={}):
|
||||
"""
|
||||
Merge two dictionaries.
|
||||
data is from the file itself, config is from the configfile
|
||||
if not os.path.exists(fname):
|
||||
return data
|
||||
|
||||
replaces data['title'] = 'My \\title' with 'My '+config['title']
|
||||
"""
|
||||
return data
|
||||
|
||||
for k in config.keys():
|
||||
if k in data and '\\'+k in data[k]:
|
||||
data[k].replace('\\'+k, config[k])
|
||||
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'])
|
||||
|
||||
# overwrite config values with data
|
||||
newdata = { **config, **data }
|
||||
|
||||
return newdata
|
||||
|
||||
def config_from_lypath(lypath, default_name='config.ily'):
|
||||
def config_from_lypath(lypath):
|
||||
''' return the configpath belonging to the lypath '''
|
||||
li = lypath.rsplit("/", 1)[0]
|
||||
return os.path.join(li,"config.ily")
|
||||
|
||||
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
|
||||
"""
|
||||
def read_path(music_paths):
|
||||
tunes = {}
|
||||
|
||||
# Music Directory to work on
|
||||
|
@ -133,16 +87,19 @@ def read_path(music_paths, exclude_dirs=[]):
|
|||
music_paths = [music_paths]
|
||||
|
||||
for path in music_paths:
|
||||
for f in walk_through_files(path, '.ly', exclude_dirs=exclude_dirs):
|
||||
for f in walk_through_files(path, '.ly'):
|
||||
if os.path.basename(os.path.dirname(f)) == 'template':
|
||||
continue;
|
||||
|
||||
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']:
|
||||
|
@ -169,6 +126,7 @@ def read_path(music_paths, exclude_dirs=[]):
|
|||
# ================================================================
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
|
||||
import json
|
||||
|
||||
parser = argparse.ArgumentParser(description="Read a music directory into a JSON file")
|
||||
|
@ -176,4 +134,4 @@ if __name__ == "__main__":
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
print(json.dumps(read_path( args.music_paths, exclude_dirs=['template'] ), indent=0))
|
||||
print(json.dumps(read_path( args.music_paths )))
|
||||
|
|
|
@ -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
|
||||
>>
|
||||
|
|
|
@ -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
|
||||
>>
|
||||
|
|
|
@ -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
|
||||
>>
|
||||
|
|
|
@ -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
|
||||
>>
|
||||
|
|
Loading…
Reference in a new issue