Skip to content

Commit 718b80d

Browse files
Organization
1 parent 542baed commit 718b80d

28 files changed

+40
-708
lines changed

src/App.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useState } from 'react';
22
import './App.css'
33
import CompositionBlocks from './CompositionBlocks';
4-
// import exampleJson from './example';
54
import exampleJson from './threeNotes';
65
import FlatEditor from './FlatEditor';
76

src/BlocklyJsonFunctions.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,44 @@ function isValidRest(note){
229229
return note.rest && !note.pitch;
230230
}
231231

232+
// Imported from old functions blockly-setup.js
232233

233-
export { generateBlocklyJson, convertFlatJsonToMeasures, updateFlatJsonNotes, parseBlocklyJSON, validFlatJSON};
234+
function newBlocklyBlockForNote(currWork, noteObj) {
235+
const duration = noteObj.type;
236+
const noteString = blocklyNoteFromMusicXMLNote(noteObj);
237+
const newB = currWork.newBlock('play_sound', null); // FIXME? why is this null?
238+
239+
if (noteString === REST_STR) {
240+
newB.setFieldValue('rest', 'STEP');
241+
newB.setFieldValue('rest', 'OCTAVE');
242+
} else {
243+
newB.setFieldValue(noteObj.pitch.octave, 'OCTAVE');
244+
newB.setFieldValue(noteObj.pitch.step, 'STEP');
245+
}
246+
newB.setFieldValue(duration, 'DURATION');
247+
248+
newB.initSvg();
249+
return newB;
250+
}
251+
252+
function buildToolBox() {
253+
const JSONToolbox = {
254+
kind: 'categoryToolbox',
255+
contents: [
256+
{
257+
kind: 'category',
258+
name: 'Notes',
259+
colour: 210,
260+
contents: [
261+
{ kind: 'block', type: 'play_sound' },
262+
{ kind: 'block', type: 'measure' }, // Add the measure block here
263+
],
264+
},
265+
],
266+
};
267+
// console.log('JSONToolbox', JSONToolbox);
268+
return JSONToolbox;
269+
}
270+
271+
272+
export { generateBlocklyJson, convertFlatJsonToMeasures, updateFlatJsonNotes, parseBlocklyJSON, validFlatJSON, newBlocklyBlockForNote, buildToolBox};

src/CompositionBlocks.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useCallback, useEffect, useRef, useState } from 'react';
2-
// import { BlocklyWorkspace } from 'react-blockly';
32
import BlocklyWorkspace from './BlocklyWorkspace';
43
// Old Functions
54
import { buildToolBox, notesFromJSON, blocklyNoteFromMusicXMLNote, newBlocklyBlockForNote, extractMeasures, recreateMusicJSON } from './blockly-setup';
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)