1
0

StreamEncoderSettings.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * StreamEncoderSettings.h
  3. * -----------------------
  4. * Purpose: Exporting streamed music files.
  5. * Notes : none
  6. * Authors: Joern Heusipp
  7. * OpenMPT Devs
  8. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  9. */
  10. #pragma once
  11. #include "openmpt/all/BuildSettings.hpp"
  12. #include "StreamEncoder.h"
  13. #include "Settings.h"
  14. OPENMPT_NAMESPACE_BEGIN
  15. template<> inline SettingValue ToSettingValue(const Encoder::Mode &val)
  16. {
  17. switch(val)
  18. {
  19. case Encoder::ModeCBR: return SettingValue(U_("CBR"), "Encoder::Mode"); break;
  20. case Encoder::ModeABR: return SettingValue(U_("ABR"), "Encoder::Mode"); break;
  21. case Encoder::ModeVBR: return SettingValue(U_("VBR"), "Encoder::Mode"); break;
  22. case Encoder::ModeQuality: return SettingValue(U_("Quality"), "Encoder::Mode"); break;
  23. case Encoder::ModeLossless: return SettingValue(U_("Lossless"), "Encoder::Mode"); break;
  24. default: return SettingValue(U_("Invalid"), "Encoder::Mode"); break;
  25. }
  26. }
  27. template<> inline Encoder::Mode FromSettingValue(const SettingValue &val)
  28. {
  29. ASSERT(val.GetTypeTag() == "Encoder::Mode");
  30. if(val.as<mpt::ustring>() == U_("")) { return Encoder::ModeInvalid; }
  31. else if(val.as<mpt::ustring>() == U_("CBR")) { return Encoder::ModeCBR; }
  32. else if(val.as<mpt::ustring>() == U_("ABR")) { return Encoder::ModeABR; }
  33. else if(val.as<mpt::ustring>() == U_("VBR")) { return Encoder::ModeVBR; }
  34. else if(val.as<mpt::ustring>() == U_("Quality")) { return Encoder::ModeQuality; }
  35. else if(val.as<mpt::ustring>() == U_("Lossless")) { return Encoder::ModeLossless; }
  36. else { return Encoder::ModeInvalid; }
  37. }
  38. template<> inline SettingValue ToSettingValue(const Encoder::Format &val)
  39. {
  40. return SettingValue(val.AsInt(), "Encoder::Format");
  41. }
  42. template<> inline Encoder::Format FromSettingValue(const SettingValue &val)
  43. {
  44. MPT_ASSERT(val.GetTypeTag() == "Encoder::Format");
  45. return Encoder::Format::FromInt(val.as<int32>());
  46. }
  47. struct StoredTags
  48. {
  49. Setting<mpt::ustring> artist;
  50. Setting<mpt::ustring> album;
  51. Setting<mpt::ustring> trackno;
  52. Setting<mpt::ustring> year;
  53. Setting<mpt::ustring> url;
  54. Setting<mpt::ustring> genre;
  55. StoredTags(SettingsContainer &conf);
  56. };
  57. struct EncoderSettingsConf
  58. {
  59. Setting<bool> Cues;
  60. Setting<bool> Tags;
  61. Setting<uint32> Samplerate;
  62. Setting<uint16> Channels;
  63. Setting<Encoder::Mode> Mode;
  64. Setting<int> Bitrate;
  65. Setting<float> Quality;
  66. Setting<Encoder::Format> Format2;
  67. Setting<int> Dither;
  68. EncoderSettingsConf(SettingsContainer &conf, const mpt::ustring &encoderName, bool cues, bool tags, uint32 samplerate, uint16 channels, Encoder::Mode mode, int bitrate, float quality, Encoder::Format format, int dither);
  69. explicit operator Encoder::Settings() const;
  70. };
  71. struct StreamEncoderSettingsConf
  72. {
  73. Setting<int32> FLACCompressionLevel;
  74. Setting<uint32> AUPaddingAlignHint;
  75. Setting<uint32> MP3ID3v2MinPadding;
  76. Setting<uint32> MP3ID3v2PaddingAlignHint;
  77. Setting<bool> MP3ID3v2WriteReplayGainTXXX;
  78. Setting<int32> MP3LameQuality;
  79. Setting<bool> MP3LameID3v2UseLame;
  80. Setting<bool> MP3LameCalculateReplayGain;
  81. Setting<bool> MP3LameCalculatePeakSample;
  82. Setting<int32> OpusComplexity;
  83. StreamEncoderSettingsConf(SettingsContainer &conf, const mpt::ustring &section);
  84. explicit operator Encoder::StreamSettings() const;
  85. };
  86. OPENMPT_NAMESPACE_END