soundEngine.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 
  2. #ifndef MODULE_SOUND
  3. #define MODULE_SOUND
  4. #include "../../DFPSR/api/soundAPI.h"
  5. #include "../../DFPSR/api/imageAPI.h"
  6. #include "Envelope.h"
  7. namespace dsr {
  8. void soundEngine_initialize();
  9. void soundEngine_terminate();
  10. // Creates a single-channel sound using the generator function
  11. // generator takes the time in seconds as input and returns a value from -1.0 to 1.0
  12. int32_t soundEngine_getSoundBufferCount();
  13. int32_t soundEngine_insertSoundBuffer(const SoundBuffer &buffer, const ReadableString &name, bool fromFile);
  14. int32_t soundEngine_loadSoundFromFile(const ReadableString &filename, bool mustExist = true);
  15. SoundBuffer soundEngine_getSound(int32_t soundIndex);
  16. // TODO: Create getters for the ouput buffer settings for converting sounds with the wrong sample rate, merging too many channels, or repeating looped sounds that are shorter than the output buffer.
  17. // Pre-conditions:
  18. // The sound at soundIndex must have the same sample rate as the engine's output buffer
  19. // and may not contain more channels than the engine's output buffer.
  20. int32_t soundEngine_playSound(int32_t soundIndex, bool repeat, float leftVolume, float rightVolume, const EnvelopeSettings &envelopeSettings);
  21. inline int32_t soundEngine_playSound(int32_t soundIndex, bool repeat = false, float leftVolume = 1.0f, float rightVolume = 1.0f) { return soundEngine_playSound(soundIndex, repeat, leftVolume, rightVolume, EnvelopeSettings()); }
  22. //int32_t playSound(int32_t soundIndex, bool repeat, double volumeLeft, double volumeRight, double speed);
  23. //int32_t playSound(int32_t soundIndex, bool repeat, double volumeLeft, double volumeRight, double speed, const EnvelopeSettings &envelopeSettings);
  24. // Begin to fade out the sound and let it delete itself once done
  25. void soundEngine_releaseSound(int64_t playerID);
  26. // Stop the sound at once
  27. void soundEngine_stopSound(int64_t playerID);
  28. // Stop all sounds at once
  29. void soundEngine_stopAllSounds();
  30. // Visualization
  31. void soundEngine_drawSound(ImageRgbaU8 target, const IRect &region, int32_t soundIndex, bool selected);
  32. }
  33. #endif