With AF3, client applications may choose to use their own preferred datatype when communicating with an audio server. They do not need to use the datatype native to an audio device.
To use automatic datatype conversion, client applications must set the ACEncodingType attribute in an AC (audio context.) Clients may set their preferred encoding type on the call to AFCreateAC(3) or through a call to AFChangeACAtributes(3).
All popular scalar datatypes are currently supported as well as several compressed datatypes.
AFFindEncodeType(3) will accept a encoding type string and return the matching enumerated encoding type for setting the attribute type. AFPrintKnownEncodingTypes(3) will print to stderr all defined strings and their accepted alternate names.
To play a mu-law sound file against an audio device with a native datatype other than mu-255, use
aplay [-d device no.] -e ulaw filename
#include <AF/AFlib.h> #include <AF/AFUtils.h> AFAudioConn *aud; AC ac; AFSetACAttributes attributes; int device; /* Open connection to default audio server */ if ( (aud = AFOpenAudioConn(NULL)) == NULL) { fprintf(stderr, "%s: can't open connection.\n", argv[0]); exit(1); } /* Select the proper audio device */ device = FindDefaultDevice(aud); /* Set the preferred attributes for audio context, include datatype */ attributes.preempt = Mix; attributes.play_gain = 0; attributes.type = MU255; /* Now create the audio context */ ac = AFCreateAC(aud, device, (ACPlayGain | ACEncodingType)), &attributes); /* Make sure we confirm encoding type is supported. */ AFSync(aud, 0);
af-bugs@crl.dec.com