diff --git a/src/LiveCodingVisualizations-Tests/SequencerVisualizationTest.class.st b/src/LiveCodingVisualizations-Tests/SequencerVisualizationTest.class.st deleted file mode 100644 index da0ecac..0000000 --- a/src/LiveCodingVisualizations-Tests/SequencerVisualizationTest.class.st +++ /dev/null @@ -1,101 +0,0 @@ -" -A SequencerVisualizationTest is a test class for testing the behavior of SequencerVisualization -" -Class { - #name : #SequencerVisualizationTest, - #superclass : #TestCase, - #instVars : [ - 'visualisation', - 'window' - ], - #category : #'LiveCodingVisualizations-Tests' -} - -{ #category : #running } -SequencerVisualizationTest >> setUp [ - super setUp. - - "Put here a common initialization logic for tests" - visualisation := SequencerVisualization new. - window := nil. - -] - -{ #category : #running } -SequencerVisualizationTest >> tearDown [ -. - - "Put here a common initialization logic for tests" - - window ifNotNil: [window delete]. - super tearDown . - -] - -{ #category : #tests } -SequencerVisualizationTest >> testAnimationProcessCreatesMarkerShape [ - -| seq| - - seq := 16 downbeats. - visualisation sequencer: seq. - visualisation build. - self assert: visualisation stepMarker isNil. - visualisation step. - self assert: visualisation stepMarker isNotNil. -] - -{ #category : #tests } -SequencerVisualizationTest >> testBuildCreates16Shapes [ - - | seq| - - seq := 16 downbeats. - visualisation sequencer: seq. - visualisation build. - - self assert: visualisation shapes size equals: 16. -] - -{ #category : #tests } -SequencerVisualizationTest >> testOpenEmptySequencerRisesError [ - - - self should: [ visualisation build. ] raise: NoSequencerError. - -] - -{ #category : #tests } -SequencerVisualizationTest >> testOpenSequencer [ - - | seq| - - seq := 16 downbeats. - visualisation sequencer: seq. - window := visualisation open. - self assert: window isDisplayed. - self assert: visualisation sequencer equals: seq. - -] - -{ #category : #tests } -SequencerVisualizationTest >> testVisualisationGatesWith2Colors [ - - | seq groups| - - seq := 16 downbeats. - visualisation sequencer: seq. - visualisation build. - groups := visualisation shapes groupedBy: [ :each | each color ]. - self assert: groups size equals: 2. -] - -{ #category : #tests } -SequencerVisualizationTest >> testVisualizationContainsTitleLabel [ - | seq label | - seq := 16 downbeats. - visualisation sequencer: seq. - visualisation build. - label := visualisation titleShape. - self assert: label text equals: seq seqKey. -] diff --git a/src/LiveCodingVisualizations-Tests/package.st b/src/LiveCodingVisualizations-Tests/package.st deleted file mode 100644 index 9a31b15..0000000 --- a/src/LiveCodingVisualizations-Tests/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'LiveCodingVisualizations-Tests' } diff --git a/src/LiveCodingVisualizations/ByteSymbol.extension.st b/src/LiveCodingVisualizations/ByteSymbol.extension.st deleted file mode 100644 index 21b515e..0000000 --- a/src/LiveCodingVisualizations/ByteSymbol.extension.st +++ /dev/null @@ -1,42 +0,0 @@ -Extension { #name : #ByteSymbol } - -{ #category : #'*LiveCodingVisualizations' } -ByteSymbol >> gatesVisualizer [ - - "simple visualization of the gates of a Sequencer - triggers are yellow, rests are white" - - | p seq | - p := Performance uniqueInstance. - seq := p at: self. - ^ seq gatesVisualizer -] - -{ #category : #'*LiveCodingVisualizations' } -ByteSymbol >> inspectorGates [ - - "simple visualization of the gates of a Sequencer - triggers are yellow, rests are white" - - | p seq | - p := Performance uniqueInstance. - seq := p at: self. - ^ seq gatesVisualizer asPresenter -] - -{ #category : #'*LiveCodingVisualizations' } -ByteSymbol >> inspectorGatesContext: context [ - - context - withoutEvaluator; - active: self isInPerformance -] - -{ #category : #'*LiveCodingVisualizations' } -ByteSymbol >> isInPerformance [ - - ^ Performance uniqueInstance includesKey: self -] - -{ #category : #'*LiveCodingVisualizations' } -ByteSymbol >> visualizeGates [ - ^ self gatesVisualizer open -] diff --git a/src/LiveCodingVisualizations/NoSequencerError.class.st b/src/LiveCodingVisualizations/NoSequencerError.class.st deleted file mode 100644 index ad50773..0000000 --- a/src/LiveCodingVisualizations/NoSequencerError.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #NoSequencerError, - #superclass : #Error, - #category : #LiveCodingVisualizations -} diff --git a/src/LiveCodingVisualizations/Performance.extension.st b/src/LiveCodingVisualizations/Performance.extension.st deleted file mode 100644 index 81c44f0..0000000 --- a/src/LiveCodingVisualizations/Performance.extension.st +++ /dev/null @@ -1,32 +0,0 @@ -Extension { #name : #Performance } - -{ #category : #'*LiveCodingVisualizations' } -Performance >> inspectorAllSequencers [ - - | presenter layout sequencers | - presenter := SpPresenter new. - layout := SpBoxLayout newVertical. - layout spacing: 5. - sequencers := self values asSortedCollection: [:seq1 :seq2| - seq1 seqKey < seq2 seqKey ]. - sequencers do: [ :each | | presenterPresenter | - presenterPresenter := each inspectorSequencer. - layout - add: each inspectorSequencer - withConstraints: [ :constraints | - constraints height: presenterPresenter canvas encompassingRectangle height ] ]. - presenter layout: (SpScrollableLayout with: layout). - - ^ presenter - - -] - -{ #category : #'*LiveCodingVisualizations' } -Performance >> inspectorAllSequencersContext: context [ - context - withoutEvaluator - active: self notEmpty - - -] diff --git a/src/LiveCodingVisualizations/Sequencer.extension.st b/src/LiveCodingVisualizations/Sequencer.extension.st deleted file mode 100644 index b520da5..0000000 --- a/src/LiveCodingVisualizations/Sequencer.extension.st +++ /dev/null @@ -1,21 +0,0 @@ -Extension { #name : #Sequencer } - -{ #category : #'*LiveCodingVisualizations' } -Sequencer >> gatesVisualizer [ - - "simple visualization of the gates of a Sequencer - triggers are yellow, rests are white" - - ^ SequencerVisualization new - sequencer: self; - yourself -] - -{ #category : #'*LiveCodingVisualizations' } -Sequencer >> inspectorSequencer [ - - "simple visualization of the gates of a Sequencer - triggers are yellow, rests are white" - - - - ^ self seqKey asSymbol inspectorGates -] diff --git a/src/LiveCodingVisualizations/SequencerVisualization.class.st b/src/LiveCodingVisualizations/SequencerVisualization.class.st deleted file mode 100644 index b777f20..0000000 --- a/src/LiveCodingVisualizations/SequencerVisualization.class.st +++ /dev/null @@ -1,102 +0,0 @@ -Class { - #name : #SequencerVisualization, - #superclass : #RSAbstractContainerBuilder, - #instVars : [ - 'sequencer', - 'stepMarker', - 'titleShape' - ], - #category : #LiveCodingVisualizations -} - -{ #category : #hooks } -SequencerVisualization >> newTitle [ - ^ RSLabel new - text: sequencer seqKey; - - bold; - noPaint; - "fontName: 'Arial';" - border: (RSBorder new color: Color red; width: 3); - fontSize: 100; - yourself -] - -{ #category : #public } -SequencerVisualization >> open [ -^ super open setLabel: sequencer seqKey -] - -{ #category : #hooks } -SequencerVisualization >> renderIn: canvas [ - | extent borderWidth colors markShape | - sequencer ifNil: [ ^ NoSequencerError new signal]. - titleShape := self newTitle. - extent := 800 @ 200. - borderWidth := #( 7 2 4 2 ). - colors := #( #white #yellow ). - canvas color: #black. - sequencer gates doWithIndex: [ :gate :stepNumber | - canvas add: (RSBox new - size: 38; - color: (colors at: gate + 1); - border: (RSBorder new - color: #blue; - width: (borderWidth at: (stepNumber - 1 rem: 4) + 1))) ]. - - "RSHorizontalLineLayout on: canvas shapes." - RSGridLayout new - lineItemsCount: 16; - on: canvas shapes. - markShape := nil. - canvas addShape: titleShape. - RSHorizontalLineLayout new - alignMiddle; - on: { titleShape. canvas nodes }. - canvas newAnimation - repeat; - onStepDo: [ self step ]. - canvas zoomToFit. - shapes := canvas nodes copy. - -] - -{ #category : #accessing } -SequencerVisualization >> sequencer [ - ^ sequencer -] - -{ #category : #accessing } -SequencerVisualization >> sequencer: aSequencer [ - sequencer := aSequencer -] - -{ #category : #stepping } -SequencerVisualization >> step [ - - | perf shapeIndex currentShape canvas| - "shapeIndex := seq gates wrap: seq noteIndex ." - canvas := self container . - perf := Performance uniqueInstance . - shapeIndex := perf transportStep - 1 % sequencer gates size + 1. - shapeIndex traceCr. - currentShape := canvas nodes at: shapeIndex . - stepMarker ifNil: [ - stepMarker := RSEllipse size: 20. - stepMarker color: Color red. - canvas add: stepMarker . - ]. - stepMarker position: currentShape position. - canvas signalUpdate - -] - -{ #category : #accessing } -SequencerVisualization >> stepMarker [ - ^ stepMarker -] - -{ #category : #accessing } -SequencerVisualization >> titleShape [ - ^ titleShape -] diff --git a/src/LiveCodingVisualizations/package.st b/src/LiveCodingVisualizations/package.st deleted file mode 100644 index b2cf097..0000000 --- a/src/LiveCodingVisualizations/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #LiveCodingVisualizations } diff --git a/src/PharoCollider/AbstractFunction.class.st b/src/PharoCollider/AbstractFunction.class.st deleted file mode 100644 index 07ef389..0000000 --- a/src/PharoCollider/AbstractFunction.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #AbstractFunction, - #superclass : #Object, - #category : #'PharoCollider-AbstractFunctions' -} - -{ #category : #converting } -AbstractFunction >> asUGenInputFor: for [ - -^ self value: for -] diff --git a/src/PharoCollider/AbstractOut.class.st b/src/PharoCollider/AbstractOut.class.st deleted file mode 100644 index d408abe..0000000 --- a/src/PharoCollider/AbstractOut.class.st +++ /dev/null @@ -1,41 +0,0 @@ -Class { - #name : #AbstractOut, - #superclass : #UGen, - #category : #'PharoCollider-UGens' -} - -{ #category : #topoSorting } -AbstractOut >> checkInputs [ - - rate = 'audio' ifTrue: [ - self class numFixedArgs to: inputs size - 1 do: [ :i | - (inputs at: i) ~= 'audio' ifTrue: [ - ^ Error new signal: - 'Input at ' , i asString , 'is Not at audio rate' ] ] ]. - inputs size <= self class numFixedArgs ifTrue: [ - ^ Error new signal: 'Missing input at index 1' ]. - ^ self checkValidInputs -] - -{ #category : #initialization } -AbstractOut >> initialize [ - -super initialize . -] - -{ #category : #writing } -AbstractOut >> numFixedArgs [ - -self subclassResponsibility -] - -{ #category : #accessing } -AbstractOut >> numOutputs [ -^ 0 -] - -{ #category : #writing } -AbstractOut >> writeOutputSpecs [ - -"empty as originally in SuperCollider" -] diff --git a/src/PharoCollider/Array.extension.st b/src/PharoCollider/Array.extension.st deleted file mode 100644 index fed2ccc..0000000 --- a/src/PharoCollider/Array.extension.st +++ /dev/null @@ -1,19 +0,0 @@ -Extension { #name : #Array } - -{ #category : #'*PharoCollider' } -Array >> asUGensGraphFunc [ - -| uggf numOfUGens | - -numOfUGens := self select: [ :i | i isUGen ]. -(numOfUGens size = self size) ifTrue: -[uggf := UGensGraphFunc with: self. ^ uggf] ifFalse: [ ^ Error new signal: 'Only arrays of UGens can be converted to a UGensGraphFunc' ] -] - -{ #category : #'*PharoCollider' } -Array >> sendToSCServer [ -"better if literal array" - (OSCMessage for: self) - sendToAddressString: SCServer address - port: SCServer port -] diff --git a/src/PharoCollider/BasicOpUgen.class.st b/src/PharoCollider/BasicOpUgen.class.st deleted file mode 100644 index dc4ee5e..0000000 --- a/src/PharoCollider/BasicOpUgen.class.st +++ /dev/null @@ -1,5 +0,0 @@ -Class { - #name : #BasicOpUgen, - #superclass : #UGen, - #category : #'PharoCollider-UGens' -} diff --git a/src/PharoCollider/BasicSamplePlayer.class.st b/src/PharoCollider/BasicSamplePlayer.class.st deleted file mode 100644 index d9f6872..0000000 --- a/src/PharoCollider/BasicSamplePlayer.class.st +++ /dev/null @@ -1,75 +0,0 @@ -" -a basic sample Player -" -Class { - #name : #BasicSamplePlayer, - #superclass : #SynthDefs, - #instVars : [ - 'id', - 'bufferNumber' - ], - #category : #PharoCollider -} - -{ #category : #accessing } -BasicSamplePlayer >> bufferNumber [ - - ^ bufferNumber -] - -{ #category : #accessing } -BasicSamplePlayer >> bufferNumber: aBufferNumber [ - - bufferNumber := aBufferNumber. - - (OSCMessage for: { - 15. - id. - 'buf'. - aBufferNumber }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #'accessing - structure variables' } -BasicSamplePlayer >> gate: oneOrZero [ - - (OSCMessage for: { - 15. - id. - 'gate'. - oneOrZero }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #accessing } -BasicSamplePlayer >> id [ -^ id -] - -{ #category : #initialization } -BasicSamplePlayer >> initialize [ - - super initialize. - (OSCMessage for: - { '/d_load'. '/Users/domenicocipriani/Library/Application Support/SuperCollider/synthdefs/basicSampler.*' }) - sendToAddressString: '127.0.0.1' - port: 57110. - self setId: (Random new nextIntegerBetween: 9 and: 99) -] - -{ #category : #playing } -BasicSamplePlayer >> play [ - - " third argument is ID" - - (OSCMessage for: { - 's_new'. - 'basicSampler'. - id. - 0. - 0 }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #initialization } -BasicSamplePlayer >> setId: anInteger [ - - id := anInteger -] diff --git a/src/PharoCollider/BinaryOpUGen.class.st b/src/PharoCollider/BinaryOpUGen.class.st deleted file mode 100644 index ed17ed2..0000000 --- a/src/PharoCollider/BinaryOpUGen.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #BinaryOpUGen, - #superclass : #BasicOpUgen, - #category : #'PharoCollider-UGens' -} - -{ #category : #'as yet unclassified' } -BinaryOpUGen >> initailize [ -super initialize. -rateNumber := 2. "audio rate by default" -] diff --git a/src/PharoCollider/Buffer.class.st b/src/PharoCollider/Buffer.class.st deleted file mode 100644 index 623b25d..0000000 --- a/src/PharoCollider/Buffer.class.st +++ /dev/null @@ -1,65 +0,0 @@ -" -Use the buffer to load samples -" -Class { - #name : #Buffer, - #superclass : #Object, - #instVars : [ - 'number' - ], - #classInstVars : [ - 'number' - ], - #category : #PharoCollider -} - -{ #category : #accessing } -Buffer class >> number [ -^ number -] - -{ #category : #accessing } -Buffer class >> number: anInteger [ - - number := anInteger -] - -{ #category : #'meta-object-protocol' } -Buffer class >> read: aStringFilePath [ - - | bufNumber instance | - number - ifNotNil: [ bufNumber := number + 1 ] - ifNil: [ bufNumber := 0 ]. - (OSCMessage for: { - 'b_allocRead'. - bufNumber. - aStringFilePath. - 0. - -1 }) sendToAddressString: '127.0.0.1' port: 57110. - instance := self new. - instance number: bufNumber. - - ^ instance -] - -{ #category : #initialization } -Buffer >> initialize [ -super initialize . -self class number - ifNotNil: [ self class number: self class number + 1 ] - ifNil: [ self class number: 0 ]. - self number: self class number -] - -{ #category : #initialization } -Buffer >> number [ - - ^ number -] - -{ #category : #initialization } -Buffer >> number: anInteger [ - - number := anInteger -] diff --git a/src/PharoCollider/Collection.extension.st b/src/PharoCollider/Collection.extension.st deleted file mode 100644 index d5cfe0c..0000000 --- a/src/PharoCollider/Collection.extension.st +++ /dev/null @@ -1,12 +0,0 @@ -Extension { #name : #Collection } - -{ #category : #'*PharoCollider' } -Collection >> asArryaWithBytesOfSize: anInteger [ - - | x c | - x := self collect: [ :i | i asByteArrayOfSize: 4 ]. - c := OrderedCollection new. - - (1 to: x size) do: [ :j | (x at: j) do: [ :i | c add: i ] ]. - ^ c -] diff --git a/src/PharoCollider/Control.class.st b/src/PharoCollider/Control.class.st deleted file mode 100644 index fc7ae98..0000000 --- a/src/PharoCollider/Control.class.st +++ /dev/null @@ -1,106 +0,0 @@ -Class { - #name : #Control, - #superclass : #UGen, - #instVars : [ - 'name', - 'values', - 'lags', - 'fixedLag', - 'spec', - 'paramName' - ], - #category : #'PharoCollider-UGens' -} - -{ #category : #instanceCreat } -Control class >> newWithName: aString [ -" creates a new instance of the control with a Control name" - ^ self new paramName: aString -] - -{ #category : #accessing } -Control >> fixedLag [ - - ^ fixedLag -] - -{ #category : #accessing } -Control >> fixedLag: aBoolean [ - - fixedLag := aBoolean -] - -{ #category : #initialization } -Control >> initialize [ - - super initialize. - self fixedLag: false. - self values: 0. - self rateNumber: 1. "at the moment all controls have kr control rate" - self outputs at: #nulla put: 0 "at the moment we just have 1 dummy output, THEN IT MUST CONNECT FOR WHAT IS PLUGGED" -] - -{ #category : #testing } -Control >> isControl [ - -"my implementation to count controls in SynthDef" -^ true -] - -{ #category : #accessing } -Control >> lags [ - - ^ lags -] - -{ #category : #accessing } -Control >> lags: anObject [ - - lags := anObject -] - -{ #category : #accessing } -Control >> name [ - ^ name -] - -{ #category : #accessing } -Control >> name: aString [ - name := aString -] - -{ #category : #accessing } -Control >> paramName [ - - ^ paramName -] - -{ #category : #accessing } -Control >> paramName: aString [ - - paramName := aString -] - -{ #category : #accessing } -Control >> spec [ - - ^ spec -] - -{ #category : #accessing } -Control >> spec: anObject [ - - spec := anObject -] - -{ #category : #accessing } -Control >> values [ - - ^ values -] - -{ #category : #accessing } -Control >> values: anObject [ - - values := anObject -] diff --git a/src/PharoCollider/InstanceCounter.class.st b/src/PharoCollider/InstanceCounter.class.st deleted file mode 100644 index b0b4669..0000000 --- a/src/PharoCollider/InstanceCounter.class.st +++ /dev/null @@ -1,41 +0,0 @@ -Class { - #name : #InstanceCounter, - #superclass : #Object, - #instVars : [ - 'number' - ], - #classInstVars : [ - 'number' - ], - #category : #PharoCollider -} - -{ #category : #initialization } -InstanceCounter class >> number [ - ^ number. -] - -{ #category : #accessing } -InstanceCounter class >> number: anInteger [ - number := anInteger -] - -{ #category : #initialization } -InstanceCounter >> initialize [ - - super initialize. - self class number - ifNotNil: [ self class number: self class number + 1 ] - ifNil: [ self class number: 0 ]. - self number: self class number. -] - -{ #category : #accessing } -InstanceCounter >> number [ - ^ number -] - -{ #category : #accessing } -InstanceCounter >> number: anInteger [ -number := anInteger. -] diff --git a/src/PharoCollider/Integer.extension.st b/src/PharoCollider/Integer.extension.st deleted file mode 100644 index 2e2cb97..0000000 --- a/src/PharoCollider/Integer.extension.st +++ /dev/null @@ -1,35 +0,0 @@ -Extension { #name : #Integer } - -{ #category : #'*PharoCollider' } -Integer >> asBitsArray [ - | binaryString bitArray| - - binaryString := self radix: 2. - bitArray := Array new: binaryString size. - 1 to: bitArray size do: [ :i | bitArray at: i put: ((binaryString at: i) digitValue ) ]. - -^ bitArray -] - -{ #category : #'*PharoCollider' } -Integer >> asBitsArrayOfSize: anInteger [ - - | bitsArraySized bitsArray| - -bitsArray := self asBitsArray . -bitsArraySized := OrderedCollection new. -1 to: (anInteger - bitsArray size) do: [ :i | bitsArraySized add: 0 ]. -bitsArraySized addAll: bitsArray . - - -^ bitsArraySized asDirtArray -] - -{ #category : #'*PharoCollider' } -Integer >> asSignedInt8 [ - - | mask result | - mask := (2 raisedTo: 8) - 1. - result :=mask bitAnd: (self abs bitXor: mask) + 1. - ^ result -] diff --git a/src/PharoCollider/ManifestPharoCollider.class.st b/src/PharoCollider/ManifestPharoCollider.class.st deleted file mode 100644 index 00e3b63..0000000 --- a/src/PharoCollider/ManifestPharoCollider.class.st +++ /dev/null @@ -1,29 +0,0 @@ -" -Frontend for the SuperCollider language. -To be developed -" -Class { - #name : #ManifestPharoCollider, - #superclass : #PackageManifest, - #category : #'PharoCollider-Manifest' -} - -{ #category : #'code-critics' } -ManifestPharoCollider class >> ruleCollectionMessagesToExternalObjectRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#SynthDef #graphDeprecated: #false)) #'2022-11-20T12:34:17.692187+01:00') ) -] - -{ #category : #'code-critics' } -ManifestPharoCollider class >> ruleCollectionProtocolRuleV1FalsePositive [ - ^ #(#(#(#RGClassDefinition #(#SynthDef)) #'2022-11-20T12:34:22.337748+01:00') ) -] - -{ #category : #'code-critics' } -ManifestPharoCollider class >> ruleFloatEqualityComparisonRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#PharoColliderTests #testMidiToFreq #false)) #'2022-08-30T22:33:20.933001+02:00') ) -] - -{ #category : #'code-critics' } -ManifestPharoCollider class >> ruleSentNotImplementedRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#PharoColliderTests #testMidiToFreq #false)) #'2022-08-30T22:33:24.391456+02:00') ) -] diff --git a/src/PharoCollider/Number.extension.st b/src/PharoCollider/Number.extension.st deleted file mode 100644 index 874eecd..0000000 --- a/src/PharoCollider/Number.extension.st +++ /dev/null @@ -1,26 +0,0 @@ -Extension { #name : #Number } - -{ #category : #'*PharoCollider' } -Number >> midiToFreq [ - - "converts a MIDI note number to a frequency value" - - | exponent | - exponent := (self - 69) / 12. - ^ (2 raisedTo: exponent) * 440 -] - -{ #category : #'*PharoCollider' } -Number >> writeInputSpec [ - - "original SuperCollider method write to a file, not to an OrderedCollection, which I called int8Array" - - | int8Array constIndex | - int8Array := OrderedCollection new. - constIndex := 0. - "var constIndex = synth.constants.at(this.asFloat) ???" - - int8Array addAll: #( -1 -1 -1 -1 ). - int8Array addAll: (constIndex asByteArrayOfSize: 4). - ^ int8Array -] diff --git a/src/PharoCollider/Out.class.st b/src/PharoCollider/Out.class.st deleted file mode 100644 index 37a4e98..0000000 --- a/src/PharoCollider/Out.class.st +++ /dev/null @@ -1,61 +0,0 @@ -" -corresponding to SuperColllider ""Out"" UGen -" -Class { - #name : #Out, - #superclass : #AbstractOut, - #instVars : [ - 'bus', - 'input' - ], - #category : #'PharoCollider-UGens' -} - -{ #category : #'instance creation' } -Out class >> bus: anInteger input: aUGen [ - - | result | - result := self new - bus: anInteger; - input: aUGen. - - aUGen isUGen ifTrue: [ ^ result ] ifFalse: [ . Transcript show: 'INPUT MUST BE A UGEN !!!!!'; cr; open. ^ nil] -] - -{ #category : #accessing } -Out >> bus [ -"The index of the bus to write out to. The lowest numbers are written to the audio hardware" - - ^ bus -] - -{ #category : #accessing } -Out >> bus: anInteger [ -bus := anInteger - - -] - -{ #category : #initialization } -Out >> initialize [ - - super initialize. - bus := 0. - numberOfConstants := 1. - inputs := { 0 . nil } -] - -{ #category : #accessing } -Out >> input [ -^ input -] - -{ #category : #accessing } -Out >> input: aUGen [ - - "An Array of channels or single output to write out. You cannot change the size of this once a SynthDef has been built. - -" - - self addInput: aUGen At: 2 -] diff --git a/src/PharoCollider/PharoColliderTests.class.st b/src/PharoCollider/PharoColliderTests.class.st deleted file mode 100644 index 6d9c636..0000000 --- a/src/PharoCollider/PharoColliderTests.class.st +++ /dev/null @@ -1,464 +0,0 @@ -Class { - #name : #PharoColliderTests, - #superclass : #TestCase, - #category : #'PharoCollider-Tests' -} - -{ #category : #running } -PharoColliderTests >> setUp [ - - super setUp. - - - "Put here a common initialization logic for tests" - " - freqControl := Control new. - oscillator := SinOsc new freq: freqControl . - out := Dac new input: oscillator . - ugGraphFunc := UGensGraphFunc with: { oscillator . out }. - sDef := SynthDef withName: 'io' graph: ugGraphFunc . - " -] - -{ #category : #tests } -PharoColliderTests >> testAddElementsOfArrayAsBytesToOrderedCollection [ - - | array arrayOfBytes oc | - array := #( 1 2 3 ). - oc := OrderedCollection new addAll: #( 0 0 0 1 0 0 0 1 0 0 0 3 ). - arrayOfBytes := (1 to: 3) collect: [ :i | (array at: i) asByteArrayOfSize: 4 ] -] - -{ #category : #tests } -PharoColliderTests >> testArrayAsUGensGraphFunc [ - -| arr oscillator out| - -oscillator := SinOsc new. -out := Out new. -arr := Array with: oscillator with: out. - -self assert: arr asUGensGraphFunc class equals: UGensGraphFunc -] - -{ #category : #tests } -PharoColliderTests >> testArrayWithBytesOfSize [ - - self - assert: ( #( 1 2 3 ) asArryaWithBytesOfSize: - 4 ) - equals: (#( 0 0 0 1 0 0 0 2 0 0 0 3 ) asOrderedCollection ) -] - -{ #category : #utilityTests } -PharoColliderTests >> testAsBitsArray [ - - -self assert: 8 asBitsArray equals: #(1 0 0 0) -] - -{ #category : #utilityTests } -PharoColliderTests >> testAsBitsArrayOfSize [ - -self assert: (8 asBitsArrayOfSize: 8 ) equals: #( 0 0 0 0 1 0 0 0) -] - -{ #category : #uGensTests } -PharoColliderTests >> testControlAsBytes [ - - "at a first moment all Controls are at Conttrol rate, kr" - - | control result | - result := #( 7 67 111 110 116 114 111 108 1 0 0 0 0 0 0 0 1 0 0 1 ). "UGen name" "kr" "0 inputs" "1 output" "special index" "output is kr" - control := Control new. - - self assert: control asBytes equals: result -] - -{ #category : #tests } -PharoColliderTests >> testControlCreationWithName [ - - self assert: (Control newWithName: 'First') name equals: 'First' -] - -{ #category : #tests } -PharoColliderTests >> testDacExists [ - - self assert: Out new bus equals: 0. - self assert: Out new input class equals: UGen -] - -{ #category : #utilityTests } -PharoColliderTests >> testFloatAsInt8Array [ - -self assert: 440.0 asInt8ArrayOfSize4 equals: #(67 -36 0 0). -] - -{ #category : #utilityTests } -PharoColliderTests >> testInt8Conversions [ - -self assert: 220 asInt8 equals: -36. -self assert: 92 asInt8 equals: 92 -] - -{ #category : #tests } -PharoColliderTests >> testMidiToFreq [ -self assert: 69 midiToFreq equals: 440 -] - -{ #category : #tests } -PharoColliderTests >> testNumberUGensBasic [ - - | s output oscillator fc | - fc := Control new. - oscillator := SinOsc new freq: fc. - output := Out new input: oscillator. - - s := SynthDef new: output. - -self assert: s numberOfUGens equals: 2 -] - -{ #category : #uGensTests } -PharoColliderTests >> testOutAsBytes [ - - "at a first moment all Controls are at Conttrol rate, kr" - - | freqControl oscillator out sd result | - result := #( 3 79 117 116 2 0 0 0 2 0 0 0 0 0 0 -1 -1 -1 -1 0 0 0 0 0 - 0 0 1 0 0 0 0 ). - freqControl := Control newWithName: 'freq'. - oscillator := SinOsc new freq: freqControl. - out := Out new input: oscillator. - sd := SynthDef new. - sd graph: { - oscillator. - out }. - - self assert: out asBytes equals: result -] - -{ #category : #uGensTests } -PharoColliderTests >> testPureUGenIsUGenSubClass [ - -self assert: (PureUGen superclass) equals: UGen. -] - -{ #category : #uGensTests } -PharoColliderTests >> testSinOscAsBytes [ - - "at a first moment all Controls are at Control rate, kr" - - | freqControl oscillator out sd result | - result := #( 6 83 105 110 79 115 99 2 0 0 0 2 0 0 0 1 0 0 0 0 0 0 0 0 - 0 0 -1 -1 -1 -1 0 0 0 0 2 ). - freqControl := Control newWithName: 'freq'. -oscillator := SinOsc new freq: freqControl . -out := Out new input: oscillator. -sd := SynthDef new. -sd graph: { oscillator .out }. - - self assert: oscillator asBytes equals: result -] - -{ #category : #tests } -PharoColliderTests >> testSinOscExists [ - - self assert: SinOsc new freq equals: 440. - self assert: SinOsc new phase equals: 0.0. - self assert: SinOsc new gain equals: 0.5 -] - -{ #category : #SinOscTests } -PharoColliderTests >> testSinOscIsPureUGen [ - -self assert: (SinOsc superclass ) equals: PureUGen -] - -{ #category : #SinOscTests } -PharoColliderTests >> testSinOscWriteDef [ - - | int8Array expectedResult | - int8Array := OrderedCollection new. - expectedResult := #( 6 83 105 110 79 115 99 2 0 0 0 2 0 0 0 1 0 0 -1 - -1 -1 -1 0 0 0 0 -1 -1 -1 -1 0 0 0 1 2 ). - - self - assert: (SinOsc new writeDef: int8Array) - equals: expectedResult asDirtArray -] - -{ #category : #tests } -PharoColliderTests >> testStringAsPString [ - - "SuperCollider pascal format string: a byte (an unsigned int8) giving the length followed by that many bytes" - - self assert: 'io' asPString equals: #[2 105 111] -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefAsBytes [ - - | bytes sDef oscillator out freqControl | - freqControl := Control newWithName: 'freq'. - oscillator := SinOsc new freq: freqControl. - out := Out new input: oscillator. - sDef := SynthDef name: 'io' with: { - oscillator. - out }. - - bytes := #( 83 67 103 102 - 0 0 0 2 - 0 1 - 2 105 111 - 0 0 0 1 - 0 0 0 0 - 0 0 0 1 - 0 0 0 0 - 0 0 0 1 - 4 102 114 101 113 - 0 0 0 0 - 0 0 0 3 - 7 67 111 110 116 114 111 108 - 1 - 0 0 0 0 - 0 0 0 1 - 0 0 - 1 - 6 83 105 110 79 115 99 - 2 - 0 0 0 2 - 0 0 0 1 - 0 0 0 0 - 0 0 - 0 0 0 0 - -1 -1 -1 -1 - 0 0 0 0 - 2 - 3 79 117 116 - 2 - 0 0 0 2 - 0 0 0 0 - 0 0 - -1 -1 -1 -1 - 0 0 0 0 - 0 0 0 1 - 0 0 0 0 - 0 0 ). "SCgf" "version" "number of synth defs" "io defname" "number of constants" "only costant is 0" "number of params" "param initial value" "number of param names" "param name (1st only) = freq" "param index" "number of UGens" "UGen name (Control)" "kontrol Rate" "inputs" "outputs" "special index" " OUTPUT is KontrolRate" "UGen name SinOsc" "AudioRate" "inputs" "outputs" "special index" "1st input index of UGen --> Control" "1st input -- index of Control's output = 0 (1st, only Control output " "2nd input (SinOSc phase) = 0xFFFFFFFF = -1 --> constant" "use the first constant" "output = AudioRate" "UGen name Out" "AudioRate" "inputs" "ouputs" "special index" "value of 1st input = constant" "constant index 0 " "2nd input comes from UGen 1 = SinOsc" "1st output from SinOsc" "num variants = 0" - - - self assert: sDef asBytes equals: bytes -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefAsBytesSCImplementation [ - - | bytes sDef oscillator out freqControl | - freqControl := Control new name: 'Control'. - oscillator := SinOsc new freq: freqControl. - out := Out new input: oscillator. - sDef := SynthDef withName: 'io' graph: { - oscillator. - out }. - - bytes := #( 83 67 103 102 0 0 0 2 0 1 2 105 111 0 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 0 0 0 0 1 4 102 114 101 113 0 0 0 0 0 0 0 3 7 67 - 111 110 116 114 111 108 1 0 0 0 0 0 0 0 1 0 0 1 6 83 105 - 110 79 115 99 2 0 0 0 2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 -1 -1 - -1 -1 0 0 0 0 2 3 79 117 116 2 0 0 0 2 0 0 0 0 0 0 -1 -1 - -1 -1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 ). "SCgf" "version" "number of synth defs" "io defname" "number of constants" "only costant is 0" "number of params" "param initial value" "number of param names" "param name (1st only) = freq" "param index" "number of UGens" "UGen name (Control)" "kontrol Rate" "inputs" "outputs" "special index" " OUTPUT is KontrolRate" "UGen name SinOsc" "AudioRate" "inputs" "outputs" "special index" "1st input index of UGen --> Control" "1st input -- index of Control's output = 0 (1st, only Control output " "2nd input (SinOSc phase) = 0xFFFFFFFF = -1 --> constant" "use the first constant" "output = AudioRate" "UGen name Out" "AudioRate" "inputs" "ouputs" "special index" "value of 1st input = constant" "constant index 0 " "2nd input comes from UGen 1 = SinOsc" "1st output from SinOsc" "num variants = 0" - - - self assert: sDef asBytesSCImplementation equals: bytes -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefCreateWith [ - - | synthDefCase | - synthDefCase := SynthDef with: #( #ugen1 #ugen2 #ugen3 ). - self assert: synthDefCase numberOfUGens equals: #[ 0 0 0 3 ] -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefCreationWithUGensGraphFunc [ - - | sDef uGen1 uGen2 | - uGen1 := SinOsc new. - uGen2 := Out new. - sDef := SynthDef with: { - uGen1. - uGen2 }. - - self assert: sDef numberOfUGens equals: #[0 0 0 2 ] -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefFixedSinOSc [ - - | bytes sDef oscillator out | - oscillator := SinOsc new freq: 220. - out := Out new input: oscillator. - sDef := SynthDef name: 'io' with: { - oscillator. - out }. - - bytes := #( 83 67 103 102 0 0 0 2 0 1 2 105 111 0 0 0 2 67 92 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 2 6 83 105 110 79 115 99 2 0 0 - 0 2 0 0 0 1 0 0 -1 -1 -1 -1 0 0 0 0 -1 -1 -1 -1 0 0 0 1 2 - 3 79 117 116 2 0 0 0 2 0 0 0 0 0 0 -1 -1 -1 -1 0 0 0 1 - 0 0 0 0 0 0 0 0 0 0 ). "SCgf" "version" "number of synth defs" "io defname" "number of constants" "only costant is 0" "number of params" "param initial value" "number of param names" "param name (1st only) = freq" "param index" "number of UGens" "UGen name (Control)" "kontrol Rate" "inputs" "outputs" "special index" " OUTPUT is KontrolRate" "UGen name SinOsc" "AudioRate" "inputs" "outputs" "special index" "1st input index of UGen --> Control" "1st input -- index of Control's output = 0 (1st, only Control output " "2nd input (SinOSc phase) = 0xFFFFFFFF = -1 --> constant" "use the first constant" "output = AudioRate" "UGen name Out" "AudioRate" "inputs" "ouputs" "special index" "value of 1st input = constant" "constant index 0 " "2nd input comes from UGen 1 = SinOsc" "1st output from SinOsc" "num variants = 0" - - - self assert: sDef asBytes equals: bytes -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefNoNameNoUgensAsBytes [ - - "returns th Int8 array with the SuperCollider SynthDefinition Format of a Synthef named 'a' and with noUgens nor controls " - - self - assert: SynthDef new asBytesDeprecated - equals: - #( 83 67 103 102 0 0 0 2 0 1 1 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) - asOrderedCollection -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefNumberOfConstants [ - -| sDef freqControl oscillator out uFunc | - freqControl := Control new. - oscillator := SinOsc new freq: freqControl . - out := Out new input: oscillator . - uFunc := { oscillator . out }. - sDef := SynthDef withName: 'io' graph: uFunc . - -self assert: sDef numberOfConstants equals: #[0 0 0 1] -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefTopoSortBasic [ - - | sDef oscillator out freqControl | - freqControl := Control new name: 'Control'. - oscillator := SinOsc new freq: freqControl. - out := Out new input: oscillator. - sDef := SynthDef with: { - oscillator. - out }. - self - assert: (sDef children asDirtArray at: 1) class name - equals: #Control. - self assert: (sDef children asDirtArray at: 2) class name equals: #SinOsc. - self assert: (sDef children asDirtArray at: 3) class name equals: #Out -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefTopoSortBasicWithName [ - - | sDef oscillator out freqControl | - freqControl := Control new name: 'Control'. - oscillator := SinOsc new freq: freqControl. - out := Out new input: oscillator. - sDef := SynthDef name: 'io' with: { - oscillator. - out }. - self - assert: (sDef children asDirtArray at: 1) class name - equals: #Control. - self assert: (sDef children asDirtArray at: 2) class name equals: #SinOsc. - self assert: (sDef children asDirtArray at: 3) class name equals: #Out -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testSynthDefuGensGraphFuncBasicSorting [ - - | sDef uGensGraphFuncIsSorted oscillator out freqControl pos1 pos2 pos3| - freqControl := Control new. - oscillator := SinOsc new freq: freqControl. - out := Out new input: oscillator. - sDef := SynthDef with: { - oscillator. - out }. -pos1 := (sDef graph at: 1) = freqControl. -pos2 := (sDef graph at: 2) = oscillator. -pos3 := (sDef graph at: 3) = out. -uGensGraphFuncIsSorted := pos1 & pos2 & pos3. - self assert: uGensGraphFuncIsSorted equals: true -] - -{ #category : #tests } -PharoColliderTests >> testSynthWithNameAndEmptyGraph [ -| newSynthDef| -newSynthDef := (SynthDef withName: 'x' graph: UGensGraphFunc new). - self - assert: newSynthDef asBytesDeprecated - equals: - #( 83 67 103 102 0 0 0 2 0 1 1 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 ) asOrderedCollection -] - -{ #category : #uGensTests } -PharoColliderTests >> testUGenInputsUGen [ - -| s fc | -fc := Control newWithName: 'freq'. -s := SinOsc new freq: fc. - -self assert: s inputsUGen equals: (Array with: fc) -] - -{ #category : #tests } -PharoColliderTests >> testUGenIsInput [ - -| uGen1 uGen2 | -uGen2 := Control new. -uGen1 := SinOsc new freq: uGen2. - - -self assert: (uGen2 isInputOf: uGen1) equals: true -] - -{ #category : #uGensTests } -PharoColliderTests >> testUGenName [ - -self assert: (SinOsc name) equals: 'SinOsc'. -] - -{ #category : #synthDefTesting } -PharoColliderTests >> testUGenSpec [ - -| oscillator bytes| - -oscillator := SinOsc new. -bytes := #( 6 83 105 110 79 115 99 "UGen name SinOsc" 2 "audio rate" 0 0 0 2 "inputs" 0 0 0 1 "output" 0 0 "special index" --1 -1 -1 -1 "1st input is constant" 0 0 0 0 "index of 1st input" -1 -1 -1 -1 "2nd input is constant" 0 0 0 1 "indexo f second constant" -2 "audioRate" - ). - -self assert: oscillator uGenSpec equals: bytes. -] - -{ #category : #uGensTests } -PharoColliderTests >> testUGenSuperClassIsAbstractFunction [ - -self assert: (UGen superclass) equals: AbstractFunction -] - -{ #category : #ugGraphFuncTesting } -PharoColliderTests >> testUGensGraphFuncSorting [ - -| freqControl oscillator out ugGraphFunc pos1 pos2 pos3 | - -freqControl := Control new. -oscillator := SinOsc new freq: freqControl . -out := Out new input: oscillator . -ugGraphFunc := UGensGraphFunc with: { oscillator . out }. - -pos1 := (ugGraphFunc at: 1) = freqControl. -pos2 := (ugGraphFunc at: 2) = oscillator . -pos3 := (ugGraphFunc at: 3) = out. -^ self assert: (pos1 & pos2 & pos3) equals: true -] diff --git a/src/PharoCollider/PositionableStream.extension.st b/src/PharoCollider/PositionableStream.extension.st deleted file mode 100644 index 99db014..0000000 --- a/src/PharoCollider/PositionableStream.extension.st +++ /dev/null @@ -1,10 +0,0 @@ -Extension { #name : #PositionableStream } - -{ #category : #'*PharoCollider' } -PositionableStream >> nextInt8Put: int8 [ - - "Write a signed integer to the next byte" - - self nextPut: int8 asSignedInt8. - ^ int8 -] diff --git a/src/PharoCollider/PureUGen.class.st b/src/PharoCollider/PureUGen.class.st deleted file mode 100644 index e38b44c..0000000 --- a/src/PharoCollider/PureUGen.class.st +++ /dev/null @@ -1,11 +0,0 @@ -Class { - #name : #PureUGen, - #superclass : #UGen, - #category : #'PharoCollider-UGens' -} - -{ #category : #writeDefinition } -PureUGen >> optimizeGraph [ - -super performDeadCodeElimination -] diff --git a/src/PharoCollider/SCServer.class.st b/src/PharoCollider/SCServer.class.st deleted file mode 100644 index 1ad985d..0000000 --- a/src/PharoCollider/SCServer.class.st +++ /dev/null @@ -1,39 +0,0 @@ -" -Convenience class to hold and change data for commmunication to the SUperCollider scsynth server - - -###??? should be implemented as a uniqueInstance? -" -Class { - #name : #SCServer, - #superclass : #Object, - #classVars : [ - 'address', - 'port' - ], - #category : #'PharoCollider-SCServer' -} - -{ #category : #accessing } -SCServer class >> address [ -^ '127.0.0.1' - -] - -{ #category : #accessing } -SCServer class >> address: aString [ - - address := aString -] - -{ #category : #accessing } -SCServer class >> port [ - - ^ 57110 -] - -{ #category : #accessing } -SCServer class >> port: anInteger [ - -port := anInteger -] diff --git a/src/PharoCollider/SamplePlayer.class.st b/src/PharoCollider/SamplePlayer.class.st deleted file mode 100644 index e2e568d..0000000 --- a/src/PharoCollider/SamplePlayer.class.st +++ /dev/null @@ -1,79 +0,0 @@ -" -Essential SamplePlayer -" -Class { - #name : #SamplePlayer, - #superclass : #SynthDefs, - #instVars : [ - 'id', - 'bufferNumber' - ], - #category : #PharoCollider -} - -{ #category : #accessing } -SamplePlayer >> bufferNumber [ -^ bufferNumber -] - -{ #category : #accessing } -SamplePlayer >> bufferNumber: aBufferNumber [ - - bufferNumber := aBufferNumber. - -(OSCMessage for: { - 15. - id. - 'buf'. - aBufferNumber }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #initialization } -SamplePlayer >> initialize [ - - super initialize. - (OSCMessage for: - { '/d_load'. '/Users/domenicocipriani/Library/Application Support/SuperCollider/synthdefs/sampy.*' }) - sendToAddressString: '127.0.0.1' - port: 57110. - self setId: (Random new nextIntegerBetween: 9 and: 99) -] - -{ #category : #playing } -SamplePlayer >> play [ - - " third argument is ID" - - (OSCMessage for: { - 's_new'. - 'sampy'. - id. - 0. - 0 }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #'as yet unclassified' } -SamplePlayer >> rate: aRate [ - - (OSCMessage for: { - 15. - id. - 'rate'. - aRate }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #initialization } -SamplePlayer >> setId: anInteger [ - - id := anInteger -] - -{ #category : #'as yet unclassified' } -SamplePlayer >> trig [ -" triiger the sample" - (OSCMessage for: { - 15. - id. - 't_tr'. - 1 }) sendToAddressString: '127.0.0.1' port: 57110 -] diff --git a/src/PharoCollider/ScSynth.class.st b/src/PharoCollider/ScSynth.class.st deleted file mode 100644 index cdfcc79..0000000 --- a/src/PharoCollider/ScSynth.class.st +++ /dev/null @@ -1,14 +0,0 @@ -" -Convenience methods to control scsynth server -" -Class { - #name : #ScSynth, - #superclass : #Object, - #category : #PharoCollider -} - -{ #category : #'as yet unclassified' } -ScSynth class >> dumpOSC [ -" prints OSC messages received by the server on SUperCollider console" -(OSCMessage for: { '/d_load' . '/Users/domenicocipriani/Library/Application Support/SuperCollider/synthdefs/sine.*' }) sendToAddressString: '127.0.0.1' port: 57110 -] diff --git a/src/PharoCollider/SinOsc.class.st b/src/PharoCollider/SinOsc.class.st deleted file mode 100644 index e06f6a3..0000000 --- a/src/PharoCollider/SinOsc.class.st +++ /dev/null @@ -1,53 +0,0 @@ -" -1537+02:00 LiveCoding4Pharo10.0.image priorSource: 3085015 -" -Class { - #name : #SinOsc, - #superclass : #PureUGen, - #instVars : [ - 'freq', - 'phase' - ], - #category : #'PharoCollider-UGens' -} - -{ #category : #'accessing - structure variables' } -SinOsc >> freq [ - - ^ inputs at: 1 -] - -{ #category : #accessing } -SinOsc >> freq: aFloatOrAUGen [ - - "frequency can be a float or a UGen, if it is a UGen, the constant is only phase" - - freq := aFloatOrAUGen. " ? " - self addInput: aFloatOrAUGen At: 1 - -] - -{ #category : #'accessing - structure variables' } -SinOsc >> initialize [ - - "initialize ad Super Collider SinOSc at audiorate" - - super initialize. - calculationRate := 2. - - outputs := #( #left ). "does this make sense?" - inputs := Array with: 440.0 with: 0.0 "the initialized SinOsc has a frequency of 440hz and a phase of 0.0" -] - -{ #category : #accessing } -SinOsc >> phase [ - - ^ inputs at: 2. -] - -{ #category : #accessing } -SinOsc >> phase: aFloatOrAUGen [ - - phase := aFloatOrAUGen. - self addInput: aFloatOrAUGen At: 2 -] diff --git a/src/PharoCollider/Sine.class.st b/src/PharoCollider/Sine.class.st deleted file mode 100644 index 1f55638..0000000 --- a/src/PharoCollider/Sine.class.st +++ /dev/null @@ -1,61 +0,0 @@ -" -Basic SineWave with frequency control -" -Class { - #name : #Sine, - #superclass : #SynthDefs, - #instVars : [ - 'id' - ], - #category : #PharoCollider -} - -{ #category : #'accessing - structure variables' } -Sine >> freq: aFrequency [ - -(OSCMessage for: { 15 . id. 'freq' .aFrequency}) sendToAddressString: '127.0.0.1' port: 57110. -] - -{ #category : #'accessing - structure variables' } -Sine >> gate: oneOrZero [ - - (OSCMessage for: { - 15. - id. - 'gate'. - oneOrZero }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #accessing } -Sine >> id [ - - ^ id -] - -{ #category : #initialization } -Sine >> initialize [ -super initialize. -(OSCMessage for: { '/d_load' . '/Users/domenicocipriani/Library/Application Support/SuperCollider/synthdefs/sine.*' }) sendToAddressString: '127.0.0.1' port: 57110. -self setId: (Random new nextIntegerBetween: 9 and: 99 ) -] - -{ #category : #'accessing - structure variables' } -Sine >> note: aNoteNumber [ - - (OSCMessage for: { - 15. - id. - 'note'. - aNoteNumber }) sendToAddressString: '127.0.0.1' port: 57110 -] - -{ #category : #playing } -Sine >> play [ -" third argument is ID" -(OSCMessage for:{'s_new'. 'sine'. id . 0 . 0}) sendToAddressString: '127.0.0.1' port: 57110. -] - -{ #category : #initialization } -Sine >> setId: anInteger [ -id := anInteger -] diff --git a/src/PharoCollider/String.extension.st b/src/PharoCollider/String.extension.st deleted file mode 100644 index 39f1abc..0000000 --- a/src/PharoCollider/String.extension.st +++ /dev/null @@ -1,15 +0,0 @@ -Extension { #name : #String } - -{ #category : #'*PharoCollider' } -String >> asPString [ - - "SuperCollider pascal format string: a byte (an unsigned int8) giving the length followed by that many bytes." - - | pString | - pString := ByteArray new: self size + 1. - pString at: 1 put: self size. - 2 to: (self size + 1) do: [ :i | - pString at: i put: (self asByteArray at: i - 1) ]. - - ^ pString -] diff --git a/src/PharoCollider/Synth.class.st b/src/PharoCollider/Synth.class.st deleted file mode 100644 index 12c859d..0000000 --- a/src/PharoCollider/Synth.class.st +++ /dev/null @@ -1,14 +0,0 @@ -" -Corresponds to SuperCollider Snth class -" -Class { - #name : #Synth, - #superclass : #Object, - #category : #'PharoCollider-SynthDef' -} - -{ #category : #'as yet unclassified' } -Synth >> playDummySynth [ - - { '/s_new'. 'io'. 1001. 0. 0 } sendToSCServer -] diff --git a/src/PharoCollider/SynthDef.class.st b/src/PharoCollider/SynthDef.class.st deleted file mode 100644 index 5801d33..0000000 --- a/src/PharoCollider/SynthDef.class.st +++ /dev/null @@ -1,510 +0,0 @@ -" -Corresponds to SuperCollider client-side definition of a synth definition. -The core of a synthdef is its unit generator graph function (, here represented by an instance variable called uGensGraphFunc that is a Sorted Collection. - -SynthDef tries to arrange the UGens in the uGensGraphFunc in depth-first. It begins with the first UGen in the list of children that is taking no input from any other UGen. (If it isn’t taking input from another UGen, then there is no UGen that needs to be calculated before this one. Thus this UGen is eligible to go into the final ordering – “available,” in the code.). -Then it follows the input-output chain as far down as it can, before moving on to any other “available” UGens that hadn’t been resolved yet. - -Usually we will find Control near the top because normally its outputs are feeding into other units, pushing those other units later in the order. (What’s the point of a Control that isn’t controlling anything?) But there is no rule that Controls must precede other units. The typical ordering is a consequence of normal usage, in which other units depend on data from Control, so those other units must follow after Control. -" -Class { - #name : #SynthDef, - #superclass : #Object, - #instVars : [ - 'defname', - 'func', - 'children', - 'controls', - 'controlNames', - 'allControlNames', - 'controlIndex', - 'constants', - 'constantsSet', - 'maxLocalBufs', - 'numberOfConstants', - 'parameters', - 'numberOfVariants', - 'constantValues', - 'numberOfUGens', - 'uGensGraphFunc', - 'available', - 'variants', - 'widthFirstUGens', - 'rewriteInProgress', - 'desc', - 'metadata' - ], - #category : #'PharoCollider-SynthDef' -} - -{ #category : #'as yet unclassified' } -SynthDef class >> name: aString with: aCollectionOfUGens [ - - ^ self new - name: aString; - graph: aCollectionOfUGens; - finishBuild -] - -{ #category : #'instance creation' } -SynthDef class >> with: aCollectionOfUGens [ - - ^ self new - graph: aCollectionOfUGens; - finishBuild -] - -{ #category : #topoSorting } -SynthDef >> addConstant: aValue [ -(constantsSet includes: aValue) not ifTrue: [ constantsSet add: aValue. constants at: aValue put: constants size ] -] - -{ #category : #topoSorting } -SynthDef >> addUGen: anUGen [ - - " if (rewriteInProgress.isNil) " - - " we forget about this for now" - - anUGen synthIndex: children size. - anUGen widthFirstAntecedents: widthFirstUGens copy. - (' I AM ADDING UGEN' , anUGen class name asString) traceCr. - self children add: anUGen -] - -{ #category : #converting } -SynthDef >> asBytes [ - - | int8Array SCgf version def | - int8Array := OrderedCollection new. - "int32 - four byte file type id containing the ASCII characters: 'SCgf' " - SCgf := 'SCgf' asByteArray. - int8Array addAll: SCgf. - "int32 - file version, currently 2." - version := #( 0 0 0 2 ). - int8Array addAll: version. - "int16 - number of synth definitions in this file (D)." - def := #( 0 1 ). "for one definition" - int8Array addAll: def. - "pstring - the name of the synth definition" - int8Array addAll: defname asPString. - "int32 - number of constants (K)" - int8Array addAll: (constants size asByteArrayOfSize: 4). - "constant values" - constants keys do: [ :item | - int8Array addAll: item asInt8ArrayOfSize4 ]. - "number of controls" - int8Array addAll: (controls size asByteArrayOfSize: 4). - "control values" - controls do: [ :c | - int8Array addAll: (c values asByteArrayOfSize: 4) ]. - "control param names - maybe must be changed!" - int8Array addAll: (controls size asByteArrayOfSize: 4). - - "param name and paramIndex" - controls do: [ :c | - int8Array - addAll: c paramName asPString; - addAll: ((controls indexOf: c) - 1 asByteArrayOfSize: 4) ]. - " number of UGens" - int8Array addAll: (self children size asByteArrayOfSize: 4). - "UGens description" - children do: [ :c | int8Array addAll: c asBytes ]. "must be implemented for UGens" - " variants ?? for the moment we leave it to 0" - int8Array addAll: (self variants asByteArrayOfSize: 2). - "end" - ^ int8Array asDirtArray -] - -{ #category : #converting } -SynthDef >> asBytesDeprecated [ - - | int8Array SCgf version def | - int8Array := OrderedCollection new. - "int32 - four byte file type id containing the ASCII characters: 'SCgf' " - SCgf := 'SCgf' asByteArray. - SCgf do: [ :i | int8Array add: i ]. - "int32 - file version, currently 2." - version := #( 0 0 0 2 ). - 1 to: version size do: [ :i | int8Array add: (version at: i) ]. - "int16 - number of synth definitions in this file (D)." - def := #( 0 1 ). "for one definition" - 1 to: def size do: [ :i | int8Array add: (def at: i) ]. - "pstring - the name of the synth definition" - - int8Array addLast: defname size. - 1 to: defname size do: [ :i | - int8Array add: (defname asByteArray at: i) ]. - "int32 - number of constants (K)" - - 1 to: numberOfConstants size do: [ :i | - int8Array add: (numberOfConstants at: i) ]. - - "[float32] * K - constant values" - - "int32 - number of parameters (P)" - - 1 to: numberOfParameters size do: [ :i | - int8Array add: (numberOfParameters at: i) ]. - - "[float32] * P - initial parameter values" - - "int32 - number of parameter names (N)" - - (1 to: numberOfParameterNames size) do: [ :i | - int8Array add: (numberOfParameterNames at: i) ]. - - "int32 - number of unit generators (U)" - - 1 to: numberOfUGens size do: [ :i | - int8Array add: (numberOfUGens at: i) ]. - - "int16 - number of variants (V)" - - 1 to: numberOfVariants size do: [ :i | - int8Array add: (numberOfVariants at: i) ]. - - - - ^ int8Array asDirtArray -] - -{ #category : #converting } -SynthDef >> asBytesSCImplementation [ - - "kind of like SC writeDef methods, using an ordered collection to store the result" - - | int8Array allControlNamesTemp allControlNamesMap | - int8Array := OrderedCollection new. "??better to have fixed size array of 256?" - int8Array add: defname asPString. - int8Array add: (controls size asByteArrayOfSize: 4). - controls do: [ :item | int8Array add: item ]. - - allControlNamesTemp := allControlNames reject: [ :cn | - cn rate = #control ]. "!!!! originally = #nonControl !!!!!!" - - int8Array add: (allControlNamesTemp size asByteArrayOfSize: 4). - allControlNamesTemp do: [ :item | - item name isNotNil ifTrue: [ - int8Array add: item name asPString. - int8Array add: (item index asByteArrayOfSize: 4) ] ]. - - int8Array add: children size. - children do: [ :item | item writeDef: int8Array ] -] - -{ #category : #accessing } -SynthDef >> available [ -^ available -] - -{ #category : #accessing } -SynthDef >> available: anOrderedCollection [ - - available := anOrderedCollection -] - -{ #category : #topoSorting } -SynthDef >> checkInputs [ - -"should be implementedMethods: " - -] - -{ #category : #accessing } -SynthDef >> children [ -^ children -] - -{ #category : #topoSorting } -SynthDef >> cleanupTopoSort [ - - children isNotNil ifTrue: [ - children do: [ :ugen | - ugen setAntecedents. - ugen setDescendants] ] -] - -{ #category : #topoSorting } -SynthDef >> collectConstants [ -children isNotNil ifTrue: [ children do: [ :ugen | ugen collectConstants ]] -] - -{ #category : #accessing } -SynthDef >> constants [ - - ^ constants -] - -{ #category : #accessing } -SynthDef >> controls [ -^ controls -] - -{ #category : #accessing } -SynthDef >> costantsSet [ - -^ constantsSet -] - -{ #category : #accessing } -SynthDef >> defname [ -^ defname -] - -{ #category : #topoSorting } -SynthDef >> dumpUGens [ - - self name traceCr. - - children do: [ :ugen | - (ugen dumpName , ', ' , ugen rate , ', ' - , ', ' , ugen inputs asString) traceCr ] -] - -{ #category : #topoSorting } -SynthDef >> finishBuild [ - - "taken from SuperCollider implementation - last method to be call to get the SynthDf asBytes" - - self available: OrderedCollection new. - - "self optimizeGraph." - self initTopoSort. - self collectConstants. - - "self checkInputs. will die on error" - - "re-sort graph, topological REindex" - - self available: OrderedCollection new - "self topologicalSort." - - "self indexUGens" - - "UGen buildSynthDef: nil" -] - -{ #category : #accessing } -SynthDef >> graph [ - -^ uGensGraphFunc -] - -{ #category : #accessing } -SynthDef >> graph: aCollectionOfUGens [ - - | tempCollection synthIndx | - synthIndx := 0. - controls := OrderedCollection new. - tempCollection := Set new. - aCollectionOfUGens do: [ :ug | - tempCollection add: ug. - tempCollection addAll: (ug inputs reject: [ :inp | inp isUGen not ]) ]. - - children := Array new: tempCollection size. - tempCollection do: [ :ugen | - ugen isControl ifTrue: [ controls add: ugen ] ]. - tempCollection do: [ :ugen | - children at: ugen aggregatedInputs size + 1 put: ugen ]. - children do: [ :ugen | ugen assignTo: self . ugen synthIndex: synthIndx . synthIndx := synthIndx + 1]. - - ^ controls -] - -{ #category : #accessing } -SynthDef >> graphDeprecated: aCollectionOfUGens [ - - | synthIndx | - synthIndx := 0. - aCollectionOfUGens do: [ :ugen | - (children includes: ugen) not ifTrue: [ self addUGen: ugen ]. - - "we must check the following part" - uGensGraphFunc sortedUGens add: ugen. - - ugen inputs do: [ :inp | - inp isUGen & (uGensGraphFunc sortedUGens includes: inp) not - ifTrue: [ - uGensGraphFunc sortedUGens add: inp. - children add: inp ] ] ]. - "corresponding to SuperCollider addUGens method of the SynthDef class - " - children do: [ :ugen | self addUGen: ugen ] - " WE TRY !!!!!!!!" - "children do: [ :ugen | - ugen assignTo: self. - ugen synthIndex: synthIndx. - ugen widthFirstAntecedents: self widthFirstUGens. - ('I AM DOING MY GRAPH JOB' , ugen synthIndex asString) traceCr. - synthIndx := synthIndx + 1 ]" -] - -{ #category : #'as yet unclassified' } -SynthDef >> graphNotWorking: aCollectionOfUGens [ - - | synthIndx | - synthIndx := 0. - aCollectionOfUGens do: [ :ugen | - (children includes: ugen) not ifTrue: [ self addUGen: ugen ]. - - "we must check the following part" - uGensGraphFunc sortedUGens add: ugen. - - ugen inputs do: [ :inp | - inp isUGen & (uGensGraphFunc sortedUGens includes: inp) not - ifTrue: [ - uGensGraphFunc sortedUGens add: inp. - children add: inp ] ] ]. - "corresponding to SuperCollider addUGens method of the SynthDef class - " - children do: [ :ugen | - ugen assignTo: self. - ugen synthIndex: synthIndx. - ugen widthFirstAntecedents: self widthFirstUGens. - ('I AM DOING MY GRAPH JOB' , ugen synthIndex asString) traceCr. - synthIndx := synthIndx + 1 ] -] - -{ #category : #topoSorting } -SynthDef >> indexUGens [ - - " counting from 1 or from 0????" - - | index | - index := 0. - children traceCr. - children ifNotNil: [children do: [ :ugen | ugen synthIndex: index . index := index + 1]] -] - -{ #category : #topoSorting } -SynthDef >> initTopoSort [ - - "initially topological sort, based on SuperCollider implementation" - - "available := nil." - -children isNotNil ifTrue: [ - children do: [ :ugen | ugen makeAvailable ]]. - -" old " -" children isNotNil ifTrue: [ - children do: [ :ugen | - ugen setAntecedents. - ugen setDescendants ] ]. - children isNotNil ifTrue: [ - children do: [ :ugen | ugen initTopoSort ] ]. - children isNotNil ifTrue: [ - children reverseDo: [ :ugen | - ugen descendants asArray sort: [ :a :b | - a synthIndex < b synthIndex ]. - ugen makeAvailable all ugens with no antecedents are made available ] ] " -] - -{ #category : #initialization } -SynthDef >> initialize [ - - super initialize. - "SuperCollider implementation" - children := Array new. - constants := Dictionary new. - constantsSet := Set new. - available := OrderedCollection new. - controls := OrderedCollection new. - controlIndex := 0. - maxLocalBufs := 0. - - "my implementation" - defname := 'io'. - controlIndex := 0. - uGensGraphFunc := UGensGraphFunc new. - "define the sortBlock for the UGensGraphFunc" - "uGensGraphFunc sortBlock: [ :a :b | a isInputOf: b ]." - numberOfConstants := 0 asByteArrayOfSize: 4. - parameters := OrderedCollection new. - numberOfUGens := 0 asByteArrayOfSize: 4. - numberOfVariants := 0 asByteArrayOfSize: 2. - variants := 0 -] - -{ #category : #accessing } -SynthDef >> name [ -^ defname -] - -{ #category : #accessing } -SynthDef >> name: aString [ - defname := aString -] - -{ #category : #accessing } -SynthDef >> numberOfConstants [ - -| numOfConsts | - -^ numOfConsts -] - -{ #category : #accessing } -SynthDef >> numberOfUGens [ - - | integerNumberOfUGens | - - integerNumberOfUGens := uGensGraphFunc size. - ^ integerNumberOfUGens asByteArrayOfSize: 4 -] - -{ #category : #accessing } -SynthDef >> numberOfUGens: anInteger [ -numberOfUGens := anInteger asByteArrayOfSize: 4 -] - -{ #category : #topoSorting } -SynthDef >> optimizeGraph [ - - self initTopoSort. - - "children copy isNotNil ifTrue: [ - children copy do: [ :ugen | ugen optimizeGraph ] ]" - -] - -{ #category : #topoSorting } -SynthDef >> topologicalSort [ - - | outStack | - - outStack := OrderedCollection new. - self initTopoSort. - - [ available isNotEmpty ] whileTrue: [ - (available removeLast schedule: outStack ) traceCr. - "outStack := (available removeLast schedule: outStack) "]. - - children := outStack. - 'in topological sort' traceCr. - children traceCr. - self cleanupTopoSort -] - -{ #category : #accessing } -SynthDef >> variants [ -^ variants -] - -{ #category : #accessing } -SynthDef >> variants: anInteger [ - - ^ anInteger -] - -{ #category : #accessing } -SynthDef >> widthFirstUGens [ -^ widthFirstUGens -] - -{ #category : #accessing } -SynthDef >> widthFirstUGens: aWidthFirstUG [ - - widthFirstUGens := aWidthFirstUG -] diff --git a/src/PharoCollider/SynthDefs.class.st b/src/PharoCollider/SynthDefs.class.st deleted file mode 100644 index dd9eec7..0000000 --- a/src/PharoCollider/SynthDefs.class.st +++ /dev/null @@ -1,10 +0,0 @@ -" -Pharo frontend for SuperCollider scynth audio server - -Your SynthDef must adhere to the LiveCoding Package syntax in order to be aable to play it with a Performance -" -Class { - #name : #SynthDefs, - #superclass : #Object, - #category : #PharoCollider -} diff --git a/src/PharoCollider/UGen.class.st b/src/PharoCollider/UGen.class.st deleted file mode 100644 index b750b46..0000000 --- a/src/PharoCollider/UGen.class.st +++ /dev/null @@ -1,488 +0,0 @@ -Class { - #name : #UGen, - #superclass : #AbstractFunction, - #instVars : [ - 'synthDef', - 'rate', - 'uGenName', - 'specialIndex', - 'synthIndex', - 'rateNumber', - 'inputs', - 'outputs', - 'numberOfInputs', - 'numberOfConstants', - 'constantValues', - 'constants', - 'antecedents', - 'descendants', - 'widthFirstAntecedents', - 'outputIndex', - 'aggregatedInputs', - 'plugs' - ], - #classInstVars : [ - 'buildSynthDef', - 'synthDef' - ], - #category : #'PharoCollider-UGens' -} - -{ #category : #'as yet unclassified' } -UGen class >> multiNew: arguments [ - -^ self multiNewList -] - -{ #category : #'instance creation' } -UGen class >> multiNewList [ -] - -{ #category : #'instance creation' } -UGen class >> multiNewList: arguments [ - - | size args newArgs results | - size := 0. - args := arguments asUGenInputFor: self. - - ^ results -] - -{ #category : #'as yet unclassified' } -UGen >> => anUGen [ - - ^ UGensGraphFunc new numberOfUGens: 2 -] - -{ #category : #accessing } -UGen >> addInput: aFloatOrAUGen At: anInteger [ - - "generic method to add input to UGen" - - inputs at: anInteger put: aFloatOrAUGen. - aFloatOrAUGen isUGen ifTrue: [self aggregatedInputs add: aFloatOrAUGen . - self aggregatedInputs addAll: - (aFloatOrAUGen inputs reject: [ :ug | ug isUGen not ])] -] - -{ #category : #accessing } -UGen >> aggregatedInputs [ -^ aggregatedInputs -] - -{ #category : #accessing } -UGen >> aggregatedInputs: anInteger [ - -aggregatedInputs := anInteger. -] - -{ #category : #accessing } -UGen >> antecedents [ -^ antecedents -] - -{ #category : #'as yet unclassified' } -UGen >> ar [ - - "set calculation rate to audio rate" - - rateNumber := 2 -] - -{ #category : #writeDefinition } -UGen >> asBytes [ - - | int8Array | - int8Array := OrderedCollection new. - int8Array - addAll: self className asPString; - addAll: (self rateNumber asByteArrayOfSize: 1); - addAll: (self inputs size asByteArrayOfSize: 4); - addAll: (self outputs size asByteArrayOfSize: 4); - addAll: (self specialIndex asByteArrayOfSize: 2). - " !!!!!! IMPLEMENT INPUT SPECS" - self inputs do: [ :inp | int8Array addAll: inp writeInputSpec ]. - "output rate" - (self outputs size > 0) ifTrue: [int8Array addAll: (self rateNumber asByteArrayOfSize: 1)]. - - ^ int8Array asDirtArray -] - -{ #category : #writeDefinition } -UGen >> assignTo: aSynthDef [ -"my implementation to assign the UGen to a SynthDef" - -synthDef := aSynthDef . -] - -{ #category : #accessing } -UGen >> assignedSynthDef [ -^ synthDef -] - -{ #category : #testing } -UGen >> checkValidInputs [ - -^ 'Shoudl this be implemented as in Super Collider?' -] - -{ #category : #writeDefinition } -UGen >> collectConstants [ -inputs do: [ :input | input isNumber ifTrue: [synthDef addConstant: input asFloat] ] - - -] - -{ #category : #accessing } -UGen >> constantValues [ - - ^ constants values collect: [ :i | i] -] - -{ #category : #accessing } -UGen >> constantValues: anArray [ - - constantValues := anArray -] - -{ #category : #accessing } -UGen >> constants [ - - ^ constants -] - -{ #category : #accessing } -UGen >> constants: aDictionary [ - - constants := aDictionary -] - -{ #category : #accessing } -UGen >> descendants [ -^ descendants -] - -{ #category : #writeDefinition } -UGen >> dumpName [ - -^ self synthIndex asString , '_' , self class name asString. -] - -{ #category : #writeDefinition } -UGen >> initTopoSort [ - - "topological sort of UGens, taken from SUperCollider" - - inputs do: [ :input | - input isUGen ifTrue: [ - self antecedents add: input source. - input source descendants add: self ] ]. - - widthFirstAntecedents ifNotNil: [ - widthFirstAntecedents do: [ :ugen | - antecedents add: ugen. - ugen descendants add: self ] ] -] - -{ #category : #initialization } -UGen >> initialize [ - - super initialize. - plugs := OrderedCollection new. - aggregatedInputs := OrderedCollection new. - inputs := Array new. - outputs := Dictionary new. - constants := Dictionary new. - rate := #audio. - rateNumber := 2. "at the moment by defaut all UGen are created at audio rate - change to COntrol rate must be specified " - specialIndex := 0. - synthIndex := -1. - outputIndex := 0. - antecedents := Set new. - descendants := Set new - "this may be temporary : source should be a member of Output Proxy" -] - -{ #category : #accessing } -UGen >> inputs [ - - ^ inputs -] - -{ #category : #accessing } -UGen >> inputs: aConstantOrAUGen [ - - inputs := aConstantOrAUGen -] - -{ #category : #testing } -UGen >> inputsHaveUGen [ - -| ug | -ug := inputs collect: [ :input | input isUGen ]. -ug isNotEmpty ifTrue: [ ^ true ] ifFalse: [ ^ false ] -] - -{ #category : #accessing } -UGen >> inputsUGen [ - | result | - result := OrderedCollection new. - self inputs do: [ :i | i isNumber ifFalse: [ result add: i ] ifTrue: [ ] ] . -^ result asDirtArray -] - -{ #category : #testing } -UGen >> isControl [ - -^ false -] - -{ #category : #testing } -UGen >> isInputOf: anUGen [ - - ^ (anUGen inputs includes: self) or: (anUGen plugs includes: self) -] - -{ #category : #testing } -UGen >> isUGen [ -^ true -] - -{ #category : #'as yet unclassified' } -UGen >> kr [ -"set calculation rate to control rate" -calculationRate := 1. -] - -{ #category : #writeDefinition } -UGen >> makeAvailable [ - - antecedents isEmpty ifTrue: [ " synthDef.available = synthDef.available.add(this) " - synthDef available add: self] -] - -{ #category : #accessing } -UGen >> numInputs [ - -^ inputs size -] - -{ #category : #accessing } -UGen >> numOutputs [ - -^ outputs size -] - -{ #category : #accessing } -UGen >> numberOfConstants [ - - ^ constants size -] - -{ #category : #accessing } -UGen >> numberOfConstants: anInteger [ - - numberOfConstants := anInteger asByteArrayOfSize: 4 -] - -{ #category : #accessing } -UGen >> numberOfInputs [ -^ numberOfInputs . -] - -{ #category : #accessing } -UGen >> numberOfInputs: anObject [ - - numberOfInputs := anObject -] - -{ #category : #writeDefinition } -UGen >> optimizeGraph [ -"empty method in SuperCollider !?!?!" -] - -{ #category : #accessing } -UGen >> outputIndex [ - - ^ 0 -] - -{ #category : #accessing } -UGen >> outputs [ - - ^ outputs -] - -{ #category : #writeDefinition } -UGen >> performDeadCodeElimination [ - - descendants isEmptyOrNil ifTrue: [ - self inputs do: [ :a | - (a isKindOf: UGen) ifTrue: [ - a descendants remove: self. - a optimizeGraph ] ]. - "buildSynthDef.removeUGen(this)" - ^ false] -] - -{ #category : #accessing } -UGen >> plugs [ -^ plugs -] - -{ #category : #accessing } -UGen >> rate [ - -" rate can be: -#audio #control #scalar #trigger -" -^ rate -] - -{ #category : #accessing } -UGen >> rateNumber [ - -^ rateNumber -] - -{ #category : #accessing } -UGen >> rateNumber: anInteger [ - -rateNumber := anInteger -] - -{ #category : #writeDefinition } -UGen >> removeAntecedents: anUGen [ - -antecedents remove: anUGen. -self makeAvailable -] - -{ #category : #writeDefinition } -UGen >> schedule: anOutStack [ - - descendants asDirtArray reverseDo: [ :ugen | ugen removeAntecedents: self ]. - - ^ anOutStack add: self -] - -{ #category : #accessing } -UGen >> setAntecedents [ - - antecedents := Set new -] - -{ #category : #accessing } -UGen >> setDescendants [ - -descendants := Set new. -] - -{ #category : #accessing } -UGen >> source [ -"source is a member of the OutputProxy class in SuperCollider" - ^ self -] - -{ #category : #accessing } -UGen >> specialIndex [ - - ^ specialIndex -] - -{ #category : #accessing } -UGen >> synthIndex [ -^ synthIndex -] - -{ #category : #accessing } -UGen >> synthIndex: anInteger [ - -synthIndex := anInteger -] - -{ #category : #accessing } -UGen >> uGenName [ - - ^ uGenName -] - -{ #category : #'as yet unclassified' } -UGen >> uGenSpec [ - -| result | - result := OrderedCollection new. - result addAll: self uGenName asPString . - result add: calculationRate . - result addAll: (self numberOfInputs asByteArrayOfSize: 4). - result addAll: (self outputs asByteArrayOfSize: 4). - result addAll: (self specialIndex asByteArrayOfSize: 2) . - - self inputs keysAndValuesDo: [ :k :v | v isNumber ifTrue: [ result addAll: #(-1 -1 -1 -1). result addAll: (k asByteArrayOfSize: 4) ] ifFalse: [ - "index of unit generator and index of unit generator output" - ] ]. - - result add: self calculationRate . - - - - ^ result asDirtArray -] - -{ #category : #accessing } -UGen >> widthFirstAntecedents [ - -^ widthFirstAntecedents -] - -{ #category : #accessing } -UGen >> widthFirstAntecedents: aWidth [ - - widthFirstAntecedents := aWidth -] - -{ #category : #writeDefinition } -UGen >> writeDef: int8Array [ - - int8Array - addAll: self class name asPString; - add: self rateNumber; - addAll: (self numInputs asByteArrayOfSize: 4); - addAll: (self numOutputs asByteArrayOfSize: 4); - addAll: (self specialIndex asByteArrayOfSize: 2). - - inputs do: [ :input | - int8Array addAll: (input writeInputSpec) ]. - self writeOutputSpec: int8Array. - - - ^ int8Array -] - -{ #category : #writeDefinition } -UGen >> writeInputSpec [ - - | int8Array | - int8Array := OrderedCollection new. - int8Array addAll: (self synthIndex asByteArrayOfSize: 4). - int8Array addAll: (self outputIndex asByteArrayOfSize: 4). - ^ int8Array asDirtArray -] - -{ #category : #writeDefinition } -UGen >> writeInputSpec: aSynthDef [ -" should we use this?" - | int8Array | - int8Array := OrderedCollection new. - int8Array addAll: (self synthIndex asByteArrayOfSize: 4). - int8Array addAll: (self outputIndex asByteArrayOfSize: 4). - ^ int8Array -] - -{ #category : #writeDefinition } -UGen >> writeOutputSpec: int8Array [ - - "original SuperCollider method write to a file, not to an OrderedCollection, which I called int8Array" - - int8Array add: self rateNumber -] diff --git a/src/PharoCollider/UGensGraphFunc.class.st b/src/PharoCollider/UGensGraphFunc.class.st deleted file mode 100644 index 0a57a95..0000000 --- a/src/PharoCollider/UGensGraphFunc.class.st +++ /dev/null @@ -1,121 +0,0 @@ -" -UGenGraphFunc is an object that contains information about the UGenGraphFunc which builds the SynthDef in SuperCollider. -My implementation in Pharo is different. -A memeber of the class is sortedUGens which is a SorteCollection of the UGens in the SynthDef -" -Class { - #name : #UGensGraphFunc, - #superclass : #Object, - #instVars : [ - 'sortedUGens', - 'numberOfConstants', - 'numberOfParameters', - 'numberOfParameterNames', - 'numberOfUGens', - 'numberOfVariants' - ], - #category : #'PharoCollider-SynthDef' -} - -{ #category : #'instance creation' } -UGensGraphFunc class >> new [ - -^ super new - - numberOfConstants: ( 0 asByteArrayOfSize: 4); - numberOfParameters: (0 asByteArrayOfSize: 4); - numberOfParameterNames: (0 asByteArrayOfSize: 4); - numberOfUGens: (0 asByteArrayOfSize: 4); - numberOfVariants: (0 asByteArrayOfSize: 2). -] - -{ #category : #'instance creation' } -UGensGraphFunc class >> with: aCollectionOfUGens [ - - | uGensSet instance | - "first collect all the inputs of all the UGens in the collection as a Set to avoid duplicate" - instance := self new sortBlock: [ :a :b | a isInputOf: b ]. - uGensSet := Set new. - uGensSet addAll: aCollectionOfUGens. - aCollectionOfUGens do: [ :i | uGensSet addAll: i inputs ]. - - "sort UGens " - - uGensSet do: [ :i | instance add: i ]. - ^ instance - - -] - -{ #category : #initialization } -UGensGraphFunc >> initialize [ - - super initialize. - sortedUGens := SortedCollection new. - sortedUGens sortBlock: [ :a :b | a isInputOf: b ] -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfConstants [ - - ^ numberOfConstants -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfConstants: anInteger [ - - numberOfConstants := anInteger asByteArrayOfSize: 4 -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfParameterNames [ - - ^ numberOfParameterNames -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfParameterNames: anObject [ - - numberOfParameterNames := anObject -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfParameters [ - - ^ numberOfParameters -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfParameters: anInteger [ - - numberOfParameters := anInteger asByteArrayOfSize: 4 -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfUGens [ - - ^ numberOfUGens -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfUGens: anInteger [ - - numberOfUGens := anInteger asByteArrayOfSize: 4 -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfVariants [ - - ^ numberOfVariants -] - -{ #category : #accessing } -UGensGraphFunc >> numberOfVariants: anInteger [ - - numberOfVariants := anInteger asByteArrayOfSize: 2 -] - -{ #category : #accessing } -UGensGraphFunc >> sortedUGens [ -^ sortedUGens -] diff --git a/src/PharoCollider/UnaryOpFunction.class.st b/src/PharoCollider/UnaryOpFunction.class.st deleted file mode 100644 index ee6a2d4..0000000 --- a/src/PharoCollider/UnaryOpFunction.class.st +++ /dev/null @@ -1,9 +0,0 @@ -Class { - #name : #UnaryOpFunction, - #superclass : #AbstractFunction, - #instVars : [ - 'selector', - 'a' - ], - #category : #'PharoCollider-AbstractFunctions' -} diff --git a/src/PharoCollider/WriteStream.extension.st b/src/PharoCollider/WriteStream.extension.st deleted file mode 100644 index af26b16..0000000 --- a/src/PharoCollider/WriteStream.extension.st +++ /dev/null @@ -1,11 +0,0 @@ -Extension { #name : #WriteStream } - -{ #category : #'*PharoCollider' } -WriteStream >> nextPutAllSignedInt8: aCollection [ - - "Append the elements of aCollection to the sequence of objects accessible - by the receiver. Answer aCollection." - - aCollection do: [ :v | self nextPut: v asSignedInt8 ]. - ^ aCollection -] diff --git a/src/PharoCollider/package.st b/src/PharoCollider/package.st deleted file mode 100644 index 3afff90..0000000 --- a/src/PharoCollider/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #PharoCollider }