dev136 - add auto patchbay toggle

This commit is contained in:
tildearrow 2023-01-10 15:58:15 -05:00
parent 02838e0a07
commit 2fbec000d7
8 changed files with 78 additions and 6 deletions

View file

@ -32,6 +32,7 @@ these fields are 0 in format versions prior to 100 (0.6pre1).
the format versions are:
- 136: Furnace dev136
- 135: Furnace dev135
- 134: Furnace dev134
- 133: Furnace 0.6pre3
@ -396,6 +397,7 @@ size | description
4 | patchbay connection count
4?? | patchbay
| - see next section for more details.
1 | automatic patchbay (>=136)
```
# patchbay

View file

@ -1693,6 +1693,27 @@ bool DivEngine::addSystem(DivSystem which) {
BUSY_END;
initDispatch();
BUSY_BEGIN;
saveLock.lock();
if (song.patchbayAuto) {
autoPatchbay();
} else {
int i=song.systemLen-1;
if (disCont[i].dispatch!=NULL) {
unsigned int outs=disCont[i].dispatch->getOutputCount();
if (outs>16) outs=16;
if (outs<2) {
for (unsigned int j=0; j<DIV_MAX_OUTPUTS; j++) {
song.patchbay.push_back((i<<20)|j);
}
} else {
for (unsigned int j=0; j<outs; j++) {
song.patchbay.push_back((i<<20)|(j<<16)|j);
}
}
}
}
saveLock.unlock();
renderSamples();
reset();
BUSY_END;
@ -1725,6 +1746,14 @@ bool DivEngine::removeSystem(int index, bool preserveOrder) {
}
}
// patchbay
for (size_t i=0; i<song.patchbay.size(); i++) {
if (((song.patchbay[i]>>20)&0xfff)==index) {
song.patchbay.erase(song.patchbay.begin()+i);
i--;
}
}
song.system[index]=DIV_SYSTEM_NULL;
song.systemLen--;
for (int i=index; i<song.systemLen; i++) {
@ -1867,6 +1896,15 @@ bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) {
song.systemFlags[src]=song.systemFlags[dest];
song.systemFlags[dest]=oldFlags;
// patchbay
for (unsigned int& i: song.patchbay) {
if (((i>>20)&0xfff)==src) {
i=(i&(~0xfff00000))|((unsigned int)dest<<20);
} else if (((i>>20)&0xfff)==dest) {
i=(i&(~0xfff00000))|((unsigned int)src<<20);
}
}
recalcChans();
saveLock.unlock();
BUSY_END;
@ -3794,6 +3832,14 @@ void DivEngine::autoPatchbay() {
}
}
void DivEngine::autoPatchbayP() {
BUSY_BEGIN;
saveLock.lock();
autoPatchbay();
saveLock.unlock();
BUSY_END;
}
bool DivEngine::patchConnect(unsigned int src, unsigned int dest) {
unsigned int armed=(src<<16)|(dest&0xffff);
for (unsigned int i: song.patchbay) {
@ -3802,6 +3848,7 @@ bool DivEngine::patchConnect(unsigned int src, unsigned int dest) {
BUSY_BEGIN;
saveLock.lock();
song.patchbay.push_back(armed);
song.patchbayAuto=false;
saveLock.unlock();
BUSY_END;
return true;
@ -3814,6 +3861,7 @@ bool DivEngine::patchDisconnect(unsigned int src, unsigned int dest) {
BUSY_BEGIN;
saveLock.lock();
song.patchbay.erase(i);
song.patchbayAuto=false;
saveLock.unlock();
BUSY_END;
return true;
@ -3961,6 +4009,14 @@ void DivEngine::updateSysFlags(int system, bool restart) {
BUSY_BEGIN_SOFT;
disCont[system].dispatch->setFlags(song.systemFlags[system]);
disCont[system].setRates(got.rate);
// patchbay
if (song.patchbayAuto) {
saveLock.lock();
autoPatchbay();
saveLock.unlock();
}
if (restart && isPlaying()) {
playSub(false);
}

View file

@ -47,8 +47,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev135"
#define DIV_ENGINE_VERSION 135
#define DIV_VERSION "dev136"
#define DIV_ENGINE_VERSION 136
// for imports
#define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02
@ -837,6 +837,7 @@ class DivEngine {
// automatic patchbay
void autoPatchbay();
void autoPatchbayP();
// connect in patchbay
// returns false if connection already made

View file

@ -2220,6 +2220,8 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
}
}
if (ds.version>=136) song.patchbayAuto=reader.readC();
// read system flags
if (ds.version>=119) {
logD("reading chip flags...");
@ -4489,6 +4491,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
for (unsigned int i: song.patchbay) {
w->writeI(i);
}
w->writeC(song.patchbayAuto);
blockEndSeek=w->tell();
w->seek(blockStartSeek,SEEK_SET);

View file

@ -329,6 +329,7 @@ struct DivSong {
bool disableSampleMacro;
bool autoSystem;
bool oldArpStrategy;
bool patchbayAuto;
std::vector<DivInstrument*> ins;
std::vector<DivWavetable*> wave;
@ -437,7 +438,8 @@ struct DivSong {
snNoLowPeriods(false),
disableSampleMacro(false),
autoSystem(true),
oldArpStrategy(false) {
oldArpStrategy(false),
patchbayAuto(true) {
for (int i=0; i<DIV_MAX_CHIPS; i++) {
system[i]=DIV_SYSTEM_NULL;
systemVol[i]=1.0;

View file

@ -6026,6 +6026,7 @@ FurnaceGUI::FurnaceGUI():
hoveredPortSet(0x1fff),
hoveredSubPort(-1),
portDragActive(false),
displayHiddenPorts(false),
subPortPos(0.0f,0.0f),
oscTotal(0),
oscZoom(0.5f),

View file

@ -1664,7 +1664,7 @@ class FurnaceGUI {
int selectedSubPort;
unsigned int hoveredPortSet;
int hoveredSubPort;
bool portDragActive;
bool portDragActive, displayHiddenPorts;
ImVec2 subPortPos;
// oscilloscope

View file

@ -249,7 +249,12 @@ void FurnaceGUI::drawMixer() {
ImGui::EndTable();
}
} else {
ImGui::Dummy(ImVec2(1.0f,ImGui::GetFrameHeightWithSpacing()*4.0f));
if (ImGui::Checkbox("Automatic patchbay",&e->song.patchbayAuto)) {
if (e->song.patchbayAuto) e->autoPatchbayP();
MARK_MODIFIED;
}
ImGui::Checkbox("Display hidden ports",&displayHiddenPorts);
ImGui::Dummy(ImVec2(1.0f,ImGui::GetFrameHeightWithSpacing()*2.0f));
}
hoveredPortSet=0x1fff;
@ -260,6 +265,8 @@ void FurnaceGUI::drawMixer() {
ImVec2 topPos=ImGui::GetCursorPos();
topPos.x+=ImGui::GetContentRegionAvail().x-60.0*dpiScale;
if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) selectedPortSet=0x1fff;
if (portDragActive) {
dl->AddLine(subPortPos,ImGui::GetMousePos(),ImGui::GetColorU32(uiColors[GUI_COLOR_PATCHBAY_CONNECTION]),2.0f*dpiScale);
}
@ -281,7 +288,7 @@ void FurnaceGUI::drawMixer() {
}
}
ImGui::SetCursorPos(topPos);
if (portSet("System",0x1000,e->getAudioDescGot().outChans,0,e->getAudioDescGot().outChans,0,selectedSubPort,portPos)) {
if (portSet("System",0x1000,displayHiddenPorts?DIV_MAX_OUTPUTS:e->getAudioDescGot().outChans,0,e->getAudioDescGot().outChans,0,selectedSubPort,portPos)) {
selectedPortSet=0x1000;
if (selectedSubPort>=0) {
portDragActive=true;