Skip to content

Commit

Permalink
add handlers for OctaveUp/OctaveDown buttons. doesnt work very good
Browse files Browse the repository at this point in the history
  • Loading branch information
lucretiomsp committed Jan 31, 2025
1 parent 17bdcf4 commit ae552b5
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 33 deletions.
7 changes: 7 additions & 0 deletions CoypuIDE/ManifestCoypuIDE.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ ManifestCoypuIDE class >> ruleBlocWidthV1FalsePositive [
<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#ICPianoNoteElement #initializeEvents #false)) #'2025-01-08T21:49:26.541018+01:00') )
]

{ #category : 'code-critics' }
ManifestCoypuIDE class >> ruleModifiesCollectionRuleV1FalsePositive [

<ignoreForCoverage>
^ #(#(#(#RGMethodDefinition #(#TpPitchMode #handleKeyboardNotes #false)) #'2025-01-31T10:21:53.507124+01:00') )
]
16 changes: 10 additions & 6 deletions CoypuIDE/TbButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,17 @@ TbButton >> initializeEvents [
on: BlMouseDownEvent
do: [ :anEvent |
self toggle.
self callbackDown value. self callback value ]).
self isToggleable ifFalse: [
button addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent |

self callbackDown value.
self callback value ]).

button addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent |
self isToggleable ifFalse: [
self toggle.
self callBackUp value ]) ]

self callBackUp value ] ])
]

