/lib/pods/SDLx/Sound.pod

http://github.com/PerlGameDev/SDL · Unknown · 125 lines · 78 code · 47 blank · 0 comment · 0 complexity · 476f1045acb87aed3f172cf9eb70be81 MD5 · raw file

  1. =head1 NAME
  2. SDLx::Sound
  3. =head1 CATEGORY
  4. Extension
  5. =head1 SYNOPSIS
  6. use SDLx::Sound;
  7. my $snd = SDLx::Sound->new();
  8. # loads and plays a single sound now
  9. $snd->play('myfile.wav');
  10. # load a single file
  11. $snd->load('theSound.aif');
  12. # plays it or all loaded files
  13. $snd->play();
  14. # more sounds
  15. my %files = (
  16. channel_01 => "/my_sound1.wav",
  17. channel_02 => "/my_sound2.ogg"
  18. );
  19. # times sounds bangs
  20. my %times = (
  21. channel_01 => 0, # start
  22. channel_01 => 1256, # milliseconds
  23. channel_02 => 2345
  24. );
  25. # Load files in channels for realtime play
  26. $snd->load(%files);
  27. # sets sound channel_01 loudness
  28. $snd->loud('channel_01', 80); # loud at 80%
  29. $snd->play(%times); # play loaded files at times
  30. $snd->play; # play again
  31. # plays sound channel_01 at 578 milliseconds from now
  32. $snd->play('channel_01', 578);
  33. # fades sound
  34. $snd->fade('channel_02', 2345, 3456, -20);
  35. # in a single act do the whole Sound
  36. my $snd = SDLx::Sound->new(
  37. files => (
  38. channel_01 => "/my_sound1.wav",
  39. channel_02 => "/my_sound2.ogg"
  40. ),
  41. loud => (
  42. channel_01 => 80,
  43. channel_02 => 75
  44. ),
  45. times => (
  46. channel_01 => 0, # start
  47. channel_01 => 1256, # milliseconds
  48. channel_02 => 2345
  49. ),
  50. fade => (
  51. channel_02 => [2345, 3456, -20]
  52. )
  53. )->play();
  54. =head1 DESCRIPTION
  55. You can think about the SDLx::Sound at 2 approaches.
  56. =over 4
  57. =item * A simple sound or
  58. =item * The sound of your game or app.
  59. =back
  60. Your application will say what the best approach.
  61. In a taste that resembles to perl and to SDL, our SDLx:Sound hooks at SDL::Audio and SDL::Mixer with a graceful and simple interface that can offer to monks a modern perlish way to manage sounds.
  62. An SDLx::Sound object can load sounds from filesystem, play it, adjust this loudness level or stops the sound.
  63. Each sound will play in the next available channel, so it can be handled isolately.
  64. =head1 METHODS
  65. =head2 new
  66. Returns a new instance of SDLx::Sound
  67. =head2 load
  68. =head2 play
  69. $sdlx_sound->play('file.wav');
  70. Play a file
  71. =head2 pause
  72. =head2 resume
  73. =head2 stop
  74. =head1 AUTHORS
  75. See L<SDL/AUTHORS>.
  76. =head1 COPYRIGHT & LICENSE
  77. This program is free software; you can redistribute it and/or modify it
  78. under the same terms as Perl itself.