Overview
RealVoice uses a microphone as an input device and speakers as an output device. The audio interface is platform independent. Both sound input and sound output can be configured with specific parameters. These parameters include sampling rate, frame width, and the size of the default read frame. Sound input and output share the same basic interface structure, which includes method to initialize sound parameters and methods to either read or write data. Audio implementation is, however, platform dependent and uses standard SGI audio libraries.
Interface Details
Realvoice audio is logically broken up into two main
classes: SoundInput and SoundOutput. These classes use a supplementary
class SoundParams, which defines platform independent parameters for RealVoice
audio. If user doesn't specify his/her parameters, the parameters are initialized
to default values defined in DefaultSoundParams.h (definition of the default
values in a separate header file insures that the parameters can be easily
modified). SoundInput provides two read methods: readData and readFrame().
readData() can be used to read an arbitrary size of data from the default
sound input device. readFrame() reads a default frame size, the absolute
size of which would vary depending on the set width of input. SoundOutput
provides writeData() method, which can write data of arbitrary type to
default sound output device. Both classes contain finalInit() method. After
this method is called, sound parameters cannot be modified.
Implementation Details
Implementation of SoundInput and SoundOutput uses
SGI (3dm) audio library. This library provides a low-level sound I/O functions.
The basic flow of control is as follows: program creates a configuration
structure containing sound input/output parameters; a port is opened and
initialized with the parameters defined in this configuration structure;
read and write calls use this port to input/output data. On input, port
is associated with the queue that stores all data from the defined input
device. On output, the port is associated with the queue that stores data
to be outputted. Read methods of SoundInput block until input queue accumulates
requested amount of data. writeData() method of SoundOutput can return
before all the data is outputted.
Performance Issues
The main performance factor is the size of data on
read calls. On input, if read call is invoked frequently with small requested
data size, the quality of sound can diminish significantly. This is due
to the overhead resulting from numerous calls to access the input queue,
and consequent overflow of that queue.
Usability
SoundInput and SoundOutput are flexible stand-alone
packages. They provide a wrapper for platform-dependent system calls. In
developing RealVoice, three additional classes were implemented (these
classes were not used in the final version of RealVoice because of the
threading issues (see RealVoice protocol)): InputThread, OutputThread,
and InputOutputThread. These classes were designed to continuously feed/received
data from RealVoice but can be easily modified to communicate with any
sound processing application.
Files
SoundInput.h SoundInput.C SoundOutput.h SoundOutput.C
SoundParams.h SoundParams.C DefaultSoundParams.h