Skip to content

Commit bcc62ca

Browse files
committed
add methods to ICOScilloscope
1 parent 1483af7 commit bcc62ca

File tree

2 files changed

+76
-5
lines changed

2 files changed

+76
-5
lines changed

CoypuIDE/DSP.extension.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ DSP >> connectToOSCServerOnPort: aPort [
158158

159159
{ #category : '*CoypuIDE' }
160160
DSP >> displayUI [
161-
"fdisplay the IU made with Bloc"
161+
"display the IU made with Bloc"
162162

163163
| space |
164164
"first we build the UI"

CoypuIDE/ICOscilloscope.class.st

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,98 @@ Class {
55
#name : 'ICOscilloscope',
66
#superclass : 'Object',
77
#instVars : [
8-
'sampleData'
8+
'sampleData',
9+
'audioDisplay',
10+
'dsp',
11+
'isUpdating'
912
],
1013
#category : 'CoypuIDE-oscilloscope',
1114
#package : 'CoypuIDE',
1215
#tag : 'oscilloscope'
1316
}
1417

18+
{ #category : 'accessing' }
19+
ICOscilloscope >> audioDisplay [
20+
21+
^ audioDisplay
22+
]
23+
24+
{ #category : 'accessing' }
25+
ICOscilloscope >> dsp [
26+
27+
^ dsp
28+
]
29+
30+
{ #category : 'accessing' }
31+
ICOscilloscope >> dsp: aDsp [
32+
]
33+
1534
{ #category : 'initialization' }
16-
ICOscilloscope >> initialize [
35+
ICOscilloscope >> initialize [
36+
37+
super initialize.
38+
self initializeSampleData.
39+
audioDisplay := ICAudioDisplay fromArray: sampleData.
1740

18-
super initialize .
19-
self initializeSampleData .
2041
]
2142

2243
{ #category : 'initialization' }
2344
ICOscilloscope >> initializeSampleData [
2445
sampleData := ( 1 to: 256 ) collect: [ :i | 0 ].
2546
]
2647

48+
{ #category : 'accessing' }
49+
ICOscilloscope >> isUpdating [
50+
51+
^ isUpdating
52+
]
53+
54+
{ #category : 'accessing' }
55+
ICOscilloscope >> isUpdating: aBoolean [
56+
57+
isUpdating := aBoolean
58+
]
59+
60+
{ #category : 'convenience' }
61+
ICOscilloscope >> openInSpace [
62+
63+
| space |
64+
"first we build the UI"
65+
space := BlSpace new title: 'ICOscilloscope'.
66+
self isUpdating: true.
67+
space root background: Color black lighter.
68+
space root addChild: self audioDisplay.
69+
self audioDisplay
70+
addEventHandlerOn: BlElementExtentChangedEvent
71+
do: [ :evt | space extent: evt target extent ].
72+
73+
74+
"ADD EVENT HANDLER TO SAFELY TERMINATE EVERY ICVISUALIZER UPDATEVALUE PROCESS"
75+
space
76+
addEventHandlerOn: BlSpaceClosedEvent
77+
do: [ self isUpdating: false ].
78+
space show.
79+
80+
81+
^ space
82+
]
83+
2784
{ #category : 'accessing' }
2885
ICOscilloscope >> sampleData [
2986

3087
^ sampleData
3188
]
89+
90+
{ #category : 'as yet unclassified' }
91+
ICOscilloscope >> updateSampleData [
92+
93+
| buf |
94+
[
95+
self isUpdating whileTrue: [
96+
buf := PhaustoDynamicEngine uniqueInstance getBuffer: self dsp.
97+
sampleData := buf
98+
readArrayOf: FFIFloat32 new
99+
until: [ :eachFloat :count | count = 513 ].
100+
self audioDisplay readArray: sampleData.
101+
0.06 seconds wait ] ] fork
102+
]

0 commit comments

Comments
 (0)