Archived
1
0
This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
winamp/Src/external_dependencies/openmpt-trunk/mptrack/Autotune.h
2024-09-24 14:54:57 +02:00

82 lines
1.6 KiB
C++

/*
* Autotune.h
* ----------
* Purpose: Class for tuning a sample to a given base note automatically.
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#pragma once
#include "openmpt/all/BuildSettings.hpp"
#include "../soundlib/Snd_defs.h"
#include "resource.h"
OPENMPT_NAMESPACE_BEGIN
struct ModSample;
class Autotune
{
protected:
ModSample &m_sample;
MODTYPE m_modType;
SmpLength m_selectionStart, m_selectionEnd;
int16 *m_sampleData = nullptr;
SmpLength m_sampleLength = 0;
public:
Autotune(ModSample &smp, MODTYPE type, SmpLength selStart, SmpLength selEnd) : m_sample(smp), m_modType(type), m_selectionStart(selStart), m_selectionEnd(selEnd)
{ };
~Autotune()
{
delete[] m_sampleData;
}
bool CanApply() const;
bool Apply(double pitchReference, int targetNote);
protected:
template <class T>
void CopySamples(const T* origSample, SmpLength sampleLoopStart, SmpLength sampleLoopEnd);
bool PrepareSample(SmpLength maxShift);
};
class CAutotuneDlg : public CDialog
{
protected:
static int m_pitchReference; // Pitch reference (440Hz by default)
static int m_targetNote; // Note which the sample should be tuned to (C by default)
CComboBox m_CbnNoteBox;
public:
CAutotuneDlg(CWnd *parent) : CDialog(IDD_AUTOTUNE, parent)
{ };
int GetPitchReference() const { return m_pitchReference; }
int GetTargetNote() const { return m_targetNote; }
protected:
BOOL OnInitDialog() override;
void OnOK() override;
void DoDataExchange(CDataExchange* pDX) override;
};
OPENMPT_NAMESPACE_END