mirror of https://github.com/AxioDL/amuse.git
VST state save/restore
This commit is contained in:
parent
e7c7e5ffd3
commit
7659371cb6
|
@ -138,6 +138,7 @@ VSTBackend::VSTBackend(audioMasterCallback cb)
|
||||||
setNumOutputs(2);
|
setNumOutputs(2);
|
||||||
setEditor(&m_editor);
|
setEditor(&m_editor);
|
||||||
sizeWindow(600, 420);
|
sizeWindow(600, 420);
|
||||||
|
programsAreChunks();
|
||||||
|
|
||||||
m_booBackend = std::make_unique<VSTVoiceEngine>();
|
m_booBackend = std::make_unique<VSTVoiceEngine>();
|
||||||
m_voxAlloc.emplace(*m_booBackend);
|
m_voxAlloc.emplace(*m_booBackend);
|
||||||
|
@ -323,6 +324,58 @@ void VSTBackend::setDrumProgram(int programNo)
|
||||||
m_curSeq->setChanProgram(9, programNo);
|
m_curSeq->setChanProgram(9, programNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VstInt32 VSTBackend::getChunk(void** data, bool)
|
||||||
|
{
|
||||||
|
size_t allocSz = 14;
|
||||||
|
if (m_curData)
|
||||||
|
allocSz += (m_curData->m_path.size() - m_userDir.size() - 1) * 2;
|
||||||
|
|
||||||
|
uint8_t* buf = new uint8_t[allocSz];
|
||||||
|
if (m_curData)
|
||||||
|
memmove(buf, m_curData->m_path.data() + m_userDir.size() + 1, allocSz - 12);
|
||||||
|
else
|
||||||
|
*reinterpret_cast<wchar_t*>(buf) = L'\0';
|
||||||
|
uint32_t* intVals = reinterpret_cast<uint32_t*>(buf + allocSz - 12);
|
||||||
|
intVals[0] = m_listenProg;
|
||||||
|
intVals[1] = m_editor.m_selGroupIdx;
|
||||||
|
intVals[2] = m_editor.m_selPageIdx;
|
||||||
|
*data = buf;
|
||||||
|
return allocSz;
|
||||||
|
}
|
||||||
|
|
||||||
|
VstInt32 VSTBackend::setChunk(void* data, VstInt32 byteSize, bool)
|
||||||
|
{
|
||||||
|
if (byteSize < 14)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
wchar_t* path = reinterpret_cast<wchar_t*>(data);
|
||||||
|
uint32_t* intVals = reinterpret_cast<uint32_t*>(path + wcslen(path) + 1);
|
||||||
|
std::wstring targetPath = m_userDir + L'\\' + path;
|
||||||
|
m_listenProg = intVals[0];
|
||||||
|
uint32_t groupIdx = intVals[1];
|
||||||
|
uint32_t pageIdx = intVals[2];
|
||||||
|
|
||||||
|
size_t colIdx = 0;
|
||||||
|
for (auto& collection : m_filePresenter.m_audioGroupCollections)
|
||||||
|
{
|
||||||
|
size_t fileIdx = 0;
|
||||||
|
for (auto& file : collection.second->m_groups)
|
||||||
|
{
|
||||||
|
if (!file.second->m_path.compare(targetPath))
|
||||||
|
{
|
||||||
|
m_editor.selectCollection(LPARAM(0x80000000 | (colIdx << 16) | fileIdx));
|
||||||
|
m_editor.selectGroup(groupIdx);
|
||||||
|
m_editor.selectPage(pageIdx);
|
||||||
|
m_editor._reselectColumns();
|
||||||
|
}
|
||||||
|
++fileIdx;
|
||||||
|
}
|
||||||
|
++colIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEffect* createEffectInstance(audioMasterCallback audioMaster)
|
AudioEffect* createEffectInstance(audioMasterCallback audioMaster)
|
||||||
|
|
|
@ -35,6 +35,7 @@ class VSTBackend : public AudioEffectX
|
||||||
const AudioGroupDataCollection* m_curData = nullptr;
|
const AudioGroupDataCollection* m_curData = nullptr;
|
||||||
size_t m_curFrame = 0;
|
size_t m_curFrame = 0;
|
||||||
std::wstring m_userDir;
|
std::wstring m_userDir;
|
||||||
|
int m_listenProg = 0;
|
||||||
AudioGroupFilePresenter m_filePresenter;
|
AudioGroupFilePresenter m_filePresenter;
|
||||||
VSTEditor m_editor;
|
VSTEditor m_editor;
|
||||||
public:
|
public:
|
||||||
|
@ -61,6 +62,9 @@ public:
|
||||||
void loadGroupSequencer(int collectionIdx, int fileIdx, int groupIdx);
|
void loadGroupSequencer(int collectionIdx, int fileIdx, int groupIdx);
|
||||||
void setNormalProgram(int programNo);
|
void setNormalProgram(int programNo);
|
||||||
void setDrumProgram(int programNo);
|
void setDrumProgram(int programNo);
|
||||||
|
|
||||||
|
VstInt32 getChunk(void** data, bool isPreset);
|
||||||
|
VstInt32 setChunk(void* data, VstInt32 byteSize, bool isPreset);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <Windowsx.h>
|
#include <Windowsx.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
@ -47,12 +48,7 @@ LRESULT CALLBACK VSTEditor::WindowProc(HWND hwnd,
|
||||||
if (itemAct.hdr.hwndFrom == editor.m_groupListView)
|
if (itemAct.hdr.hwndFrom == editor.m_groupListView)
|
||||||
editor.selectGroup(itemAct.iItem);
|
editor.selectGroup(itemAct.iItem);
|
||||||
else if (itemAct.hdr.hwndFrom == editor.m_pageListView)
|
else if (itemAct.hdr.hwndFrom == editor.m_pageListView)
|
||||||
{
|
editor.selectPage(itemAct.iItem);
|
||||||
if (itemAct.lParam & 0x80000000)
|
|
||||||
editor.selectDrumPage(itemAct.lParam & 0x7fffffff);
|
|
||||||
else
|
|
||||||
editor.selectNormalPage(itemAct.lParam & 0x7fffffff);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case TVN_SELCHANGED:
|
case TVN_SELCHANGED:
|
||||||
|
@ -201,7 +197,7 @@ bool VSTEditor::open(void* ptr)
|
||||||
treeItem.item.pszText = L"Root A";
|
treeItem.item.pszText = L"Root A";
|
||||||
|
|
||||||
LVCOLUMN column = {};
|
LVCOLUMN column = {};
|
||||||
column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
|
column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||||
column.fmt = LVCFMT_LEFT | LVCFMT_FIXED_WIDTH;
|
column.fmt = LVCFMT_LEFT | LVCFMT_FIXED_WIDTH;
|
||||||
column.cx = 199;
|
column.cx = 199;
|
||||||
|
|
||||||
|
@ -250,7 +246,7 @@ bool VSTEditor::open(void* ptr)
|
||||||
m_collectionAdd = CreateWindowW(WC_BUTTON,
|
m_collectionAdd = CreateWindowW(WC_BUTTON,
|
||||||
L"+",
|
L"+",
|
||||||
WS_CHILD | WS_CLIPSIBLINGS | BS_PUSHBUTTON,
|
WS_CHILD | WS_CLIPSIBLINGS | BS_PUSHBUTTON,
|
||||||
1, m_windowRect.bottom - m_windowRect.top - 26,
|
1, m_windowRect.bottom - m_windowRect.top - 25,
|
||||||
25, 24,
|
25, 24,
|
||||||
m_rootView,
|
m_rootView,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -258,12 +254,12 @@ bool VSTEditor::open(void* ptr)
|
||||||
nullptr);
|
nullptr);
|
||||||
SetWindowFont(m_collectionAdd, GetStockObject(ANSI_FIXED_FONT), FALSE);
|
SetWindowFont(m_collectionAdd, GetStockObject(ANSI_FIXED_FONT), FALSE);
|
||||||
Button_Enable(m_collectionAdd, TRUE);
|
Button_Enable(m_collectionAdd, TRUE);
|
||||||
SetWindowPos(m_collectionAdd, HWND_TOP, 1, m_windowRect.bottom - m_windowRect.top - 26, 25, 24, SWP_SHOWWINDOW);
|
SetWindowPos(m_collectionAdd, HWND_TOP, 1, m_windowRect.bottom - m_windowRect.top - 25, 25, 24, SWP_SHOWWINDOW);
|
||||||
|
|
||||||
m_collectionRemove = CreateWindowW(WC_BUTTON,
|
m_collectionRemove = CreateWindowW(WC_BUTTON,
|
||||||
L"-",
|
L"-",
|
||||||
WS_CHILD | WS_CLIPSIBLINGS | BS_PUSHBUTTON,
|
WS_CHILD | WS_CLIPSIBLINGS | BS_PUSHBUTTON,
|
||||||
26, m_windowRect.bottom - m_windowRect.top - 26,
|
26, m_windowRect.bottom - m_windowRect.top - 25,
|
||||||
25, 24,
|
25, 24,
|
||||||
m_rootView,
|
m_rootView,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -271,7 +267,7 @@ bool VSTEditor::open(void* ptr)
|
||||||
nullptr);
|
nullptr);
|
||||||
SetWindowFont(m_collectionRemove, GetStockObject(ANSI_FIXED_FONT), FALSE);
|
SetWindowFont(m_collectionRemove, GetStockObject(ANSI_FIXED_FONT), FALSE);
|
||||||
Button_Enable(m_collectionRemove, FALSE);
|
Button_Enable(m_collectionRemove, FALSE);
|
||||||
SetWindowPos(m_collectionRemove, HWND_TOP, 26, m_windowRect.bottom - m_windowRect.top - 26, 25, 24, SWP_SHOWWINDOW);
|
SetWindowPos(m_collectionRemove, HWND_TOP, 26, m_windowRect.bottom - m_windowRect.top - 25, 25, 24, SWP_SHOWWINDOW);
|
||||||
|
|
||||||
|
|
||||||
m_groupListView = CreateWindowW(WC_LISTVIEW,
|
m_groupListView = CreateWindowW(WC_LISTVIEW,
|
||||||
|
@ -305,7 +301,7 @@ bool VSTEditor::open(void* ptr)
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
column.pszText = L"Page";
|
column.pszText = L"Page";
|
||||||
column.cx = 198;
|
column.cx = 198 - GetSystemMetrics(SM_CXVSCROLL);
|
||||||
header = ListView_GetHeader(m_pageListView);
|
header = ListView_GetHeader(m_pageListView);
|
||||||
SetWindowLongPtrW(header, GWLP_USERDATA, LONG_PTR(column.pszText));
|
SetWindowLongPtrW(header, GWLP_USERDATA, LONG_PTR(column.pszText));
|
||||||
SetWindowLongPtr(header, GWLP_WNDPROC, LONG_PTR(ColHeaderWindowProc));
|
SetWindowLongPtr(header, GWLP_WNDPROC, LONG_PTR(ColHeaderWindowProc));
|
||||||
|
@ -315,10 +311,7 @@ bool VSTEditor::open(void* ptr)
|
||||||
ListView_InsertColumn(m_pageListView, 0, &column);
|
ListView_InsertColumn(m_pageListView, 0, &column);
|
||||||
ShowWindow(m_pageListView, SW_SHOW);
|
ShowWindow(m_pageListView, SW_SHOW);
|
||||||
|
|
||||||
m_backend.getFilePresenter().populateCollectionColumn(*this);
|
update();
|
||||||
m_backend.getFilePresenter().populateGroupColumn(*this, m_selCollectionIdx, m_selFileIdx);
|
|
||||||
m_backend.getFilePresenter().populatePageColumn(*this, m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
|
|
||||||
_reselectColumns();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +323,12 @@ void VSTEditor::close()
|
||||||
|
|
||||||
void VSTEditor::update()
|
void VSTEditor::update()
|
||||||
{
|
{
|
||||||
|
m_backend.getFilePresenter().populateCollectionColumn(*this);
|
||||||
|
m_backend.getFilePresenter().populateGroupColumn(*this, m_selCollectionIdx, m_selFileIdx);
|
||||||
|
m_backend.loadGroupSequencer(m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
|
||||||
|
m_backend.getFilePresenter().populatePageColumn(*this, m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
|
||||||
|
selectPage(m_selPageIdx);
|
||||||
|
_reselectColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VSTEditor::addAction()
|
void VSTEditor::addAction()
|
||||||
|
@ -414,6 +412,19 @@ void VSTEditor::selectGroup(int idx)
|
||||||
m_backend.getFilePresenter().populatePageColumn(*this, m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
|
m_backend.getFilePresenter().populatePageColumn(*this, m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VSTEditor::selectPage(int idx)
|
||||||
|
{
|
||||||
|
m_selPageIdx = idx;
|
||||||
|
LV_ITEM item = {};
|
||||||
|
item.mask = LVIF_PARAM;
|
||||||
|
item.iItem = idx;
|
||||||
|
ListView_GetItem(m_pageListView, &item);
|
||||||
|
if (item.lParam & 0x80000000)
|
||||||
|
selectDrumPage(item.lParam & 0x7fffffff);
|
||||||
|
else
|
||||||
|
selectNormalPage(item.lParam & 0x7fffffff);
|
||||||
|
}
|
||||||
|
|
||||||
void VSTEditor::selectNormalPage(int idx)
|
void VSTEditor::selectNormalPage(int idx)
|
||||||
{
|
{
|
||||||
m_backend.setNormalProgram(idx);
|
m_backend.setNormalProgram(idx);
|
||||||
|
|
|
@ -14,19 +14,20 @@ class VSTBackend;
|
||||||
/** Editor UI class */
|
/** Editor UI class */
|
||||||
class VSTEditor : public AEffEditor
|
class VSTEditor : public AEffEditor
|
||||||
{
|
{
|
||||||
|
friend class VSTBackend;
|
||||||
friend class AudioGroupFilePresenter;
|
friend class AudioGroupFilePresenter;
|
||||||
friend struct AudioGroupCollection;
|
friend struct AudioGroupCollection;
|
||||||
|
|
||||||
VSTBackend& m_backend;
|
VSTBackend& m_backend;
|
||||||
ERect m_windowRect = {0, 0, 420, 600};
|
ERect m_windowRect = {0, 0, 420, 600};
|
||||||
|
|
||||||
HWND m_rootView;
|
HWND m_rootView = 0;
|
||||||
HWND m_collectionHeader;
|
HWND m_collectionHeader = 0;
|
||||||
HWND m_collectionTree;
|
HWND m_collectionTree = 0;
|
||||||
HWND m_collectionAdd;
|
HWND m_collectionAdd = 0;
|
||||||
HWND m_collectionRemove;
|
HWND m_collectionRemove = 0;
|
||||||
HWND m_groupListView;
|
HWND m_groupListView = 0;
|
||||||
HWND m_pageListView;
|
HWND m_pageListView = 0;
|
||||||
|
|
||||||
int m_selCollectionIdx = -1;
|
int m_selCollectionIdx = -1;
|
||||||
int m_selFileIdx = -1;
|
int m_selFileIdx = -1;
|
||||||
|
@ -62,6 +63,7 @@ public:
|
||||||
|
|
||||||
void selectCollection(LPARAM idx);
|
void selectCollection(LPARAM idx);
|
||||||
void selectGroup(int idx);
|
void selectGroup(int idx);
|
||||||
|
void selectPage(int idx);
|
||||||
void selectNormalPage(int idx);
|
void selectNormalPage(int idx);
|
||||||
void selectDrumPage(int idx);
|
void selectDrumPage(int idx);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue