1al_create_audio_stream(3) al_create_audio_stream(3)
2
3
4
6 al_create_audio_stream - Allegro 5 API
7
9 #include <allegro5/allegro_audio.h>
10
11 ALLEGRO_AUDIO_STREAM *al_create_audio_stream(size_t fragment_count,
12 unsigned int frag_samples, unsigned int freq, ALLEGRO_AUDIO_DEPTH depth,
13 ALLEGRO_CHANNEL_CONF chan_conf)
14
16 Creates an ALLEGRO_AUDIO_STREAM(3). The stream will be set to play by
17 default. It will feed audio data from a buffer, which is split into a
18 number of fragments.
19
20 Parameters:
21
22 · fragment_count - How many fragments to use for the audio stream.
23 Usually only two fragments are required - splitting the audio buffer
24 in two halves. But it means that the only time when new data can be
25 supplied is whenever one half has finished playing. When using many
26 fragments, you usually will use fewer samples for one, so there
27 always will be (small) fragments available to be filled with new
28 data.
29
30 · frag_samples - The size of a fragment in samples. See note below.
31
32 · freq - The frequency, in Hertz.
33
34 · depth - Must be one of the values listed for ALLEGRO_AUDIO_DEPTH(3).
35
36 · chan_conf - Must be one of the values listed for ALLEGRO_CHAN‐
37 NEL_CONF(3).
38
39 The choice of fragment_count, frag_samples and freq directly influences
40 the audio delay. The delay in seconds can be expressed as:
41
42 delay = fragment_count * frag_samples / freq
43
44 This is only the delay due to Allegro's streaming, there may be addi‐
45 tional delay caused by sound drivers and/or hardware.
46
47 Note: If you know the fragment size in bytes, you can get the
48 size in samples like this:
49
50 sample_size = al_get_channel_count(chan_conf) * al_get_audio_depth_size(depth);
51 samples = bytes_per_fragment / sample_size;
52
53 The size of the complete buffer is:
54
55 buffer_size = bytes_per_fragment * fragment_count
56
57 Note: Unlike many Allegro objects, audio streams are not implic‐
58 itly destroyed when Allegro is shut down. You must destroy them
59 manually with al_destroy_audio_stream(3) before the audio system
60 is shut down.
61
62
63
64Allegro reference manual al_create_audio_stream(3)