.. / Hz.Builtins / Hz.StreamIn

Hz.ADC . Hz.DAC
Hz.StreamIn . Hz.AudioFileOut . Hz.Scope
Hz.ModLFO . Hz.ModRand . Hz.ModEnv . Hz.ModExpr
see also Hz.Plugins, Hz.Builtins Examples


Stream live audio from the internet and into your soundscapes.

Overview

Have you dreamed of streaming live internet audio directly into your soundscapes? This is Hz.StreamIn reason for being.

There are a few types of internet radio streams:

  1. a url suffices to connect to html5 stream (.mp3, .aac)
  2. a url may be redirected and utilize context to validate/track the stream.
  3. a uri which produces a playlist.

Hz currently supports #1, mp3 and AAC public audio streams that can be connected to via single public URL.

Usage

let ascene = await Ascene.BeginFiber(this);
console.log("Audio scene is ready to go.");
let dac = ascene.GetDAC();
let anode = ascene.NewAnode("Hz.StreamIn"); // magically receives audio packets.
ascene.Chain(anode, dac);
await ascene.Sync();

let [host, stream] = ["https://live.radioradicale.it", "/live.mp3"];
let ret = await StreamMgr.AudioStreamOpen(host, stream, anode.GetId())
console.log(`open returned ${JSON.stringify(ret)}`);
if(ret.tid != null)
{
    // Listen for 20 seconds. Streaming may take a while to
    // get going.
    setTimeout(async () =>
    {
        console.log(`closing ${ret.tid}`);
        StreamMgr.AudioStreamClose(ret.tid);        
        await Aengine.Close();
    }, 20000);
}

See Also

StreamMgr . Radio example

home .. topics .. interface .. reference .. examples .. tipjar