Page 1 of 1

Microphone Support

Posted: Mon May 08, 2017 8:57 pm
by CanadianGamer
I need some help with microphone support. I checked the forums and I discovered that it seems that there was a Lua library made to implement this, which was later committed to the core build. Unfortunately I couldn't find much documentation on how to use this input system. Any help would greatly appreciated.

Re: Microphone Support

Posted: Mon May 08, 2017 9:13 pm
by zorg
Committed, yes; to 0.11, meaning it's not out yet. You have two choices;
Use lpghatguy's lib: https://github.com/LPGhatguy/love-microphone/
Or if you're using a nightly version of Löve, which already have this functionality, then you'll need to look into the source of it:
https://bitbucket.org/rude/love/src/cbe ... ce.cpp-134
https://bitbucket.org/rude/love/src/cbe ... io.cpp-507

Re: Microphone Support

Posted: Mon May 08, 2017 9:19 pm
by raidho36
You can't find documentation because it doesn't exist yet - it's impemented in minor branch, which means it's only coming when the next minor release is coming.

Code: Select all

local devices = love.audio.getRecordingDevices( )
local default = devices[ 1 ]
print ( default:getName ( ) )

local success = default:start( maxsamples, samplerate, bitdepth, channels )
assert ( success )

local source = love.audio.newQueueableSource ( samplerate, bitdepth, channels )

if default:isRecording ( ) and default:getSampleCount ( ) > minsamples then
	local recorded = default:getData ( )
	source:queue ( recorded )
end

if stop and default:isRecording ( ) then
	local lastrecorded = default:stop ( )
	source:queue ( lastrecorded )
end

Re: Microphone Support

Posted: Mon May 08, 2017 10:25 pm
by zorg
raidho36 wrote: Mon May 08, 2017 9:19 pm

Code: Select all

if stop and default:isRecording ( ) then
	local lastrecorded = default:stop ( )
	source:queue ( lastrecorded )
	--> from here
end
You forgot the source:play() :3

Re: Microphone Support

Posted: Mon May 08, 2017 10:42 pm
by raidho36
If you look closely enough you'll also notice that there's no recording nor playback loop either, and there are number of constants that were never defined, and flag variables that never change, etc.

Re: Microphone Support

Posted: Mon May 08, 2017 10:58 pm
by zorg
I mean sure, but that can be alleviated and inferred easier imho... in any case, it doesn't matter that much.