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
|
%% 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. | }
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
%% Globals
|
%% Globals
|
||||||
global = {
|
global = {
|
||||||
\time 6/8
|
\time 6/8
|
||||||
\key d \major
|
}
|
||||||
}
|
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 4 \grace{s1}s4 }
|
part = { \partial 4 \grace{s1}s4 }
|
||||||
measure = { \grace {s1} s2. | }
|
measure = { \grace {s1} s2. | }
|
||||||
|
|
|
@ -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. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace{s4.} s8 }
|
part = { \partial 8 \grace{s4.} s8 }
|
||||||
measure = { \grace {s1} s2. | }
|
measure = { \grace {s1} s2. | }
|
||||||
|
|
|
@ -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. = 100
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace{s4.} s8 }
|
part = { \partial 8 \grace{s4.} s8 }
|
||||||
measure = { \grace {s1} s2. | }
|
measure = { \grace {s1} s2. | }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key a \mixolydian
|
\key a \mixolydian
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 2. = 90
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace { s4 } s8 }
|
part = { \partial 8 \grace { s4 } s8 }
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
global = {
|
global = {
|
||||||
\key b \minor
|
\key b \minor
|
||||||
\time 6/8
|
\time 6/8
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace{s4.} s8 }
|
part = { \partial 8 \grace{s4.} s8 }
|
||||||
measure = { \grace {s1} s2. | }
|
measure = { \grace {s1} s2. | }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key a \mixolydian
|
\key a \mixolydian
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 s8 }
|
part = { \partial 8 s8 }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key a \mixolydian
|
\key a \mixolydian
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace { s4 } s8 }
|
part = { \partial 8 \grace { s4 } s8 }
|
||||||
|
|
|
@ -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 | }
|
||||||
|
|
|
@ -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. | }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key d \major
|
\key d \major
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace {s4} s8 }
|
part = { \partial 8 \grace {s4} s8 }
|
||||||
|
|
|
@ -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. | }
|
||||||
|
|
|
@ -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 = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace{s32} s8 }
|
part = { \partial 8 \grace{s32} s8 }
|
||||||
measure = { \grace {s1} s2. | }
|
measure = { \grace {s1} s2. | }
|
||||||
|
|
|
@ -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 = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 \grace {s4.} s8 }
|
part = { \partial 8 \grace {s4.} s8 }
|
||||||
measure = { \grace {s1} s2. | }
|
measure = { \grace {s1} s2. | }
|
||||||
|
|
|
@ -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 }
|
||||||
|
|
|
@ -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. | }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key a \mixolydian
|
\key a \mixolydian
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4 = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 s8 }
|
part = { \partial 8 s8 }
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
%% Globals
|
%% Globals
|
||||||
global = {
|
global = {
|
||||||
\time 9/8
|
\time 9/8
|
||||||
\key d \major
|
}
|
||||||
}
|
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 s8 }
|
part = { \partial 8 s8 }
|
||||||
measure = { \grace {s1} s4.*3 | }
|
measure = { \grace {s1} s4.*3 | }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key a \mixolydian
|
\key a \mixolydian
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 2. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
measure = { \grace {s1} s4.*3 | }
|
measure = { \grace {s1} s4.*3 | }
|
||||||
|
|
|
@ -5,7 +5,7 @@ global = {
|
||||||
\key a \mixolydian
|
\key a \mixolydian
|
||||||
}
|
}
|
||||||
confTempo = {
|
confTempo = {
|
||||||
\tempo 4. = 90
|
\tempo 4. = 80
|
||||||
}
|
}
|
||||||
%% Format
|
%% Format
|
||||||
part = { \partial 8 s8 }
|
part = { \partial 8 s8 }
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
%% 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 King"
|
title = "God Save The Queen"
|
||||||
meter = "British National Anthem"
|
meter = "British National Anthem"
|
|
@ -3,14 +3,13 @@
|
||||||
\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
|
||||||
|
@ -21,14 +20,10 @@
|
||||||
\bar "|."
|
\bar "|."
|
||||||
}%Format
|
}%Format
|
||||||
|
|
||||||
\new NullVoice = "tune" {
|
\new Voice = "tune" {
|
||||||
\songA
|
\songA
|
||||||
}
|
}
|
||||||
\new Voice = "pipes" {
|
|
||||||
\pipesA
|
|
||||||
\pipesB
|
|
||||||
\pipesC
|
|
||||||
}
|
|
||||||
\new Lyrics = "lyrics" {
|
\new Lyrics = "lyrics" {
|
||||||
\lyricsto "tune" {
|
\lyricsto "tune" {
|
||||||
\lyricsA
|
\lyricsA
|
||||||
|
@ -54,20 +49,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\markup {
|
\markup {
|
||||||
\combine \null \vspace #0.5
|
\line{
|
||||||
\fill-line {
|
|
||||||
\column {
|
\column {
|
||||||
\verseB
|
\verseA
|
||||||
\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 {
|
||||||
\verseF
|
\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)
|
% 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 King,
|
God save our grac- ious Queen,
|
||||||
Long live our no- ble King,
|
Long live our no- ble Queen,
|
||||||
God save the King:
|
God save the Queen:
|
||||||
Send him vic- tor- i- ous,
|
Send her 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 King.
|
God save the Queen.
|
||||||
}
|
}
|
||||||
verseA = \markup \column {
|
verseA = \markup \column {
|
||||||
\line \bold {1.}
|
\line \bold {1.}
|
||||||
\line { God save our gracious King,}
|
\line { God save our gracious Queen,}
|
||||||
\line { Long live our noble King,}
|
\line { Long live our noble Queen,}
|
||||||
\line { God save the King:}
|
\line { God save the Queen:}
|
||||||
\line { Send him victorious,}
|
\line { Send her 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 King.}
|
\line { God save the Queen.}
|
||||||
}
|
}
|
||||||
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 him enemies,}
|
\line { Scatter her 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 him be pleased to pour;}
|
\line { On her 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 King.}
|
\line { God save the Queen.}
|
||||||
}
|
}
|
||||||
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 King!}
|
\line { God save the Queen!}
|
||||||
\line { O'er him thine arm extend,}
|
\line { O'er her thine arm extend,}
|
||||||
\line { For Britain's sake defend,}
|
\line { For Britain's sake defend,}
|
||||||
\line { Our father, prince, and friend,}
|
\line { Our mother, prince, and friend,}
|
||||||
\line { God save the King!}
|
\line { God save the Queen!}
|
||||||
}
|
}
|
||||||
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 King!}
|
\line { God save the Queen!}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
% 3/4 God Save The King
|
% 3/4 God Save The Queen
|
||||||
% Pipes
|
% Pipes
|
||||||
\version "2.18.2"
|
\version "2.18.2"
|
||||||
composerPipes = ""
|
composerPipes = ""
|
108
scores2json.py
108
scores2json.py
|
@ -6,17 +6,9 @@
|
||||||
|
|
||||||
#{{{ Functions
|
#{{{ Functions
|
||||||
import os
|
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):
|
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):
|
||||||
|
@ -29,9 +21,13 @@ def rreplace(s, old, new, occurrence):
|
||||||
return new.join(li)
|
return new.join(li)
|
||||||
|
|
||||||
|
|
||||||
def search_file_for_tuneinfo(fname, textsearches = [], keywords = []):
|
def read_config(config_path):
|
||||||
data = {}
|
''' return a dict created from the configfile '''
|
||||||
with open(fname, 'r') as fh:
|
import re
|
||||||
|
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
|
||||||
|
@ -40,92 +36,50 @@ def search_file_for_tuneinfo(fname, textsearches = [], keywords = []):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for t in textsearches:
|
for t in textsearches:
|
||||||
if not t in data:
|
if not t in config:
|
||||||
result = re.search(t +'\s*=\s*(?P<quote>[\'\"])(.*?)(?P=quote)', line)
|
result = re.search(t +' = (?P<quote>[\'\"])(.*?)(?P=quote)', line)
|
||||||
if result:
|
if result:
|
||||||
data[t] = result.group(2)
|
config[t] = result.group(2)
|
||||||
|
|
||||||
for keyword in keywords:
|
for keyword in ['\\\\tempo', '\\\\time', '\\\\partial']:
|
||||||
if not keyword in data:
|
if not keyword in config:
|
||||||
result = re.search(keyword+'\s*(.*)', line)
|
result = re.search(keyword+'\s*(.*)', line)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
data[keyword.replace('\\','')] = result.group(1).strip().replace('\\', '')
|
config[keyword.replace('\\','')] = result.group(1).strip()
|
||||||
return data
|
return config
|
||||||
|
|
||||||
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 = {}
|
||||||
|
|
||||||
def merge_data_and_config(data={}, config={}):
|
if not os.path.exists(fname):
|
||||||
"""
|
return data
|
||||||
Merge two dictionaries.
|
|
||||||
data is from the file itself, config is from the configfile
|
|
||||||
|
|
||||||
replaces data['title'] = 'My \\title' with 'My '+config['title']
|
return data
|
||||||
"""
|
|
||||||
|
|
||||||
for k in config.keys():
|
def merge_data_and_config(data, config):
|
||||||
if k in data and '\\'+k in data[k]:
|
if 'title' in data and '\\title' in data['title'] and 'title' in config:
|
||||||
data[k].replace('\\'+k, config[k])
|
data['title'].replace('\\title',config['title'])
|
||||||
|
|
||||||
# overwrite config values with data
|
|
||||||
newdata = { **config, **data }
|
newdata = { **config, **data }
|
||||||
|
|
||||||
return newdata
|
return newdata
|
||||||
|
|
||||||
def config_from_lypath(lypath, default_name='config.ily'):
|
def config_from_lypath(lypath):
|
||||||
''' 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")
|
||||||
|
|
||||||
if False:
|
def read_path(music_paths):
|
||||||
# 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
|
||||||
|
@ -133,7 +87,9 @@ def read_path(music_paths, exclude_dirs=[]):
|
||||||
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', 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)
|
data = analyse_tune_ly(f)
|
||||||
config_path = config_from_lypath(f)
|
config_path = config_from_lypath(f)
|
||||||
|
@ -143,6 +99,7 @@ def read_path(music_paths, exclude_dirs=[]):
|
||||||
# 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']:
|
||||||
|
@ -169,6 +126,7 @@ def read_path(music_paths, exclude_dirs=[]):
|
||||||
# ================================================================
|
# ================================================================
|
||||||
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")
|
||||||
|
@ -176,4 +134,4 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
args = parser.parse_args()
|
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 }
|
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
|
||||||
>>
|
>>
|
||||||
|
|
|
@ -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
|
||||||
>>
|
>>
|
||||||
|
|
|
@ -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
|
||||||
>>
|
>>
|
||||||
|
|
|
@ -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
|
||||||
>>
|
>>
|
||||||
|
|
Loading…
Reference in a new issue