## piano construal ## to make the finger frames match up between the staves gapBetweenStaves = 2* staveSpaceWidth; stave1KeySignature is dMajorKS; stave2KeySignature is dMajorKS; stave1KeySignature is currentKS; stave2KeySignature is currentKS; currentKS is cMajorKS; ## chosenKeys is a pun (!) - relates to keys on the keyboard! ## must be in chosen keys mode and set explicitly defined observable 'highlightedKeys' ## e.g. a triad highlightedKeys = ["C1", "E1", "G1"]; currPianoKey is findPianoKeyUnderMousePointer(mouseX, mouseY); currNoteNameInKey is noteNameInKey(currPianoKey, currentKS); currPianoKey = 44; highlightedKeys is [currNoteNameInKey]; currPianoKey = 88; ## top of the keyboard currPianoKey = 89; ## off the top of the keyboard, nothing is highlighted mouseOnKeyboard is (mouseX > 0) && (mouseX < 1040) && (mouseY > 205) && (mouseY < 340); currPianoKey is (!mouseOnKeyboard) ? 89: findPianoKeyUnderMousePointer(mouseX, mouseY); ## above attempt to highlight the piano key under the mouse pointer doesn't seem to work ## traverse keyboard in octaves currPianoKey is 1 + octave * 12; octave++; ## traverse keyboard in 5ths currPianoKey is 1 + fifth * 7; fifth++; ## exercise - highlight all the fifths from lowest A on piano to the highest ## do same with octaves ## compute the frequencies from the base frequency using multipliers ## well-tempered keyboard issue - all have assigned frequencies ## also can consider cycle-of-keys / harmonic sequence - overtones ## "the cycle of fifths" ## emulate different instruments by balancing overtones? ## issue to do with generating the audio output for arbitrary frequencies writeln(pow(1.5,12)); writeln(pow(2,7)); ## bug in finger frame button action - was responding to two changes to button clicked: proc stave1MoveFingerFrameUp : stave1FingerFrameUpButton_clicked { if (stave1FingerFrameUpButton_clicked) stave1FingerFrameBaseline = stave1FingerFrameBaseline + 0.5; } proc stave1MoveFingerFrameDown : stave1FingerFrameDownButton_clicked { if (stave1FingerFrameDownButton_clicked ) stave1FingerFrameBaseline = stave1FingerFrameBaseline - 0.5; } thumbColour = "red"; indexFingerColour = "yellow"; middleFingerColour = "#FF0080"; ringFingerColour = "#FFFF80"; littleFingerColour = "magenta"; stave1FingerFrameIsLSLSL is isInt(stave1FingerFrameBaseline); thumbColour is (stave1FingerFrameIsLSLSL) ? "red" : "yellow"; indexFingerColour is (stave1FingerFrameIsLSLSL) ? "yellow" : "red"; middleFingerColour is (stave1FingerFrameIsLSLSL) ? "red" : "yellow"; ringFingerColour is (stave1FingerFrameIsLSLSL) ? "yellow" : "red"; littleFingerColour is (stave1FingerFrameIsLSLSL) ? "red" : "yellow"; stavePicture is stave1Spaces // stave1Lines // stave2Spaces // stave2Lines // [stave1ClefImage, stave2ClefImage] // stave1FingerFrame // stave1FingerFrameUI;