Page selection bug fixes; working drum pages

This commit is contained in:
Jack Andersen 2016-06-16 12:18:17 -10:00
parent 797908a126
commit 7b9c7a4eb6
6 changed files with 47 additions and 16 deletions

View File

@ -408,6 +408,7 @@ void AudioGroupFilePresenter::populateGroupColumn(VSTEditor& editor, int collect
item.mask = LVIF_TEXT;
ListView_DeleteAllItems(editor.m_groupListView);
ListView_DeleteAllItems(editor.m_pageListView);
if (collectionIdx < m_iteratorVec.size())
{
CollectionIterator& it = m_iteratorVec[collectionIdx];

View File

@ -192,6 +192,7 @@ VstInt32 VSTBackend::processEvents(VstEvents* events)
if (m_curSeq)
m_curSeq->kill();
m_curSeq = m_engine->seqPlay(m_reqGroup, -1, nullptr);
m_editor.reselectPage();
}
if (engine.m_midiReceiver)
@ -201,6 +202,11 @@ VstInt32 VSTBackend::processEvents(VstEvents* events)
VstMidiEvent* evt = reinterpret_cast<VstMidiEvent*>(events->events[i]);
if (evt->type == kVstMidiType)
{
if (m_routeChannel != -1)
{
evt->midiData[0] &= ~0xf;
evt->midiData[0] |= m_routeChannel & 0xf;
}
(*engine.m_midiReceiver)(std::vector<uint8_t>(std::cbegin(evt->midiData),
std::cbegin(evt->midiData) + evt->byteSize),
(m_curFrame + evt->deltaFrames) / sampleRate);
@ -343,22 +349,32 @@ void VSTBackend::setGroup(int groupIdx, bool immediate)
}
}
void VSTBackend::setNormalProgram(int programNo)
void VSTBackend::_setNormalProgram(int programNo)
{
std::unique_lock<std::mutex> lk(m_lock);
if (!m_curSeq)
return;
m_curSeq->setChanProgram(0, programNo);
m_routeChannel = 0;
}
void VSTBackend::setNormalProgram(int programNo)
{
std::unique_lock<std::mutex> lk(m_lock);
_setNormalProgram(programNo);
}
void VSTBackend::_setDrumProgram(int programNo)
{
if (!m_curSeq)
return;
m_curSeq->setChanProgram(9, programNo);
m_routeChannel = 9;
}
void VSTBackend::setDrumProgram(int programNo)
{
std::unique_lock<std::mutex> lk(m_lock);
if (!m_curSeq)
return;
m_curSeq->setChanProgram(9, programNo);
_setDrumProgram(programNo);
}
VstInt32 VSTBackend::getChunk(void** data, bool)
@ -373,7 +389,7 @@ VstInt32 VSTBackend::getChunk(void** data, bool)
else
*reinterpret_cast<wchar_t*>(buf) = L'\0';
uint32_t* intVals = reinterpret_cast<uint32_t*>(buf + allocSz - 12);
intVals[0] = m_listenProg;
intVals[0] = 0;
intVals[1] = m_editor.m_selGroupIdx;
intVals[2] = m_editor.m_selPageIdx;
*data = buf;
@ -388,7 +404,6 @@ VstInt32 VSTBackend::setChunk(void* data, VstInt32 byteSize, bool)
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];

View File

@ -38,7 +38,7 @@ class VSTBackend : public AudioEffectX
const AudioGroupDataCollection* m_curData = nullptr;
size_t m_curFrame = 0;
std::wstring m_userDir;
int m_listenProg = 0;
int m_routeChannel = -1;
AudioGroupFilePresenter m_filePresenter;
VSTEditor m_editor;
public:
@ -64,7 +64,9 @@ public:
void loadGroupFile(int collectionIdx, int fileIdx);
void setGroup(int groupIdx, bool immediate);
void _setNormalProgram(int programNo);
void setNormalProgram(int programNo);
void _setDrumProgram(int programNo);
void setDrumProgram(int programNo);
VstInt32 getChunk(void** data, bool isPreset);

View File

@ -367,9 +367,7 @@ void VSTEditor::addAction()
}
m_backend.getFilePresenter().addCollection(name, std::move(data));
m_backend.getFilePresenter().populateCollectionColumn(*this);
m_backend.getFilePresenter().populateGroupColumn(*this, m_selCollectionIdx, m_selFileIdx);
m_backend.getFilePresenter().populatePageColumn(*this, m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
update();
}
}
@ -414,6 +412,7 @@ void VSTEditor::selectGroup(int idx)
m_selGroupIdx = idx;
m_backend.setGroup(m_selGroupIdx, false);
m_backend.getFilePresenter().populatePageColumn(*this, m_selCollectionIdx, m_selFileIdx, m_selGroupIdx);
m_lastLParam = -1;
}
void VSTEditor::selectPage(int idx)
@ -423,12 +422,24 @@ void VSTEditor::selectPage(int idx)
item.mask = LVIF_PARAM;
item.iItem = idx;
ListView_GetItem(m_pageListView, &item);
m_lastLParam = item.lParam;
if (item.lParam & 0x80000000)
selectDrumPage(item.lParam & 0x7fffffff);
else
selectNormalPage(item.lParam & 0x7fffffff);
}
void VSTEditor::reselectPage()
{
if (m_lastLParam != -1)
{
if (m_lastLParam & 0x80000000)
m_backend._setDrumProgram(m_lastLParam & 0x7fffffff);
else
m_backend._setNormalProgram(m_lastLParam & 0x7fffffff);
}
}
void VSTEditor::selectNormalPage(int idx)
{
m_backend.setNormalProgram(idx);

View File

@ -33,6 +33,7 @@ class VSTEditor : public AEffEditor
int m_selFileIdx = -1;
int m_selGroupIdx = -1;
int m_selPageIdx = -1;
int m_lastLParam = -1;
HTREEITEM m_deferredCollectionSel = 0;
@ -64,6 +65,7 @@ public:
void selectCollection(LPARAM idx);
void selectGroup(int idx);
void selectPage(int idx);
void reselectPage();
void selectNormalPage(int idx);
void selectDrumPage(int idx);
};

View File

@ -219,7 +219,7 @@ bool Voice::_advanceSample(int16_t& samp, int32_t& newPitch)
{
/* Lerp within 160-sample block */
float t = rem / 160.f;
float l = m_lastLevel * (1.f - t) + m_nextLevel * t;
float l = clamp(0.f, m_lastLevel * (1.f - t) + m_nextLevel * t, 1.f);
/* Apply total volume to sample using decibel scale */
ApplyVolume(l, samp);
@ -244,7 +244,7 @@ bool Voice::_advanceSample(int16_t& samp, int32_t& newPitch)
if (m_envelopeCurve)
t = (*m_envelopeCurve)[int(t*127.f)] / 127.f;
m_curVol = clamp(0.f, (start * (1.0f - t)) + (end * t), 1.f);
//printf("%d %f\n", m_vid, m_curVol);
/* Done with envelope */
@ -347,7 +347,7 @@ bool Voice::_advanceSample(int16_t& samp, int32_t& newPitch)
}
}
m_nextLevel = ClampFull<float>(m_nextLevel);
m_nextLevel = clamp(0.f, m_nextLevel, 1.f);
/* Apply total volume to sample using decibel scale */
ApplyVolume(m_nextLevel, samp);