lphasor
Prev | Orchestra Opcodes and Operators | Next

## lphasor

lphasor — Generates a table index for sample playback

## Description

This opcode can be used to generate table index for sample playback (e.g. tablexkt).

## Syntax

    ares lphasor xtrns [, ilps] [, ilpe] [, imode] [, istrt] [, istor]

## Initialization

ilps -- loop start.

ilpe -- loop end (must be greater than ilps to enable looping). The default value of ilps and ilpe is zero.

imode (optional: default = 0) -- loop mode. Allowed values are:

- 0: no loop

- 1: forward loop

- 2: backward loop

- 3: forward-backward loop

istrt (optional: default = 0) -- The initial output value (phase). It must be less than ilpe if looping is enabled, but is allowed to be greater than ilps (i.e. you can start playback in the middle of the loop).

istor (optional: default = 0) -- skip initialization if set to any non-zero value.

## Performance

ares -- a raw table index in samples (same unit for loop points). Can be used as index with the table opcodes.

xtrns -- transpose factor, expressed as a playback ratio. ares is incremented by this value, and wraps around loop points. For example, 1.5 means a fifth above, 0.75 means fourth below. It is not allowed to be negative.

## Examples

Here is an example of the lphasor opcode. It uses the file lphasor.csd.

Example 513. Example of the lphasor 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
    ; Audio out   Audio in
    -odac           -iadc     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o lphashor.wav -W ;;; for file output any platform
    </CsOptions>

    <CsInstruments>
    ; Example by Jonathan Murphy Dec 2006

      sr	    =  44100
      ksmps	    =  10
      nchnls    =  1

        instr 1

      ifn	    =  1   ; table number
      ilen	    =  nsamp(ifn)    ; return actual number of samples in table
      itrns	    =  1   ; no transposition
      ilps	    =  0   ; loop starts at index 0
      ilpe	    =  ilen ; ends at value returned by nsamp above
      imode	    =  3    ; loop forwards & backwards
      istrt	    =  10000  ; commence playback at index 10000 samples
      ; lphasor provides index into f1
      alphs	    lphasor   itrns, ilps, ilpe, imode, istrt
      atab	    tablei    alphs, ifn
    	    ; amplify signal
      atab	    =  atab * 10000

    	    out	      atab

        endin

    </CsInstruments>

    <CsScore>
    f 1 0 262144 1 "beats.wav" 0 4 1
    i1 0 60
    e
    </CsScore>

    </CsoundSynthesizer>

## Credits

Author: Istvan Varga
January 2002
Example by: Jonathan Murphy

New in version 4.18

Updated April 2002 and November 2002 by Istvan Varga

Prev | Up | Next
lpfreson | Home | lpinterp