1SDL::AudioSpec(3)     User Contributed Perl Documentation    SDL::AudioSpec(3)
2
3
4

NAME

6       SDL::AudioSpec -- SDL Bindings for structure SDL::AudioSpec
7

CATEGORY

9       Core, Audio, Structure
10

SYNOPSIS

12        use SDL;
13        use SDL::AudioSpec;
14
15        SDL::init(SDL_INIT_AUDIO);
16
17        my $audio_spec = SDL::AudioSpec->new();
18
19            $audio_spec->freq(22050);          # 22050Hz - FM Radio quality
20            $audio_spec->format(AUDIO_S16SYS); # 16-bit signed audio
21            $audio_spec->samples(8192);        # Large audio buffer reduces risk of dropouts but increases response time
22            $audio_spec->channels(1);          # Mono
23            $audio_spec->callback('main::callback');
24
25        sub callback
26        {
27            # do something here
28        }
29

DESCRIPTION

31       The "SDL::AudioSpec" structure is used to describe the format of some
32       audio data. This structure is used by "SDL::Audio::open_audio" and
33       "SDL::Audio::load_wav".  While all fields are used by
34       "SDL::Audio::open_audio", only "freq", "format", "samples" and
35       "channels" are used by "SDL::Audio::load_wav".  We will detail these
36       common members here.
37

METHODS

39   freq
40       The number of samples sent to the sound device every second. Common
41       values are 11025, 22050 and 44100. The higher the better.
42
43   format
44       Specifies the size and type of each sample element. Values it can take
45       are:
46
47       AUDIO_U8
48           Unsigned 8-bit samples.
49
50       AUDIO_S8
51           Signed 8-bit samples.
52
53       AUDIO_U16 or AUDIO_U16LSB
54           not supported by all hardware (unsigned 16-bit little-endian)
55
56       AUDIO_S16 or AUDIO_S16LSB
57           not supported by all hardware (signed 16-bit little-endian)
58
59       AUDIO_U16MSB
60           not supported by all hardware (unsigned 16-bit big-endian)
61
62       AUDIO_S16MSB
63           not supported by all hardware (signed 16-bit big-endian)
64
65       AUDIO_U16SYS
66           Either AUDIO_U16LSB or AUDIO_U16MSB depending on hardware CPU
67           endianness
68
69       AUDIO_S16SYS
70           Either AUDIO_S16LSB or AUDIO_S16MSB depending on hardware CPU
71           endianness
72
73   channels
74       The number of separate sound channels. 1 is mono (single channel), 2 is
75       stereo (dual channel).
76
77   samples
78       When used with "SDL::Audio::open_audio" this refers to the size of the
79       audio buffer in samples. A sample is a chunk of audio data of the size
80       specified in format multiplied by the number of channels. When the
81       "SDL::AudioSpec" is used with "SDL::Audio::load_wav" samples is set to
82       4096.
83
84   callback
85       To be documented.
86

AUTHORS

88       See "AUTHORS" in SDL.
89
90
91
92perl v5.32.0                      2020-07-28                 SDL::AudioSpec(3)
Impressum