5131
clevermous
1
2
>
3
>
4
>SDL_AudioCVT
5
>
6
NAME="GENERATOR"
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
8
">
9
REL="HOME"
10
TITLE="SDL Library Documentation"
11
HREF="index.html">
12
REL="UP"
13
TITLE="Audio"
14
HREF="audio.html">
15
REL="PREVIOUS"
16
TITLE="SDL_FreeWAV"
17
HREF="sdlfreewav.html">
18
REL="NEXT"
19
TITLE="SDL_BuildAudioCVT"
20
HREF="sdlbuildaudiocvt.html">
21
>
22
CLASS="REFENTRY"
23
BGCOLOR="#FFF8DC"
24
TEXT="#000000"
25
LINK="#0000ee"
26
VLINK="#551a8b"
27
ALINK="#ff0000"
28
>
29
CLASS="NAVHEADER"
30
>
31
WIDTH="100%"
32
BORDER="0"
33
CELLPADDING="0"
34
CELLSPACING="0"
35
>
36
>
37
COLSPAN="3"
38
ALIGN="center"
39
>SDL Library Documentation
40
>
41
>
42
>
43
WIDTH="10%"
44
ALIGN="left"
45
VALIGN="bottom"
46
>
47
HREF="sdlfreewav.html"
48
>Prev
49
>
50
>
51
WIDTH="80%"
52
ALIGN="center"
53
VALIGN="bottom"
54
>
55
>
56
WIDTH="10%"
57
ALIGN="right"
58
VALIGN="bottom"
59
>
60
HREF="sdlbuildaudiocvt.html"
61
>Next
62
>
63
>
64
>
65
>
66
ALIGN="LEFT"
67
WIDTH="100%">
68
>
69
>
70
NAME="SDLAUDIOCVT"
71
>SDL_AudioCVT
72
>
73
>
74
CLASS="REFNAMEDIV"
75
>
76
NAME="AEN6337"
77
>
78
>
79
>Name
80
>SDL_AudioCVT -- Audio Conversion Structure
81
>
82
CLASS="REFSECT1"
83
>
84
NAME="AEN6340"
85
>
86
>
87
>Structure Definition
88
>
89
CLASS="PROGRAMLISTING"
90
>typedef struct{
91
int needed;
92
Uint16 src_format;
93
Uint16 dest_format;
94
double rate_incr;
95
Uint8 *buf;
96
int len;
97
int len_cvt;
98
int len_mult;
99
double len_ratio;
100
void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
101
int filter_index;
102
} SDL_AudioCVT;
103
>
104
>
105
CLASS="REFSECT1"
106
>
107
NAME="AEN6343"
108
>
109
>
110
>Structure Data
111
>
112
CLASS="INFORMALTABLE"
113
>
114
NAME="AEN6345"
115
>
116
>
117
>
118
>
314
>
315
>
316
>
317
>
318
>
319
CLASS="REFSECT1"
320
>
321
NAME="AEN6397"
322
>
323
>
324
>Description
325
>
326
>The
327
CLASS="STRUCTNAME"
328
>SDL_AudioCVT
329
> is used to convert audio data between different formats. A
330
CLASS="STRUCTNAME"
331
>SDL_AudioCVT
332
> structure is created with the
333
HREF="sdlbuildaudiocvt.html"
334
>
335
CLASS="FUNCTION"
336
>SDL_BuildAudioCVT
337
>
338
> function, while the actual conversion is done by the
339
HREF="sdlconvertaudio.html"
340
>
341
CLASS="FUNCTION"
342
>SDL_ConvertAudio
343
>
344
> function.
345
>
346
>Many of the fields in the
347
CLASS="STRUCTNAME"
348
>SDL_AudioCVT
349
> structure should be considered private and their function will not be discussed here.
350
>
351
>
352
>
353
CLASS="VARIABLELIST"
354
>
355
>
356
>
357
CLASS="TYPE"
358
>Uint8 *
359
>
360
CLASS="STRUCTFIELD"
361
>
362
>buf
363
>
364
>
365
>
366
>
367
>This points to the audio data that will be used in the conversion. It is both the source and the destination, which means the converted audio data overwrites the original data. It also means that the converted data may be larger than the original data (if you were converting from 8-bit to 16-bit, for instance), so you must ensure
368
CLASS="STRUCTFIELD"
369
>
370
>buf
371
>
372
> is large enough. See below.
373
>
374
>
375
>
376
CLASS="TYPE"
377
>int
378
>
379
CLASS="STRUCTFIELD"
380
>
381
>len
382
>
383
>
384
>
385
>
386
>This is the length of the original audio data in bytes.
387
>
388
>
389
>
390
CLASS="TYPE"
391
>int
392
>
393
CLASS="STRUCTFIELD"
394
>
395
>len_mult
396
>
397
>
398
>
399
>
400
>As explained above, the audio buffer needs to be big enough to store the converted data, which may be bigger than the original audio data. The length of
401
CLASS="STRUCTFIELD"
402
>
403
>buf
404
>
405
> should be
406
CLASS="STRUCTFIELD"
407
>
408
>len
409
>
410
>*
411
CLASS="STRUCTFIELD"
412
>
413
>len_mult
414
>
415
>.
416
>
417
>
418
>
419
CLASS="TYPE"
420
>double
421
>
422
CLASS="STRUCTFIELD"
423
>
424
>len_ratio
425
>
426
>
427
>
428
>
429
>When you have finished converting your audio data, you need to know how much of your audio buffer is valid.
430
CLASS="STRUCTFIELD"
431
>
432
>len
433
>
434
>*
435
CLASS="STRUCTFIELD"
436
>
437
>len_ratio
438
>
439
> is the size of the converted audio data in bytes. This is very similar to
440
CLASS="STRUCTFIELD"
441
>
442
>len_mult
443
>
444
>, however when the convert audio data is shorter than the original
445
CLASS="STRUCTFIELD"
446
>
447
>len_mult
448
>
449
> would be 1.
450
CLASS="STRUCTFIELD"
451
>
452
>len_ratio
453
>
454
>, on the other hand, would be a fractional number between 0 and 1.
455
>
456
>
457
>
458
>
459
>
460
CLASS="REFSECT1"
461
>
462
NAME="AEN6442"
463
>
464
>
465
>See Also
466
>
467
>
468
HREF="sdlbuildaudiocvt.html"
469
>
470
CLASS="FUNCTION"
471
>SDL_BuildAudioCVT
472
>
473
>,
474
475
HREF="sdlconvertaudio.html"
476
>
477
CLASS="FUNCTION"
478
>SDL_ConvertAudio
479
>
480
>,
481
482
HREF="sdlaudiospec.html"
483
>
484
CLASS="STRUCTNAME"
485
>SDL_AudioSpec
486
>
487
>
488
>
489
>
490
CLASS="NAVFOOTER"
491
>
492
ALIGN="LEFT"
493
WIDTH="100%">
545
>
546
>
547
>
548
>