Browse Source

Clean up list of allowed tags. Add tag aliases.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
d2e7cd7486
5 changed files with 84 additions and 48 deletions
  1. +2
    -0
      include/app/Scene.hpp
  2. +1
    -1
      include/plugin.hpp
  3. +4
    -2
      src/app/Scene.cpp
  4. +75
    -43
      src/plugin.cpp
  5. +2
    -2
      src/string.cpp

+ 2
- 0
include/app/Scene.hpp View File

@@ -25,6 +25,8 @@ struct Scene : widget::OpaqueWidget {
bool checkedVersion = false; bool checkedVersion = false;
std::string latestVersion; std::string latestVersion;


double lastAutoSaveTime = 0.0;

Scene(); Scene();
~Scene(); ~Scene();
void step() override; void step() override;


+ 1
- 1
include/plugin.hpp View File

@@ -25,12 +25,12 @@ std::string getAllowedTag(std::string tag);
bool isSlugValid(std::string slug); bool isSlugValid(std::string slug);




extern const std::vector<std::string> allowedTags;
extern std::list<Plugin*> plugins; extern std::list<Plugin*> plugins;
extern bool isDownloading; extern bool isDownloading;
extern float downloadProgress; extern float downloadProgress;
extern std::string downloadName; extern std::string downloadName;
extern std::string loginStatus; extern std::string loginStatus;
extern const std::vector<std::string> allowedTags;




} // namespace plugin } // namespace plugin


+ 4
- 2
src/app/Scene.cpp View File

@@ -56,13 +56,15 @@ void Scene::step() {
zoomWidget->box.size = rackWidget->box.size.mult(zoomWidget->zoom); zoomWidget->box.size = rackWidget->box.size.mult(zoomWidget->zoom);


// Autosave every 15 seconds // Autosave every 15 seconds
int frame = APP->window->frame;
if (frame > 0 && frame % (60 * 15) == 0) {
double time = glfwGetTime();
if (time - lastAutoSaveTime >= 15.0) {
lastAutoSaveTime = time;
APP->patch->save(asset::user("autosave.vcv")); APP->patch->save(asset::user("autosave.vcv"));
settings.save(asset::user("settings.json")); settings.save(asset::user("settings.json"));
} }


// Set zoom every few frames // Set zoom every few frames
int frame = APP->window->frame;
if (frame % 10 == 0) if (frame % 10 == 0)
zoomWidget->setZoom(std::round(settings.zoom * 100) / 100); zoomWidget->setZoom(std::round(settings.zoom * 100) / 100);




+ 75
- 43
src/plugin.cpp View File

@@ -14,6 +14,7 @@
#include <sys/param.h> // for MAXPATHLEN #include <sys/param.h> // for MAXPATHLEN
#include <fcntl.h> #include <fcntl.h>
#include <thread> #include <thread>
#include <map>
#include <stdexcept> #include <stdexcept>


#define ZIP_STATIC #define ZIP_STATIC
@@ -516,41 +517,20 @@ Model *getModel(std::string pluginSlug, std::string modelSlug) {
return model; return model;
} }


std::string getAllowedTag(std::string tag) {
tag = string::lowercase(tag);
for (std::string allowedTag : allowedTags) {
if (tag == string::lowercase(allowedTag))
return allowedTag;
}
return "";
}

bool isSlugValid(std::string slug) {
for (char c : slug) {
if (!(std::isalnum(c) || c == '-' || c == '_'))
return false;
}
return true;
}


std::list<Plugin*> plugins;
bool isDownloading = false;
float downloadProgress = 0.f;
std::string downloadName;
std::string loginStatus;



