A simple audio engine for Go with an SDL2 back-end and others to come eventually.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

  1. package audio
  2. // Engine is a music and sound effects driver.
  3. type Engine interface {
  4. // Setup runs initialization tasks for the audio engine.
  5. Setup() error
  6. // Teardown runs closing tasks for the audio engine to shut down gracefully.
  7. Teardown() error
  8. // Playing returns a bool if something is actively playing.
  9. // PlayingMusic and PlayingSound check specifically if music or sound
  10. // effects are currently playing.
  11. Playing() bool
  12. PlayingMusic() bool
  13. PlayingSound() bool
  14. // StopAll stops all music and sound effects.
  15. // StopMusic and StopSounds to selectively stop either the music or all
  16. // sound effects, respectively.
  17. StopAll()
  18. StopMusic()
  19. StopSounds()
  20. // LoadMusic opens a music file from disk and loads it into memory.
  21. // LoadMusicBin to load file by bytes in memory instead.
  22. LoadMusic(filename string) (Playable, error)
  23. LoadMusicBin(data []byte) (Playable, error)
  24. // LoadSound opens a sound effect file.
  25. // LoadSoundBin to load file by bytes in memory instead.
  26. LoadSound(filename string) (Playable, error)
  27. LoadSoundBin(data []byte) (Playable, error)
  28. }
  29. // Playable is a music or sound effect object that can be played and managed.
  30. type Playable interface {
  31. Play(loops int) error
  32. Pause() error
  33. Stop() error
  34. // Destroy deallocates and frees the memory.
  35. Destroy() error
  36. }