cps2pch

cps2pch --  Converts a pitch-class value into cycles-per-second for equal divisions of the octave.

Description

Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of the octave.

Syntax

icps cps2pch ipch, iequal

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.

NoteNote
 

  1. The following are essentially the same

    ia  =  cpspch(8.02)
    ib     cps2pch  8.02, 12
    ic     cpsxpch  8.02, 12, 2, 1.02197503906
                

  2. These are opcodes not functions

  3. Negative values of ipch are allowed.

Examples

Here is an example of the cps2pch opcode. It uses the files cps2pch.orc and cps2pch.sco.

Example 1. Example of the cps2pch opcode.

/* cps2pch.orc */
; 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

  icps cps2pch ipch, iequal

  print icps
endin
/* cps2pch.orc */
        
/* cps2pch.sco */
; Play Instrument #1 for one second.
i 1 0 1
e
/* cps2pch.sco */
        
Its output should include lines like this:
instr 1:  icps = 293.666
      

Here is an example of the cps2pch opcode using a table of frequency multipliers. It uses the files cps2pch_ftable.orc and cps2pch_ftable.sco.

Example 2. Example of the cps2pch opcode using a table of frequency multipliers.

/* cps2pch_ftable.orc */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
  ipch = 8.02

  ; Use Table #1, a table of frequency multipliers.
  icps cps2pch ipch, -1

  print icps
endin
/* cps2pch_ftable.orc */
        
/* cps2pch_ftable.sco */
; Table #1: a table of frequency multipliers.
; Creates a 10-note scale of unequal divisions.
f 1 0 16 -2 1 1.1 1.2 1.3 1.4 1.6 1.7 1.8 1.9

; Play Instrument #1 for one second.
i 1 0 1
e
/* cps2pch_ftable.sco */
        
Its output should include lines like this:
instr 1:  icps = 313.951
      

Here is an example of the cps2pch opcode using a 19ET scale. It uses the files cps2pch_19et.orc and cps2pch_19et.sco.

Example 3. Example of the cps2pch opcode using a 19ET scale.

/* cps2pch_19et.orc */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
  ; Use 19ET scale.
  ipch = 8.02
  iequal = 19

  icps cps2pch ipch, iequal

  print icps
endin
/* cps2pch_19et.orc */
        
/* cps2pch_19et.sco */
; Play Instrument #1 for one second.
i 1 0 1
e
/* cps2pch_19et.sco */
        
Its output should include lines like this:
instr 1:  icps = 281.429
      

See Also

cpspch, cpsxpch

Credits

Author: John ffitch

University of Bath/Codemist Ltd.

Bath, UK

1997

Gabriel Maldonado

Italy

1998 (New in Csound version 3.492)