mtof
Prev | Orchestra Opcodes and Operators | Next

## mtof

mtof — Convert a midi to frequency

## Description

Convert a midi note number value to cycles per second, taking global value of A4 into account.

## Syntax

    ifreq mtof imidi

    kfreq mtof kmidi

## Performance

kmidi / imidi -- Midi note number

kfreq / ifreq -- Frequency corresponding to midi note value

## Examples

Here is an example of the mtof opcode. It uses the file mtof-ftom.csd.

Example 585. Example of the mtof opcode.

    <CsoundSynthesizer>
    <CsOptions>
    </CsOptions>
    <CsInstruments>

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

    instr 1
        kfreq = mtof(69)
        printks2 "midi 69   -> %f\n", kfreq

        kmidi = ftom(442)
        printks2 "freq 442  -> %f\n", kmidi

        kfreq = mtof(kmidi)
        printks "midi %f -> %f\n", 1, kmidi, kfreq

        imidi = ftom:i(440)
        print imidi

        ifreq = mtof:i(60)
        print ifreq

        turnoff
    endin

    </CsInstruments>
    <CsScore>
    i 1 0 1
    </CsScore>
    </CsoundSynthesizer>

## See Also

cpsmidinn, ftom, mton, ntom

## Credits

By: Eduardo Moguillansky 2017

New in version 6.09

Prev | Up | Next
mrtmsg | Home | mton