Difference between revisions of "Microphone"

From GiderosMobile
(language)
Line 6: Line 6:
 
=== Description ===
 
=== Description ===
 
Use this plugin to record to an audio clip using a connected microphone.
 
Use this plugin to record to an audio clip using a connected microphone.
 +
 +
=== Example ===
 +
<source lang="lua">
 +
require "microphone"
 +
 +
local microphone = Microphone.new(nil, 22050, 1, 16)
 +
 +
microphone:addEventListener(Event.DATA_AVAILABLE, function(event)
 +
print(event.peakAmplitude)
 +
end)
 +
 +
microphone:setOutputFile("|D|record.wav")
 +
 +
local function onRecord()
 +
microphone:start()
 +
end
 +
--record:addEventListener(Event.CLICK, onRecord)
 +
 +
local function onRecordStop()
 +
microphone:stop()
 +
end
 +
--recordStop:addEventListener(Event.CLICK, onRecordStop)
 +
</source>
  
 
{|-
 
{|-

Revision as of 17:48, 25 May 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.png
Available since: Gideros 2013.06

Description

Use this plugin to record to an audio clip using a connected microphone.

Example

require "microphone"

local microphone = Microphone.new(nil, 22050, 1, 16)

microphone:addEventListener(Event.DATA_AVAILABLE, function(event)
	print(event.peakAmplitude)
end)

microphone:setOutputFile("|D|record.wav")

local function onRecord()
	microphone:start()
end
--record:addEventListener(Event.CLICK, onRecord)

local function onRecordStop()
	microphone:stop()
end
--recordStop:addEventListener(Event.CLICK, onRecordStop)

Methods

Microphone.new creates a new Microphone object
Microphone:setOutputFile sets the output file
Microphone:start starts recording with device
Microphone:stop stops recording

Events

Event.DATA_AVAILABLE

Constants