dd_sound.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef DD_SOUND_H
  2. #define DD_SOUND_H
  3. #if DD_PLATFORM_ANDROID
  4. #else
  5. #include <SDL2/SDL.h>
  6. #include <SDL2/SDL_mixer.h>
  7. #endif
  8. extern int dd_hasAudio;
  9. /*
  10. * support audio formats
  11. */
  12. enum dd_audio_format {
  13. DD_AUDIO_FORMAT_WAV,
  14. };
  15. /* sound element
  16. * meant for small-size sound effects
  17. */
  18. struct dd_sound {
  19. #if DD_PLATFORM_ANDROID
  20. char filename[100];
  21. int index;
  22. #else
  23. Mix_Chunk *sound;
  24. #endif
  25. int playingChannel;
  26. void (*load)(struct dd_sound *, const char *filename, enum dd_audio_format format);
  27. void (*clean)(struct dd_sound *);
  28. void (*play)(struct dd_sound *);
  29. void (*playLoop)(struct dd_sound *, int loops);
  30. void (*stop)(struct dd_sound *);
  31. void (*setVolume)(struct dd_sound *, int volume);
  32. };
  33. void dd_sound_create(struct dd_sound *);
  34. void dd_sound_load(struct dd_sound *, const char *filename, enum dd_audio_format format);
  35. void dd_sound_clean(struct dd_sound *);
  36. void dd_sound_play(struct dd_sound *);
  37. void dd_sound_playLoop(struct dd_sound *, int loops);
  38. void dd_sound_stop(struct dd_sound *);
  39. void dd_sound_setVolume(struct dd_sound *, int volume);
  40. #endif