ms2st
Prev | Orchestra Opcodes and Operators | Next

## ms2st

ms2st — Mid-Side to stereo Conversion.

## Description

This opcode implements mid-side (MS) to stereo conversion with a width control. It is a pure function with no side effects.

## Syntax

    aleft,aright ms2st as,am,kwidth

## Performance

aleft -- left channel output.

aright -- right channel output.

am -- mid signal input.

as -- side signal input.

kwidth -- stereo width (0 to 1). At 0, no side signal is output, and at 1 no mid signal is present. A value of 0.5 restores a stereo to MS conversion (st2ms) exactly.

## Examples

Here is an example of the ms2st opcode. It uses the files ms2st.csd, MSjungle_interleaved.wav, MSjungleMid.wav and MSjungleSide.wav.

Example 628. Example of the ms2st opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac     ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o ms2st.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    ; by  Menno Knevel - 2021
    ; sample = ambient sound of waterfall + animals (monkey, birds)

    instr 1 ; MS sample is interleaved

    am, as    diskin2    "MSjungle_interleaved.wav", 1, 0, 1 ; interleaved stereo, MS encoded
    kwidth = p4                                              ; left = M, right = S
    al, ar ms2st  am, as, kwidth
    outs al, ar
    endin

    instr 2 ; 2 separate samples

    am    diskin2    "MSjungleMid.wav", 1        ; M sound as a separate mono sound
    as    diskin2    "MSjungleSide.wav", 1       ; S sound as a separate mono sound
    kwidth = p4
    al, ar ms2st  am, as, kwidth
    outs al, ar

    endin
    </CsInstruments>
    <CsScore>

    i1 0 6.7 0          ; M only
    i1 + 6.7 .3         ; M and a bit of S
    i1 + 6.7 .5         ; M + S equal volume
    i1 + 6.7 1          ; S only

    i2 28 6.7 0         ; M only
    i2 +  6.7 .3        ; M and a bit of S
    i2 +  6.7 .5        ; M + S equal volume
    i2 +  6.7 1         ; S only
    e
    </CsScore>
    </CsoundSynthesizer>

one interleaved encoded MS file: MSjungle_interleaved.wav as used in instr 1

the two separate files MSjungleMid.wav and MSjungleSide.wav as used in instr 2

## See Also

st2ms

## Credits

Author: Victor Lazzarini
April 2021

Prev | Up | Next
mrtmsg | Home | mtof