File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -118,17 +118,15 @@ export class Audio {
118
118
}
119
119
120
120
setPeriodUs ( periodUs : number ) {
121
- this . frequency = 1000000 / periodUs ;
121
+ // CODAL defaults in this way:
122
+ this . frequency = periodUs === 0 ? 6068 : 1000000 / periodUs ;
122
123
if ( this . oscillator ) {
123
124
this . oscillator . frequency . value = this . frequency ;
124
125
}
125
126
}
126
127
127
128
setAmplitudeU10 ( amplitudeU10 : number ) {
128
- if ( this . oscillator ) {
129
- this . oscillator . stop ( ) ;
130
- this . oscillator = undefined ;
131
- }
129
+ this . stopOscillator ( ) ;
132
130
if ( amplitudeU10 ) {
133
131
this . oscillator = this . context ! . createOscillator ( ) ;
134
132
this . oscillator . type = "sine" ;
@@ -138,7 +136,16 @@ export class Audio {
138
136
}
139
137
}
140
138
141
- boardStopped ( ) { }
139
+ boardStopped ( ) {
140
+ this . stopOscillator ( ) ;
141
+ }
142
+
143
+ private stopOscillator ( ) {
144
+ if ( this . oscillator ) {
145
+ this . oscillator . stop ( ) ;
146
+ this . oscillator = undefined ;
147
+ }
148
+ }
142
149
}
143
150
144
151
class BufferedAudio {
You can’t perform that action at this time.
0 commit comments