1
0

Autotune.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Autotune.h
  3. * ----------
  4. * Purpose: Class for tuning a sample to a given base note automatically.
  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 "../soundlib/Snd_defs.h"
  12. #include "resource.h"
  13. OPENMPT_NAMESPACE_BEGIN
  14. struct ModSample;
  15. class Autotune
  16. {
  17. protected:
  18. ModSample &m_sample;
  19. MODTYPE m_modType;
  20. SmpLength m_selectionStart, m_selectionEnd;
  21. int16 *m_sampleData = nullptr;
  22. SmpLength m_sampleLength = 0;
  23. public:
  24. Autotune(ModSample &smp, MODTYPE type, SmpLength selStart, SmpLength selEnd) : m_sample(smp), m_modType(type), m_selectionStart(selStart), m_selectionEnd(selEnd)
  25. { };
  26. ~Autotune()
  27. {
  28. delete[] m_sampleData;
  29. }
  30. bool CanApply() const;
  31. bool Apply(double pitchReference, int targetNote);
  32. protected:
  33. template <class T>
  34. void CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd);
  35. bool PrepareSample(SmpLength maxShift);
  36. };
  37. class CAutotuneDlg : public CDialog
  38. {
  39. protected:
  40. static int m_pitchReference; // Pitch reference (440Hz by default)
  41. static int m_targetNote; // Note which the sample should be tuned to (C by default)
  42. CComboBox m_CbnNoteBox;
  43. public:
  44. CAutotuneDlg(CWnd *parent) : CDialog(IDD_AUTOTUNE, parent)
  45. { };
  46. int GetPitchReference() const { return m_pitchReference; }
  47. int GetTargetNote() const { return m_targetNote; }
  48. protected:
  49. BOOL OnInitDialog() override;
  50. void OnOK() override;
  51. void DoDataExchange(CDataExchange* pDX) override;
  52. };
  53. OPENMPT_NAMESPACE_END