cent

cent --  Calculates a factor to raise/lower a frequency by a given amount of cents.

Description

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

Syntax

cent(x)

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

Initialization

x -- a value expressed in cents.

Performance

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

Examples

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

Example 1. Example of the cent opcode.

/* cent.orc */
/* Written by Kevin Conder */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
  ; The root note is A above middle-C (440 Hz)
  iroot = 440

  ; Raise the root note by 300 cents to C.
  icents = 300

  ; Calculate the new note.
  ifactor = cent(icents)
  inew = iroot * ifactor

  ; Print out of all of the values.
  print iroot
  print ifactor
  print inew
endin
/* cent.orc */
        
/* cent.sco */
/* Written by Kevin Conder */
; Play Instrument #1 for one second.
i 1 0 1
e
/* cent.sco */
        
Its output should include lines like:
instr 1:  iroot = 440.000
instr 1:  ifactor = 1.189
instr 1:  inew = 523.229
      

See Also

db, octave, semitone

Credits

Author: Kevin Conder

New in version 4.16