Audio Volume and Mixing

Volume

Use the volume operator to adjusts the level of an input or output audio stream. The volume determines the linear gain applied to all channels. A linear gain of 1.0 is equivalent to a logarithmic gain of 0 dB.

For example the following composition attenuates the volume by -6 dB (0.5):

---
input:
  container:
  - name: input1
    audio:
    - name: a1
      volume: 0.5
output:
  container:
  - name: output1
    type: 'wav '
    audio:
    - name: a1
{
  "input": {
    "container": [
      {
        "name": "input1",
        "audio": [
          {
            "name": "a1",
            "volume": 0.5
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "name": "output1",
        "type": "wav ",
        "audio": [
          {
            "name": "a1"
          }
        ]
      }
    ]
  }
}

Fade Up/Down

The volume of an input stream can be interpolated to achieve a fade up or fade down effect. For example the following composition produces a 2 second fade at the beginning of the audio stream:

---
input:
  segment:
    container:
    - name: input1
      audio:
      - name: a1
        head:
          duration: 2.0
          volume: 0.0
        body:
          volume: 1.0
  output:
    container:
    - name: output1
      type: 'wav '
      audio:
      - name: a1
{
  "input": {
    "segment": {
      "container": [
        {
          "name": "input1",
          "audio": [
            {
              "name": "a1",
              "head": {
                "duration": 2.0,
                "volume": 0.0
              },
              "body": {
                "volume": 1.0
              }
            }
          ]
        }
      ]
    },
    "output": {
      "container": [
        {
          "name": "output1",
          "type": "wav ",
          "audio": [
            {
              "name": "a1"
            }
          ]
        }
      ]
    }
  }
}

See the Stream Parts reference for details.

Stream Mixing

Use the mix operator to combine multiple audio input streams. The name property identifies each input stream and the level property specifies linear gain applied to that input.

For example the following composition combines streams a1 and a2 attenuating the music by -6 dB (0.5):

---
input:
  container:
  - name: program
    audio:
    - name: a1
  - name: music
    audio:
    - name: a2
output:
  container:
  - audio:
    - mix:
      - name: a1
        level: 1.0
      - name: a2
        level: 0.5
{
  "input": {
    "container": [
      {
        "name": "program",
        "audio": [
          {
            "name": "a1"
          }
        ]
      },
      {
        "name": "music",
        "audio": [
          {
            "name": "a2"
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "audio": [
          {
            "mix": [
              {
                "name": "a1",
                "level": 1.0
              },
              {
                "name": "a2",
                "level": 0.5
              }
            ]
          }
        ]
      }
    ]
  }
}

Channel Mixing

By default the mix operator combines the channels from each input stream starting with channel number 1. Use the channel array to specify the input channel numbers for each stream. The output stream channels property determines the size of the array.

For example the following composition produces a 2 channel output stream using channels 3/4 from the program input and channels 1/2 from the music input:

input:
  container:
  - name: program
    audio:
    - name: a1
      channels: 4
  - name: music
    audio:
    - name: a2
      channels: 2
output:
  container:
  - audio:
    - channels: 2
      mix:
      - name: a1
        channel:
        - 3
        - 4
      - name: a2
        channel:
        - 1
        - 2
{
  "input": {
    "container": [
      {
        "name": "program",
        "audio": [
          {
            "name": "a1",
            "channels": 4
          }
        ]
      },
      {
        "name": "music",
        "audio": [
          {
            "name": "a2",
            "channels": 2
          }
        ]
      }
    ]
  },
  "output": {
    "container": [
      {
        "audio": [
          {
            "channels": 2,
            "mix": [
              {
                "name": "a1",
                "channel": [
                  3,
                  4
                ]
              },
              {
                "name": "a2",
                "channel": [
                  1,
                  2
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

The channel array may also specify the level and phase for each input channel.


Did this page help you?