![Vlsi VS1063a Скачать руководство пользователя страница 13](http://html.mh-extra.com/html/vlsi/vs1063a/vs1063a_programmers-manual_1042916013.webp)
PRELIMINARY
VS1063a Prog. Guide
5
WRITING PLUGINS
acceptable. If the number of samples did grow, samples must be written to some other location
than what is pointed to by
**d
. This new pointer must be returned in
*d
.
Note: If
mode
== APPL_OUT_OF_DATA, then
n
is 0 if there still are still at least 64 stereo
samples in the audio output buffer. Otherwise it is 1. If the function returns non-zero, then 32
empty stereo samples will be inserted into the output audio stream. So, in a typical case it is
convenient to just return
n
.
Input data is always interleaved stereo, left channel first.
Volume control is placed after any user plugins. Thus it is generally a better idea to only write
filters that attenuate some frequencies and don’t emphasize any. To compensate for the lower
volume, main volume setting may be turned higher.
5.2.3
Simple Example Audio Path Plugin
This very simple plugin attenuates its input signal by a given number of decibels. The user
can give the number of decibels for the left channel in SCI_AICTRL0 and right channel in
SCI_AICTRL1.
auto u_int16 DbToLin(register u_int16 dB);
s_int16 MyPlugin(register s_int16 __i0 **data,
register u_int16 __a1 mode, register u_int16 __a0 n) {
static u_int16 multL, multR;
// Multipliers, 32768 equals 1.0
switch (mode) {
case APPL_RESET:
// *** Reset/initialize; REQUIRED!
multL = DbToLin(PERIP(SCI_AICTRL0)); // Convert decibel to linear, left
multR = DbToLin(PERIP(SCI_AICTRL1)); // Convert decibel to linear, right
return 0;
//
Do not change samplerate
break;
//
break not required, written for clarity
case APPL_AUDIO:
// *** Actual audio data; REQUIRED!
{
int i;
s_int16 *d = *data;
for (i=0; i<n; i++) {
*d = ((s_int32)(*d) * multL) >> 15; // Apply volume to left channel
d++;
*d = ((s_int32)(*d) * multR) >> 15; // Apply volume to right channel
d++;
} /* for (i=0; i<n; i++) */
}
break;
Version: 0.40, 2011-09-02
13