Transmitting Data

Transmitter

frameLength

length in bytes of each underlying transmit frame. calls to transmit() will automatically slice passed arraybuffer into frames of this length or shorter

Transmitter.transmit()

Callback for user to provide data to a Quiet transmitter

Transmitter.destroy()

immediately stop playback and release all resources

Transmitter.getAverageEncodeTime()

returns average time in ms spent encoding data into sound samples over the last 3 runs

Quiet.transmitter

Quiet.transmitter(opts,

                  opts.profile [,

                  opts.onFinish [,

                  opts.onEnqueue [,

                  clampFrame]]])

Parameters

opts - transmitter params

opts.profile - name of profile to use, must be a key in quiet-profiles.json OR an object which contains a single profile

opts.onFinish - user callback which will notify user when playback of all data in queue is complete if the user calls transmit multiple times before waiting for onFinish, then onFinish will be called only once after all of the data has been played out

opts.onEnqueue - user callback which will notify user when all data passed to transmit() has been written to the transmit queue and has thus entered the transmit pipeline. for convenience, quiet.js is designed to hold as much data as you ask it to and write it to the libquiet transmit queue over time. this callback is handy because it informs the user that all data resides in libquiet, which is useful if you would like to stream data to the transmitter. this callback is the appropriate place to stream the next chunk. doing so will prevent excess memory bloat while maintaining the maximum transmit throughput. if the user calls transmit multiple times before waiting for onEnqueue, then onEnqueue will be called only once after all of the data has been played out

clampFrame - Prevent frames from overlapping sample blocks. Web Audio collects sound samples in blocks, and the browser ensures that each block plays out smoothly and atomically. However, it is possible for playback gaps to occur between these blocks due to GC pause or similar conditions. This is especially common on mobile.

Enabling this flag ensures that data frames do not overlap these sample blocks so that no playback gaps will occur within a frame, which greatly degrades error performance. Setting this flag to false will increase throughput but can significantly increase error rate. Defaults to true.

Returns

  • Transmitter object

Transmitter.transmit

Transmitter.transmit(payload)

Parameters

payload - bytes which will be encoded and sent to speaker

Transmitter.destroy

Transmitter.destroy()

immediately stop playback and release all resources

Transmitter.getAverageEncodeTime

Transmitter.getAverageEncodeTime()

returns average time in ms spent encoding data into sound samples over the last 3 runs