octave
Prev | Orchestra Opcodes and Operators | Next

## octave

octave — Calculates a factor to raise/lower a frequency by a given amount of octaves.

## Description

Calculates a factor to raise/lower a frequency by a given amount of octaves.

## Syntax

    octave(x)

This function works at a-rate, i-rate, and k-rate.

## Initialization

x -- a value expressed in octaves.

## Performance

The value returned by the octave function is a factor. You can multiply a frequency by this factor to raise/lower it by the given amount of octaves.

## Examples

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

Example 552. Example of the octave 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 octave.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    iroot = 440		; root note is A above middle-C (440 Hz)
    koct  lfo 5, 1, 5	; generate sawtooth, go from 5 octaves higher to root
    koc = int(koct)		; produce only whole numbers
    kfactor = octave(koc)	; for octave
    knew = iroot * kfactor
    printk2 knew

    asig pluck 1, knew, 1000, 0, 1
    asig dcblock asig	;remove DC
         outs asig, asig

    endin
    </CsInstruments>
    <CsScore>

    i 1 0 5
    e

    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like:

     i1  3520.00000
     i1  1760.00000
     i1   880.00000
     i1   440.00000
     i1  7040.00000
     i1  3520.00000
     i1  1760.00000
     i1   880.00000
     i1   440.00000
     .......

## See Also

cent, db, semitone

## Credits

New in version 4.16

Prev | Up | Next
ntrpol | Home | octcps