Skip to content

Commit

Permalink
Merge branch 'dsp56300:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
biggator6 authored Jul 14, 2024
2 parents 81b709e + 9ded811 commit 1645c78
Show file tree
Hide file tree
Showing 22 changed files with 228 additions and 67 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(APPLE)
message("CMAKE_OSX_DEPLOYMENT_TARGET: " ${CMAKE_OSX_DEPLOYMENT_TARGET})
endif()

project(gearmulator VERSION 1.3.15)
project(gearmulator VERSION 1.3.16)

include(base.cmake)
include(CTest)
Expand Down
14 changes: 13 additions & 1 deletion doc/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Release Notes

1.3.15
1.3.16

Vavra:

- [Fix] Do not crash on right click in device skin
- [Fix] Reset filter keytrack to 0% on double click, not -200%

Xenia:

- [Imp] Performance improvements
- [Imp] Added support for MW1 patches

1.3.15 (2023.07.06)

Framework:

Expand Down
5 changes: 5 additions & 0 deletions source/jucePluginEditorLib/pluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ namespace jucePluginEditorLib
void Editor::copyCurrentPatchToClipboard() const
{
// copy patch of current part to Clipboard
if(!m_patchManager)
return;

const auto p = m_patchManager->requestPatchForPart(m_patchManager->getCurrentPart());

if(!p)
Expand All @@ -245,6 +248,8 @@ namespace jucePluginEditorLib

bool Editor::replaceCurrentPatchFromClipboard() const
{
if(!m_patchManager)
return false;
return m_patchManager->activatePatchFromClipboard();
}

Expand Down
44 changes: 24 additions & 20 deletions source/jucePluginEditorLib/pluginEditorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,32 +348,36 @@ void PluginEditorState::openMenu(const juce::MouseEvent* _event)
{
menu.addSeparator();

if(auto* pm = editor->getPatchManager())
{
#ifdef JUCE_MAC
const std::string ctrlName = "Cmd";
const std::string ctrlName = "Cmd";
#else
const std::string ctrlName = "Ctrl";
const std::string ctrlName = "Ctrl";
#endif

{
juce::PopupMenu::Item item("Copy current Patch to Clipboard");
item.shortcutKeyDescription = ctrlName + "+C";
item.action = [editor]
{
editor->copyCurrentPatchToClipboard();
};
menu.addItem(item);
}
juce::PopupMenu::Item item("Copy current Patch to Clipboard");
item.shortcutKeyDescription = ctrlName + "+C";
item.action = [editor]
{
editor->copyCurrentPatchToClipboard();
};
menu.addItem(item);
}

auto patches = editor->getPatchManager()->getPatchesFromClipboard();
if(!patches.empty())
{
juce::PopupMenu::Item item("Replace current Patch from Clipboard");
item.shortcutKeyDescription = ctrlName + "+V";
item.action = [editor]
{
editor->replaceCurrentPatchFromClipboard();
};
menu.addItem(item);
auto patches = pm->getPatchesFromClipboard();
if(!patches.empty())
{
juce::PopupMenu::Item item("Replace current Patch from Clipboard");
item.shortcutKeyDescription = ctrlName + "+V";
item.action = [editor]
{
editor->replaceCurrentPatchFromClipboard();
};
menu.addItem(item);
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/mqJucePlugin/parameterDescriptions_mq.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
{"index":78, "name":"F1Cutoff", "default":127},
{"index":80, "name":"F1Resonance"},
{"index":81, "name":"F1Drive"},
{"index":86, "name":"F1KeyTrack", "isBipolar":true, "toText":"keytrack"},
{"index":86, "name":"F1KeyTrack", "isBipolar":true, "toText":"keytrack", "default":64},
{"index":87, "name":"F1EnvMod", "isBipolar":true, "toText":"signed"},
{"index":88, "name":"F1VelMod", "isBipolar":true, "toText":"signed"},
{"index":89, "name":"F1ModSource", "min":0 , "max":13, "isDiscrete":true, "toText":"fastModSource"},
Expand All @@ -112,7 +112,7 @@
{"index":98, "name":"F2Cutoff", "default":127},
{"index":100, "name":"F2Resonance"},
{"index":101, "name":"F2Drive"},
{"index":106, "name":"F2KeyTrack", "isBipolar":true, "toText":"keytrack"},
{"index":106, "name":"F2KeyTrack", "isBipolar":true, "toText":"keytrack", "default":64},
{"index":107, "name":"F2EnvMod", "isBipolar":true, "toText":"signed"},
{"index":108, "name":"F2VelMod", "isBipolar":true, "toText":"signed"},
{"index":109, "name":"F2ModSource", "min":0 , "max":13, "isDiscrete":true, "toText":"fastModSource"},
Expand Down
10 changes: 9 additions & 1 deletion source/mqLib/mqdsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "../wLib/dspBootCode.h"

#include "dsp56kEmu/aar.h"

namespace mqLib
{
static dsp56k::DefaultMemoryValidator g_memoryValidator;
Expand All @@ -34,9 +36,15 @@ namespace mqLib

config.aguSupportBitreverse = true;
config.linkJitBlocks = true;
config.dynamicPeripheralAddressing = true;
config.dynamicPeripheralAddressing = false;
#ifdef _DEBUG
config.debugDynamicPeripheralAddressing = true;
#endif
config.maxInstructionsPerBlock = 0; // TODO: needs to be 1 if DSP factory tests are run, to be investigated

// allow dynamic peripheral addressing for code following clr b M_AAR3,r2
enableDynamicPeripheralAddressing(config, m_dsp, 0x62f41b, dsp56k::M_AAR3, 16);

m_dsp.getJit().setConfig(config);

// fill P memory with something that reminds us if we jump to garbage
Expand Down
2 changes: 2 additions & 0 deletions source/portmidi/pm_linux/pmlinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
PmDeviceID pm_default_input_device_id = -1;
PmDeviceID pm_default_output_device_id = -1;

PmDeviceID find_default_device(char *path, int input, PmDeviceID id);

void pm_init()
{
/* Note: it is not an error for PMALSA to fail to initialize.
Expand Down
15 changes: 14 additions & 1 deletion source/virusIntegrationTest/integrationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ int main(int _argc, char* _argv[])

forever = cmd.contains("forever");

std::vector<std::pair<std::string, std::string>> finishedTests; // rom, preset
finishedTests.reserve(64);

if(cmd.contains("rom") && cmd.contains("preset"))
{
const auto romFile = cmd.get("rom");
const auto preset = cmd.get("preset");

IntegrationTest test(cmd, romFile, preset, std::string(), virusLib::DeviceModel::Snow);
return test.run();

const auto res = test.run();
if(0 == res)
std::cout << "test successful, ROM " << synthLib::getFilenameWithoutPath(romFile) << ", preset " << preset << '\n';
return res;
}
if(cmd.contains("folder"))
{
Expand Down Expand Up @@ -164,11 +171,17 @@ int main(int _argc, char* _argv[])
IntegrationTest test(cmd, romFile, preset, subfolder + '/', virusLib::DeviceModel::Snow);
if(test.run() != 0)
return -1;
finishedTests.emplace_back(romFile, preset);
}
}

if(!forever)
{
std::cout << "All " << finishedTests.size() << " tests finished successfully:" << '\n';
for (const auto& [rom,preset] : finishedTests)
std::cout << "ROM " << synthLib::getFilenameWithoutPath(rom) << ", preset " << preset << '\n';
return 0;
}
}
}
std::cout << "invalid command line arguments" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion source/virusLib/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ namespace virusLib

std::thread Device::bootDSP(DspSingle& _dsp, const ROMFile& _rom, const bool _createDebugger)
{
auto res = _rom.bootDSP(_dsp.getDSP(), _dsp.getHDI08());
auto res = _rom.bootDSP(_dsp);
_dsp.startDSPThread(_createDebugger);
return res;
}
Expand Down
41 changes: 41 additions & 0 deletions source/virusLib/dspSingle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,45 @@ namespace virusLib
while(!outs.empty())
outs.pop_front();
}

std::thread DspSingle::boot(const ROMFile::BootRom& _bootRom, const std::vector<dsp56k::TWord>& _commandStream)
{
// Copy BootROM to DSP memory
for (uint32_t i=0; i<_bootRom.data.size(); i++)
{
const auto p = _bootRom.offset + i;
getMemory().set(dsp56k::MemArea_P, p, _bootRom.data[i]);
getJIT().notifyProgramMemWrite(p);
}

// dsp.memory().saveAssembly((m_file + "_BootROM.asm").c_str(), bootRom.offset, bootRom.size, false, false, &periph);

// Write command stream to HDI08 RX
m_commandStream = _commandStream;
m_commandStreamReadIndex = 0;

while(!getHDI08().dataRXFull() && m_commandStreamReadIndex < m_commandStream.size())
getHDI08().writeRX(&m_commandStream[m_commandStreamReadIndex++], 1);

getHDI08().setReadRxCallback([this]
{
if(m_commandStreamReadIndex >= m_commandStream.size())
{
getHDI08().setReadRxCallback(nullptr);
return;
}

getHDI08().writeRX(&m_commandStream[m_commandStreamReadIndex++], 1);
});

std::thread waitForCommandStreamWrite([this]()
{
while(m_commandStreamReadIndex < m_commandStream.size())
std::this_thread::yield();
});

// Initialize the DSP
getDSP().setPC(_bootRom.offset);
return waitForCommandStreamWrite;
}
}
7 changes: 7 additions & 0 deletions source/virusLib/dspSingle.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "romfile.h"

#include "dsp56kEmu/dspthread.h"
#include "dsp56kEmu/memory.h"
#include "dsp56kEmu/peripherals.h"
Expand Down Expand Up @@ -39,6 +41,8 @@ namespace virusLib
void disableESSI1();
void drainESSI1();

std::thread boot(const ROMFile::BootRom& _bootRom, const std::vector<dsp56k::TWord>& _commandStream);

template<typename T> static void ensureSize(std::vector<T>& _buf, size_t _size)
{
if(_buf.size() >= _size)
Expand Down Expand Up @@ -72,5 +76,8 @@ namespace virusLib
dsp56k::Jit* m_jit = nullptr;

std::unique_ptr<dsp56k::DSPThread> m_dspThread;

std::vector<dsp56k::TWord> m_commandStream;
uint32_t m_commandStreamReadIndex = 0;
};
}
44 changes: 13 additions & 31 deletions source/virusLib/romfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <cstring> // memcpy

#include "demoplaybackTI.h"
#include "dsp56kEmu/memory.h"
#include "dspSingle.h"

namespace virusLib
{
Expand All @@ -24,7 +24,7 @@ ROMFile::ROMFile(std::vector<uint8_t> _data, std::string _name, const DeviceMode
if(initialize())
return;
m_romFileData.clear();
bootRom.size = 0;
m_bootRom.size = 0;
}

ROMFile ROMFile::invalid()
Expand Down Expand Up @@ -58,15 +58,15 @@ bool ROMFile::initialize()
if (chunks.empty())
return false;

bootRom.size = chunks[0].items[0];
bootRom.offset = chunks[0].items[1];
bootRom.data = std::vector<uint32_t>(bootRom.size);
m_bootRom.size = chunks[0].items[0];
m_bootRom.offset = chunks[0].items[1];
m_bootRom.data = std::vector<uint32_t>(m_bootRom.size);

// The first chunk contains the bootrom
uint32_t i = 2;
for (; i < bootRom.size + 2; i++)
for (; i < m_bootRom.size + 2; i++)
{
bootRom.data[i-2] = chunks[0].items[i];
m_bootRom.data[i-2] = chunks[0].items[i];
}

// The rest of the chunks is made up of the command stream
Expand All @@ -77,8 +77,8 @@ bool ROMFile::initialize()
i = 0;
}

printf("Program BootROM size = 0x%x\n", bootRom.size);
printf("Program BootROM offset = 0x%x\n", bootRom.offset);
printf("Program BootROM size = 0x%x\n", m_bootRom.size);
printf("Program BootROM offset = 0x%x\n", m_bootRom.offset);
printf("Program CommandStream size = 0x%x\n", static_cast<uint32_t>(m_commandStream.size()));

#if VIRUS_SUPPORT_TI
Expand Down Expand Up @@ -126,7 +126,7 @@ bool ROMFile::initialize()
if(j == searchSize-1)
{
TPreset preset;
memcpy(&preset[0], &fw.DSP[i - 4], std::size(preset));
memcpy(preset.data(), &fw.DSP[i - 4], std::size(preset));

// validate that we found the correct data by checking part volumes. It might just be a string somewhere in the data
for(size_t k=0; k<16; ++k)
Expand All @@ -136,7 +136,7 @@ bool ROMFile::initialize()

if(k == 15)
{
for(size_t k=0; k<getPresetsPerBank(); ++k)
for(size_t p=0; p<getPresetsPerBank(); ++p)
m_multis.push_back(preset);
}
}
Expand Down Expand Up @@ -330,27 +330,9 @@ bool ROMFile::loadPresetFile(std::istream& _file, DeviceModel _model)
return true;
}

std::thread ROMFile::bootDSP(dsp56k::DSP& dsp, dsp56k::HDI08& _hdi08) const
std::thread ROMFile::bootDSP(DspSingle& _dsp) const
{
// Load BootROM in DSP memory
for (uint32_t i=0; i<bootRom.data.size(); i++)
{
const auto p = bootRom.offset + i;
dsp.memory().set(dsp56k::MemArea_P, p, bootRom.data[i]);
dsp.getJit().notifyProgramMemWrite(p);
}

// dsp.memory().saveAssembly((m_file + "_BootROM.asm").c_str(), bootRom.offset, bootRom.size, false, false, &periph);

// Attach command stream
std::thread feedCommandStream([&]()
{
_hdi08.writeRX(m_commandStream);
});

// Initialize the DSP
dsp.setPC(bootRom.offset);
return feedCommandStream;
return _dsp.boot(m_bootRom, m_commandStream);
}

std::string ROMFile::getModelName() const
Expand Down
Loading

0 comments on commit 1645c78

Please sign in to comment.