gaGetInputBuffer(int,int)

Syntax

gaGetInputBuffer(int,int)

Example

channel = 0
inputBuffer = memarray('float', BUFFER_SIZE)
stretch = OUTPUT_W/(BUFFER_SIZE-1)
zeroOffset = OUTPUT_H/2


function setup()
 // init the buffer
 for i = 0, BUFFER_SIZE - 1 do
 inputBuffer[i] = 0.0 
 end
end

function update()
 for i = 0, BUFFER_SIZE - 1 do
 inputBuffer[i] = gaGetInputBuffer(channel,i) 
 end
end

function draw()
 gaBackground(0.0,0.1)
 
 ofTranslate(0,OUTPUT_H/2,0)
 // draw Audio Scope
 ofSetColor(255)
 ofNoFill()
 ofBeginShape()
 for i = 0, BUFFER_SIZE - 1 do
 ofVertex(i* stretch, hardClip(inputBuffer[i]) * zeroOffset)
 end
 ofEndShape(false)
 
end

// CUSTOM FUNCTIONS
// --------------------------------------
function hardClip(x)
 local x1 = math.abs(x+1.0)
 local x2 = math.abs(x-1.0)
 
 return 0.5*(x1-x2)
end

Description

We use this function in a for loop in order to navigate all over the audio input buffer, and obtain a realtime input signal visualization. The index permitted move inside the range 0 - BUFFER_SIZE-1. You can change the BUFFER_SIZE settings from main menu, GAmuza/Preferences/Audio Streaming tab.

Parameters

int,int

Returns

«Float, The audio signal buffer on the specified input channel, at the specified index