Table of Contents
audio_render_write
Writes audio samples to an audio renderer.
Description
The audio_render_write function writes audio samples to an audio renderer. A "sample" consists of the data for all channels at one time instant. For example,
for AUDIO_FORMAT_PCM (16-bits) where two channels are used, a sample consists of 2 * sizeof(t_int16) = 4
bytes. It is more
efficient to write as many samples as possible at one time, such as a full audio buffer.
Prototype
t_error audio_render_write(t_audio_render render, t_uint num_samples, const t_audio_samples * data);
Parameters
t_audio_render render
A handle to the audio render session, as returned by audio_render_open.
Return value
The return value is 1 if the samples are written to the audio render session successfully. Otherwise a negative
error code is returned. Error codes are
defined in quanser_errors.h
. A suitable error message
may be retrieved using msg_get_error_message.
Error codes
QERR_INVALID_ARGUMENT
An invalid argument was passed to the audio_render_write function. Note that once a render session has been closed using audio_render_close, the session handle is invalid.
Requirements
Include Files |
Libraries |
---|---|
quanser_audio.h |
quanser_media.lib;quanser_runtime.lib;quanser_common.lib |
Examples
/* Generate the next samples as stereo audio */ for (i = 0; i < num_samples; i++) { t_double t1 = t + i / sample_rate; samples[0][i] = 440 * sin(2 * pi * 0.2 * t1); /* left channel */ samples[1][i] = 440 * sin(2 * pi * 0.2 * t1 + pi/2); /* right channel */ } /* Render the audio samples */ result = audio_render_write(render, num_samples, samples);
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.