Specifications
Modifying the Source Code to Use Host Channels and Pipes
Connecting to I/O Devices
7-11
Void A2DscaleD2A(HST_Obj *inpChannel, HST_Obj *outChannel)
{
PIP_Obj *inp_PIP;
PIP_Obj *out_PIP;
sample *input;
sample *output;
Uns size;
inp_PIP = HST_getpipe(inpChannel);
out_PIP = HST_getpipe(outChannel);
if ((PIP_getReaderNumFrames(inp_PIP) <= 0) ||
(PIP_getWriterNumFrames(out_PIP) <= 0)) {
/* Software interrupt should not have been triggered! */
error();
}
/* Read a new volume when the hosts send it */
if (!RTDX_channelBusy(&control_channel))
RTDX_readNB(&control_channel, &volume, sizeof(volume));
/* A2D: get digitized input (get signal from the host
* through HST). Obtain input frame and allocate output
* frame from the host pipes. */
PIP_get(inp_PIP);
PIP_alloc(out_PIP);
input = PIP_getReaderAddr(inp_PIP);
output = PIP_getWriterAddr(out_PIP);
size = PIP_getReaderSize(inp_PIP);
/* Vector Scale: Scale the input signal by the volume
* factor to produce the output signal. */
while(size--){
*output++ = *input++ * volume;
}
/* D2A: produce analog output (send signal to the host
* through HST). Send output data to the host pipe and
* free the frame from the input pipe. */
PIP_put(out_PIP);
PIP_free(inp_PIP);
}
The A2DscaleD2A function is called by the A2DscaleD2A_SWI
object. You create this SWI object in the next section and make it call
the A2DscaleD2A function.
The A2DscaleD2A_SWI object passes two HST objects to this
function. This function then calls HST_getpipe to get the address of
the internal PIP object used by each HST object.