/** List of allowed tags in human display form.
All tags here should be in sentence caps for display consistency.
However, tags are case-insensitive in plugin metadata.
*/
const std::vector<std::string> allowedTags = { const std::vector<std::string> allowedTags = {
"VCA",
"Arpeggiator", "Arpeggiator",
"Attenuator",
"Blank",
"Attenuator", // With a level knob and not much else.
"Blank", // No parameters or ports. Serves no purpose except visual.
"Chorus", "Chorus",
"Clock Modulator", // Clock dividers, multipliers, etc.
"Clock",
"Compressor",
"Controller", // Use only if the artist "performs" with this module. Knobs are not sufficient. Examples: on-screen keyboard, XY pad.
"Clock generator",
"Clock modulator", // Clock dividers, multipliers, etc.
"Compressor", // With threshold, ratio, knee, etc parameters.
"Controller", // Use only if the artist "performs" with this module. Simply having knobs is not enough. Examples: on-screen keyboard, XY pad.
"Delay", "Delay",
"Digital", "Digital",
"Distortion", "Distortion",
@@ -558,46 +538,98 @@ const std::vector<std::string> allowedTags = {
"Dual", // The core functionality times two. If multiple channels are a requirement for the module to exist (ring modulator, mixer, etc), it is not a Dual module. "Dual", // The core functionality times two. If multiple channels are a requirement for the module to exist (ring modulator, mixer, etc), it is not a Dual module.
"Dynamics", "Dynamics",
"Effect", "Effect",
"Envelope Follower",
"Envelope Generator",
"Envelope follower",
"Envelope generator",
"Equalizer", "Equalizer",
"External", "External",
"Filter",
"Flanger", "Flanger",
"Function Generator",
"Function generator",
"Granular", "Granular",
"LFO", "LFO",
"Limiter", "Limiter",
"Logic", "Logic",
"Low Pass Gate",
"Low pass gate",
"MIDI", "MIDI",
"Mixer", "Mixer",
"Multiple", "Multiple",
"Noise", "Noise",
"VCO",
"Panning", "Panning",
"Phaser", "Phaser",
"Poly",
"Physical Modeling",
"Physical modeling",
"Polyphonic",
"Quad", // The core functionality times four. If multiple channels are a requirement for the module to exist (ring modulator, mixer, etc), it is not a Quad module. "Quad", // The core functionality times four. If multiple channels are a requirement for the module to exist (ring modulator, mixer, etc), it is not a Quad module.
"Quantizer", "Quantizer",
"Random", "Random",
"Recording", "Recording",
"Reverb", "Reverb",
"Ring Modulator",
"Sample and Hold",
"Ring modulator",
"Sample and hold",
"Sampler", "Sampler",
"Sequencer", "Sequencer",
"Slew Limiter",
"Slew limiter",
"Switch", "Switch",
"Synth Voice", // A synth voice must have an envelope built-in.
"Synth voice", // A synth voice must have, at the minimum, a built-in oscillator and envelope.
"Tuner", "Tuner",
"Utility", // Serves only extremely basic functions, like inverting, max, min, multiplying by 2, etc. "Utility", // Serves only extremely basic functions, like inverting, max, min, multiplying by 2, etc.
"VCA",
"VCF",
"VCO",
"Visual", "Visual",
"Vocoder", "Vocoder",
"Waveshaper", "Waveshaper",
}; };




/** List of common synonyms for allowed tags.
Aliases and tags must be lowercase.
*/
const std::map<std::string, std::string> tagAliases = {
{"amplifier", "vca"},
{"clock", "clock generator"},
{"drums", "drum"},
{"eq", "equalizer"},
{"filter", "vcf"},
{"low frequency oscillator", "lfo"},
{"lowpass gate", "low pass gate"},
{"oscillator", "vco"},
{"percussion", "drum"},
{"poly", "polyphonic"},
{"s&h", "sample and hold"},
{"voltage controlled amplifier", "vca"},
{"voltage controlled filter", "vcf"},
{"voltage controlled oscillator", "vco"},
};


std::string getAllowedTag(std::string tag) {
tag = string::lowercase(tag);
// Transform aliases
auto it = tagAliases.find(tag);
if (it != tagAliases.end())
tag = it->second;
// Find allowed tag
for (std::string allowedTag : allowedTags) {
if (tag == string::lowercase(allowedTag))
return allowedTag;
}
return "";
}

bool isSlugValid(std::string slug) {
for (char c : slug) {
if (!(std::isalnum(c) || c == '-' || c == '_'))
return false;
}
return true;
}


std::list<Plugin*> plugins;
bool isDownloading = false;
float downloadProgress = 0.f;
std::string downloadName;
std::string loginStatus;


} // namespace plugin } // namespace plugin
} // namespace rack } // namespace rack

+ 2
- 2
src/string.cpp View File

@@ -25,12 +25,12 @@ std::string f(const char *format, ...) {
} }


std::string lowercase(std::string s) { std::string lowercase(std::string s) {
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return std::tolower(c); });
return s; return s;
} }


std::string uppercase(std::string s) { std::string uppercase(std::string s) {
std::transform(s.begin(), s.end(), s.begin(), ::toupper);
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return std::toupper(c); });
return s; return s;
} }




Loading…
Cancel
Save