1
0

ifc_replaygain_settings.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. /* ok, this could have easily been a config group, but I decided to make it its own interface for two reasons
  4. 1) it's a little more maintainable and easier to understand and use, rather than just using a generic key/value interface
  5. 2) the original ReplayGain specs suggests using the average gain of the last 10 played tracks in cases of missing replay gain data
  6. http://replaygain.hydrogenaudio.org/proposal/player_scale.html
  7. So we need a way to have the playback object pass along gain values so they can be averages in this way
  8. */
  9. // {1CE24DEC-A189-4BC7-86A7-C6CDB0F8953D}
  10. static const GUID replaygain_settings_interface_guid =
  11. { 0x1ce24dec, 0xa189, 0x4bc7, { 0x86, 0xa7, 0xc6, 0xcd, 0xb0, 0xf8, 0x95, 0x3d } };
  12. class ifc_metadata;
  13. class ifc_replaygain_settings : public Wasabi2::Dispatchable
  14. {
  15. protected:
  16. ifc_replaygain_settings() : Wasabi2::Dispatchable(DISPATCHABLE_VERSION) {}
  17. ~ifc_replaygain_settings() {}
  18. public:
  19. static GUID GetInterfaceGUID() { return replaygain_settings_interface_guid; }
  20. enum
  21. {
  22. REPLAYGAIN_OFF=0x0,
  23. REPLAYGAIN_ON=0x1,
  24. REPLAYGAIN_MODE_TRACK=0x2,
  25. REPLAYGAIN_MODE_ALBUM=0x4,
  26. REPLAYGAIN_MODE_MASK=REPLAYGAIN_MODE_TRACK|REPLAYGAIN_MODE_ALBUM,
  27. REPLAYGAIN_PREVENT_CLIPPING=0x8,
  28. REPLAYGAIN_AUTO=0x16, // automatically determine gain values for unscanned tracks from prior history
  29. };
  30. /* pass the ifc_metadata associated with the track
  31. warning values:
  32. NErr_Success: gain is set to the gain adjustment to play this track with
  33. NErr_False: gain is set to the default gain adjustment because there was no metadata
  34. NErr_Unknown: gain is set to the default gain adjustment, because the metadata object does not understand the ReplayGain metadata keys (MetadataKeys::TRACK_GAIN, etc)
  35. return values:
  36. NErr_Success: *gain has been assigned and is valid
  37. NErr_Disabled: ReplayGain is turned off
  38. */
  39. int GetGain(ifc_metadata *metadata, double *gain, int *warning) { return ReplayGainSettings_GetGain(metadata, gain, warning); }
  40. /* Adds a track to the history, which is optionally used when playing back tracks without ReplayGain
  41. pass the track length (or an estimate). Pass 0.0 for length if don't know.
  42. You should only call this if GetGain returned NErr_Success and there was no warning!
  43. */
  44. int AddToHistory(double seconds, double gain) { return ReplayGainSettings_AddToHistory(seconds, gain); }
  45. private:
  46. virtual int WASABICALL ReplayGainSettings_GetGain(ifc_metadata *metadata, double *gain, int *warning)=0;
  47. virtual int WASABICALL ReplayGainSettings_AddToHistory(double seconds, double gain)=0;
  48. enum
  49. {
  50. DISPATCHABLE_VERSION,
  51. };
  52. };