Miles Sound System SDK 7.2a

AIL_sample_position

The function AIL_sample_position reports the current playback position of a sample.

U32 AIL_sample_position(
  HSAMPLE S
);

In Parameters

S
indicates the sample whose playback position is to be reported.

Returns

The offset in bytes of the next sample point to be fetched, relative to the beginning of the sample's data buffer.

Discussion

The granularity of the reported position offset depends on the hardware's buffer latency, but it will always reflect an address which has not yet been reached by the playback mechanism.

The Miles Sound System digital audio mixer operates on the application's audio data in small chunks, called blocks. Part of the system's responsibility is to poll the hardware buffers in the background to determine when the next block of audio data from the application should be processed and copied into an empty hardware half-buffer. As an example, consider a hardware driver which is configured to play 16-bit audio at 20,000 Hz with a pair of 1,000-byte half-buffers. The driver's data rate is 40,000 bytes per second, implying a half-buffer playback rate of 40,000 / 1,000, or 40 buffer transitions per second.

At a rate of 40 times per second, then, a sample block equivalent to one half-buffer's worth of data is fetched from the application's sample data buffer at the current playback position. The samples are resampled if necessary to conform to the driver's hardware rate, converted between 8-bit and 16-bit formats where appropriate, mathematically scaled for volume and panpot control, algebraically added to data from other active samples, clipped, and copied into the driver's empty half-buffer to be played as soon as the other half-buffer finishes playing.

AIL_sample_position reports the location of the beginning of the next application data block to be fetched and processed by this mechanism.

You can use the AIL_sample_ms_position function to retrieve the current sample position in milliseconds.


Group: Digital Audio Services
Related Functions: AIL_register_SOB_callback, AIL_sample_granularity, AIL_sample_ms_position, AIL_sample_position, AIL_set_sample_ms_position, AIL_set_sample_position
Related Basic Types: HSAMPLE, U32
Related FAQs: What's the best way to port my older Miles application to MSS 7?

For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.