Skip to content

fix: browser microphone connection to Csound with user warnings#428

Open
Nandos0804 wants to merge 1 commit intocsound:developfrom
Nandos0804:audio-in
Open

fix: browser microphone connection to Csound with user warnings#428
Nandos0804 wants to merge 1 commit intocsound:developfrom
Nandos0804:audio-in

Conversation

@Nandos0804
Copy link
Contributor

This PR introduces support for routing browser microphone input directly into Csound when the -iadc or --input=adc flags are present in the Csound options.

  • Detects -iadc/--input=adc flags in <CsOptions> and strips them from the CSD before compiling, mapping them to browser microphone input instead.

  • Adds error handling for microphone input startup, including user notification and proper cleanup if permissions or browser policy prevent audio input.

  • Installs the microphone bridge and ensures audio input is enabled at the correct time in the Csound startup sequence.

@Nandos0804
Copy link
Contributor Author

Nandos0804 commented Mar 20, 2026

If this is a clear sign of errors on @csound/wasm build, than this PR is safe to close without review. Attempt to fix #411

Comment on lines +146 to +156
const hasAdcInputFlagInCsOptions = (csd: string = ""): boolean => {
const match = csd.match(/<CsOptions>[\s\S]*?<\/CsOptions>/i);
if (!match) {
return false;
}
const options = match[0].replace(/;.*$/gm, "");
return (
/(^|\s)-i\s*(?:"adc"|'adc'|adc)(?=\s|$)/i.test(options) ||
/(^|\s)--input\s*(?:=\s*)?(?:"adc"|'adc'|adc)(?=\s|$)/i.test(options)
);
};
Copy link
Member

Choose a reason for hiding this comment

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

I'll try to help here, we can probably get this more reliably. There's a chance that the regex doesn't find the option in some cases, or some cases where the option isn't set in the file. For example project settings should be able to configure flags. Other parts look fine, I'll review better this weekend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok thank you. It would be nice also to double check if orc + sco project without explicit csd option can now use input

@vlazzarini
Copy link
Member

As I said in the issue - there is no problem getting audio input in other projects using Csound wasm, so the audio input problem is the web ide code.

@Nandos0804
Copy link
Contributor Author

As I said in the issue - there is no problem getting audio input in other projects using Csound wasm, so the audio input problem is the web ide code.

Yes agreed, sorry for not explaining my self well. The problem as I was able to identify is on the ide, because without rebuild Csound wasm I was able to connect the input. But my knowledge is very limited in scope so I am not able to identify possible better solution (in the ide itself, or elsewhere). Thank you for the patience

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.

3 participants