Skip to content

Commit

Permalink
simple notes patternwrite works on Tp33
Browse files Browse the repository at this point in the history
  • Loading branch information
lucretiomsp committed Jan 27, 2025
1 parent 4e59b1e commit 8381530
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 51 deletions.
8 changes: 5 additions & 3 deletions CoypuIDE/TbButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ TbButton >> callBackUp: aBlock [
{ #category : 'accessing' }
TbButton >> callback [

^ callback
^ callback ifNil: [ callback := [ ] ]
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -217,11 +217,13 @@ TbButton >> initializeEvents [
on: BlMouseDownEvent
do: [ :anEvent |
self toggle.
self callbackDown value ]).
self callbackDown value. self callback value ]).
self isToggleable ifFalse: [
button addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent | self toggle. self callBackUp value ]) ]
do: [ :anEvent |
self toggle.
self callBackUp value ]) ]
]

{ #category : 'initialization' }
Expand Down
29 changes: 11 additions & 18 deletions CoypuIDE/TbWidget_Function.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,17 @@ TbWidget_Function >> initialize [
{ #category : 'initialization' }
TbWidget_Function >> initializeEvents [

switch
childrenDo: [ :i|
i addEventHandler: (BlEventHandler
on: BlMouseDownEvent
do: [ :anEvent |
self toggleValue.
self indicator toggle.
]).
i addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent |
self toggleValue.
self indicator toggle.
]).

].


switch childrenDo: [ :i |
i addEventHandler: (BlEventHandler
on: BlMouseDownEvent
do: [ :anEvent |
self toggleValue.
self indicator toggle . ]).
i addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent |
self toggleValue.
self indicator toggle ]) ]
]

