Microphone: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
'''Supported platforms:''' android, ios, mac, pc<br/>
<!-- GIDEROSOBJ:Microphone -->
{{PLATFORMS ALL}}
'''Available since:''' Gideros 2013.06<br/>
'''Available since:''' Gideros 2013.06<br/>
=== 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.
| style="width: 50%;"|
<syntaxhighlight lang="lua">
require "microphone"
</syntaxhighlight>
 
=== Example ===
<syntaxhighlight 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)
</syntaxhighlight>
 
{|-
| style="width: 50%; vertical-align:top;"|
=== Methods ===
=== Methods ===
[[Microphone.new]] - Creates a new Microphone object.<br/>
[[Microphone.new]] ''creates a new Microphone object''<br/><!--GIDEROSMTD:Microphone.new(deviceName,sampleRate,numChannels,bitsPerSample,quality) creates a new Microphone object-->
[[Microphone:setOutputFile]] - Sets the output file<br/>
 
[[Microphone:start]] - Start recording with device.<br/>
[[Microphone:getDeviceList]] ''lists available mics''<br/><!--GIDEROSMTD:Microphone:getDeviceList() lists available mics-->
[[Microphone:stop]] - Stop recording<br/>
[[Microphone:getStreamId]] ''gets the mic stream id''<br/><!--GIDEROSMTD:Microphone:getStreamId() gets the mic stream id-->
| style="width: 50%;"|
[[Microphone:isPaused]] ''returns the mic paused status''<br/><!--GIDEROSMTD:Microphone:isPaused() returns the mic paused status-->
[[Microphone:isRecording]] ''returns the mic recording status''<br/><!--GIDEROSMTD:Microphone:isRecording() returns the mic recording status-->
[[Microphone:setOutputFile]] ''sets the mic stream output file''<br/><!--GIDEROSMTD:Microphone:setOutputFile(fileName) sets the mic stream output file-->
[[Microphone:setPaused]] ''sets the mic paused state''<br/><!--GIDEROSMTD:Microphone:setPaused() sets the mic paused state-->
[[Microphone:start]] ''starts mic recording''<br/><!--GIDEROSMTD:Microphone:start() starts mic recording-->
[[Microphone:stop]] ''stops mic recording''<br/><!--GIDEROSMTD:Microphone:stop() stops mic recording-->
[[Microphone:writeAudio]] ''writes microphone output to buffer''<br/><!--GIDEROSMTD:Microphone:writeAudio(buffer) writes microphone output to buffer-->
 
| style="width: 50%; vertical-align:top;"|
=== Events ===
=== Events ===
[[Event.DATA_AVAILABLE]]<br/>
[[Event.DATA_AVAILABLE]]<br/><!--GIDEROSEVT:Event.DATA_AVAILABLE dataAvailable-->
 
=== Constants ===
=== Constants ===
|}
|}
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 21:14, 11 October 2026

Supported platforms:
Available since: Gideros 2013.06

Description

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

require "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:getDeviceList lists available mics
Microphone:getStreamId gets the mic stream id
Microphone:isPaused returns the mic paused status
Microphone:isRecording returns the mic recording status
Microphone:setOutputFile sets the mic stream output file
Microphone:setPaused sets the mic paused state
Microphone:start starts mic recording
Microphone:stop stops mic recording
Microphone:writeAudio writes microphone output to buffer

Events

Event.DATA_AVAILABLE

Constants