Repository navigation
fix: use Csound API for microphone startup - #428
Conversation
|
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 |
| 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) | ||
| ); | ||
| }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Ok thank you. It would be nice also to double check if orc + sco project without explicit csd option can now use input
|
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 |
- warning in case of user -iadc
|
@Nandos0804 do you have bandwidth to test the mic input on this branch I pushed to, using the upstream input detection I added |
|
it works, I ran this on the dev / localhost and it pulled the mic automatically <CsoundSynthesizer>
<CsOptions>
-iadc -odac
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 32
nchnls = 2
nchnls_i = 1
0dbfs = 1
instr 1
aMic inch 1
aRing oscili 1, 75
aRobot = aMic * aRing
aEcho1 delay aRobot, 0.45
aEcho2 delay aRobot, 0.90
; Quiet output, bounded to 0.2 peak.
aOut = 0.2 * tanh(2 * (aEcho1 + 0.45 * aEcho2))
outs aOut, aOut
endin
</CsInstruments>
<CsScore>
i 1 0 60
e
</CsScore>
</CsoundSynthesizer> |
Sorry for the delay. Safe to merge from my end since you tested it |
Use Csound's
isRequestingRtAudioInput()after compilation to request microphone access only when the project needs live input. CallenableAudioInput()before startup in both single-thread and worker modes, and let Csound handle routing and stream cleanup.Remove the custom Web Audio bridge and CSD option parsing. Keep the UI loading while microphone access is pending, report permission errors through the existing error UI, and let Stop cancel setup without starting audio later. Rebased onto the latest
develop.Validation: all 134 tests, lint, type checks, formatting, and the production build passed. Chrome checks with a simulated microphone passed in single-thread, worker, and SharedArrayBuffer modes, covering output-only playback, input flags, track cleanup, and permission denial.