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 {
118118 }
119119
120120 setPeriodUs ( periodUs : number ) {
121- this . frequency = 1000000 / periodUs ;
121+ // CODAL defaults in this way:
122+ this . frequency = periodUs === 0 ? 6068 : 1000000 / periodUs ;
122123 if ( this . oscillator ) {
123124 this . oscillator . frequency . value = this . frequency ;
124125 }
125126 }
126127
127128 setAmplitudeU10 ( amplitudeU10 : number ) {
128- if ( this . oscillator ) {
129- this . oscillator . stop ( ) ;
130- this . oscillator = undefined ;
131- }
129+ this . stopOscillator ( ) ;
132130 if ( amplitudeU10 ) {
133131 this . oscillator = this . context ! . createOscillator ( ) ;
134132 this . oscillator . type = "sine" ;
@@ -138,7 +136,16 @@ export class Audio {
138136 }
139137 }
140138
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+ }
142149}
143150
144151class BufferedAudio {
You can’t perform that action at this time.
0 commit comments