1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
6<title>axvpb.pb.addr</title>
7<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
8<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 6.5.0.0 for Windows">
9<META http-equiv="Content-Style-Type" content="text/css">
10</head>
11
12<body>
13
14<h1 align="left">axvpb.pb.addr</h1>
15
16
17<h2>C Specification</h2>
18<BLOCKQUOTE>
19<pre><CODE>// loopFlag
20#define AXPBADDR_LOOP_OFF   0       // one shot
21#define AXPBADDR_LOOP_ON    1       // looped
22
23// format
24#define AX_PB_FORMAT_PCM16  0x000A  // signed 16 bit PCM (mono)
25#define AX_PB_FORMAT_PCM8   0x0019  // signed 8 bit PCM (mono)
26#define AX_PB_FORMAT_ADPCM  0x0000  // ADPCM encoded (mono)
27
28typedef struct _AXPBADDR
29{
30
31u16 loopFlag;                   // one shot or looped sample (see above)
32u16 format;                     // sample format used (see above)
33u16 loopAddressHi;              // Loop start
34u16 loopAddressLo;
35u16 endAddressHi;               // Loop/sample end, including last sample played
36u16 endAddressLo;
37u16 currentAddressHi;           // Current playback position
38u16 currentAddressLo;
39
40} AXPBADDR;</CODE></pre>
41</BLOCKQUOTE>
42<h2>Description</h2>
43
44<p>The <code>AXPBADDR</code> structure specifies the memory-addressing context.</p>
45
46<p>The <code>loopFlag</code> parameter specifies whether the given sample is looped or played only once (&quot;one-shot&quot;).</p>
47
48<p>The <code>format</code> parameter specifies the type of sample the DSP should load from memory. This in turn dictates the addressing mode of the DSP's streaming cache. If the sample is encoded as &quot;raw&quot; 16-bit PCM, the cache will address memory in 16-bit words. For 8-bit PCM, the cache will address memory as bytes. For ADPCM samples, the cache will address memory as 4-bit nibbles. <B>Note:</B> All memory addresses used in the <code>ADDR</code> member are absolute memory addresses. They are accessed using an offset from the bottom of memory (address <code>0x0000000</code>).</p>
49
50<p>The <code>loopAddressHi</code> and <code>loopAddressLo</code> values specify the beginning address of the loop for the given sample. <BR><B>Note:</B> The interpretation of the address will depend on the format of the sample (as specified in <code>format</code>). The <code>endAddressHi</code> and <code>endAddressLo</code> values specify the end address of the loop for the given sample. The <code>currentAddressHi</code> and <code>currentAddressLo</code> values specify the current playback position of the sample.</p>
51
52<p>Once these addresses have been programmed into the streaming cache, the DSP will begin reading samples from memory. If the current sample address exceeds the loop-end address, the streaming cache will reset itself to the loop-start position and assert an interrupt.</p>
53
54<p>The associated interrupt service routine will determine how the loop should be handled. If the <code>loopFlag</code> is <code>AXPBADDR_LOOP_ON</code>, the DSP will simply continue to read samples from the loop-start location. If <code>loopFlag</code> is <code>AXPBADDR_LOOP_OFF</code>, the DSP will set the voice state to <code>AX_PB_STATE_STOP</code> and continue reading samples (from the specified loop-start address) for the remainder of the frame.</p>
55
56<h3>The Zero Buffer</h3>
57
58<p>Applications must prepare a &quot;zero buffer&quot; in memory to accomodate samples that finish playing mid-frame. The zero buffer is a contiguous block of at least 256 bytes in memory. Each byte must be set to zero. The buffer must be 32-byte aligned in memory and must be a multiple of 32 bytes in length. The buffer is required for all DSP audio applications.</p>
59
60<p>The buffer is part of a sample-address optimization scheme, used by the DSP to reduce processing overhead when mixing voices. Essentially, the DSP checks every <i>millisecond</i> if a voice has reached the end of a sound effect, rather than on every individual <i>sample</i>. Upon reaching the end of a sound effect, the sample-address engine will casually extract samples from the zero buffer until the DSP can turn the voice off.</p>
61
62<p>The millisecond accuracy for voice termination is not considered an issue, because voice <i>acquisition</i> can only occur on (three-millisecond) frame boundaries. This optimization saves several million DSP cycles per second.<br></p>
63
64<h3>The DSP-ADPCM data format</h3>
65
66<p>DSP ADPCM frames are 8 bytes long. The first byte is the frame header and contains the predictor and scale values needed to decode the samples within the given frame. The following seven bytes contain a payload of 14 samples. A sound effect encoded in DSP-ADPCM format must be stored on an 8-byte boundary in memory because the DSP's hardware ADPCM decoder assumes that data on an 8-byte boundary contains a frame header. <BR><B>Note:</B> The sound effect does not have to <i>end</i> on an 8-byte boundary.</p>
67
68<p>When programming the address parameter block for an ADPCM-encoded sample, the memory addresses (<code>loopAddress</code>, <code>endAddress</code>, <code>currentAddress</code>) must never point to the frame header. A simple formula for calculating the appropriate nibble address for a given sample offset (starting from zero) is given below:</p>
69
70<blockquote><code>nibble_address = ((sample/14)*16) + (sample % 14) + 2);</code></blockquote>
71
72<h3>Synchronization</h3>
73
74<p>If the <code>loopFlag</code> parameter has changed, assert the <code>AX_SYNC_USER_LOOP</code> bit in the <code>axvpb.sync</code> member.</p>
75
76<p>If <code>loopAddress*</code> has changed, assert the <code>AX_SYNC_USER_LOOPADDR</code> bit in the <code>axvpb.sync</code> member.</p>
77
78<p>If <code>currentAddress*</code> has changed, assert the <code>AX_SYNC_USER_CURRADDR</code> bit in the <code>axvpb.sync</code> member.</p>
79
80<p>If <code>endAddress*</code> has changed, assert the <code>AX_SYNC_USER_ENDADDR</code> bit in the <code>axvpb.sync</code> member.</p>
81
82<p>To force synchronization of the entire structure, assert the <code>AX_SYNC_USER_ADDR</code> bit.</p>
83
84<h2>See Also</h2>
85<p>
86<code><a href="../Voice_Parameter_Blocks/sync.html">axvpb.sync</a><br> <a href="../Voice_Parameters/AXSetVoiceAddr.html">AXSetVoiceAddr</a><br></code>
87</p>
88
89<h2>Revision History</h2>
90
91<P>03/01/2006 Initial version.</P>
92</body>
93</html>
94