loscil3
Prev | Orchestra Opcodes and Operators | Next

## loscil3

loscil3 — Read sampled sound from a table using cubic interpolation. A version that outputs the exact table position (phase) corresponding to the output sample is provided as an alternative opcode.

## Description

Read sampled sound (mono or stereo) from a table, with optional sustain and release looping, using cubic interpolation.

## Syntax

    ar1 [,ar2] loscil3 xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] \
        [, imod2] [, ibeg2] [, iend2]

    aph, ar1 [,ar2] loscil3phs xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] \
          [, imod2] [, ibeg2] [, iend2]

## Initialization

ifn -- function table number, typically denoting an sampled sound segment with prescribed looping points loaded using GEN01. The source file may be mono or stereo.

ibas (optional) -- base frequency in Hz of the recorded sound. This optionally overrides the frequency given in the audio file, but is required if the file did not contain one. The default value is 261.626 Hz, i.e. middle C. (New in Csound 4.03). If this value is not known or not present, use 1 here and in kcps.

imod1, imod2 (optional, default=-1) -- play modes for the sustain and release loops. A value of 1 denotes normal looping, 2 denotes forward & backward looping, 0 denotes no looping. The default value (-1) will defer to the mode and the looping points given in the source file. Make sure you select an appropriate mode if the file does not contain this information.

ibeg1, iend1, ibeg2, iend2 (optional, dependent on mod1, mod2) -- begin and end points of the sustain and release loops. These are measured in sample frames (a set of samples with the same timestamp, one for each channel. Mono: 1 frame = 1 sample. Stereo: 1 frame = 2 samples etc.) from the beginning of the file, so will look the same whether the sound segment is monaural or stereo. If no loop points are specified, and a looping mode (imod1, imod2) is given, the file will be looped for the whole length.

## Performance

aph -- the normalised table position corresponding to the output sample (loscil3phs only).

ar1, ar2 -- the output at audio-rate. There is just ar1 for mono output. However, there is both ar1 and ar2 for stereo output.

xamp -- the amplitude of the output signal.

kcps -- the frequency of the output signal in cycles per second.

loscil3 is identical to loscil except that it uses cubic interpolation. New in Csound version 3.50.

| Note to Windows users
Windows users typically use back-slashes, “\”, when specifying the paths of their files. As an example, a Windows user might use the path “c:\music\samples\loop001.wav”. This is problematic because back-slashes are normally used to specify special characters. To correctly specify this path in Csound, one may alternately: Use forward slashes: c:/music/samples/loop001.wav Use back-slash special characters, “\\”: c:\\music\\samples\\loop001.wav

| Note
This is mono loscil3:
    a1 loscil3 10000, 1, 1, 1, 1
...and this is stereo loscil3:
    a1, a2 loscil3 10000, 1, 1, 1, 1

## Examples

Here is an example of the loscil3 opcode. It uses the file loscil3.csd, mary.wav and kickroll.wav.

Example 536. Example of the loscil3 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 realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o loscil3.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    ichnls = ftchnls(p4)
    print ichnls

    if (ichnls == 1) then
       asigL loscil3 .8, 1, p4, 1
       asigR = 	asigL
    elseif (ichnls == 2) then
       asigL, asigR loscil3 .8, 1, p4, 1
    ;safety precaution if not mono or stereo
    else
       asigL = 0
       asigR = 0
    endif
            outs asigL, asigR

    endin
    </CsInstruments>
    <CsScore>
    f 1 0 0 1 "mary.wav" 0 0 0
    f 2 0 0 1 "kickroll.wav" 0 0 0

    i 1 0 3 1 ;mono file
    i 1 + 2 2 ;stereo file
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

loscil and GEN01

## Credits

Note about the mono/stereo difference was contributed by Rasmus Ekman.

Prev | Up | Next
loscil | Home | loscilx