Skip to content

Commit

Permalink
Merge pull request #43 from jordanmontt/branch1
Browse files Browse the repository at this point in the history
Some Refactors
  • Loading branch information
lucretiomsp authored Oct 22, 2024
2 parents 7b040a9 + a96492f commit 6fe7689
Showing 1 changed file with 29 additions and 48 deletions.
77 changes: 29 additions & 48 deletions src/Coypu/Performance.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,11 @@ Performance class >> reset [
Performance class >> uniqueInstance [

self orbit: 0.

^ uniqueInstance ifNil: [ uniqueInstance := super new . self performanceType: PerfType new. ]
]

{ #category : 'as yet unclassified' }
Performance >> Dictionary [ Variable or expression expected -><< #Performance
layout: VariableLayout;
slots: {
#visualization .
#performer .
#canvas .
#rsGroupDictionary .
#freq .
#backup .
#bpm .
#transportStep .
#activeProcess.
};
tag: 'Performance';
package: 'LiveCoding'
^ uniqueInstance ifNil: [
uniqueInstance := super new.
self performanceType: PerfType new.
uniqueInstance ]
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -114,8 +99,8 @@ Performance >> activeProcess: anObject [
{ #category : 'performance - adding' }
Performance >> add: aSequencer channel: anIntegerBetween1And16 [

aSequencer midiChannel: anIntegerBetween1And16.
super add: aSequencer.
aSequencer midiChannel: anIntegerBetween1And16.
self add: aSequencer
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -168,6 +153,12 @@ Performance >> dirtMIDIDevice: aString [
dirtMIDIDevice := aString
]

{ #category : 'modifying' }
Performance >> doBackup [

backup := self asDictionary
]

{ #category : 'accessing' }
Performance >> freq [
"better to convert it to Float to avoid OSC sending issues"
Expand Down Expand Up @@ -206,8 +197,7 @@ Performance >> length [
"return the number of steps of the largest array contained in the performance values"

| valuesSizes maxLength |
valuesSizes := (1 to: self values size) collect: [ :i |
((self values at: i) at: 1) size ].
valuesSizes := (1 to: self values size) collect: [ :i | ((self values at: i) at: 1) size ].
maxLength := valuesSizes inject: 0 into: [ :a :c | a max: c ].
^ maxLength
]
Expand All @@ -219,25 +209,20 @@ Performance >> mute: aKeyOrAnArrayOfKeys [
| tracks |
tracks := #( #Kick #TpSampler #Fm2Op #PsgPlus #Chordy ).

aKeyOrAnArrayOfKeys isArray
ifTrue: [
aKeyOrAnArrayOfKeys isArray ifTrue: [
aKeyOrAnArrayOfKeys do: [ :i | self removeKey: i ifAbsent: [ ] ] ]
ifFalse: [
self removeKey: aKeyOrAnArrayOfKeys.
self performanceType class = PerfTypeMooflod ifTrue: [
self performanceType visualizer cleanRow:
(tracks indexOf: aKeyOrAnArrayOfKeys) ] ]
self performanceType visualizer cleanRow: (tracks indexOf: aKeyOrAnArrayOfKeys) ] ]
]

{ #category : 'muting and soloing' }
Performance >> muteAll [
" remove all keys from the Performance"

| anArrayOfKeys |
backup := self asDictionary.
self keysDo: [ :i | self removeKey: i ifAbsent: [ nil ] ].

"remove all keys from the Performance"

self doBackup.
self keysDo: [ :i | self removeKey: i ifAbsent: [ nil ] ]
]

{ #category : 'LiveCoding - satelliteEvent' }
Expand Down Expand Up @@ -333,27 +318,23 @@ Performance >> performer [

{ #category : 'accessing' }
Performance >> performer: aPerformer [
"choose a Performer for the Performance"
" to be safe, it clear the performance"
Performance uniqueInstance muteAll.
performer := aPerformer.
Performance uniqueInstance muteAll.
"choose a Performer for the Performance"
"to be safe, it clear the performance"

self muteAll.
performer := aPerformer.
self muteAll
]

{ #category : 'playing' }
Performance >> play [
" reset all the Sequencers"
"reset all the Sequencers"

self resetAllSequencers.

"just on performance at once"
self activeProcess
ifNil: [ self performer play ]
ifNotNil: [ (self activeProcess isTerminated )
ifTrue: [ self performer play ] ]
.



self activeProcess ifNil: [ self performer play ]
ifNotNil: [ self activeProcess isTerminated ifTrue: [ self performer play ] ]
]

{ #category : 'playing' }
Expand Down Expand Up @@ -608,7 +589,7 @@ Performance >> solo: aKeyOrAnArrayOfKeys [
" remove all keys from the Performance except aKey or anArrayOfKeys"

| anArrayOfKeys |
backup := self asDictionary. "do the backup"
self doBackup.
anArrayOfKeys := self keys.
aKeyOrAnArrayOfKeys isArray
ifTrue: [
Expand Down

0 comments on commit 6fe7689

Please sign in to comment.