Microphone:getData

Returns a new SoundData with all of the buffered audio samples that the Microphone has recorded.

Get all available audio as a newly created SoundData.

soundData = Microphone:getData()

Arguments

None

Returns

NameTypeDescription
soundDatasoundDataA SoundData with sampleCount of samples in it (or less if less was available; or all if sampleCount was not given). Nothing is returned if no data is available.

Get at most sampleCount samples from the microphone's internal queue as a newly created SoundData.

soundData = Microphone:getData(sampleCount)

Arguments

NameTypeDescription
sampleCountnumberHow many samples of audio to get right now, at most. If less is available, you will get less (use Microphone:getSampleCount to check the exact number).

Returns

NameTypeDescription
soundDatasoundDataA SoundData with sampleCount of samples in it (or less if less was available; or all if sampleCount was not given). Nothing is returned if no data is available.

Get at all available audio and write it into soundData.

soundData = Microphone:getData(soundData)

Arguments

NameTypeDescription
soundDatasoundDataThe SoundData to fill with audio (instead of creating a new one).

Returns

NameTypeDescription
soundDatasoundDataA SoundData with sampleCount of samples in it (or less if less was available; or all if sampleCount was not given). Nothing is returned if no data is available.

Get at all available audio and write it into soundData starting at offset samples into soundData.

soundData = Microphone:getData(soundData, offset)

Arguments

NameTypeDescription
soundDatasoundDataThe SoundData to fill with audio (instead of creating a new one).
offsetnumberIndex in samples into soundData at which to start to overwrite with new audio data from the microphone's internal buffer.'

Returns

NameTypeDescription
soundDatasoundDataA SoundData with sampleCount of samples in it (or less if less was available; or all if sampleCount was not given). Nothing is returned if no data is available.

Notes

There's a limit on the number of samples the Microphone is able to hold, which can be set at creation time in lovr.audio.newMicrophone. While the Microphone is recording, be sure to call this function periodically to get a new chunk of audio in order to make room for more.

You can use Microphone:getSampleCount to figure out how many samples the Microphone is currently holding.

See also