{ #category : 'initialization' }
Expand Down
48 changes: 27 additions & 21 deletions CoypuIDE/Tp33.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,7 @@ Tp33 >> initializeNotesArray [
{ #category : 'initialization' }
Tp33 >> initializeNotesCallbacks [

| noteNumbers |
noteNumbers := #( 60 61 62 63 64 65 66 67 68 69 70 71 72 73 ).

notesArray do: [ :key | "callbacks on mouseDown"
key callbackDown: [
audioEngine
setValue:
(noteNumbers at: (notesArray indexOf: key)) midiNoteToFreq
parameter: 'AcidNote'.
audioEngine setValue: 1 parameter: 'AcidGate'.
(noteNumbers at: (notesArray indexOf: key)) midiNoteToFreq traceCr ].

"On mouseUp"
key callBackUp: [ audioEngine setValue: 0 parameter: 'AcidGate' ] ]
self mode handleKeyboardNotes.
]

{ #category : 'initialization' }
Expand All @@ -152,16 +139,20 @@ Tp33 >> initializeWidgetsCallbacks [
ifTrue: [ Performance uniqueInstance playFor: 88 bars ]
ifFalse: [ Performance uniqueInstance stop ] ].
"we change the state and toggle the other button on the UI "
self widget_PitchMode callback: [
self mode handleSwitchPitchMode.
].
self widget_PitchMode callback: [ self mode handleSwitchPitchMode ].
"ENTER TIME MODE"
self widget_TimeMode switch callback: [
self mode handleSwitchTimeMode.
].
self mode handleSwitchTimeMode ].
"we need to access the button inside the widget"
(self widget_PatternClear children at: 4) callback: [
16 rests to: #Acid ]
self widget_PatternClear switch callback: [ 16 rests to: #Acid ].

"note_9 , note_0 and note_100 behaviour depends on the mode"
self note_9 callback: [ self mode handleNote_9 ].
self note_0 callback: [ self mode handleNote_0 ].
self note_100 callback: [ self mode handleNote_100 ].

"function button"
self widget_Function switch callback: [ self mode handleFunctionSwitch ]
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -206,6 +197,14 @@ audioEngine := aDsp.
self initialize.
]

{ #category : 'accessing' }
Tp33 >> noteNumbers [

"MIDI NOTE NUMBERS at CENTER POSITION"

^ #( 48 49 50 51 52 53 54 55 56 57 58 59 60 )
]

{ #category : 'accessing' }
Tp33 >> notesArray [

Expand All @@ -218,6 +217,13 @@ Tp33 >> notesArray: anArrayOfBlElements [
notesArray := anArrayOfBlElements
]

{ #category : 'as yet unclassified' }
Tp33 >> octaves [
"Tp33 has 3 octaves, they can be changed with the transpose switches both for execution and writing"
^ self shouldBeImplemented

]

{ #category : 'accessing' }
Tp33 >> patternPlay [

Expand Down
46 changes: 44 additions & 2 deletions CoypuIDE/TpIdleMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,53 @@ Class {
#tag : 'Acid'
}

{ #category : 'as yet unclassified' }
TpIdleMode >> handleFunctionSwitch [

'DOING NOTHING WITH FUNCTION SWITCH ' traceCr.
]

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

self machine notesArray do: [ :key | "callbacks on mouseDown"
key callbackDown: [
self machine audioEngine
setValue:
(self machine noteNumbers at:
(self machine notesArray indexOf: key)) midiNoteToFreq
parameter: 'AcidNote'.
self machine audioEngine setValue: 1 parameter: 'AcidGate'.
"(self machine noteNumbers at:
(self machine notesArray indexOf: key)) midiNoteToFreq traceCr" ].

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

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

"do nothing"
]

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

"do nothing"
]

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

"do nothing"
]

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

self machine mode: (TpPitchMode new machine: machine)
self machine mode: (TpPitchMode new machine: machine; handleKeyboardNotes )
]

{ #category : 'action handling' }
Expand Down
30 changes: 30 additions & 0 deletions CoypuIDE/TpMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ Class {
#tag : 'Acid'
}

{ #category : 'as yet unclassified' }
TpMode >> handleFunctionSwitch [

^ self subclassResponsibility
]

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

^ self subclassResponsibility
]

{ #category : 'action handling' }
TpMode >> handleNote_0 [

^ self subclassResponsibility
]

{ #category : 'action handling' }
TpMode >> handleNote_100 [

^ self subclassResponsibility
]

{ #category : 'action handling' }
TpMode >> handleNote_9 [

^ self subclassResponsibility
]

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

Expand Down
60 changes: 58 additions & 2 deletions CoypuIDE/TpPitchMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,47 @@ Octave and accent can also be changed.
Class {
#name : 'TpPitchMode',
#superclass : 'TpMode',
#instVars : [
'tempNotesPattern',
'tempNotesPatternIndex'
],
#category : 'CoypuIDE-Acid',
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'as yet unclassified' }
TpPitchMode >> handleFunctionSwitch [

(Performance uniqueInstance at: #Acid) notes: self tempNotesPattern asArray
]

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

self machine notesArray do: [ :key | "callbacks on mouseDown"
key callbackDown: [
self machine audioEngine
setValue:
(self machine noteNumbers at:
(self machine notesArray indexOf: key)) 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 .

].

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

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

Expand All @@ -21,7 +57,27 @@ TpPitchMode >> handleSwitchPitchMode [
TpPitchMode >> handleSwitchTimeMode [

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

"switch the UI led"
self machine widget_PitchMode indicator toggle.
]

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

tempNotesPattern := OrderedCollection new.
tempNotesPatternIndex := 1
]

{ #category : 'accessing' }
TpPitchMode >> tempNotesPattern [

^ tempNotesPattern
]

{ #category : 'accessing' }
TpPitchMode >> tempNotesPatternIndex [

^ tempNotesPatternIndex
]
58 changes: 53 additions & 5 deletions CoypuIDE/TpTimeMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,74 @@ While in TimeMode we can insert gates, rests and ties with the buttons in the Ti
Class {
#name : 'TpTimeMode',
#superclass : 'TpMode',
#instVars : [
'tempGatesPattern',
'tempGatesPatternIndex'
],
#category : 'CoypuIDE-Acid',
#package : 'CoypuIDE',
#tag : 'Acid'
}

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

(Performance uniqueInstance at: #Acid) gates: self tempNotesPattern
]

{ #category : 'action handling' }
TpTimeMode >> handleSwitchPitchMode [
"change the state"
TpTimeMode >> handleNote_100 [
"note_9 insert a gate"

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

]

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

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

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

self machine mode: (TpPitchMode new machine: machine).
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
]

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

self machine mode: (TpIdleMode new machine: self machine)

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

]

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

tempGatesPattern := OrderedCollection new.
tempGatesPatternIndex := 1
]

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

^ tempGatesPattern
]

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

^ tempGatesPatternIndex
]

0 comments on commit 8381530

Please sign in to comment.