NorskTransform.audioMix() method

Mix multiple audio streams together into a single output, with optional gain control on each input.

Signature:

audioMix<Pins extends string>(settings: AudioMixSettings<Pins>): Promise<AudioMixNode<Pins>>;

Parameters

Parameter Type Description

settings

AudioMixSettings<Pins>

Settings for the mixer, including the gain vectors

Returns:

Promise<AudioMixNode<Pins>>

Example [15_compose.ts]

Compose multiple sources into a single output and vary how they are arranged

let mixerSettings: AudioMixSettings<"input1" | "input2"> = {
  id: "mixer",
  onError: (err) => console.log("MIXER ERR", err),
  sampleRate: 48000,
  sources: [
    { pin: "input1" },
    { pin: "input2" }
  ],
  outputSource: "output",
};

let mixer = await norsk.processor.transform.audioMix(mixerSettings);
mixer.subscribeToPins([
  { source: input1, sourceSelector: audioToPin('input1') },
  { source: input2, sourceSelector: audioToPin('input2') }
]);

Run the following commands together to generate example inputs at urls srt://127.0.0.1:5001, rtmp://127.0.0.1:5002/acme/high:

ffmpeg -v error -re -f lavfi -i "sine=frequency=220:sample_rate=48000" -loop 1 -i data/test-src-still.png -vf drawtext=fontfile=Arial.ttf:text="%{frame_num}":start_number=1:x=980:y=330:fontcolor=black:fontsize=40:box=1:boxcolor=white:boxborderw=5,scale=1280:720 -vcodec h264 -b:v 150000 -b:a 20000 -aspect 1280:720 -x264opts "keyint=25:min-keyint=25:no-scenecut:bframes=0" -bluray-compat true -tune stillimage -preset fast -pix_fmt yuv420p -acodec aac -metadata language=en -f mpegts -flush_packets 0 'srt://127.0.0.1:5001'
ffmpeg -v error -re -f lavfi -i "sine=frequency=220:sample_rate=48000" -loop 1 -i data/test-src-still.png -vf drawtext=fontfile=Arial.ttf:text="%{frame_num}":start_number=1:x=980:y=330:fontcolor=black:fontsize=40:box=1:boxcolor=white:boxborderw=5,scale=1280:720 -vcodec h264 -b:v 150000 -b:a 20000 -aspect 1280:720 -x264opts "keyint=25:min-keyint=25:no-scenecut:bframes=0" -bluray-compat true -tune stillimage -preset fast -pix_fmt yuv420p -acodec aac -metadata language=en -f flv 'rtmp://127.0.0.1:5002/acme/high'

Find Examples