1al_create_audio_stream(3)                            al_create_audio_stream(3)
2
3
4

NAME

6       al_create_audio_stream - Allegro 5 API
7

SYNOPSIS

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

DESCRIPTION

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 al‐
27         ways will be (small) fragments available to be filled with new data.
28
29       · frag_samples - The size of a fragment in samples.  See note  and  ex‐
30         planation 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       A sample that is referred to by the frag_samples parameter refers to  a
40       sequence  channel  intensities.  E.g.  if you're making a stereo stream
41       with the frag_samples set to 4, then the layout  of  the  data  in  the
42       fragment will be:
43
44              LRLRLRLR
45
46       Where  L  and R are the intensities for the left and right channels re‐
47       spectively.  A single sample, then, refers to the LR pair in this exam‐
48       ple.
49
50       The choice of fragment_count, frag_samples and freq directly influences
51       the audio delay.  The delay in seconds can be expressed as:
52
53              delay = fragment_count * frag_samples / freq
54
55       This is only the delay due to Allegro's streaming, there may  be  addi‐
56       tional delay caused by sound drivers and/or hardware.
57
58              Note:  If  you  know the fragment size in bytes, you can get the
59              size in samples like this:
60
61                     sample_size = al_get_channel_count(chan_conf) * al_get_audio_depth_size(depth);
62                     samples = bytes_per_fragment / sample_size;
63
64              The size of the complete buffer is:
65
66                     buffer_size = bytes_per_fragment * fragment_count
67
68              Note: Unlike many Allegro objects, audio streams are not implic‐
69              itly destroyed when Allegro is shut down.  You must destroy them
70              manually with al_destroy_audio_stream(3) before the audio system
71              is shut down.
72
73
74
75Allegro reference manual                             al_create_audio_stream(3)
Impressum