1play_audio_stream(3) Allegro manual play_audio_stream(3)
2
3
4
6 play_audio_stream - Creates a new audio stream and starts playing it.
7 Allegro game programming library.
8
10 #include <allegro.h>
11
12
13 AUDIOSTREAM *play_audio_stream(int len, int bits, int stereo, int freq,
14 int vol, int pan);
15
17 This function creates a new audio stream and starts playing it. The
18 length is the size of each transfer buffer in sample frames (not
19 bytes), where a sample frame is a single sample value for mono data or
20 a pair of interleaved sample values (left first) for stereo data. The
21 length should normally be (but doesn't have to be) a power of 2 some‐
22 where around 1k in size. Larger buffers are more efficient and require
23 fewer updates, but result in more latency between you providing the
24 data and it actually being played.
25
26 The `bits' parameter must be 8 or 16. `freq' is the sample rate of the
27 data in Hertz. The `vol' and `pan' values use the same 0-255 ranges as
28 the regular sample playing functions. The `stereo' parameter should be
29 set to 1 for stereo streams, or 0 otherwise.
30
31 If you want to adjust the pitch, volume, or panning of a stream once it
32 is playing, you can use the regular voice_*() functions with
33 stream->voice as a parameter. The format of the sample data is
34 described in the SAMPLE entry of the "Structures and types defined by
35 Allegro" chapter. The formula to get the size of the buffers in bytes
36 could be:
37
38 bytes = length * (bits / 8) * (stereo ? 2 : 1)
39 Example:
40
41 /* Create a 22KHz 8bit mono audio stream. */
42 stream = play_audio_stream(1024, 8, FALSE, 22050, 255, 128);
43 if (!stream)
44 abort_on_error("Error creating audio stream!\n");
45
47 This function returns a pointer to the audio stream or NULL if it could
48 not be created.
49
50
52 install_sound(3), get_audio_stream_buffer(3), stop_audio_stream(3),
53 AUDIOSTREAM(3), exstream(3)
54
55
56
57Allegro version 4.4.3 play_audio_stream(3)