Skip to content

Commit aea7937

Browse files
Activate sim mic light when recording
Passing this.microphone.microphoneOn/Off functions as BoardAudio constructors in board/index.ts didn't work for some reasons. The microphone element was flagged as being undefined. So instead I passed the element directly into the BoardAudio constructor, which worked.
1 parent 4ed8c93 commit aea7937

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/board/audio/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export class BoardAudio {
2929
currentSoundExpressionCallback: undefined | (() => void);
3030
private stopActiveRecording: (() => void) | undefined;
3131

32-
constructor() {}
32+
constructor(
33+
private microphoneEl: SVGElement
34+
) {}
3335

3436
initializeCallbacks({
3537
defaultAudioCallback,
@@ -190,6 +192,7 @@ export class BoardAudio {
190192
this.stopRecording();
191193
return;
192194
}
195+
this.microphoneEl.style.display = "unset"
193196

194197
const source = this.context!.createMediaStreamSource(micStream);
195198
// TODO: wire up microphone sensitivity to this gain node
@@ -227,6 +230,7 @@ export class BoardAudio {
227230
gain.disconnect();
228231
source.disconnect();
229232
micStream.getTracks().forEach(track => track.stop())
233+
this.microphoneEl.style.display = "none"
230234
this.stopActiveRecording = undefined;
231235
};
232236
}

src/board/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export class Board {
202202
this.pins[MICROBIT_HAL_PIN_P19] = new StubPin("pin19");
203203
this.pins[MICROBIT_HAL_PIN_P20] = new StubPin("pin20");
204204

205-
this.audio = new BoardAudio();
205+
this.audio = new BoardAudio(this.svg.querySelector("#LitMicrophone")!);
206206
this.temperature = new RangeSensor("temperature", -5, 50, 21, "°C");
207207
this.accelerometer = new Accelerometer(onChange);
208208
this.compass = new Compass();

0 commit comments

Comments
 (0)