gaNToF(CONSTANT)

Syntax

gaNToF(CONSTANT)

Example

dim = BUFFER_SIZE*AUDIO_OUTPUT_CHANNELS
outputBuffer = memarray('float', dim)
stretch = OUTPUT_W/(dim-1)
zeroOffset = OUTPUT_H/4

notes = {DO_3,DOB_3,RE_3,REB_3,MI_3,FA_3,FAB_3,SOL_3,SOLB_3,LA_3,LAB_3,SI_3}
numNotes = 0

function setup()
    gaWave(GA_SINE,100)
    gaWaveVolume(0,0.7)

    numNotes = table.getn(notes)-1
    
    // init the buffer
    for i = 0, dim - 1 do
        outputBuffer[i] = 0.0 
    end
end

function update()
    actualNote = math.ceil(gaMouseX()/OUTPUT_W*numNotes)
    playNote = notes[actualNote+1]
    gaWaveFrequency(0,gaNToF(playNote))

    for i = 0, dim - 1 do
        outputBuffer[i] = gaGetOutputBuffer(i) 
    end
end

function draw()
    gaBackground(0.0,0.5)

    ofTranslate(0,OUTPUT_H/2,0)
    // draw Audio Scope
    ofSetColor(255)
    ofNoFill()
    ofBeginShape()
    for i = 0, dim - 1 do
        ofVertex(i* stretch, outputBuffer[i] * zeroOffset)
    end
    ofEndShape(false)
end

Description

Converts a note (latin musical notation) constants into his harmonic frequency, using the Just Scale, sometimes referred to as "Harmonic tuning" or "Helmholtz's scale". Note constants available are DO_N, DOB_N, RE_N, REB_N, MI_N, FA_N, FAB_N, SOL_N, SOLB_N, LA_N, LAB_N, SI_N; with N from 0 to 8, where LA_4 is a 440 Hz.

Parameters

CONSTANT

Returns

«Float, The harmonic frequency of the selected note