Home |
Function USBAudioTranslate |
Function USBAudioTranslateUSBAudioTranslate translates one audio data format into another: int USBAudioTranslate(UINT FromFormatTag, UINT ToFormatTag, UINT FromChannels, UINT ToChannels, UINT FromBytes, UINT ToBytes, UINT FromFreq, UINT ToFreq, const void * FromData, UINT FromLen, void * ToData, UINT ToLen, DWORD Flags); ParametersFromFormatTagThe USB Audio Format Tag of the input data. Currently, values USB_AUDIO_PCM (16 bit signed int) and USB_AUDIO_PCM8 (8 bit unsigned byte) are supported. ToFormatTagThe USB Audio Format Tag of the output data. Currently, values USB_AUDIO_PCM (16 bit signed int) and USB_AUDIO_PCM8 (8 bit unsigned byte) are supported. FromChannelsNumber of audio channels in the input data. Values 1 (Mono) and 2 (Stereo) are supported. ToChannelsNumber of audio channels in the output data. Values 1 (Mono) and 2 (Stereo) are supported. FromBytesNumber of bytes in each audio data sample in the input data. Values 1 (for FromFormatTag USB_AUDIO_PCM8) and 2 (for FromFormatTag USB_AUDIO_PCM) are supported. ToBytesNumber of bytes in each audio data sample in the output data. Values 1 (for ToFormatTag USB_AUDIO_PCM8) and 2 (for ToFormatTag USB_AUDIO_PCM) are supported. FromFreqFrequency (sampling rate) of the input data in Hertz. ToFreqFrequency (sampling rate) of the output data in Hertz. FromDataPointer to the audio data to be converted. This value may be identical with ToData for in-place conversions. FromLenNumber of bytes pointed to by parameter FromData. ToDataPointer to a buffer to receive the resulting audio data after conversion. This value may be identical with FromData for in-place conversions. ToLenSize in bytes of the buffer pointed to by parameter ToData. FlagsZero or optional flag USB_TRANSLATE_VERBOSE. If USB_TRANSLATE_VERBOSE is specified, this function will display minor warnings via RTUDiagMessage. Severe warnings or errors are always displayed. return valueThe number of bytes written to *ToData or a negative error code. This function can be used to bring audio data into the format an audio playback function expects, or it can convert recorded data into a more compact format for disk storage. If an audio stream is converted in smaller segments (i.e., not a complete song is converted with a single call to USBAudioTranslate), it is recommend to choose the segment size such that the segment comprises an integral number of milliseconds, both in the input and output data. For example, if the input frequency (parameter FromFreq) is 22050 and the output frequency (parameter ToFreq) is 48000, only periods which are a multiple of 20 milliseconds would fulfil this condition. USBAudioTranslate will detect identical formats and merely copy the data (if the input and output buffers are not identical) in this case.
|