Skip to content

Commit

Permalink
Remove manually added *mclef interpretations
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangDrescher committed Feb 12, 2024
1 parent 2ea73f5 commit 6974efa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
16 changes: 1 addition & 15 deletions scripts/extract-cadences.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ function tokenIsDataRecord(token, includeNullToken = false) {
return !token.startsWith('!') && !token.startsWith('*') && !token.startsWith('=') && !(!includeNullToken && token === '.');
}

function addMclefInterpretations(file, kern) {
const mclefLine = execSync(`cat ${file}`).toString().split('\n').find((line) => line.includes('*mclef'));
if (mclefLine) {
kern = kern.split('\n').map(line => {
if (mclefLine && line.includes('*clef')) {
return `${line}\n${mclefLine}`;
}
return line;
}).join('\n');
}
return kern;
}

execSync(`rm -rf ${cadencesKernPath}`);
execSync(`mkdir -p ${cadencesKernPath}`);
execSync(`rm -rf ${cadencesYamlPath}`);
Expand Down Expand Up @@ -86,8 +73,7 @@ getFiles(pathToKernScores).forEach(file => {
const startLine = startLineIndex + 1;
const endLine = endLineIndex + 1;

const kern = execSync(`cat ${file} | myank -I -l ${startLine}-${endLine} --hide-starting --hide-ending`).toString().trim();
const cadenceKern = addMclefInterpretations(file, kern);
const cadenceKern = execSync(`cat ${file} | myank -I -l ${startLine}-${endLine} --hide-starting --hide-ending`).toString().trim();
const cadenceFilename = `${uuidv5(cadenceKern, UUID_NAMESPACE)}.krn`;
fs.writeFileSync(`${cadencesKernPath}${cadenceFilename}`, cadenceKern);

Expand Down
16 changes: 1 addition & 15 deletions scripts/extract-imitations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,6 @@ function formatImitationKern(kern, upperStartBeat, upperEndBeat, lowerStartBeat,
return formattedLines.join('\n');
}

function addMclefInterpretations(file, kern) {
const mclefLine = execSync(`cat ${file}`).toString().split('\n').find((line) => line.includes('*mclef'));
if (mclefLine) {
kern = kern.split('\n').map(line => {
if (mclefLine && line.includes('*clef')) {
return `${line}\n${mclefLine}`;
}
return line;
}).join('\n');
}
return kern;
}

execSync(`rm -rf ${imitationsKernPath}`);
execSync(`mkdir -p ${imitationsKernPath}`);
execSync(`rm -rf ${imitationsYamlPath}`);
Expand Down Expand Up @@ -169,8 +156,7 @@ getFiles(pathToKernScores).forEach(file => {
const endBeat = Math.max(upperEndBeat, lowerEndBeat);

const formattedKern = formatImitationKern(kern, upperStartBeat, upperEndBeat, lowerStartBeat, lowerEndBeat);
const tmpKern = execSync(`echo ${escapeShell(formattedKern)} | extractxx -f 1-4 | myank -I -l ${startLine}-${endLine} --hide-starting --hide-ending | echo -ne "$(cat)" | cat - <(echo -e -n "\n!!!RDF**kern: @ = marked note, color=#ccc\n!!!RDF**kern: { = phrase, brack")`, { shell: '/bin/bash' }).toString().trim();
const imitationKern = addMclefInterpretations(file, tmpKern);
const imitationKern = execSync(`echo ${escapeShell(formattedKern)} | extractxx -f 1-4 | myank -I -l ${startLine}-${endLine} --hide-starting --hide-ending | echo -ne "$(cat)" | cat - <(echo -e -n "\n!!!RDF**kern: @ = marked note, color=#ccc\n!!!RDF**kern: { = phrase, brack")`, { shell: '/bin/bash' }).toString().trim();
const imitationFilename = `${uuidv5(imitationKern, UUID_NAMESPACE)}.krn`;
fs.writeFileSync(`${imitationsKernPath}${imitationFilename}`, imitationKern);

Expand Down

0 comments on commit 6974efa

Please sign in to comment.