{ #category : 'initialization' }
Expand Down
10 changes: 8 additions & 2 deletions CoypuIDE/TpIdleMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ TpIdleMode >> handleNote_9 [
{ #category : 'action handling' }
TpIdleMode >> handleSwitchPitchMode [

self machine mode: (TpPitchMode new machine: machine; handleKeyboardNotes )
self machine mode: (TpPitchMode new
machine: machine;
handleKeyboardNotes).
self machine note_0 isToggleable: true.
self machine note_9 isToggleable: true.
]

{ #category : 'action handling' }
TpIdleMode >> handleSwitchTimeMode [

self machine mode: (TpTimeMode new machine: self machine )
self machine mode: (TpTimeMode new machine: self machine).
" self machine note_0 isToggleable: false.
self machine note_9 isToggleable: false"
]
49 changes: 37 additions & 12 deletions CoypuIDE/TpPitchMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,69 @@ TpPitchMode >> handleFunctionSwitch [
{ #category : 'action handling' }
TpPitchMode >> handleKeyboardNotes [

| octaveUp octaveDown |


self machine notesArray do: [ :key | "callbacks on mouseDown"
key callbackDown: [

octaveUp := (self machine note_0 value * 12).
octaveDown := (self machine note_9 value * -12).

self machine audioEngine
setValue:
(self machine noteNumbers at:
(self machine notesArray indexOf: key)) midiNoteToFreq
((self machine noteNumbers at:
(self machine notesArray indexOf: key)) + octaveUp
+ octaveDown) midiNoteToFreq
parameter: 'AcidNote'.
self machine audioEngine setValue: 1 parameter: 'AcidGate'.
(self machine noteNumbers at:
(self machine notesArray indexOf: key)) traceCr .
"add notes to temporary pattern"
self tempNotesPattern add: (self machine noteNumbers at: (self machine notesArray indexOf: key)).
"increment index"
tempNotesPatternIndex := self tempNotesPatternIndex + 1.
tempNotesPattern asString traceCr .

].
(self machine notesArray indexOf: key)) traceCr.
"add notes to temporary pattern"
self tempNotesPattern add: ((self machine noteNumbers at:
(self machine notesArray indexOf: key)) + octaveUp + octaveDown).
"increment index"
tempNotesPatternIndex := self tempNotesPatternIndex + 1.
( octaveUp + octaveDown ) asString traceCr ].

"On mouseUp"
key callBackUp: [
self machine audioEngine setValue: 0 parameter: 'AcidGate' ] ]
]

{ #category : 'action handling' }
TpPitchMode >> handleSwitchPitchMode [
TpPitchMode >> handleNote_0 [

"do nothing"
]

{ #category : 'action handling' }
TpPitchMode >> handleNote_9 [
"do nothing"


]

{ #category : 'action handling' }
TpPitchMode >> handleSwitchPitchMode [

self machine mode: (TpIdleMode new machine: self machine)
self machine mode: (TpIdleMode new machine: self machine).
self machine note_0 isToggleable: false.
self machine note_9 isToggleable: false
]

{ #category : 'action handling' }
TpPitchMode >> handleSwitchTimeMode [


self machine mode: (TpTimeMode new machine: self machine).
"switch the UI toggle"
self machine widget_PitchMode switch toggle.
"switch the UI led"
self machine widget_PitchMode indicator toggle.

self machine note_0 isToggleable: false.
self machine note_9 isToggleable: false
]

{ #category : 'initialization' }
Expand Down
59 changes: 46 additions & 13 deletions CoypuIDE/TpTimeMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,102 @@ Class {
#superclass : 'TpMode',
#instVars : [
'tempGatesPattern',
'tempGatesPatternIndex'
'tempGatesPatternIndex',
'tempGateTimesPattern'
],
#category : 'CoypuIDE-Acid',
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'as yet unclassified' }
{ #category : 'action handling' }
TpTimeMode >> handleFunctionSwitch [

(Performance uniqueInstance at: #Acid) gates: self tempGatesPattern asArray .

"switch the UI toggle"
(Performance uniqueInstance at: #Acid)
gates: self tempGatesPattern asArray;
gateTimes: self tempGateTimesPattern asArray.
self machine mode: (TpIdleMode new machine: self machine).
"switch the UI toggle"
self machine widget_TimeMode switch toggle.
"switch the UI led"
self machine widget_TimeMode indicator toggle
]

{ #category : 'as yet unclassified' }
TpTimeMode >> handleKeyboardNotes [

"do nothoing"
]

{ #category : 'action handling' }
TpTimeMode >> handleNote_0 [
"note_0 insert a tie, it means, it modfies the previous gateTime to 1 and increment the index into the tempGatesOatternIndex"

| currentStep previousStep |

currentStep := self tempGatesPatternIndex.
previousStep := currentStep - 1.
self tempGateTimesPattern add: 1.
tempGatesPatternIndex := currentStep + 1
]

{ #category : 'action handling' }
TpTimeMode >> handleNote_100 [
"note_9 insert a gate"
"note_9 insert a gate with 80% gateTime"

self tempGatesPattern add: 0.
tempGatesPatternIndex := self tempGatesPatternIndex + 1.

self tempGateTimesPattern add: 0.8.
tempGatesPatternIndex := self tempGatesPatternIndex + 1
]

{ #category : 'action handling' }
TpTimeMode >> handleNote_9 [
"note_9 insert a gate"

self tempGatesPattern add: 1.
tempGatesPatternIndex := self tempGatesPatternIndex + 1
self tempGateTimesPattern add: 0.8.
tempGatesPatternIndex := self tempGatesPatternIndex + 1
]

{ #category : 'action handling' }
TpTimeMode >> handleSwitchPitchMode [
"change the state"

self machine mode: (TpPitchMode new machine: machine; handleKeyboardNotes).
self machine mode: (TpPitchMode new
machine: machine;
handleKeyboardNotes).
"switch the UI toggle"
self machine widget_TimeMode switch toggle.
"switch the UI led"
self machine widget_TimeMode toggle
self machine widget_TimeMode toggle.
self machine note_0 isToggleable: true.
self machine note_9 isToggleable: true.
]

{ #category : 'action handling' }
TpTimeMode >> handleSwitchTimeMode [


self machine mode: (TpIdleMode new machine: self machine).
tempGatesPattern := OrderedCollection new.
tempGatesPatternIndex := 1.

self machine note_0 isToggleable: false.
self machine note_9 isToggleable: false
]

{ #category : 'initialization' }
TpTimeMode >> initialize [

tempGatesPattern := OrderedCollection new.
tempGateTimesPattern := OrderedCollection new.
tempGatesPatternIndex := 1
]

{ #category : 'accessing' }
TpTimeMode >> tempGateTimesPattern [

^ tempGateTimesPattern
]

{ #category : 'accessing' }
TpTimeMode >> tempGatesPattern [

Expand Down

0 comments on commit ae552b5

Please sign in to comment.