st2ms
Prev | Orchestra Opcodes and Operators | Next

## st2ms

st2ms — Stereo to Mid-Side Conversion.

## Description

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

## Syntax

    am,as st2ms aleft,aright

## Performance

am -- mid signal output.

as -- side signal output.

aleft -- left channel input.

aright -- right channel input.

## Examples

Here is an example of the st2ms opcode. It uses the files st2ms.csd and stereoJungle.wav.

Example 1006. Example of the st2ms 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 st2ms.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)

    instr 1
    al, ar    diskin2    "stereoJungle.wav", 1          ; stereo sample
    am, as st2ms  al,ar
    fout "MSJungleEncoded.wav", -1, am *.6, as *.6      ; write MS encoded audio file to disk
    outs am *.6, as *.6                                 ; & reduce volume a bit

    endin

    instr 2
    al, ar    diskin2    "MSJungleEncoded.wav", 1       ; get back in the MS encoded sample
    am, as ms2st  al,ar, p4
    outs am, as

    endin

    </CsInstruments>
    <CsScore>

    i1 0 6.7          ; encode signal, write to disk

    i2 10 6.7 .5      ; read encoded file from disk and decode 1:1
    i2 17 6.7 .7      ; decode but with more width

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

More information on MS stereo can be found on the Wikipedia page.

ms2st

## Credits

Author: Victor Lazzarini
April 2021

Prev | Up | Next
sr | Home | statevar