Skip to content

Add microphone input support #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 19, 2025
Merged

Add microphone input support #499

merged 11 commits into from
May 19, 2025

Conversation

mattgodbolt
Copy link
Owner

Summary

  • Add support for using microphone input as an analogue source for the BBC Micro's ADC
  • Implement a clean UI in the configuration panel with channel selection
  • Handle microphone permissions and provide clear status messages

Test plan

  1. Open the emulator configuration panel
  2. Select a microphone channel (0-3)
  3. Grant microphone permissions when prompted
  4. Test with software that uses the ADC input like MicroMike

🤖 Generated with Claude Code

mattgodbolt and others added 8 commits May 18, 2025 10:46
Implements GitHub issue #175, adding support for connecting the browser's
microphone to the BBC Micro's analogue port to support software like MicroMike.

Key changes:
- Create AnalogueSource interface for ADC inputs
- Implement GamepadSource to replace the existing hardcoded gamepad handling
- Add MicrophoneInput implementation using Web Audio API
- Refactor ADC to use multiple sources
- Add UI controls in the configuration dialog
- Add URL parameter support for settings persistence

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove debug console logs from production code
- Maintain explicit channel sources in ADC implementation
- Fix test to match channel used in test case

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove separate checkbox for enabling microphone input
- Always show microphone settings with disabled option
- Centralize microphone handling in Config class
- Simplify channel selection with proper disabling option
- Add better status messaging for microphone permissions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@mattgodbolt mattgodbolt requested a review from Copilot May 18, 2025 22:35
@mattgodbolt mattgodbolt linked an issue May 18, 2025 that may be closed by this pull request
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for using the microphone as an analogue input source for the emulator's ADC, along with corresponding UI updates and configuration handling.

  • Introduces a new MicrophoneInput class for managing audio context and microphone data.
  • Integrates microphone channel selection into the configuration panel and main emulator setup.
  • Updates the configuration and UI (dropdown menu) to allow users to select and configure the microphone channel.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/microphone-input.js Implements the MicrophoneInput class with audio initialisation and value computation
src/main.js Integrates microphone input into the emulator pipeline and handles permissions/resuming the audio context
src/config.js Adds configuration support for selecting microphone channels
index.html Adds a new dropdown menu for microphone channel selection

@mattgodbolt mattgodbolt requested a review from Copilot May 19, 2025 00:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for using the system microphone as an analogue source for the BBC Micro’s ADC, complete with UI controls and permission handling.

  • Introduces a new MicrophoneInput class for capturing and scaling audio data.
  • Integrates microphone channel selection into the configuration panel and URL parameters.
  • Displays permission status and error messages in the UI.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/microphone-input.js Implements MicrophoneInput with init, value scaling, and cleanup
src/main.js Imports and configures microphone source, handles URL & permissions
src/config.js Adds click handler & setter for microphoneChannel
index.html Adds dropdown and status text for microphone channel selection
Comments suppressed due to low confidence (1)

src/microphone-input.js:102

  • Consider adding unit tests for getValue, mocking the analyser to verify scaling and 16-bit mapping behavior.
getValue(_channel) {


// Scale up the signal using a configurable scaling factor
// This can be adjusted based on testing
const scaleFactor = 800; // Amplify the signal
Copy link
Preview

Copilot AI May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Extract the magic number 800 into a named constant or configurable property to clarify its purpose and make tuning easier.

Suggested change
const scaleFactor = 800; // Amplify the signal
const scaleFactor = DEFAULT_SCALE_FACTOR; // Amplify the signal

Copilot uses AI. Check for mistakes.

@mattgodbolt mattgodbolt merged commit 44bf650 into main May 19, 2025
3 checks passed
@mattgodbolt mattgodbolt deleted the claude/microphone branch May 19, 2025 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to connect analogue port to microphone input
1 participant