ntof
Prev | Orchestra Opcodes and Operators | Next

## ntof

ntof — Convert note name to frequency

## Description

Plugin opcode in emugens.

Convert note name to frequency (Hz). It allows note name to include microtones or a deviation in cents.

## Syntax

    kfreq ntof Snote

    ifreq ntof Snote

## Performance

Snote -- Note name

kfreq -- Frequency

| Note
The frequency returned depends on the value of the global variable A4

| Note
4C is the central C in the piano.

## Examples

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

Example 622. Example of the ntof opcode.

    <CsoundSynthesizer>
    <CsOptions>
    --nosound
    </CsOptions>
    <CsInstruments>

    /*

    Example for ntof: notename to frequency

    A notename is a string of the form

    <octave><pitchclass>[cents]

    Example notenames are:

    "4A"     -> A in the 4th octave
    "5C+31"  -> C5, 31 cents higher
    "4Db-13" -> D flat, 4th octave, 13 cents lower
    "7F#+"   -> F# quarter tone higher
    "5G-"    -> G5 a quarter tone lower

    NB: the frequency returned by ntof depends on the value of A4

    */

    A4 = 442

    instr 1
        ifreq ntof "4A"
        print ifreq

        koctave = 1
        while (koctave <= 8) do
            Snote sprintfk "%dC", koctave
            kfreq ntof Snote
            printf "notename: %s  freq: %.2f \n", koctave, Snote, kfreq
            koctave += 1
        od

        turnoff
    endin

    </CsInstruments>
    <CsScore>

    i 1 0 1

    </CsScore>
    </CsoundSynthesizer>

## See Also

mtof, ftom, mton mton

## Credits

By: Eduardo Moguillansky 2019

New in 6.13

Prev | Up | Next
ntom | Home | nstrnum