Microphone input implemented.

RecordingDevice class added
(number)love.audio.getRecordingDeviceCount() and (table)love.audio.getRecordingDevices() exposed
(bool):startRecording([samples, sampleRate, bitDepth, channels], (SoundData):stopRecording([SoundData]),
(SoundData):getData([SoundData]), (number):getSampleCount(), (number):getSampleRate(), (number):getBitDepth(),
(number):getChannels(), (string):getName(), (number):getID(), (bool):isRecording() member functions exposed
previously existed stub implementation removed
getFormat moved to love::audio::openal::Audio
getFormat arguments order swapped to (bitDepth, channels)
getFormat now returns AL_NONE if format is invalid

--HG--
branch : minor-mic-input
This commit is contained in:
Raidho
2016-10-23 17:56:52 +03:00
parent e5be492431
commit 87f0b2811e
21 changed files with 922 additions and 192 deletions
+24 -46
View File
@@ -257,49 +257,6 @@ int w_getDopplerScale(lua_State *L)
return 1;
}
int w_record(lua_State *)
{
instance()->record();
return 0;
}
int w_getRecordedData(lua_State *L)
{
love::sound::SoundData *sd = instance()->getRecordedData();
if (!sd)
lua_pushnil(L);
else
{
luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
sd->release();
}
return 1;
}
int w_stopRecording(lua_State *L)
{
if (luax_optboolean(L, 1, true))
{
love::sound::SoundData *sd = instance()->stopRecording(true);
if (!sd)
lua_pushnil(L);
else
{
luax_pushtype(L, SOUND_SOUND_DATA_ID, sd);
sd->release();
}
return 1;
}
instance()->stopRecording(false);
return 0;
}
int w_canRecord(lua_State *L)
{
luax_pushboolean(L, instance()->canRecord());
return 1;
}
int w_setDistanceModel(lua_State *L)
{
const char *modelStr = luaL_checkstring(L, 1);
@@ -320,6 +277,27 @@ int w_getDistanceModel(lua_State *L)
return 1;
}
int w_getRecordingDeviceCount(lua_State *L)
{
lua_pushnumber(L, instance()->getRecordingDeviceCount());
return 1;
}
int w_getRecordingDevices(lua_State *L)
{
int count = instance()->getRecordingDeviceCount();
lua_createtable(L, count, 0);
for (int i = 0; i < count; i++)
{
RecordingDevice *device = instance()->getRecordingDevice(i);
luax_pushtype(L, AUDIO_RECORDING_DEVICE_ID, device);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
// List of functions to wrap.
static const luaL_Reg functions[] =
{
@@ -339,17 +317,17 @@ static const luaL_Reg functions[] =
{ "getVelocity", w_getVelocity },
{ "setDopplerScale", w_setDopplerScale },
{ "getDopplerScale", w_getDopplerScale },
/*{ "record", w_record },
{ "getRecordedData", w_getRecordedData },
{ "stopRecording", w_stopRecording },*/
{ "setDistanceModel", w_setDistanceModel },
{ "getDistanceModel", w_getDistanceModel },
{ "getRecordingDeviceCount", w_getRecordingDeviceCount },
{ "getRecordingDevices", w_getRecordingDevices },
{ 0, 0 }
};
static const lua_CFunction types[] =
{
luaopen_source,
luaopen_recordingdevice,
0
};