cpsxpch
Prev | Orchestra Opcodes and Operators | Next

## cpsxpch

cpsxpch — Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of any interval.

## Description

Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of any interval. There is a restriction of no more than 100 equal divisions.

## Syntax

    icps cpsxpch ipch, iequal, irepeat, ibase

## Initialization

ipch -- Input number of the form 8ve.pc, indicating an 'octave' and which note in the octave.

iequal -- if positive, the number of equal intervals into which the 'octave' is divided. Must be less than or equal to 100. If negative, is the number of a table of frequency multipliers.

irepeat -- Number indicating the interval which is the 'octave.' The integer 2 corresponds to octave divisions, 3 to a twelfth, 4 is two octaves, and so on. This need not be an integer, but must be positive.

ibase -- The frequency which corresponds to pitch 0.0

| Note
1. The following are essentially the same
       ia  =  cpspch(8.02)
       ib     cps2pch  8.02, 12
       ic     cpsxpch  8.02, 12, 2, 1.02197503906
These are opcodes not functions Negative values of ipch are allowed, but not negative irepeat, iequal or ibase.

## Examples

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

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

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Use a normal twelve-tone scale.
      ipch = 8.02
      iequal = 12
      irepeat = 2
      ibase = 1.02197503906

      icps cpsxpch ipch, iequal, irepeat, ibase

      print icps
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for one second.
    i 1 0 1
    e

    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like this:

    instr 1:  icps = 293.666

Here is an example of the cpsxpch opcode using a 10.5 ET scale. It uses the file cpsxpch_105et.csd.

Example 169. Example of the cpsxpch opcode using a 10.5 ET scale.

    <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 cpsxpch_105et.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Use a 10.5ET scale.
      ipch = 4.02
      iequal = 21
      irepeat = 4
      ibase = 16.35160062496

      icps cpsxpch ipch, iequal, irepeat, ibase

      print icps
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for one second.
    i 1 0 1
    e

    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like this:

    instr 1:  icps = 4776.824

Here is an example of the cpsxpch opcode using a Pierce scale centered on middle A. It uses the file cpsxpch_pierce.csd.

Example 170. Example of the cpsxpch opcode using a Pierce scale centered on middle A.

    <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 cpsxpch_pierce.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Use a Pierce scale centered on middle A.
      ipch = 2.02
      iequal = 12
      irepeat = 3
      ibase = 261.62561

      icps cpsxpch ipch, iequal, irepeat, ibase

      print icps
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for one second.
    i 1 0 1
    e

    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like this:

    instr 1:  icps = 2827.762

## See Also

cpspch, cps2pch

## Credits

Author: John ffitch
University of Bath/Codemist Ltd.
Bath, UK
1997

New in Csound version 3.492

Prev | Up | Next
cpstuni | Home | cpumeter