mirror of
https://github.com/love2d/love.git
synced 2026-08-13 17:10:54 +02:00
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:
@@ -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
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user