Examples / AudioIO / Audio In

Right-click to copy examples to your workspace


This example opens the default audio input device and routes it to Hz.Scope and to your audio output.

If your input can hear the output WATCH OUT FOR FEEDBACK, or disable the connection to dac.

audioin.js

// Here we route input to output. 
// If your input can hear the output WATCH OUT FOR FEEDBACK.
let ascene = await Ascene.BeginFiber(this);

// Most digital interfaces place a mic or guitar on a single
// channel. If you have multiple inputs you can use chanoffset
// to select it.
let adc = ascene.NewAnode("Hz.ADC",
            {cfg:"mono", preset:{numchan:1, chanoffset:1}}); 
            // default is numchan:1, chanoffset 0
let dac = ascene.GetDAC();
let gain = ascene.NewAnode("Hz.Mix", {cfg:"mono"});
let scope = ascene.NewAnode("Hz.Scope");
ascene.Chain(adc, gain, dac, scope);
ascene.VisualizeGraph();
await ascene.Sync();
gain.Show();
for(let i=0;i<100;i++)
{
    await ascene.Wait(ascene.Seconds(.1));
    yield
}
console.log("Done.");
home .. topics .. interface .. reference .. examples .. tipjar