Page 1 of 1

record audio

Posted: Fri Nov 10, 2017 4:45 pm
by jack0088
Hey guys I have been exploring the audio API and found something about recording from microphone here: https://bitbucket.org/rude/love/src/37e ... ew-default

but frankly the API seems to be not exposed. Any ideas if that is complete and how can be used?

Re: record audio

Posted: Fri Nov 10, 2017 4:48 pm
by jack0088
oh, sorry. found out myself. its deactivated.

Code: Select all

// List of functions to wrap.
static const luaL_Reg functions[] =
{
	{ "getSourceCount", w_getSourceCount },
	{ "newSource", w_newSource },
	{ "play", w_play },
	{ "stop", w_stop },
	{ "pause", w_pause },
	{ "resume", w_resume },
	{ "rewind", w_rewind },
	{ "setVolume", w_setVolume },
	{ "getVolume", w_getVolume },
	{ "setPosition", w_setPosition },
	{ "getPosition", w_getPosition },
	{ "setOrientation", w_setOrientation },
	{ "getOrientation", w_getOrientation },
	{ "setVelocity", w_setVelocity },
	{ "getVelocity", w_getVelocity },
	{ "setDopplerScale", w_setDopplerScale },
	{ "getDopplerScale", w_getDopplerScale },
	
	/*{ "record", w_record },
	{ "getRecordedData", w_getRecordedData },
	{ "stopRecording", w_stopRecording },*/
	
	{ "setDistanceModel", w_setDistanceModel },
	{ "getDistanceModel", w_getDistanceModel },
	{ "setMixMode", w_setMixMode },
	{ 0, 0 }
};

Re: record audio

Posted: Fri Nov 10, 2017 4:49 pm
by zorg
jack0088 wrote: Fri Nov 10, 2017 4:48 pm oh, sorry. found out myself. its deactivated.
To be more precise, if you look into the minor branch, you can see a fully functioning API there; Audio recording and queueable sources, along with effect objects and tons of other things will come with the next version, 0.11, which will be released sometime in the future.
(You can already try it out by getting the nightly builds)

Re: record audio

Posted: Fri Nov 10, 2017 5:09 pm
by jack0088
I didn't notice this branch. thank you for clarifying :)

Re: record audio

Posted: Fri Nov 10, 2017 5:35 pm
by incognito_mage
Still no latency reporting, or did I miss it? ._.

Re: record audio

Posted: Fri Nov 10, 2017 6:35 pm
by zorg
incognito_mage wrote: Fri Nov 10, 2017 5:35 pm Still no latency reporting, or did I miss it? ._.
Depends on what you mean.

Re: record audio

Posted: Sat Nov 11, 2017 11:26 am
by incognito_mage
When making a rhythm game, you need to know exactly how many samples of delay there are from when you start playing music and when that music is played on a speaker. if the player presses a key at t = 1.123, and the music is at t = 1.223, that might be a good or a perfect hit depending on exactly what the latency is.

In this particular case, the latency to the audio interface for a particular sound should be enough, even though the best thing for audio-focused games (or audio applications) would be to have an actual audio callback where you can fill the buffer with all your audio data yourself.

Re: record audio

Posted: Sat Nov 11, 2017 4:22 pm
by zorg
incognito_mage wrote: Sat Nov 11, 2017 11:26 am When making a rhythm game, you need to know exactly how many samples of delay there are from when you start playing music and when that music is played on a speaker. if the player presses a key at t = 1.123, and the music is at t = 1.223, that might be a good or a perfect hit depending on exactly what the latency is.
Usually, those games allow you to change the timings so the graphics can be spot-on with the system's added audio latencies.
incognito_mage wrote: Sat Nov 11, 2017 11:26 amIn this particular case, the latency to the audio interface for a particular sound should be enough, even though the best thing for audio-focused games (or audio applications) would be to have an actual audio callback where you can fill the buffer with all your audio data yourself.
Queueable sources say hi; consult with the minor branch in bitbucket, or download a nightly release since they're a 0.11 feature yet to be released officially.

You fill those with your own callback, so you can have samplepoint-accurate timing (on the lua-side anyway; the Audio driver will most likely add a bit of latency too, but not much)

The size of the SoundData you use as buffer will of course determine the "lua-side" latency. (including the sample/sampling rate as well)

Re: record audio

Posted: Wed Nov 15, 2017 12:59 am
by Sulunia
incognito_mage wrote: Sat Nov 11, 2017 11:26 am When making a rhythm game, you need to know exactly how many samples of delay there are from when you start playing music and when that music is played on a speaker. if the player presses a key at t = 1.123, and the music is at t = 1.223, that might be a good or a perfect hit depending on exactly what the latency is.

In this particular case, the latency to the audio interface for a particular sound should be enough, even though the best thing for audio-focused games (or audio applications) would be to have an actual audio callback where you can fill the buffer with all your audio data yourself.

Coming from someone who developed a rhythm game on Love, I'd say you're looking preeeetty far down the system, and you probably don't need all this to sync game and music. :monocle:

Using love's Source:tell("seconds")*1000 is probably more than enough for all your needs.
Simply update your logic according to the Tell function result.
After that's done, you may want to look into timer interpolation, so you avoid things being jittery on systems with higher latencies, such as Android, for example.