Skip to content

Commit

Permalink
Extra Content optional; Don't make Surge Docs Dir if not needed (#739)
Browse files Browse the repository at this point in the history
1. Update SurgeStorage to have a config object as an argument.
2. Make it so that we don't create the Surge XT user dir unless
   you reveal it. Closes #732
3. Scan the extra content path for wavetables; implement download;
   implement download ui; remove 3rd party wt from vcvplugin.
   Closes #710
  • Loading branch information
baconpaul committed Dec 13, 2022
1 parent 6a2c063 commit 00082de
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment ver
project(SurgeXTRack VERSION 1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(PLUGIN_NAME ${PROJECT_NAME})
set(ADDITIONAL_PLUGIN_DISTRIBUTABLES docs patches presets README.md)
Expand Down Expand Up @@ -109,7 +110,6 @@ add_dependencies(${PROJECT_NAME}_quick_install ${RACK_PLUGIN_LIB})
file(INSTALL surge/resources/surge-shared/configuration.xml
surge/resources/surge-shared/windows.wt
surge/resources/data/wavetables
surge/resources/data/wavetables_3rdparty
surge/resources/data/fx_presets
res/surge_extra_data/fx_presets
DESTINATION ${PLUGIN_NAME}/build/surge-data)
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ build/surge-data:
cp surge/resources/surge-shared/windows.wt build/surge-data
cp surge/resources/surge-shared/configuration.xml build/surge-data
cp -R surge/resources/data/wavetables build/surge-data/wavetables
cp -R surge/resources/data/wavetables_3rdparty build/surge-data/wavetables_3rdparty
cp -R surge/resources/data/fx_presets build/surge-data/fx_presets
cp -R res/surge_extra_data/fx_presets build/surge-data

Expand Down
35 changes: 31 additions & 4 deletions src/VCO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ template <int oscType> struct WavetableMenuBuilder
static void downloadExtraContent(VCO<oscType> *module)
{
auto t = std::thread([module]() {
float progress{0};
module->downloadingContent = true;
std::string archivePath = rack::asset::user("SurgeXTRack/SurgeXT_ExtraContent.tar.zst");
std::string url = "https://github.com/surge-synthesizer/surge-rack/releases/download/"
"Content/SurgeXTRack_ExtraContent.tar.zst";
std::string dirPath = rack::asset::user("SurgeXTRack/");
rack::network::requestDownload(url, archivePath, &progress);
rack::network::requestDownload(url, archivePath, &module->contentProgress);
rack::system::unarchiveToDirectory(archivePath, dirPath);
rack::system::remove(archivePath);

module->downloadingContent = false;
module->forceRefreshWT = true;
});
t.detach();
Expand Down Expand Up @@ -226,12 +227,11 @@ template <int oscType> struct WavetableMenuBuilder
}
}));
menu->addChild(new rack::MenuSeparator);
#if PROGRESS_ON_710
menu->addChild(rack::createMenuItem("Download Extra Wavetable Content", "",
[module]() { downloadExtraContent(module); }));
#endif

menu->addChild(rack::createMenuItem("Reveal User Wavetables Directory", "", [module]() {
module->storage->createUserDirectory(); // fine if it exists
rack::system::openDirectory((module->storage->userDataPath / "Wavetables").u8string());
}));
menu->addChild(rack::createMenuItem("Rescan Wavetables", "",
Expand Down Expand Up @@ -445,6 +445,7 @@ struct OSCPlotWidget : public rack::widget::TransparentWidget, style::StyleParti
}

std::set<rack::Widget *> deleteOnNextStep;
bool lastDownloadContent{false};
void step() override
{
for (auto d : deleteOnNextStep)
Expand Down Expand Up @@ -487,6 +488,19 @@ struct OSCPlotWidget : public rack::widget::TransparentWidget, style::StyleParti
bdw->dirty = true;
bdwPlot->dirty = true;
}

if (module->downloadingContent)
{
bdw->dirty = true;
bdwPlot->dirty = true;
}

if (module->downloadingContent != lastDownloadContent)
{
bdw->dirty = true;
bdwPlot->dirty = true;
}
lastDownloadContent = module->downloadingContent;
}

if constexpr (VCOConfig<oscType>::supportsCustomEditor())
Expand Down Expand Up @@ -1067,6 +1081,19 @@ struct OSCPlotWidget : public rack::widget::TransparentWidget, style::StyleParti
nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
nvgText(vg, box.size.x * 0.5, box.size.y * 0.5 + 3, "VCO", nullptr);
}
else if (module->downloadingContent)
{
nvgBeginPath(vg);
nvgFontFaceId(vg, style()->fontIdBold(vg));
nvgFontSize(vg, 18);
nvgFillColor(vg, style()->getColor(style::XTStyle::PLOT_CURVE));
nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM);
nvgText(vg, box.size.x * 0.5, box.size.y * 0.5 + 2, "Downloading", nullptr);

auto r = fmt::format("{} pct", (int)(module->contentProgress * 100));
nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
nvgText(vg, box.size.x * 0.5, box.size.y * 0.5 + 3, r.c_str(), nullptr);
}
else if (!oscPath.empty())
{
bool is3D{false};
Expand Down
3 changes: 2 additions & 1 deletion src/VCO.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ template <int oscType> struct VCO : public modules::XTModule
std::array<std::unique_ptr<sst::filters::HalfRate::HalfRateFilter>, MAX_POLY> halfbandOUT;
sst::filters::HalfRate::HalfRateFilter halfbandIN;
float audioInBuffer[BLOCK_SIZE_OS];
std::atomic<bool> forceRefreshWT{false};
std::atomic<bool> forceRefreshWT{false}, downloadingContent{false};
float contentProgress{0};

rack::dsp::SchmittTrigger reTrigger[MAX_POLY];

Expand Down
20 changes: 9 additions & 11 deletions src/XTModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,24 @@ struct XTModule : public rack::Module

void setupSurgeCommon(int NUM_PARAMS, bool loadWavetables)
{
std::string dataPath = SurgeStorage::skipPatchLoadDataPathSentinel;
SurgeStorage::SurgeStorageConfig config;
config.suppliedDataPath = SurgeStorage::skipPatchLoadDataPathSentinel;
config.createUserDirectory = false;

if (loadWavetables)
dataPath = rack::asset::plugin(pluginInstance, "build/surge-data/");
{
config.suppliedDataPath = rack::asset::plugin(pluginInstance, "build/surge-data/");
config.extraThirdPartyWavetablesPath =
fs::path{rack::asset::user("SurgeXTRack/SurgeXTRack_ExtraContent")};
}

showBuildInfo();
storage = std::make_unique<SurgeStorage>(dataPath);
storage = std::make_unique<SurgeStorage>(config);
storage->getPatch().init_default_values();
storage->getPatch().copy_globaldata(storage->getPatch().globaldata);
storage->getPatch().copy_scenedata(storage->getPatch().scenedata[0], 0);
storage->getPatch().copy_scenedata(storage->getPatch().scenedata[1], 1);

if (!showedPathsOnce)
{
showedPathsOnce = true;
INFO("[SurgeXTRack] storage::dataPath = '%s'", storage->datapath.u8string().c_str());
INFO("[SurgeXTRack] storage::userDataPath = '%s'",
storage->userDataPath.u8string().c_str());
}

onSampleRateChange();
}

Expand Down
2 changes: 1 addition & 1 deletion surge

0 comments on commit 00082de

Please sign in to comment.