eas_pcm.h revision a8c89077d78769bf4840fa91609edc51fe2fa02d
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*----------------------------------------------------------------------------
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * File:
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * eas_pcm.h
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Contents and purpose:
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * External function prototypes for eas_pcm.c module
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright Sonic Network Inc. 2005
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License");
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * you may not use this file except in compliance with the License.
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * You may obtain a copy of the License at
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      http://www.apache.org/licenses/LICENSE-2.0
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Unless required by applicable law or agreed to in writing, software
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS,
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * See the License for the specific language governing permissions and
221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * limitations under the License.
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci *----------------------------------------------------------------------------
251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * Revision Control:
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *   $Revision: 847 $
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *   $Date: 2007-08-27 21:30:08 -0700 (Mon, 27 Aug 2007) $
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *----------------------------------------------------------------------------
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef _EAS_PCM_H
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define _EAS_PCM_H
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* default gain setting - roughly unity gain */
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PCM_DEFAULT_GAIN_SETTING    0x6000
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct s_pcm_state_tag *EAS_PCM_HANDLE;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef void (*EAS_PCM_CALLBACK) (EAS_DATA_HANDLE pEASData, EAS_VOID_PTR cbInstData, EAS_PCM_HANDLE pcmHandle, EAS_STATE state);
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* parameters for EAS_PEOpenStream */
41eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochtypedef struct s_pcm_open_params_tag
42eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch{
43eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    EAS_FILE_HANDLE     fileHandle;
44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    EAS_I32             decoder;
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    EAS_U32             sampleRate;
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_I32             size;
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_U32             loopStart;
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_U32             loopSamples;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    EAS_I32             blockSize;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    EAS_U32             flags;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_U32             envData;
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_I16             volume;
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_PCM_CALLBACK    pCallbackFunc;
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    EAS_VOID_PTR        cbInstData;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } S_PCM_OPEN_PARAMS;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*----------------------------------------------------------------------------
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * EAS_PEInit()
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *----------------------------------------------------------------------------
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Purpose:
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Initializes the PCM engine
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Inputs:
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
66b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) * Outputs:
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
69c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) * Side Effects:
70c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) *
71c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) *----------------------------------------------------------------------------
72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)*/
73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)EAS_RESULT EAS_PEInit (EAS_DATA_HANDLE pEASData);
74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)/*----------------------------------------------------------------------------
76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) * EAS_PEShutdown()
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) *----------------------------------------------------------------------------
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Purpose:
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Shuts down the PCM engine
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Inputs:
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Outputs:
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Side Effects:
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *----------------------------------------------------------------------------
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EAS_RESULT EAS_PEShutdown (EAS_DATA_HANDLE pEASData);
92
93/*----------------------------------------------------------------------------
94 * EAS_PEOpenStream()
95 *----------------------------------------------------------------------------
96 * Purpose:
97 * Starts up a PCM playback
98 *
99 * Inputs:
100 *
101 *
102 * Outputs:
103 *
104 *
105 * Side Effects:
106 *
107 *----------------------------------------------------------------------------
108*/
109EAS_RESULT EAS_PEOpenStream (EAS_DATA_HANDLE pEASData, S_PCM_OPEN_PARAMS *pParams, EAS_PCM_HANDLE *pHandle);
110
111/*----------------------------------------------------------------------------
112 * EAS_PEContinueStream()
113 *----------------------------------------------------------------------------
114 * Purpose:
115 * Continues a PCM stream
116 *
117 * Inputs:
118 *
119 *
120 * Outputs:
121 *
122 *
123 * Side Effects:
124 *
125 *----------------------------------------------------------------------------
126*/
127EAS_RESULT EAS_PEContinueStream (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle, EAS_I32 size);
128
129/*----------------------------------------------------------------------------
130 * EAS_PEGetFileHandle()
131 *----------------------------------------------------------------------------
132 * Purpose:
133 * Returns the file handle of a stream
134 *
135 * Inputs:
136 *
137 *
138 * Outputs:
139 *
140 *
141 * Side Effects:
142 *
143 *----------------------------------------------------------------------------
144*/
145EAS_RESULT EAS_PEGetFileHandle (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle, EAS_FILE_HANDLE *pFileHandle);
146
147/*----------------------------------------------------------------------------
148 * EAS_PERender()
149 *----------------------------------------------------------------------------
150 * Purpose:
151 * Render a buffer of PCM audio
152 *
153 * Inputs:
154 *
155 *
156 * Outputs:
157 *
158 *
159 * Side Effects:
160 *
161 *----------------------------------------------------------------------------
162*/
163EAS_RESULT EAS_PERender (EAS_DATA_HANDLE pEASData, EAS_I32 numSamples);
164
165/*----------------------------------------------------------------------------
166 * EAS_PEUpdateParams()
167 *----------------------------------------------------------------------------
168 * Purpose:
169 * Update the pitch and volume parameters using MIDI controls
170 *
171 * Inputs:
172 *
173 *
174 * Outputs:
175 *
176 *
177 * Side Effects:
178 *
179 *----------------------------------------------------------------------------
180*/
181EAS_RESULT EAS_PEUpdateParams (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I16 pitch, EAS_I16 gainLeft, EAS_I16 gainRight);
182
183/*----------------------------------------------------------------------------
184 * EAS_PELocate()
185 *----------------------------------------------------------------------------
186 * Purpose:
187 * This function seeks to the requested place in the file. Accuracy
188 * is dependent on the sample rate and block size.
189 *
190 * Inputs:
191 * pEASData         - pointer to overall EAS data structure
192 * pState           - stream handle
193 * time             - media time in milliseconds
194 *----------------------------------------------------------------------------
195*/
196EAS_RESULT EAS_PELocate (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I32 time);
197
198/*----------------------------------------------------------------------------
199 * EAS_PEUpdateVolume()
200 *----------------------------------------------------------------------------
201 * Purpose:
202 * Update the volume parameters for a PCM stream
203 *
204 * Inputs:
205 * pEASData         - pointer to EAS library instance data
206 * handle           - pointer to S_PCM_STATE for this stream
207 * gainLeft         - linear gain multipler in 1.15 fraction format
208 * gainRight        - linear gain multipler in 1.15 fraction format
209 * initial          - initial settings, set current gain
210 *
211 * Outputs:
212 *
213 *
214 * Side Effects:
215 *
216 * Notes
217 * In mono mode, leftGain controls the output gain and rightGain is ignored
218 *----------------------------------------------------------------------------
219*/
220/*lint -esym(715, pEASData) reserved for future use */
221EAS_RESULT EAS_PEUpdateVolume (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I16 volume);
222
223/*----------------------------------------------------------------------------
224 * EAS_PEUpdatePitch()
225 *----------------------------------------------------------------------------
226 * Purpose:
227 * Update the pitch parameter for a PCM stream
228 *
229 * Inputs:
230 * pEASData         - pointer to EAS library instance data
231 * pState           - pointer to S_PCM_STATE for this stream
232 * pitch            - new pitch value in pitch cents
233 *----------------------------------------------------------------------------
234*/
235/*lint -esym(715, pEASData) reserved for future use */
236EAS_RESULT EAS_PEUpdatePitch (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I16 pitch);
237
238/*----------------------------------------------------------------------------
239 * EAS_PEState()
240 *----------------------------------------------------------------------------
241 * Purpose:
242 * Returns the current state of the stream
243 *
244 * Inputs:
245 * pEASData         - pointer to overall EAS data structure
246 * handle           - pointer to file handle
247 * pState           - pointer to variable to store state
248 *
249 * Outputs:
250 *
251 *
252 * Side Effects:
253 *
254 * Notes:
255 * This interface is also exposed in the internal library for use by the other modules.
256 *----------------------------------------------------------------------------
257*/
258EAS_RESULT EAS_PEState (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle, EAS_STATE *pState);
259
260/*----------------------------------------------------------------------------
261 * EAS_PEClose()
262 *----------------------------------------------------------------------------
263 * Purpose:
264 * Close the file and clean up
265 *
266 * Inputs:
267 * pEASData         - pointer to overall EAS data structure
268 * handle           - pointer to file handle
269 *
270 * Outputs:
271 *
272 *
273 * Side Effects:
274 *
275 *----------------------------------------------------------------------------
276*/
277EAS_RESULT EAS_PEClose (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
278
279/*----------------------------------------------------------------------------
280 * EAS_PEReset()
281 *----------------------------------------------------------------------------
282 * Purpose:
283 * Reset the sequencer. Used for locating backwards in the file.
284 *
285 * Inputs:
286 * pEASData         - pointer to overall EAS data structure
287 * handle           - pointer to file handle
288 *
289 * Outputs:
290 *
291 *
292 * Side Effects:
293 *
294 *----------------------------------------------------------------------------
295*/
296EAS_RESULT EAS_PEReset (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
297
298/*----------------------------------------------------------------------------
299 * EAS_PEPause()
300 *----------------------------------------------------------------------------
301 * Purpose:
302 * Mute and pause rendering a PCM stream. Sets the gain target to zero and stops the playback
303 * at the end of the next audio frame.
304 *
305 * Inputs:
306 * pEASData         - pointer to EAS library instance data
307 * handle           - pointer to S_PCM_STATE for this stream
308 *
309 * Outputs:
310 *
311 *
312 * Side Effects:
313 *
314 *----------------------------------------------------------------------------
315*/
316EAS_RESULT EAS_PEPause (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
317
318/*----------------------------------------------------------------------------
319 * EAS_PEResume()
320 *----------------------------------------------------------------------------
321 * Purpose:
322 * Resume rendering a PCM stream. Sets the gain target back to its
323 * previous setting and restarts playback at the end of the next audio
324 * frame.
325 *
326 * Inputs:
327 * pEASData         - pointer to EAS library instance data
328 * handle           - pointer to S_PCM_STATE for this stream
329 *
330 * Outputs:
331 *
332 *
333 * Side Effects:
334 *
335 *----------------------------------------------------------------------------
336*/
337EAS_RESULT EAS_PEResume (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
338
339/*----------------------------------------------------------------------------
340 * EAS_PERelease()
341 *----------------------------------------------------------------------------
342 * Purpose:
343 * Put the PCM stream envelope into release.
344 *
345 * Inputs:
346 * pEASData         - pointer to EAS library instance data
347 * handle           - pointer to S_PCM_STATE for this stream
348 *
349 * Outputs:
350 *
351 *
352 * Side Effects:
353 *
354 *----------------------------------------------------------------------------
355*/
356EAS_RESULT EAS_PERelease (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
357
358#endif /* end _EAS_PCM_H */
359
360