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 file cent.csd.

Example 105. Example of the cent 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     ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o cent.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1	; original pitch
  
iroot = 440	; root note = A (440 Hz)

print iroot	;print out

asig oscili 0.6, iroot, 1 
     outs asig, asig

endin

instr 2
  
iroot   = 440	; root note = A (440 Hz)
icents  = p4	; change root note by 300 and 1200 cents

ifactor = cent(icents) ; calculate new note
inew    = iroot * ifactor

print iroot	; Print all
print ifactor
print inew

asig oscili 0.6, inew, 1 
     outs asig, asig

endin

</CsInstruments>
<CsScore>
; sine wave
f1 0 32768 10 1

i 1 0  2  0	;no change
i 2 2.5 2 300	;note = C above A
i 2 5  2 1200	;1 octave higher 

e

</CsScore>
</CsoundSynthesizer>


Its output should include lines like:

instr 1:  iroot = 440.000

instr 2:  iroot = 440.000
instr 2:  ifactor = 1.189
instr 2:  inew = 523.251

instr 2:  iroot = 440.000
instr 2:  ifactor = 2.000
instr 2:  inew = 880.000

See Also

db, octave, semitone

New in version 4.16