Microphone:writeAudio: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2025.7<br/> '''Class:''' Microphone<br/> === Description === Writes microphone output to buffer. <syntaxhighlight lang="lua"> Mic..."
 
 
Line 13: Line 13:


=== Example ===
=== Example ===
'''Encoding an audio file from lua generated data'''
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
require "microphone"
require "microphone"

Latest revision as of 01:16, 14 November 2026

Available since: Gideros 2025.7
Class: Microphone

Description

Writes microphone output to buffer.

Microphone:writeAudio(b)

Parameters

b: (buffer) the buffer name

Example

Encoding an audio file from lua generated data

require "microphone"

local microphone = Microphone.new(8000, 1, 16)
microphone:setOutputFile("|D|test.wav")
microphone:start()

local b = buffer.create(8000*2)
buffer.setarrayaccess(b, "i16")
for i = 0, 8000-1 do
	b[i] = math.sin(i/3)*30000
end

microphone:writeAudio(b)
microphone:stop()

local snd = Sound.new("|D|test.wav")
snd:play()