Module ctr.mic

The mic module.

Usage:

    local mic = require("ctr.mic")

Functions

init ([bufferSize=0x50000]) Initialize the mic module.
shutdown () Shutdown the mic module.
startSampling ([encoding="PCM8"[, rate=8180[, loop=false[, size=bufferFreeSize-4[, restart=false]]]]]) Start sampling from the mic.
stopSampling () Stop sampling from the mic.
adjustSampling (rate) Adjust the sampling rate.
isSampling () Check whether the mic is sampling.
getData ([lastSampleOnly=true]) Return a string containing the raw sampled audio data.
setGain (gain) Set the gain of the mic.
getGain () Return the gain of the mic.
setPower (power) Power on/off the mic.
getPower () Return the power status of the mic.
setClamp (clamp) Set whether to clamp the mic input.
getClamp () Check if the mic input is clamped.
allowShellClosed (allow) Allow or not to sample when the shell is closed.


Functions

init ([bufferSize=0x50000])
Initialize the mic module.

Parameters:

  • bufferSize number size of the buffer (must be a multiple of 0x1000) (default 0x50000)

Returns:

    boolean true if everything went fine

Or

  1. boolean false in case of error
  2. integer/string error code/message
shutdown ()
Shutdown the mic module.
startSampling ([encoding="PCM8"[, rate=8180[, loop=false[, size=bufferFreeSize-4[, restart=false]]]]])
Start sampling from the mic.

Parameters:

  • encoding encoding encoding of the data to record, can be "PCM8" or "PCM16" (default "PCM8")
  • rate number sampling rate, can be 8180, 10910, 16360 or 32730 (default 8180)
  • loop boolean if true, loop back to the beginning of the buffer when the end is reached (default false)
  • size number size of audio data to write to the buffer, can be reduced to fit in the buffer (default bufferFreeSize-4)
  • restart boolean if true, start at position 0 in the buffer; if false, start after the last sample (default false)
stopSampling ()
Stop sampling from the mic.
adjustSampling (rate)
Adjust the sampling rate.

Parameters:

  • rate number sampling rate, can be 8180, 10910, 16360 or 32730
isSampling ()
Check whether the mic is sampling.

Returns:

    boolean true if sampling
getData ([lastSampleOnly=true])
Return a string containing the raw sampled audio data.

Parameters:

  • lastSampleOnly boolean set to true to only get the last sample, and to false to get everything (default true)

Returns:

    string raw audio data
setGain (gain)
Set the gain of the mic.

Parameters:

  • gain number gain
getGain ()
Return the gain of the mic.

Returns:

    number
setPower (power)
Power on/off the mic.

Parameters:

  • power boolean true to power on, false to power off
getPower ()
Return the power status of the mic.

Returns:

    boolean true if powered, false if not
setClamp (clamp)
Set whether to clamp the mic input.

Parameters:

  • clamp boolean true to clamp, false to not
getClamp ()
Check if the mic input is clamped.

Returns:

    boolean true if clamped, false if not
allowShellClosed (allow)
Allow or not to sample when the shell is closed.

Parameters:

  • allow boolean true to allow, false to not.
generated by LDoc 1.4.3 Last updated 2017-06-05 14:35:27