-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheVY1.11.cs
executable file
·1882 lines (1798 loc) · 50.5 KB
/
eVY1.11.cs
1
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 15 August 2014 at 1:49:01 am'!Object subclass: #ScratchNotePlayer instanceVariableNames: 'midiPort channel volume midiKey snd ' classVariableNames: 'KanaPADictionary PAKanaDictionary ' poolDictionaries: '' category: 'Scratch-Sound'!!CommandBlockMorph methodsFor: 'menus' stamp: 'ka 12/12/2013 22:03'!rightButtonMenu | menu sFrame choice spec | menu _ CustomMenu new. menu add: 'help' action: #presentHelpScreen. (owner isKindOf: ScratchBlockPaletteMorph) ifFalse: [ menu addLine. (#(+ - * / \\) includes: selector) ifTrue: [ #(+ - * / mod) with: #(+ - * / \\) do: [:s :op | menu add: s action: op]]. (#(< = >) includes: selector) ifTrue: [ #(< = >) do: [:op | menu add: op action: op]]. (#(& |) includes: selector) ifTrue: [ #(and or) with: #(& |) do: [:s :op | menu add: s action: op]]. menu addLine. menu add: 'duplicate' action: #duplicate. (self owner isKindOf: BlockMorph) ifFalse: [ "can't yet delete a blocks inside a script" menu add: 'delete' action: #delete]]. sFrame _ self ownerThatIsA: ScratchFrameMorph. (sFrame notNil and: [#(sensor: sensorPressed:) includes: selector]) ifTrue: [ menu addLine. menu add: 'show ScratchBoard watcher' action: #showSensorBoard. sFrame workPane scratchServer ifNil: [menu add: 'enable remote sensor connections' action: #enableRemoteSensors] ifNotNil: [menu add: 'disable remote sensor connections' action: #exitScratchSession]]. (sFrame notNil and: [#(drum:duration:elapsed:from: noteOn:duration:elapsed:from:) includes: selector]) ifTrue: [ menu addLine. menu add: 'play via MIDI' action: #openMIDI]. DebugMenu ifTrue: [ menu addLine. menu add: 'show tuples' action: #showTuples]. (choice _ menu localize; startUp) ifNil: [^ self]. (#(presentHelpScreen duplicate delete) includes: choice) ifTrue: [^ self perform: choice]. choice = #showSensorBoard ifTrue: [sFrame showSensorBoard. ^ self]. choice = #enableRemoteSensors ifTrue: [sFrame enableRemoteSensors. ^ self]. choice = #exitScratchSession ifTrue: [sFrame exitScratchSession. ^ self]. choice = #showTuples ifTrue: [^ self showTuples]. choice = #openMIDI ifTrue: [sFrame openMIDI. ^ self]. "change operator" spec _ '%n ', choice, ' %n'. '\\' = choice ifTrue: [spec _ ScratchTranslator translationFor: '%n mod %n']. '&' = choice ifTrue: [spec _ ScratchTranslator translationFor: '%b and %b']. '|' = choice ifTrue: [spec _ ScratchTranslator translationFor: '%b or %b']. self commandSpec: spec. self selector: choice.! !!ScratchNotePlayer methodsFor: 'playing' stamp: 'ka 8/15/2014 01:40'!sendPhoneticSymbol: phoneticString midiPort ifNotNil: [midiPort midiOutput: #(240 67 121 9 0 80 16 ) asByteArray; midiOutput: phoneticString asByteArray; midiOutput: #(0 247 ) asByteArray]! !!ScratchNotePlayer class methodsFor: 'initialize-release' stamp: 'ka 7/11/2014 14:28'!initialize "ScratchNotePlayer initialize" | kanas pas | KanaPADictionary _ Dictionary new. kanas _ OrderedCollection new add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 130; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 129; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 131; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 132; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 132; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 133; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 134; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 134; at: 4 put: 227; at: 5 put: 129; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 134; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 136; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 137; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 138; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 140; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 139; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 139; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 142; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; yourself); add: ((ByteArray new: 9) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; at: 7 put: 227; at: 8 put: 129; at: 9 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 142; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 9) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; at: 7 put: 227; at: 8 put: 130; at: 9 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 142; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 9) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; at: 7 put: 227; at: 8 put: 130; at: 9 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 142; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 9) at: 1 put: 227; at: 2 put: 129; at: 3 put: 141; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; at: 7 put: 227; at: 8 put: 130; at: 9 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 144; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 143; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 143; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 146; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 145; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 145; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 148; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 147; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 147; at: 4 put: 227; at: 5 put: 130; at: 6 put: 156; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 150; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 149; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 152; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 151; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 152; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 151; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 152; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 151; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 152; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 151; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 152; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 151; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 154; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 153; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 154; at: 4 put: 227; at: 5 put: 129; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 153; at: 4 put: 227; at: 5 put: 129; at: 6 put: 131; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 156; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 155; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 158; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 157; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 160; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 159; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 162; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 161; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 161; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 161; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 161; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 161; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 165; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 164; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 164; at: 4 put: 227; at: 5 put: 129; at: 6 put: 131; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 167; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 166; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 167; at: 4 put: 227; at: 5 put: 129; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 167; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 169; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 168; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 170; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 171; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 171; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 171; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 171; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 171; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 172; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 173; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 174; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 176; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 175; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 177; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 179; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 178; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 180; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 179; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 178; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 180; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 179; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 178; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 180; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 179; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 178; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 180; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 179; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 178; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 180; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 182; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 183; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 181; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 181; at: 4 put: 227; at: 5 put: 129; at: 6 put: 129; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 181; at: 4 put: 227; at: 5 put: 129; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 181; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 181; at: 4 put: 227; at: 5 put: 129; at: 6 put: 137; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 181; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 185; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 184; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 186; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 188; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 187; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 189; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 190; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 129; at: 3 put: 191; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 191; at: 4 put: 227; at: 5 put: 129; at: 6 put: 135; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 191; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 191; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 129; at: 3 put: 191; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 128; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 129; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 130; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 132; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 134; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 136; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 137; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 138; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 130; at: 3 put: 138; at: 4 put: 227; at: 5 put: 130; at: 6 put: 131; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 130; at: 3 put: 138; at: 4 put: 227; at: 5 put: 130; at: 6 put: 133; yourself); add: ((ByteArray new: 6) at: 1 put: 227; at: 2 put: 130; at: 3 put: 138; at: 4 put: 227; at: 5 put: 130; at: 6 put: 135; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 139; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 140; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 141; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 143; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 146; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 147; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 147; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 147; yourself); add: ((ByteArray new: 3) at: 1 put: 227; at: 2 put: 130; at: 3 put: 147; yourself); add: ((ByteArray new: 3) at: 1 put: 229; at: 2 put: 144; at: 3 put: 184; yourself); add: ((ByteArray new: 3) at: 1 put: 229; at: 2 put: 144; at: 3 put: 184; yourself); add: ((ByteArray new: 3) at: 1 put: 229; at: 2 put: 144; at: 3 put: 184; yourself); add: ((ByteArray new: 3) at: 1 put: 229; at: 2 put: 144; at: 3 put: 144; yourself); add: ((ByteArray new: 3) at: 1 put: 229; at: 2 put: 144; at: 3 put: 144; yourself); yourself. pas _ OrderedCollection new add: ((ByteArray new: 1) at: 1 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 104; at: 2 put: 92; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 104; at: 2 put: 92; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 1) at: 1 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 106; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 104; at: 2 put: 92; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 1) at: 1 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 119; at: 2 put: 32; at: 3 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 119; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 1) at: 1 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 104; at: 2 put: 92; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 104; at: 2 put: 92; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 1) at: 1 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 103; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 107; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 78; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 103; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 107; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 78; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 78; at: 2 put: 39; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 103; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 107; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 78; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 103; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 107; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 78; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 103; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 4) at: 1 put: 107; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 4) at: 1 put: 78; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 103; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 107; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 78; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 103; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 107; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 78; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 103; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 107; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 78; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 122; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 115; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 90; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 83; at: 2 put: 32; at: 3 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 90; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 83; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 90; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 83; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 90; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 83; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 90; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 83; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 122; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 115; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 122; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 115; at: 2 put: 32; at: 3 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 122; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 115; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 122; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 115; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 100; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 116; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 100; at: 2 put: 32; at: 3 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 83; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 83; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 83; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 83; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 83; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 100; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 115; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 116; at: 2 put: 115; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 100; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 116; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 100; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 100; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 116; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 110; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 74; at: 2 put: 32; at: 3 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 74; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 74; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 74; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 74; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 110; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 110; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 110; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 104; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 112; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 98; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 3) at: 1 put: 67; at: 2 put: 32; at: 3 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 98; at: 2 put: 39; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 67; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 39; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 98; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 67; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 98; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 67; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 98; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 67; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 112; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 92; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 92; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 5) at: 1 put: 112; at: 2 put: 92; at: 3 put: 39; at: 4 put: 32; at: 5 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 92; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 112; at: 2 put: 92; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 5) at: 1 put: 112; at: 2 put: 92; at: 3 put: 39; at: 4 put: 32; at: 5 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 104; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 112; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 104; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 112; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 109; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 109; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 109; at: 2 put: 39; at: 3 put: 32; at: 4 put: 101; yourself); add: ((ByteArray new: 4) at: 1 put: 109; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 109; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 109; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 109; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 109; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 109; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 106; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 106; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 106; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 52; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 52; at: 2 put: 39; at: 3 put: 32; at: 4 put: 105; yourself); add: ((ByteArray new: 4) at: 1 put: 52; at: 2 put: 39; at: 3 put: 32; at: 4 put: 97; yourself); add: ((ByteArray new: 4) at: 1 put: 52; at: 2 put: 39; at: 3 put: 32; at: 4 put: 77; yourself); add: ((ByteArray new: 4) at: 1 put: 52; at: 2 put: 39; at: 3 put: 32; at: 4 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 52; at: 2 put: 32; at: 3 put: 77; yourself); add: ((ByteArray new: 3) at: 1 put: 52; at: 2 put: 32; at: 3 put: 101; yourself); add: ((ByteArray new: 3) at: 1 put: 52; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 3) at: 1 put: 119; at: 2 put: 32; at: 3 put: 97; yourself); add: ((ByteArray new: 3) at: 1 put: 119; at: 2 put: 32; at: 3 put: 111; yourself); add: ((ByteArray new: 1) at: 1 put: 78; yourself); add: ((ByteArray new: 1) at: 1 put: 110; yourself); add: ((ByteArray new: 2) at: 1 put: 78; at: 2 put: 39; yourself); add: ((ByteArray new: 2) at: 1 put: 78; at: 2 put: 92; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 114; at: 3 put: 49; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 114; at: 3 put: 50; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 114; at: 3 put: 51; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 114; at: 3 put: 52; yourself); add: ((ByteArray new: 3) at: 1 put: 98; at: 2 put: 114; at: 3 put: 53; yourself); yourself. 1 to: kanas size do: [:index | KanaPADictionary at: (UTF8 withAll: (kanas at: index)) asUTF32 put: (UTF8 withAll: (pas at: index))]! !!ScratchNotePlayer class methodsFor: 'utilities' stamp: 'ka 7/11/2014 13:09'!paAt: kanaString ^ KanaPADictionary at: kanaString asUTF32 ifAbsent: [^ String new]! !!ScratchSpriteLibraryMorph methodsFor: 'dropping/grabbing' stamp: 'ka 7/17/2014 01:02'!acceptDroppingMorph: aMorph event: evt "This method allows re-ordering of sprites in the sprite library area." | insertAfter libraryItems spriteLibrary movedThumbnail mostOverlap mostOverlapIndex sf | ((aMorph isKindOf: LibraryItemMorph) and: [(spriteLibrary _ self ownerThatIsA: ScratchSpriteLibraryMorph) notNil]) ifFalse: [^ super acceptDroppingMorph: aMorph event: evt]. "Set the new position of the morph that just moved" movedThumbnail _ self submorphs detect: [:m | (m target == aMorph target)] ifNone: [^ self]. libraryItems _ self submorphs select: [:m | (m bounds intersects: aMorph bounds) and: [(m ~~ aMorph)]]. "Select the thumbnail with the most overlap with movedThumbnail" libraryItems _ libraryItems sort: [:m1 :m2 | ((m1 bounds intersect: aMorph bounds) area < (m2 bounds intersect: aMorph bounds) area)]. movedThumbnail position: aMorph position. aMorph delete. libraryItems isEmpty ifTrue: [insertAfter _ nil] "end of list" ifFalse: [ mostOverlap _ libraryItems last. (movedThumbnail center x > mostOverlap center x) ifTrue: [ mostOverlapIndex _ self submorphs indexOf: mostOverlap. self submorphCount == mostOverlapIndex ifTrue: [insertAfter _ nil] ifFalse: [insertAfter _ self submorphs at: (mostOverlapIndex + 1)]] ifFalse: [insertAfter _ mostOverlap]]. spriteLibrary insertItem: movedThumbnail before: insertAfter. sf _ self ownerThatIsA: ScratchFrameMorph. sf ifNotNil: [ sf workPane updateSpritesList ]. sf workPane closeMIDI! !!ScriptableScratchMorph methodsFor: 'sound ops' stamp: 'ka 7/11/2014 14:33'!sendKana: kanaString self sendPhoneticSymbol: (ScratchNotePlayer paAt: kanaString asUTF32)! !!ScriptableScratchMorph methodsFor: 'sound ops' stamp: 'ka 12/13/2013 01:14'!sendPhoneticSymbol: phoneticString | stage player | (stage _ self ownerThatIsA: ScratchStageMorph) ifNil: [^ ScratchNotePlayer new]. (player _ stage notePlayerFor: self) ifNil: [^ ScratchNotePlayer new]. ^ player copy sendPhoneticSymbol: phoneticString! !!ScriptableScratchMorph methodsFor: 'blocks' stamp: 'ka 7/11/2014 14:58'!defaultArgsFor: blockSpec "Answer the default argument for the given block specification." | defaultArgs stage sel currentSize list | defaultArgs _ blockSpec copyFrom: 4 to: blockSpec size. "may be empty" stage _ self ownerThatIsA: ScratchStageMorph. sel _ (blockSpec at: 3) asSymbol. #gotoX:y: = sel ifTrue: [ defaultArgs _ Array with: self referencePosition x rounded with: self referencePosition y rounded]. #glideSecs:toX:y:elapsed:from: = sel ifTrue: [ defaultArgs _ Array with: 1 with: self referencePosition x rounded with: self referencePosition y rounded]. #motor:direction: = self ifTrue: [ defaultArgs _ Array with: 'reverse' localized with: 'this way' localized with: 'that way']. #setSizeTo: = sel ifTrue: [ currentSize _ (100.0 * (self scalePoint x max: self scalePoint y)) rounded. defaultArgs _ Array with: currentSize]. #getAttribute:of: = sel ifTrue: [ (stage _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [ list _ stage submorphs select: [:m | m isKindOf: ScratchSpriteMorph]. list sort: [:s1 :s2 | s1 objName asLowercase < s2 objName asLowercase]. list size > 0 ifTrue: [defaultArgs _ Array with: 'x position' with: list first] ifFalse: [defaultArgs _ Array with: 'background #' with: stage]] ifNil:[defaultArgs _ Array with: 'x position' with: self]]. #concatenate:with: = sel ifTrue: [ defaultArgs _ Array with: 'hello ' localized with: 'world' localized]. #doAsk = sel ifTrue: [ defaultArgs _ Array with: 'What''s your name?' localized]. #letter:of: = sel ifTrue: [ defaultArgs _ Array with: 1 with: 'world' localized]. #stringLength: = sel ifTrue: [ defaultArgs _ Array with: 'world' localized]. #say:duration:elapsed:from: = sel ifTrue: [ defaultArgs _ Array with: 'Hello!!' localized with: 2]. #say: = sel ifTrue: [ defaultArgs _ Array with: 'Hello!!' localized]. #think:duration:elapsed:from: = sel ifTrue: [ defaultArgs _ Array with: 'Hmm...' localized with: 2]. #think: = sel ifTrue: [ defaultArgs _ Array with: 'Hmm...' localized]. (#(lookLike: showBackground:) includes: sel) ifTrue: [ defaultArgs _ Array with: self costumeNames last]. (#(playSound: doPlaySoundAndWait) includes: sel) ifTrue: [ list _ self soundNames. defaultArgs _ list size <= 2 ifTrue: [Array with: ''] ifFalse: [Array with: (list at: (list size - 2))]]. (#(broadcast: doBroadcastAndWait) includes: sel) ifTrue: [ stage ifNotNil: [defaultArgs _ Array with: stage defaultEventName]]. (#(append:toList: deleteLine:ofList: insert:at:ofList:) includes: sel) ifTrue: [ defaultArgs size >= 1 ifTrue: [ defaultArgs at: 1 put: (defaultArgs at: 1) localized]]. (#(append:toList: deleteLine:ofList: getLine:ofList: insert:at:ofList: lineCountOfList:) includes: sel) ifTrue: [ defaultArgs _ defaultArgs copyWith: self defaultListName]. #setLine:ofList:to: = sel ifTrue: [ defaultArgs size >= 3 ifTrue: [ defaultArgs at: 2 put: self defaultListName. defaultArgs at: 3 put: (defaultArgs at: 3) localized]]. #appendLettersOf:toList: = sel ifTrue: [ defaultArgs size >= 2 ifTrue: [ defaultArgs at: 1 put: (defaultArgs at: 1) localized. defaultArgs at: 2 put: self defaultListName]]. #list:contains: = sel ifTrue: [ defaultArgs size >= 2 ifTrue: [ defaultArgs at: 1 put: self defaultListName. defaultArgs at: 2 put: (defaultArgs at: 2) localized]]. #sendKana: = sel ifTrue: [ defaultArgs _ Array with: 'kanaSample' localized]. ^ defaultArgs! !!ScratchStageMorph methodsFor: 'scratch processes/events' stamp: 'ka 12/14/2013 00:02'!stopAll "Stop all processes and make sure I am stepping." | sFrame | World hands do: [:h | h newKeyboardFocus: nil; clearUnclaimedKeystrokes]. Sensor clearKeystate. SoundPlayer stopPlayingAll. self class stopSoundRecorder. self stopAllProcesses. self stopAsks. self deleteAllClones. self midiAllNotesOff. WeDoPlugin resetWeDo. self allMorphsDo: [:m | (m isKindOf: ScriptableScratchMorph) ifTrue: [m stopPlaying]]. self stopPlaying. (sFrame _ self ownerThatIsA: ScratchFrameMorph) ifNotNil: [ sFrame scriptsPane allMorphsDo: [:m | (m respondsTo: #stop) ifTrue: [m stop]. (m respondsTo: #litUp:) ifTrue: [m litUp: false]]. World startSteppingSubmorphsOf: sFrame]. World startSteppingSubmorphsOf: self.! !!ScratchStageMorph methodsFor: 'midi' stamp: 'ka 7/16/2014 21:52'!midiAllNotesOff "If the MIDI port is open, send an 'all notes off' command on every channel." ScratchNotePlayer allInstances do: [:player | player noteOff]. midiPort ifNil: [^ self]. midiPort ensureOpenIfFail: [self closeMIDI]. notePlayerDict do: [:player | player noteOff].! !!ScratchStageMorph methodsFor: 'midi' stamp: 'ka 7/17/2014 00:48'!notePlayerFor: aScratchObject "Answer a note player for the given object, creating one if necessary. Open the MIDI port if necessary." | deletedMorphs channelUsage ch newCh newPlayer spriteThumbnails | midiPort ifNil: [self tryToOpenMidiPort]. (notePlayerDict includesKey: aScratchObject) ifTrue: [ ^ notePlayerDict at: aScratchObject]. "remove deleted morphs from the note player dictionary" deletedMorphs _ notePlayerDict keys select: [:m | m owner isNil]. deletedMorphs do: [:m | notePlayerDict removeKey: m]. "find the channel used by the fewest objects" channelUsage _ Array new: 16 withAll: 0. channelUsage at: 10 put: 1000000. "make sure channel 10 (drums) is not chosen" channelUsage at: 1 put: 1000000. "make sure channel 1 (vocaloid) is not chosen" notePlayerDict do: [:player | ch _ player channel. channelUsage at: ch put: (channelUsage at: ch) + 1]. newCh _ channelUsage indexOf: channelUsage min. spriteThumbnails _ self owner libraryPane spriteThumbnails. spriteThumbnails isEmpty ifFalse: [ spriteThumbnails first target == aScratchObject ifTrue: [newCh _ 1]]. newPlayer _ ScratchNotePlayer new channel: newCh; midiPort: midiPort; instrument: 1. notePlayerDict at: aScratchObject put: newPlayer. ^ newPlayer! !!ScratchStageMorph methodsFor: 'midi' stamp: 'ka 7/21/2014 01:33'!tryToOpenMidiPort "Attempt to open the MIDI port. First try the port selected by the user, if any. If that port number is not a MIDI output port, try to find another port number. If all measures fail, leave midiPort set to nil." | possiblePorts dir portNum | "Smalltalk isUnix ifTrue: [midiPort _ nil. ^ self]." possiblePorts _ (0 to: SimpleMIDIPort primPortCount - 1) select: [:i | dir _ SimpleMIDIPort primPortDirectionalityOf: i. (dir = 2) | (dir = 3)]. "out or in/out port" possiblePorts size = 0 ifTrue: [midiPort _ nil. ^ self]. "no midi ports" (possiblePorts includes: midiPortNum) ifTrue: [portNum _ midiPortNum] "use the port requested by the user" ifFalse: [portNum _ possiblePorts last]. "use the first available port" [midiPort _ SimpleMIDIPort openOnPortNumber: portNum] ifError: [midiPort _ nil].! !!ScriptableScratchMorph class methodsFor: 'block specs' stamp: 'ka 7/11/2014 15:02'!blockSpecs "Answer a collection of block specifications for the blocks that are common to all objects. Block specificatons (Arrays) are interspersed with category names (Strings). A block specification is an Array of the form: (<block spec string> <block type> <selector> [optional initial argument values]). Explanation of flags: - no flags b boolean reporter c c-shaped block containing a sequence of commands (always special form) r reporter s special form command with its own evaluation rule t timed command, like wait or glide E message event hat K key event hat M mouse-click event hat S start event hat W when <condition> hat (obsolete)" | blocks | blocks _ #( 'control' ('when %m clicked' S -) ('when %k key pressed' K -) ('when %m clicked' M -) - ('wait %n secs' t wait:elapsed:from: 1) - ('forever' c doForever) ('repeat %n' c doRepeat 10) - ('broadcast %e' - broadcast:) ('broadcast %e and wait' s doBroadcastAndWait) ('when I receive %e' E -) - ('forever if %b' c doForeverIf) ('if %b' c doIf) ('if %b' c doIfElse) ('wait until %b' s doWaitUntil) ('repeat until %b' c doUntil) - ('stop script' s doReturn) ('stop all' - stopAll) 'operators' ('%n + %n' r + - -) ('%n - %n' r - - -) ('%n * %n' r * - -) ('%n / %n' r / - -) - ('pick random %n to %n' r randomFrom:to: 1 10) - ('%s < %s' b < '' '') ('%s = %s' b = '' '') ('%s > %s' b > '' '') - ('%b and %b' b &) ('%b or %b' b |) ('not %b' b not) - ('join %s %s' r concatenate:with: 'hello ' 'world') ('letter %n of %s' r letter:of: 1 'world') ('length of %s' r stringLength: 'world') - ('%n mod %n' r \\ - -) ('round %n' r rounded -) - ('%f of %n' r computeFunction:of: 'sqrt' 10) 'sound' ('play sound %S' - playSound:) ('play sound %S until done' s doPlaySoundAndWait) ('stop all sounds' - stopAllSounds) - ('play drum %D for %n beats' t drum:duration:elapsed:from: 48 0.2) ('rest for %n beats' t rest:elapsed:from: 0.2) - ('play note %N for %n beats' t noteOn:duration:elapsed:from: 60 0.5) ('set instrument to %I' - midiInstrument: 1) ('send phonetic symbol %s' - sendPhoneticSymbol: 'p'' o') ('send kana %s' - sendKana: 'aiueo') - ('change volume by %n' - changeVolumeBy: -10) ('set volume to %n%' - setVolumeTo: 100) ('volume' r volume) - ('change tempo by %n' - changeTempoBy: 20) ('set tempo to %n bpm' - setTempoTo: 60) ('tempo' r tempo) 'motor' ('motor on for %n secs' t motorOnFor:elapsed:from: 1) ('motor on' - allMotorsOn) ('motor off' - allMotorsOff) ('motor power %n' - startMotorPower: 100) ('motor direction %W' - setMotorDirection: 'this way') 'variables' ('show variable %v' - showVariable:) ('hide variable %v' - hideVariable:) 'list' ('add %s to %L' - append:toList: 'thing') - ('delete %y of %L' - deleteLine:ofList: 1) ('insert %s at %i of %L' - insert:at:ofList: 'thing' 1) ('replace item %i of %L with %s' - setLine:ofList:to: 1 'list' 'thing') - ('item %i of %L' r getLine:ofList: 1) ('length of %L' r lineCountOfList:) ('%L contains %s' b list:contains: 'list' 'thing') ). ^ blocks, self obsoleteBlockSpecs! !ScratchNotePlayer initialize!!ScratchNotePlayer class reorganize!('initialize-release' initialize)('utilities' paAt:)!Object subclass: #ScratchNotePlayer instanceVariableNames: 'midiPort channel volume midiKey snd ' classVariableNames: 'KanaPADictionary ' poolDictionaries: '' category: 'Scratch-Sound'!