Ctrl_smp.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Ctrl_smp.h
  3. * ----------
  4. * Purpose: Sample tab, upper panel.
  5. * Notes : (currently none)
  6. * Authors: Olivier Lapicque
  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 "../soundlib/SampleIO.h"
  13. #include "../tracklib/FadeLaws.h"
  14. OPENMPT_NAMESPACE_BEGIN
  15. enum OpenSampleTypes
  16. {
  17. OpenSampleKnown = (1<<0),
  18. OpenSampleRaw = (1<<1),
  19. };
  20. MPT_DECLARE_ENUM(OpenSampleTypes)
  21. class CCtrlSamples: public CModControlDlg
  22. {
  23. protected:
  24. friend class DoPitchShiftTimeStretch;
  25. struct SampleSelectionPoints
  26. {
  27. SmpLength nStart;
  28. SmpLength nEnd;
  29. bool selectionActive; // does sample selection exist or not?
  30. };
  31. CModControlBar m_ToolBar1, m_ToolBar2;
  32. CEdit m_EditSample, m_EditName, m_EditFileName, m_EditFineTune;
  33. CEdit m_EditLoopStart, m_EditLoopEnd, m_EditSustainStart, m_EditSustainEnd;
  34. CEdit m_EditVibSweep, m_EditVibDepth, m_EditVibRate;
  35. CEdit m_EditVolume, m_EditGlobalVol, m_EditPanning;
  36. CSpinButtonCtrl m_SpinVolume, m_SpinGlobalVol, m_SpinPanning, m_SpinVibSweep, m_SpinVibDepth, m_SpinVibRate;
  37. CSpinButtonCtrl m_SpinLoopStart, m_SpinLoopEnd, m_SpinSustainStart, m_SpinSustainEnd;
  38. CSpinButtonCtrl m_SpinFineTune, m_SpinSample;
  39. CSpinButtonCtrl m_SpinSequenceMs, m_SpinSeekWindowMs, m_SpinOverlap, m_SpinStretchAmount;
  40. CComboBox m_ComboAutoVib, m_ComboLoopType, m_ComboSustainType, m_ComboZoom, m_CbnBaseNote;
  41. CButton m_CheckPanning;
  42. double m_dTimeStretchRatio = 100;
  43. uint32 m_nSequenceMs = 0;
  44. uint32 m_nSeekWindowMs = 0;
  45. uint32 m_nOverlapMs = 0;
  46. SAMPLEINDEX m_nSample = 1;
  47. INSTRUMENTINDEX m_editInstrumentName = INSTRUMENTINDEX_INVALID;
  48. bool m_rememberRawFormat = false;
  49. bool m_startedEdit = false;
  50. CComboBox m_ComboPitch, m_ComboQuality, m_ComboFFT;
  51. void UpdateTimeStretchParameters();
  52. void ReadTimeStretchParameters();
  53. void ApplyAmplify(const double amp, const double fadeInStart, const double fadeOutEnd, const bool fadeIn, const bool fadeOut, const Fade::Law fadeLaw);
  54. void ApplyResample(SAMPLEINDEX smp, uint32 newRate, ResamplingMode mode, bool ignoreSelection = false, bool updatePatternCommands = false);
  55. SampleSelectionPoints GetSelectionPoints();
  56. void SetSelectionPoints(SmpLength nStart, SmpLength nEnd);
  57. void PropagateAutoVibratoChanges();
  58. bool IsOPLInstrument() const;
  59. INSTRUMENTINDEX GetParentInstrumentWithSameName() const;
  60. public:
  61. CCtrlSamples(CModControlView &parent, CModDoc &document);
  62. ~CCtrlSamples();
  63. bool SetCurrentSample(SAMPLEINDEX nSmp, LONG lZoom = -1, bool bUpdNum = true);
  64. bool InsertSample(bool duplicate, int8 *confirm = nullptr);
  65. bool OpenSample(const mpt::PathString &fileName, FlagSet<OpenSampleTypes> types = OpenSampleKnown | OpenSampleRaw);
  66. bool OpenSample(const CSoundFile &sndFile, SAMPLEINDEX nSample);
  67. void OpenSamples(const std::vector<mpt::PathString> &files, FlagSet<OpenSampleTypes> types);
  68. void SaveSample(bool doBatchSave);
  69. void Normalize(bool allSamples);
  70. void RemoveDCOffset(bool allSamples);
  71. Setting<LONG> &GetSplitPosRef() override {return TrackerSettings::Instance().glSampleWindowHeight;}
  72. public:
  73. //{{AFX_VIRTUAL(CCtrlSamples)
  74. BOOL OnInitDialog() override;
  75. void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
  76. CRuntimeClass *GetAssociatedViewClass() override;
  77. void RecalcLayout() override;
  78. void OnActivatePage(LPARAM) override;
  79. void OnDeactivatePage() override;
  80. void UpdateView(UpdateHint hint, CObject *pObj = nullptr) override;
  81. LRESULT OnModCtrlMsg(WPARAM wParam, LPARAM lParam) override;
  82. BOOL GetToolTipText(UINT uId, LPTSTR pszText) override;
  83. BOOL PreTranslateMessage(MSG* pMsg) override;
  84. //}}AFX_VIRTUAL
  85. protected:
  86. //{{AFX_MSG(CCtrlSamples)
  87. afx_msg void OnEditFocus();
  88. afx_msg void OnSampleChanged();
  89. afx_msg void OnZoomChanged();
  90. afx_msg void OnPrevInstrument();
  91. afx_msg void OnNextInstrument();
  92. afx_msg void OnTbnDropDownToolBar(NMHDR* pNMHDR, LRESULT* pResult);
  93. afx_msg void OnSampleNew();
  94. afx_msg void OnSampleDuplicate() { InsertSample(true); }
  95. afx_msg void OnSampleOpen();
  96. afx_msg void OnSampleOpenKnown();
  97. afx_msg void OnSampleOpenRaw();
  98. afx_msg void OnSampleSave();
  99. afx_msg void OnSampleSaveOne() { SaveSample(false); }
  100. afx_msg void OnSampleSaveAll() { SaveSample(true); }
  101. afx_msg void OnSamplePlay();
  102. afx_msg void OnNormalize();
  103. afx_msg void OnAmplify();
  104. afx_msg void OnQuickFade();
  105. afx_msg void OnRemoveDCOffset();
  106. afx_msg void OnResample();
  107. afx_msg void OnReverse();
  108. afx_msg void OnSilence();
  109. afx_msg void OnInvert();
  110. afx_msg void OnSignUnSign();
  111. afx_msg void OnAutotune();
  112. afx_msg void OnNameChanged();
  113. afx_msg void OnFileNameChanged();
  114. afx_msg void OnVolumeChanged();
  115. afx_msg void OnGlobalVolChanged();
  116. afx_msg void OnSetPanningChanged();
  117. afx_msg void OnPanningChanged();
  118. afx_msg void OnFineTuneChanged();
  119. afx_msg void OnFineTuneChangedDone();
  120. afx_msg void OnBaseNoteChanged();
  121. afx_msg void OnLoopTypeChanged();
  122. afx_msg void OnLoopPointsChanged();
  123. afx_msg void OnSustainTypeChanged();
  124. afx_msg void OnSustainPointsChanged();
  125. afx_msg void OnVibTypeChanged();
  126. afx_msg void OnVibDepthChanged();
  127. afx_msg void OnVibSweepChanged();
  128. afx_msg void OnVibRateChanged();
  129. afx_msg void OnXFade();
  130. afx_msg void OnStereoSeparation();
  131. afx_msg void OnKeepSampleOnDisk();
  132. afx_msg void OnVScroll(UINT, UINT, CScrollBar *);
  133. afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM);
  134. afx_msg void OnXButtonUp(UINT nFlags, UINT nButton, CPoint point);
  135. afx_msg void OnPitchShiftTimeStretch();
  136. afx_msg void OnEnableStretchToSize();
  137. afx_msg void OnEstimateSampleSize();
  138. afx_msg void OnInitOPLInstrument();
  139. MPT_NOINLINE void SetModified(SampleHint hint, bool updateAll, bool waveformModified);
  140. void PrepareUndo(const char *description, sampleUndoTypes type = sundo_none, SmpLength start = 0, SmpLength end = 0);
  141. //}}AFX_MSG
  142. DECLARE_MESSAGE_MAP()
  143. };
  144. OPENMPT_NAMESPACE_END