1SDLx::Sound(3)        User Contributed Perl Documentation       SDLx::Sound(3)
2
3
4

NAME

6       SDLx::Sound
7

CATEGORY

9       Extension
10

SYNOPSIS

12           use SDLx::Sound;
13
14           my $snd = SDLx::Sound->new();
15
16           # loads and plays a single sound now
17           $snd->play('myfile.wav');
18
19           # load a single file
20           $snd->load('theSound.aif');
21
22           # plays it or all loaded files
23           $snd->play();
24
25           # more sounds
26           my %files = (
27               channel_01 => "/my_sound1.wav",
28               channel_02 => "/my_sound2.ogg"
29           );
30
31           # times sounds bangs
32           my %times = (
33               channel_01 => 0,      # start
34               channel_01 => 1256,   # milliseconds
35               channel_02 => 2345
36           );
37
38           # Load files in channels for realtime play
39           $snd->load(%files);
40
41           # sets sound channel_01 loudness
42           $snd->loud('channel_01', 80);       # loud at 80%
43           $snd->play(%times);                 # play loaded files at times
44           $snd->play;                         # play again
45
46           # plays sound channel_01 at 578 milliseconds from now
47           $snd->play('channel_01', 578);
48
49           # fades sound
50           $snd->fade('channel_02', 2345, 3456, -20);
51
52           # in a single act do the whole Sound
53           my $snd = SDLx::Sound->new(
54               files => (
55                   channel_01 => "/my_sound1.wav",
56                   channel_02 => "/my_sound2.ogg"
57
58               ),
59               loud  => (
60                   channel_01 => 80,
61                   channel_02 => 75
62               ),
63               times => (
64                   channel_01 => 0,      # start
65                   channel_01 => 1256,   # milliseconds
66                   channel_02 => 2345
67               ),
68               fade  => (
69                   channel_02 => [2345, 3456, -20]
70               )
71           )->play();
72

DESCRIPTION

74       You can think about the SDLx::Sound at 2 approaches.
75
76       •   A simple sound or
77
78       •   The sound of your game or app.
79
80       Your application will say what the best approach.
81
82       In a taste that resembles to perl and to SDL, our SDLx:Sound hooks at
83       SDL::Audio and SDL::Mixer with a graceful and simple interface that can
84       offer to monks a modern perlish way to manage sounds.
85
86       An SDLx::Sound object can load sounds from filesystem, play it, adjust
87       this loudness level or stops the sound.
88
89       Each sound will play in the next available channel, so it can be
90       handled isolately.
91

METHODS

93   new
94       Returns a new instance of SDLx::Sound
95
96   load
97   play
98        $sdlx_sound->play('file.wav');
99
100       Play a file
101
102   pause
103   resume
104   stop

AUTHORS

106       See "AUTHORS" in SDL.
107
109       This program is free software; you can redistribute it and/or modify it
110       under the same terms as Perl itself.
111
112
113
114perl v5.36.0                      2022-07-22                    SDLx::Sound(3)
Impressum