Skip to content

Commit 888afdf

Browse files
Co-authored-by: Michael C. Stewart <hcientist@users.noreply.github.com>
Office hours 4/18 Changes
1 parent 4685146 commit 888afdf

File tree

7 files changed

+4256
-369
lines changed

7 files changed

+4256
-369
lines changed

docs/generateFlatIOJSON.html

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<body>
1111
<h1>Flat.io Embed JSON Test</h1>
1212
<!-- copy and paste from FlatIO share by embedding section -->
13-
<!-- Only change score and sharing KEY values -->
13+
<!-- Only change score and sharing KEY values -->
1414
<div id="embed-container"></div>
1515
<script src="https://prod.flat-cdn.com/embed-js/v2.3.0/embed.min.js"></script>
1616
<script>
@@ -23,31 +23,35 @@ <h1>Flat.io Embed JSON Test</h1>
2323
'sharingKey': 'd61fc1be1b3df01d6c52162d81e4d58834ce3f30ad9eb9a49d3f642d0a822b04c929b2ee20aaa2af838b5e3fe39d6200f5d82895241a832fdbe7b01f2cbe7586'
2424
},
2525
{ // 3 notes
26-
scoreId:'67bcb6fe61f27a0a88a4db86',
26+
scoreId: '67bcb6fe61f27a0a88a4db86',
2727
'sharingKey': '9ef465415e0c8f77bddd388d56599f5ee6b8e553e9ea94b59c8bf2a724e37ed5cd897ee700005fe209bd889d571205755bdc1b675e5d397eaf5f69d9cf9e3ed0'
28+
},
29+
{
30+
scoreId: "65f3164ea114758e30975d47",
31+
"sharingKey": "89b9d230dddd45edd858af771f3630b148705b2f5fa361678cf46864697cee3611f4dd49494c307513e8d261f65221692de79b474882560b649249fe2f2ad7b2"
2832
}
2933
]
3034
var container = document.getElementById("embed-container");
3135
var embed = new Flat.Embed(container, {
3236
"width": "100%",
3337
"height": "450",
34-
"score": scores[1].scoreId,
38+
"score": scores[2].scoreId,
3539
"embedParams": {
3640
"appId": "60a51c906bcde01fc75a3ad0",
37-
"sharingKey": scores[1].sharingKey
41+
"sharingKey": scores[2].sharingKey
3842
},
3943
});
4044
// You can now use the `embed` instance.
4145
// Check out the docs at https://flat.io/developers/docs/embed/javascript.html
4246

43-
// Wait for the embed to initialize, then fetch JSON
44-
embed.getJSON()
45-
.then(function (data) {
46-
console.log("Flat.io JSON Data:", data);
47-
})
48-
.catch(function (error) {
49-
console.error("Error fetching JSON:", error);
50-
});
47+
// Wait for the embed to initialize, then fetch JSON
48+
embed.getJSON()
49+
.then(function (data) {
50+
console.log("Flat.io JSON Data:", data);
51+
})
52+
.catch(function (error) {
53+
console.error("Error fetching JSON:", error);
54+
});
5155
</script>
5256
</body>
5357

src/CompositionBlocks.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,25 @@ function changeBlocks(workspace, json) {
6262
// console.log(`Created measure block ${measureIndex}`);
6363

6464
// Process notes in this measure
65+
const noteList = [];
6566
measure['note'].forEach(note => {
6667
const noteBlock = newBlocklyBlockForNote(workspace, note);
6768
if (noteBlock) {
6869
const notesInput = measureBlock.getInput('NOTES');
69-
if (notesInput && notesInput.connection && noteBlock.previousConnection) {
70+
// if (notesInput && notesInput.connection && noteBlock.previousConnection) {
71+
// notesInput.connection.connect(noteBlock.previousConnection);
72+
// }
73+
if (noteList.length) {
74+
noteList[noteList.length - 1].nextConnection.connect(noteBlock.previousConnection)
75+
// notesInput.connection.connect(noteList[noteList.length - 1]);
76+
} else {
7077
notesInput.connection.connect(noteBlock.previousConnection);
7178
}
7279
}
80+
noteList.push(noteBlock);
7381
});
7482

83+
7584
// Connect the current measure block to the previous one
7685
if (previousMeasureBlock && previousMeasureBlock.nextConnection && measureBlock.previousConnection) {
7786
previousMeasureBlock.nextConnection.connect(measureBlock.previousConnection);

src/FlatEditor.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ function FlatEditor({
6363
})
6464
.then(()=> {
6565
console.log('loaded the following flatjson without throwing an error', flatJSON)
66+
return embed.getJSON().then((json) => {
67+
console.log('got the json we just loaded', json)
68+
console.log('expected vs actual', JSON.stringify(flatJSON)===JSON.stringify(json))
69+
console.log('expected vs actual', JSON.stringify(convertFlatJsonToMeasures(flatJSON))===JSON.stringify(convertFlatJsonToMeasures(json)))
70+
});
6671
})
6772
.catch((e) => {
6873
console.error("Flat.io Initialization Error:", e);

src/testing/testing.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,15 @@
6565
{
6666
"staff": "1",
6767
"voice": "1",
68-
"duration": "2",
68+
"duration": "4",
6969
"pitch": {
7070
"octave": "4",
7171
"step": "E"
7272
},
7373
"$adagio-location": {
7474
"timePos": 0
7575
},
76-
"type": "half"
77-
},
78-
{
79-
"staff": "1",
80-
"voice": "1",
81-
"duration": "2",
82-
"pitch": {
83-
"octave": "4",
84-
"step": "E"
85-
},
86-
"type": "half",
87-
"$adagio-location": {
88-
"timePos": 2
89-
}
76+
"type": "whole"
9077
}
9178
],
9279
"harmony": [],

0 commit comments

Comments
 (0)