Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Schwarzentruber committed May 28, 2024
1 parent 5525899 commit fe1a1a1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
21 changes: 9 additions & 12 deletions js/abcd2abc.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function isStaffInstrumentAndOpenCurlyBracket(abcdLine) {

async function abcd2abc(abcd) {

function getABCPreambule(lines) {
function getABCLinesPreambule(lines) {
const abc = [];
abc.push("X:1");
abc.push("L:1/4");
Expand All @@ -212,7 +212,7 @@ async function abcd2abc(abcd) {

let i = 0;

while (true) {
while (lines.length > 0) {
let line = lines[0].trim();
if (line != "") {
if (isStaffLine(line))
Expand All @@ -227,18 +227,15 @@ async function abcd2abc(abcd) {
return abc;
}
}
else
lines.shift();
}
return abc;
}


const lines = abcd.split("\n");
const abc = getABCPreambule(lines);

const iScoreInABC = abc.length - 1;




const abc = getABCLinesPreambule(lines);

let scoreStructure = new ScoreStructure();
let scoreData = new ScoreData();
Expand Down Expand Up @@ -296,6 +293,9 @@ async function abcd2abc(abcd) {
let currentTimeSignature = 1; // bydefaut

measures = await Promise.all(measures.map(async (measureStr) => {
if (measureStr == "") // DO NOT REMOVE. It enables to handle "||"
return "";

let accidentals = {};

const getCurrentAccidental = (pitch) => {
Expand Down Expand Up @@ -355,9 +355,6 @@ async function abcd2abc(abcd) {
const ppure = new Pitch(note.pitch.value, 0);
accidentals[ppure.toStringABC()] = noteAccidental;

console.log(noteAccidental)

console.log((currentA == noteAccidental))
if (currentA == noteAccidental)
return note.toStringABC();
else {
Expand Down
5 changes: 3 additions & 2 deletions js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dialogOpenButtonOpen.onclick = () => {
editor.text = Save.load();//editor.setValue(Save.load(), -1);
}
else {
alert("No document with name '" + newid + "' found!")
alert("No document with id name '" + newid + "' found!")
}
}

Expand Down Expand Up @@ -44,7 +44,7 @@ buttonDialogOpen.onclick = () => {


buttonSave.onclick = () => {
const newid = prompt("What name do you want to give to this score?", Save.getId());
const newid = prompt("What id name do you want to give to this score?", Save.getId());
Save.setId(newid);
Save.save();
}
Expand Down Expand Up @@ -128,6 +128,7 @@ async function update() {
synthControl.load("#audio", null, { displayRestart: true, displayPlay: true, displayProgress: true });
synthControl.setTune(visualObj, false);
}

editor.onchange = update;
update();
/**
Expand Down
4 changes: 0 additions & 4 deletions js/rhythmguess.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class RhythmGuess {
const nbSpacesArray = [];
let isElement = false;
const elements = []; //array of Element, Chord or string :)
console.log("tokens: ", tokens);


tokens.map((token) => {
if (token == "") {
Expand Down Expand Up @@ -249,7 +247,6 @@ function tokenize(abcdStr) {
abcdStr = abcdStr.replaceAll("-", " - ");

const L = abcdStr.split(" ");
console.log(L)

for (const chunk of L) {
if (!isBracket) {
Expand All @@ -276,7 +273,6 @@ function tokenize(abcdStr) {
bracketToken += chunk + " ";
}
}
console.log(tokens)
return tokens;
}

Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: absolute;
top: 76px;
right: 0px;
bottom: 50%;
bottom: 60%;
left: 0;
border: 1px solid black;
}
Expand All @@ -18,7 +18,7 @@
#outputWrapper {
overflow: auto;
position: absolute;
top: 50%;
top: 40%;
left: 0px;
right: 0px;
bottom: 0px;
Expand Down

0 comments on commit fe1a1a1

Please sign in to comment.