Guest User

SFML Audio Crash

a guest
Jul 30th, 2011
296
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Input.cpp:
  3.  
  4. if(InputData->E && InputDataLastFrm->E)
  5. {
  6.     // Do nothing
  7. }
  8. else if(InputData->E)
  9. {
  10.     // Play a sound
  11.  
  12.     PlaySoundSFML();
  13. }
  14. else
  15.     InputDataLastFrm->E = false;
  16.  
  17.  
  18.  
  19. SFML_Audio.h:
  20.  
  21. #pragma once
  22.  
  23. #include <SFML/Audio.hpp>
  24.  
  25. void PlaySoundSFML();
  26.  
  27. extern sf::SoundBuffer Buffer;
  28. extern sf::Sound Sound;
  29.  
  30.  
  31.  
  32. SFML_Audio.cpp:
  33.  
  34. #include "SFML_Audio.h"
  35.  
  36. sf::SoundBuffer Buffer;
  37. sf::Sound Sound(Buffer);
  38.  
  39. void PlaySoundSFML()
  40. {
  41.     // Load a sound buffer from a wav file
  42.     if (!Buffer.LoadFromFile("Test3.wav"))
  43.         return;
  44.  
  45.     // Play sound instance
  46.     Sound.Play();
  47. }
RAW Paste Data