Re: Microphone Support for LÖVE!
Posted: Thu Jan 12, 2017 9:42 pm
I thought like that too before, and raidho implemented it like that at first, as well... but there were issues with it, i think.
If old SoundData is not exactly identical parameter-wise to would-be new SoundData, it has to be re-allocated entirely, at which point it's computationally cheaper to delete it from memory and produce new one from scratch, also not managing memory manually is one less headache for the user. It also eliminates possible problems with pointers to SoundData's data becoming invalid and causing segfault crashes if FFI attempts to use them.Dr. Peeps wrote:This works well, but .... What is the likelihood of having a variant of getData that doesn't create a new SoundData object with every call, instead "refilling" an existing buffer with new data?LÖVE 0.11 wrote:getData removes currently recorded samples from input and puts them into new SoundData
Let's say that in love.update, i call the function to dump recorded data into a sounddata, i push that onto a qsource, then i nil the sounddata. When should i call the object:release, if i should at all? before or after nilling? Should i even nil the variable? Can manually calling :release introduce issues with automatic ref. count decreases (not counting cases where you actually want to keep objects around, only for one-shot objects, like in the above example)slime wrote:0.11 also has a new Object:release method, which immediately decreases an Object's internal reference count and prevents it from being used in Lua after that. If there are no more internal references to that object (in love's C++ code or in another love thread), the object will be cleaned up and deallocated immediately.
This will help to keep consistent performance in the case where you're creating and throwing away objects.
Before. You won't have access to it after setting the variable to nilzorg wrote:When should i call the object:release, if i should at all? before or after nilling?
Sure, since it makes it more explicit in your code that the object is no longer usable.zorg wrote:Should i even nil the variable?
Nope. It basically just performs the release operation that normally happens when the Lua reference to the object is garbage-collected, and then prevents you from using the Lua reference to the object by causing an error if you try. It won't do the release operation again when the Lua reference to the object is actually garbage collected, so it won't cause any issues.zorg wrote:Can manually calling :release introduce issues with automatic ref. count decreases (not counting cases where you actually want to keep objects around, only for one-shot objects, like in the above example)
Code: Select all
data = inputs[ 1 ]:getData ( )
Code: Select all
data:release()
data = inputs[ 1 ]:getData ( )
Realtime intercom, if I'd say.Jasoco wrote:So what exactly can you do with microphone support in Löve? It's not like you can process voice commands in real-time.
Maybe emulate the Famicom to kill rabbit enemies in a Zelda game or stuff the DS, 3DS and Wii U do in some games?
Actually, to some degree, you can process voice commands in realtime.buckle2000 wrote:Realtime intercom, if I'd say.Jasoco wrote:So what exactly can you do with microphone support in Löve? It's not like you can process voice commands in real-time.
Maybe emulate the Famicom to kill rabbit enemies in a Zelda game or stuff the DS, 3DS and Wii U do in some games?