@@ -3,7 +3,7 @@ import Component, {IContainer} from "../Component";
3
3
import CodeInstance from "../expr/CodeInstance" ;
4
4
import compileExpr , { ICompileResult } from "../expr/compileExpr" ;
5
5
import IMain from "../IMain" ;
6
- import { BlendMode , Channels , Color , parseColorNorm , Source , WebGLVarType } from "../utils" ;
6
+ import { AudioChannels , AudioSource , BlendMode , Color , parseColorNorm , WebGLVarType } from "../utils" ;
7
7
import Buffer from "../webgl/Buffer" ;
8
8
import RenderingContext from "../webgl/RenderingContext" ;
9
9
import ShaderProgram from "../webgl/ShaderProgram" ;
@@ -59,11 +59,11 @@ export interface ISuperScopeOpts {
59
59
/**
60
60
* Channel for scope values. Default: `CENTER`
61
61
*/
62
- channel : string ;
62
+ audioChannel : string ;
63
63
/**
64
64
* Data source of scope value. Default: `SPECTRUM`
65
65
*/
66
- source : string ;
66
+ audioSource : string ;
67
67
/**
68
68
* Drawing mode for the scope. see [[SuperScopeDrawMode]]. Default: `LINES`
69
69
*/
@@ -120,19 +120,20 @@ export default class SuperScope extends Component {
120
120
public static componentName : string = "SuperScope" ;
121
121
public static componentTag : string = "render" ;
122
122
protected static optUpdateHandlers = {
123
+ audioChannel : "updateAudioChannel" ,
124
+ audioSource : "updateAudioSource" ,
123
125
blendMode : "updateProgram" ,
124
- channel : "updateChannel" ,
125
126
clone : "updateClones" ,
126
127
code : [ "updateCode" , "updateClones" ] ,
127
128
colors : "updateColors" ,
128
129
cycleSpeed : "updateSpeed" ,
129
130
drawMode : "updateDrawMode" ,
130
- source : "updateSource" ,
131
131
thickness : "updateThickness" ,
132
132
} ;
133
133
protected static defaultOptions : ISuperScopeOpts = {
134
+ audioChannel : "CENTER" ,
135
+ audioSource : "SPECTRUM" ,
134
136
blendMode : "REPLACE" ,
135
- channel : "CENTER" ,
136
137
clone : 1 ,
137
138
code : {
138
139
init : "n=800" ,
@@ -143,7 +144,6 @@ export default class SuperScope extends Component {
143
144
colors : [ "#ffffff" ] ,
144
145
cycleSpeed : 0.01 ,
145
146
drawMode : "LINES" ,
146
- source : "SPECTRUM" ,
147
147
thickness : 1 ,
148
148
} ;
149
149
@@ -153,8 +153,8 @@ export default class SuperScope extends Component {
153
153
private code : ISSCodeInstance [ ] ;
154
154
private inited : boolean ;
155
155
private program : ShaderProgram < ISuperScopeShaderValues > ;
156
- private source : Source ;
157
- private channel : Channels ;
156
+ private audioSource : AudioSource ;
157
+ private audioChannel : AudioChannels ;
158
158
private drawMode : SuperScopeDrawMode ;
159
159
private veryThick : boolean ;
160
160
private colors : Color [ ] ;
@@ -168,13 +168,13 @@ export default class SuperScope extends Component {
168
168
169
169
public init ( ) {
170
170
this . updateDrawMode ( ) ;
171
- this . updateSource ( ) ;
171
+ this . updateAudioSource ( ) ;
172
172
this . updateProgram ( ) ;
173
173
this . updateCode ( ) ;
174
174
this . updateClones ( ) ;
175
175
this . updateSpeed ( ) ;
176
176
this . updateColors ( ) ;
177
- this . updateChannel ( ) ;
177
+ this . updateAudioChannel ( ) ;
178
178
this . updateThickness ( ) ;
179
179
this . listenTo ( this . main , "resize" , ( ) => this . handleResize ( ) ) ;
180
180
@@ -221,10 +221,10 @@ export default class SuperScope extends Component {
221
221
222
222
const nPoints = Math . floor ( code . n ) ;
223
223
let data ;
224
- if ( this . source === Source . SPECTRUM ) {
225
- data = this . main . getAnalyser ( ) . getSpectrum ( this . channel ) ;
224
+ if ( this . audioSource === AudioSource . SPECTRUM ) {
225
+ data = this . main . getAnalyser ( ) . getSpectrum ( this . audioChannel ) ;
226
226
} else {
227
- data = this . main . getAnalyser ( ) . getWaveform ( this . channel ) ;
227
+ data = this . main . getAnalyser ( ) . getWaveform ( this . audioChannel ) ;
228
228
}
229
229
const dots = this . drawMode === SuperScopeDrawMode . DOTS ;
230
230
const bucketSize = data . length / nPoints ;
@@ -466,12 +466,12 @@ export default class SuperScope extends Component {
466
466
}
467
467
}
468
468
469
- private updateChannel ( ) {
470
- this . channel = Channels [ this . opts . channel ] ;
469
+ private updateAudioChannel ( ) {
470
+ this . audioChannel = AudioChannels [ this . opts . audioChannel ] ;
471
471
}
472
472
473
- private updateSource ( ) {
474
- this . source = Source [ this . opts . source ] ;
473
+ private updateAudioSource ( ) {
474
+ this . audioSource = AudioSource [ this . opts . audioSource ] ;
475
475
}
476
476
477
477
private updateDrawMode ( ) {
0 commit comments