1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> 2<head> 3<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 4<title>SND_SetupChannelPcm</title> 5<link rel="stylesheet" href="../css/nitro.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.65.1"> 7</head> 8<body> 9<div class="refentry" lang="ja"><a name="IDAFLWT"></a><div class="titlepage"> 10<div></div> 11<div></div> 12</div> 13<h1>SND_SetupChannelPcm <IMG src="../image/NTR.gif" width="24" height="12" border="0" align=middle><IMG src="../image/TWL.gif" width="24" height="12" border="0" align=middle></h1> 14<h2>Syntax</h2> 15<dl> 16<dd><pre class="funcsynopsisinfo"><code>#include <nitro/snd.h></code></pre></dd> 17<dd><pre class="funcprototype"><code class="funcprototype">void SND_SetupChannelPcm( 18int <var>chNo</var>, 19SNDWaveFormat <var>format</var>, 20const void* <var>dataAddr</var>, 21SNDChannelLoop <var>loop</var>, 22int <var>loopStart</var>, 23int <var>loopLen</var>, 24int <var>volume</var>, 25SNDChannelDataShift <var>shift</var>, 26int <var>timer</var>, 27int <var>pan</var> );</code><br></pre></dd> 28</dl> 29<div class="refsection" lang="ja"><a name="IDAHOWT"></a> 30<h2>Arguments</h2> 31 32 <div class="variablelist"> 33<table border="0"> 34<col align="left" valign="top"> 35<tbody> 36<tr> 37<td><SPAN class="argument">chNo</SPAN></td> 38<td>Channel number. Takes a value between 0 and 15.</td> 39</tr> 40<tr> 41<td><SPAN class="argument">format</SPAN></td> 42<td>Format of the waveform data.</td> 43</tr> 44<tr> 45<td><SPAN class="argument">dataAddr</SPAN></td> 46<td>Starting address of the waveform data. Must have 4-byte alignment.</td> 47</tr> 48<tr> 49<td><SPAN class="argument">loop</SPAN></td> 50<td>Loop playback setting.</td> 51</tr> 52<tr> 53<td><SPAN class="argument">loopStart</SPAN></td> 54<td>Loop-start position. Expressed in units of words. Takes a value of 0 to <CODE>0xffff</CODE>.</td> 55</tr> 56<tr> 57<td><SPAN class="argument">loopLen</SPAN></td> 58<td>Length of the loop. Expressed in units of words. Takes a value of 0 to <CODE>0x3fffff</CODE>.</td> 59</tr> 60<tr> 61<td><SPAN class="argument">volume</SPAN></td> 62<td>Volume. Takes a value between 0 and 127.</td> 63</tr> 64<tr> 65<td><SPAN class="argument">shift</SPAN></td> 66<td>Data shift setting.</td> 67</tr> 68<tr> 69<td><SPAN class="argument">timer</SPAN></td> 70<td>Timer. Takes a value between 0x10 and 0xffff.</td> 71</tr> 72<tr> 73<td><SPAN class="argument">pan</SPAN></td> 74<td>Pan. Takes values in the range of 0 (left) to 64 (center) to 127 (right).</td> 75</tr> 76</tbody> 77</table> 78</div> 79 80 </div> 81<div class="refsection" lang="ja"><a name="IDAYQWT"></a> 82<h2>Return Values</h2> 83 84<p>None.</p> 85 </div> 86<div class="refsection" lang="ja"><a name="IDA5QWT"></a> 87<h2>Description</h2> 88 <p> 89Sets up channels for PCM playback. 90</p> 91 <p> 92The function sets the parameters for the channel specified by <SPAN class="argument">chNo</SPAN>. The channel must first be locked by the <a href="SND_LockChannel.html"><CODE>SND_LockChannel</CODE></a> function. Once the parameters have been set, call the <a href="SND_StartTimer.html"><CODE>SND_StartTimer</CODE></a> function to begin actual playback. 93</p> 94 <p> 95Choose from among these values for the waveform data format <SPAN class="argument">format</SPAN>. 96</p> 97<div class="table"><a name="IDAZRWT"></a><p class="title"><b><b>Table. SNDWaveFormat</b></b></p> 98<table summary="SNDWaveFormat" border="1"> 99<colgroup><col><col></colgroup> 100<thead> 101<tr> 102<th>Label</th> 103<th>Description</th> 104</tr> 105</thead> 106<tbody> 107<tr> 108<td><CODE>SND_WAVE_FORMAT_PCM8</CODE></td> 109<td>8-bit PCM</td> 110</tr> 111<tr> 112<td><CODE>SND_WAVE_FORMAT_PCM16</CODE></td> 113<td>16-bit PCM</td> 114</tr> 115<tr> 116<td><CODE>SND_WAVE_FORMAT_ADPCM</CODE></td> 117<td>IMA-ADPCM</td> 118</tr> 119</tbody> 120</table> 121</div> 122 123 <p> 124The waveform data's starting address <SPAN class="argument">dataAddr</SPAN> must have 4-byte alignment. 125</p> 126 <p> 127Choose from among these values for the loop playback setting <SPAN class="argument">loop</SPAN>. 128</p> 129<div class="table"><a name="IDAOTWT"></a><p class="title"><b><b>Table. SNDChannelLoop</b></b></p> 130<table summary="SNDChannelLoop" border="1"> 131<colgroup><col><col></colgroup> 132<thead> 133<tr> 134<th>Label</th> 135<th>Description</th> 136</tr> 137</thead> 138<tbody> 139<tr> 140<td><CODE>SND_CHANNEL_LOOP_MANUAL</CODE></td> 141<td>Continues playing, regardless of the loop setting.</td> 142</tr> 143<tr> 144<td><CODE>SND_CHANNEL_LOOP_REPEAT</CODE></td> 145<td>When playback has reached the end of the loop (<SPAN class="argument">loopStart</SPAN> + <SPAN class="argument">loopLen</SPAN>), continues playing from the start of the loop at <SPAN class="argument">loopStart</SPAN>.</td> 146</tr> 147<tr> 148<td><CODE>SND_CHANNEL_LOOP_1SHOT</CODE></td> 149<td>When playback has reached the end of the loop (<SPAN class="argument">loopStart</SPAN> + <SPAN class="argument">loopLen</SPAN>), playback stops automatically.</td> 150</tr> 151</tbody> 152</table> 153</div> 154 155 <p> 156The loop starting position <SPAN class="argument">loopStart</SPAN> and the loop length <SPAN class="argument">loopLen</SPAN> are specified in word units. The value is ignored when the loop playback setting <SPAN class="argument">loop</SPAN> is set to <code>SND_CHANNEL_LOOP_MANUAL</code>. 157</p> 158 <p> 159Choose from among these values for the data shift setting <SPAN class="argument">shift</SPAN>. 160</p> 161<div class="table"><a name="IDA1VWT"></a><p class="title"><b><b>Table. SNDChannelDataShift</b></b></p> 162<table summary="SNDChannelDataShift" border="1"> 163<colgroup><col><col></colgroup> 164<thead> 165<tr> 166<th>Label</th> 167<th>Description</th> 168</tr> 169</thead> 170<tbody> 171<tr> 172<td><CODE>SND_CHANNEL_DATASHIFT_NONE</CODE></td> 173<td>Do not perform a data shift.</td> 174</tr> 175<tr> 176<td><CODE>SND_CHANNEL_DATASHIFT_1BIT</CODE></td> 177<td>Shift data 1 bit right.</td> 178</tr> 179<tr> 180<td><CODE>SND_CHANNEL_DATASHIFT_2BIT</CODE></td> 181<td>Shift data 2 bits right.</td> 182</tr> 183<tr> 184<td><CODE>SND_CHANNEL_DATASHIFT_4BIT</CODE></td> 185<td>Shift data 4 bits right.</td> 186</tr> 187</tbody> 188</table> 189</div> 190 191 <p> 192The <SPAN class="argument">timer</SPAN> argument specifies the number of clock ticks for outputting one sample. The number of ticks per second is approximately 16.757 MHz with <code>SND_TIMER_CLOCK</code>. Thus, if you want to play the waveform data without changing the pitch, and the sampling rate is <SPAN class="argument">rate</SPAN> Hz, then you calculate <SPAN class="argument">timer</SPAN> as follows. 193</p> 194<pre class="programlisting"><SPAN class="argument">timer</SPAN> = <CODE>SND_TIMER_CLOCK</CODE> / <SPAN class="argument">rate</SPAN></pre> 195 <p> 196 197</p> 198 199 <div class="note"> 200<h3 class="title">Note</h3> 201<p> 202This function is an ARM7 reserved function. After this function is called, its processing occurs only after the command is issued with the <a href="SND_FlushCommand.html"><CODE>SND_FlushCommand</CODE></a> function. 203</p> 204<p> 205If program execution must be synchronized with process completion, first use the <a href="SND_GetCurrentCommandTag.html"><CODE>SND_GetCurrentCommandTag</CODE></a> function to get the command tag immediately after calling this function. Then, after the command is issued, use the command tag and call the <a href="SND_IsFinishedCommandTag.html"><CODE>SND_IsFinishedCommandTag</CODE></a> or <a href="SND_WaitForCommandProc.html"><CODE>SND_WaitForCommandProc</CODE></a> function to confirm that processing has finished or to wait for it to complete. 206</p> 207</div> 208 209 </div> 210<h2>See Also</h2> 211<p><a href="SND_LockChannel.html"><CODE>SND_LockChannel</CODE></a><BR> <a href="SND_StartTimer.html"><CODE>SND_StartTimer</CODE></a><BR> <a href="SND_FlushCommand.html"><CODE>SND_FlushCommand</CODE></a><BR> <a href="SND_GetCurrentCommandTag.html"><CODE>SND_GetCurrentCommandTag</CODE></a><BR> <a href="SND_IsFinishedCommandTag.html"><CODE>SND_IsFinishedCommandTag</CODE></a><BR> <a href="SND_WaitForCommandProc.html"><CODE>SND_WaitForCommandProc</CODE></a></p> 212<h2>Revision History</h2> 213<p> 2142008/11/19 Corrected mistaken explanation of loop length as data length.<br> 2005/02/17 Added precaution about ARM7 command processing.<br> 2004/10/07 Corrected <CODE>SND_CHANNEL_LOOP_REPAET</CODE> to read <CODE>SND_CHANNEL_LOOP_REPEAT</CODE>.<br> 2004/07/20 Initial version. 215</p> 216</div> 217<hr><p>CONFIDENTIAL</p></body> 218</html> 219