1
0

mod2wave.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * mod2wave.h
  3. * ----------
  4. * Purpose: Module to WAV conversion (dialog + conversion code).
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include "StreamEncoder.h"
  12. #include "StreamEncoderSettings.h"
  13. #include "Settings.h"
  14. #include "ProgressDialog.h"
  15. OPENMPT_NAMESPACE_BEGIN
  16. ///////////////////////////////////////////////////////////////////////////////////////////////////
  17. // Direct To Disk Recording
  18. struct CWaveConvertSettings
  19. {
  20. std::vector<EncoderFactoryBase*> EncoderFactories;
  21. std::vector<std::unique_ptr<EncoderSettingsConf>> EncoderSettings;
  22. Setting<mpt::ustring> EncoderName;
  23. std::size_t EncoderIndex;
  24. StoredTags storedTags;
  25. FileTags Tags;
  26. int repeatCount;
  27. ORDERINDEX minOrder, maxOrder;
  28. SAMPLEINDEX sampleSlot;
  29. SEQUENCEINDEX minSequence, maxSequence;
  30. bool normalize : 1;
  31. bool silencePlugBuffers : 1;
  32. bool outputToSample : 1;
  33. std::size_t FindEncoder(const mpt::ustring &name) const;
  34. void SelectEncoder(std::size_t index);
  35. EncoderFactoryBase *GetEncoderFactory() const;
  36. const Encoder::Traits *GetTraits() const;
  37. EncoderSettingsConf &GetEncoderSettings() const;
  38. Encoder::Settings GetEncoderSettingsWithDetails() const;
  39. CWaveConvertSettings(SettingsContainer &conf, const std::vector<EncoderFactoryBase*> &encFactories);
  40. };
  41. class CWaveConvert: public CDialog
  42. {
  43. public:
  44. CWaveConvertSettings m_Settings;
  45. const Encoder::Traits *encTraits;
  46. CSoundFile &m_SndFile;
  47. uint64 m_dwSongLimit;
  48. ORDERINDEX m_nNumOrders;
  49. CComboBox m_CbnFileType, m_CbnSampleRate, m_CbnChannels, m_CbnDither, m_CbnSampleFormat, m_CbnSampleSlot;
  50. CSpinButtonCtrl m_SpinLoopCount, m_SpinMinOrder, m_SpinMaxOrder, m_SpinMinSequence, m_SpinMaxSequence;
  51. bool m_bGivePlugsIdleTime;
  52. bool m_bChannelMode; // Render by channel
  53. bool m_bInstrumentMode; // Render by instrument
  54. CEdit m_EditTitle, m_EditAuthor, m_EditURL, m_EditAlbum, m_EditYear;
  55. CComboBox m_CbnGenre;
  56. CEdit m_EditGenre;
  57. private:
  58. void FillFileTypes();
  59. void FillSamplerates();
  60. void FillChannels();
  61. void FillFormats();
  62. void FillDither();
  63. void FillTags();
  64. void LoadTags();
  65. void SaveEncoderSettings();
  66. void SaveTags();
  67. public:
  68. CWaveConvert(CWnd *parent, ORDERINDEX minOrder, ORDERINDEX maxOrder, ORDERINDEX numOrders, CSoundFile &sndFile, const std::vector<EncoderFactoryBase*> &encFactories);
  69. public:
  70. void UpdateDialog();
  71. BOOL OnInitDialog() override;
  72. void DoDataExchange(CDataExchange *pDX) override;
  73. void OnOK() override;
  74. afx_msg void OnCheckTimeLimit();
  75. afx_msg void OnCheckChannelMode();
  76. afx_msg void OnCheckInstrMode();
  77. afx_msg void OnFileTypeChanged();
  78. afx_msg void OnSamplerateChanged();
  79. afx_msg void OnChannelsChanged();
  80. afx_msg void OnDitherChanged();
  81. afx_msg void OnFormatChanged();
  82. afx_msg void OnPlayerOptions();
  83. afx_msg void OnExportModeChanged();
  84. afx_msg void OnSampleSlotChanged();
  85. DECLARE_MESSAGE_MAP()
  86. };
  87. class CDoWaveConvert: public CProgressDialog
  88. {
  89. public:
  90. const CWaveConvertSettings &m_Settings;
  91. CSoundFile &m_SndFile;
  92. mpt::ofstream &fileStream;
  93. const CString &caption;
  94. uint64 m_dwSongLimit;
  95. bool m_bGivePlugsIdleTime;
  96. public:
  97. CDoWaveConvert(CSoundFile &sndFile, mpt::ofstream &f, const CString &caption, const CWaveConvertSettings &settings, CWnd *parent = NULL)
  98. : CProgressDialog(parent)
  99. , m_Settings(settings)
  100. , m_SndFile(sndFile)
  101. , fileStream(f)
  102. , caption(caption)
  103. , m_dwSongLimit(0)
  104. { }
  105. void Run() override;
  106. };
  107. OPENMPT_NAMESPACE_END