Difference between revisions of "Microphone"

From GiderosMobile
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
+
<!-- GIDEROSOBJ:Microphone -->
'''<translate>Available since</translate>:''' Gideros 2013.06<br/>
+
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
=== <translate>Description</translate> ===
+
'''Available since:''' Gideros 2013.06<br/>
<translate>Use this plugin to record to an audio clip using a connected microphone.</translate>
+
 
 +
=== Description ===
 +
Use this plugin to record to an audio clip using a connected microphone.
 +
 
 +
=== 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;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
[[Special:MyLanguage/Microphone.new|Microphone.new]] ''<translate>Creates a new Microphone object.</translate>''<br/>
+
[[Microphone.new]] ''creates a new Microphone object''<br/><!--GIDEROSMTD:Microphone.new(deviceName,sampleRate,numChannels,bitsPerSample,quality) creates a new Microphone object-->
[[Special:MyLanguage/Microphone:setOutputFile|Microphone:setOutputFile]] ''<translate>Sets the output file</translate>''<br/>
+
 
[[Special:MyLanguage/Microphone:start|Microphone:start]] ''<translate>Start recording with device.</translate>''<br/>
+
[[Microphone:getStreamId]] ''gets the mic stream id''<br/><!--GIDEROSMTD:Microphone:getStreamId() gets the mic stream id-->
[[Special:MyLanguage/Microphone:stop|Microphone:stop]] ''<translate>Stop recording</translate>''<br/>
+
[[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-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
[[Special:MyLanguage/Event.DATA_AVAILABLE|Event.DATA_AVAILABLE]]<br/>
+
[[Event.DATA_AVAILABLE]]<br/><!--GIDEROSEVT:Event.DATA_AVAILABLE dataAvailable-->
=== <translate>Constants</translate> ===
+
 
 +
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 02:32, 26 August 2024

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: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

Events

Event.DATA_AVAILABLE

Constants