Skip to content

Commit

Permalink
highest/lowest notes in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
sksum committed Aug 25, 2020
1 parent b01d78a commit fb033bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ class Logo {
if (logo.collectingStats){
console.debug("stats collection completed")
logo.projectStats = getStatsFromNotation(logo);
logo.statsWindow.jsonObject.innerHTML = JSON.stringify(projectStats);
logo.statsWindow.jsonObject.innerHTML = JSON.stringify(projectStats,undefined,4);
} else {
console.debug("saving lilypond output:");
save.afterSaveLilypond();
Expand Down
14 changes: 13 additions & 1 deletion js/rubrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ let getStatsFromNotation = (logo) => {
end : []
};
projectStats["pitches"] = [];
projectStats["numberOfNotes"] = 0;

let noteId = 0;

for (tur in notation.notationStaging){
for (it in notation.notationStaging[tur]) {
Expand All @@ -751,9 +754,18 @@ let getStatsFromNotation = (logo) => {
if (typeof item == "object" && item[0].length){
for (note of item[0]) {
projectStats["pitchNames"].add(note[0]);
let freq = logo.synth._getFrequency(note);
projectStats["pitches"].push(
logo.synth._getFrequency(note)
freq
);
if (projectStats["lowestNote"] == undefined || freq < projectStats["lowestNote"][2]) {
projectStats["lowestNote"] = [note,noteId,freq];
}
if (projectStats["highestNote"] == undefined || freq > projectStats["highestNote"][2]) {
projectStats["highestNote"] = [note,noteId,freq];
}
projectStats["numberOfNotes"]++;
noteId++;
}
}

Expand Down
4 changes: 3 additions & 1 deletion js/widgets/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function StatsWindow() {
imageData = myRadarChart.toBase64Image();
img = new Image();
img.src = imageData;
img.width = 200;
this.widgetWindow.getWidgetBody().appendChild(img)
blocks.hideBlocks();
logo.showBlocksAfterRun = false;
Expand All @@ -78,7 +79,8 @@ function StatsWindow() {
options = getChartOptions(__callback);
myRadarChart = new Chart(ctx).Radar(data, options);

this.jsonObject = document.createElement('p');
this.jsonObject = document.createElement('pre');
this.jsonObject.style.float = 'left';
this.widgetWindow.getWidgetBody().appendChild(this.jsonObject)

};
Expand Down

0 comments on commit fb033bc

Please sign in to comment.