zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit ea70639eb0b7a91521bc4543ed5656374a1f2cbb
parent 159c5d7aefe3af3b05e28903dc8d09a1e43bdcb8
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Mon, 24 Jul 2017 16:25:31 -0400

Enhance InsStats Tool For Patch Resource Usage

Diffstat:
Msrc/Tests/InstrumentStats.cpp | 261+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 248 insertions(+), 13 deletions(-)

diff --git a/src/Tests/InstrumentStats.cpp b/src/Tests/InstrumentStats.cpp @@ -22,6 +22,13 @@ #include "../Misc/Microtonal.h" #include "../DSP/FFTwrapper.h" #include "../globals.h" + +#include "../Effects/EffectMgr.h" +#include "../Params/LFOParams.h" +#include "../Params/EnvelopeParams.h" +#include "../Params/ADnoteParameters.h" +#include "../Params/PADnoteParameters.h" +#include "../Params/SUBnoteParameters.h" using namespace std; using namespace zyn; @@ -143,22 +150,250 @@ void memUsage() printf("%lld", alloc.totalAlloced()); } +/* + * Kit fields used + * + * Kit type + * + * Add synth engines used + * Add synth voices used + * Sub synth engines used + * Pad synth engines used + * + * + * Total Envelopes + * Optional Envelopes + * + * Total Free mode Envelopes + * + * Total LFO + * Optional LFO + * + * Total Filters + * + * Total 'Analog' Filters + * Total SVF Filters + * Total Formant Filters + * + * Total Effects + */ +void usage_stats(void) +{ + int kit_type = 0; + int kits_used = 0; + int add_engines = 0; + int add_voices = 0; + int sub_engines = 0; + int pad_engines = 0; + + int env_total = 0; + int env_optional = 0; + int env_free = 0; + + int lfo_total = 0; + int lfo_optional = 0; + + int filter_total = 0; + int filter_analog = 0; + int filter_svf = 0; + int filter_formant = 0; + + int effects_total = 0; + + kit_type = p->Pkitmode; + for(int i=0; i<NUM_KIT_ITEMS; ++i) { + auto &k = p->kit[i]; + if(!(k.Penabled || (i==0 && p->Pkitmode == 0l))) + continue; + + if(k.Padenabled) { + auto &e = *k.adpars; + add_engines += 1; + for(int j=0; j<NUM_VOICES; ++j) { + auto &v = k.adpars->VoicePar[j]; + if(!v.Enabled) + continue; + add_voices += 1; + if(v.PFilterEnabled) { + auto &f = *v.VoiceFilter; + filter_total += 1; + if(f.Pcategory == 0) + filter_analog += 1; + else if(f.Pcategory == 1) + filter_formant += 1; + else + filter_svf += 1; + } + if(v.PFreqLfoEnabled && v.FreqLfo->Pintensity) { + lfo_optional += 1; + lfo_total += 1; + } + if(v.PFilterLfoEnabled && v.FilterLfo->Pintensity) { + lfo_optional += 1; + lfo_total += 1; + } + if(v.PAmpLfoEnabled && v.AmpLfo->Pintensity) { + lfo_optional += 1; + lfo_total += 1; + } + if(v.PFreqEnvelopeEnabled) { + env_optional += 1; + env_total += 1; + env_free += !!v.FreqEnvelope->Pfreemode; + } + if(v.PFilterEnvelopeEnabled) { + env_optional += 1; + env_total += 1; + env_free += !!v.FilterEnvelope->Pfreemode; + } + if(v.PAmpEnvelopeEnabled) { + env_optional += 1; + env_total += 1; + env_free += !!v.AmpEnvelope->Pfreemode; + } + } + + + + if(e.GlobalPar.GlobalFilter) { + auto &f = *e.GlobalPar.GlobalFilter; + filter_total += 1; + if(f.Pcategory == 0) + filter_analog += 1; + else if(f.Pcategory == 1) + filter_formant += 1; + else + filter_svf += 1; + } + if(e.GlobalPar.FreqLfo->Pintensity) + lfo_total += 1; + if(e.GlobalPar.FilterLfo->Pintensity) + lfo_total += 1; + if(e.GlobalPar.AmpLfo->Pintensity) + lfo_total += 1; + env_total += 3; + env_free += !!e.GlobalPar.FreqEnvelope->Pfreemode; + env_free += !!e.GlobalPar.FilterEnvelope->Pfreemode; + env_free += !!e.GlobalPar.AmpEnvelope->Pfreemode; + } + + if(k.Ppadenabled) { + pad_engines += 1; + auto &e = *k.padpars; + if(e.GlobalFilter) { + auto &f = *e.GlobalFilter; + filter_total += 1; + if(f.Pcategory == 0) + filter_analog += 1; + else if(f.Pcategory == 1) + filter_formant += 1; + else + filter_svf += 1; + } + if(e.FreqLfo->Pintensity) + lfo_total += 1; + if(e.FilterLfo->Pintensity) + lfo_total += 1; + if(e.AmpLfo->Pintensity) + lfo_total += 1; + env_total += 3; + env_free += !!e.FreqEnvelope->Pfreemode; + env_free += !!e.FilterEnvelope->Pfreemode; + env_free += !!e.AmpEnvelope->Pfreemode; + } + + if(k.Psubenabled) { + sub_engines += 1; + auto &e = *k.subpars; + + if(e.PGlobalFilterEnabled) { + auto &f = *e.GlobalFilter; + filter_total += 1; + if(f.Pcategory == 0) + filter_analog += 1; + else if(f.Pcategory == 1) + filter_formant += 1; + else + filter_svf += 1; + } + if(e.PFreqEnvelopeEnabled) { + env_total += 1; + env_optional += 1; + env_free += !!e.FreqEnvelope->Pfreemode; + } + if(e.PGlobalFilterEnabled) { + env_total += 1; + env_optional += 1; + env_free += !!e.GlobalFilterEnvelope->Pfreemode; + } + if(e.PBandWidthEnvelopeEnabled) { + env_total += 1; + env_optional += 1; + env_free += !!e.BandWidthEnvelope->Pfreemode; + } + } + + kits_used += 1; + } + + for(int i=0; i<NUM_PART_EFX; ++i) { + if(p->partefx[i]->efx) + effects_total += 1; + } + + printf("Kit type: %d\n", kit_type); + printf("Kits used: %d\n", kits_used); + printf("Add engines: %d\n", add_engines); + printf(" Add voices: %d\n", add_voices); + printf("Sub engines: %d\n", sub_engines); + printf("Pad engines: %d\n", pad_engines); + + printf("\n"); + + printf("Env total: %d\n", env_total); + printf("Env optional: %d\n", env_optional); + printf("Env free: %d\n", env_free); + + printf("\n"); + + printf("LFO total: %d\n", lfo_total); + printf("LFO optional: %d\n", lfo_optional); + + printf("\n"); + + printf("Filter total: %d\n", filter_total); + printf("Filter analog: %d\n", filter_analog); + printf("Filter svf: %d\n", filter_svf); + printf("Filter formant: %d\n", filter_formant); + + printf("\n"); + + printf("Effects Total: %d\n", effects_total); +} + int main(int argc, char **argv) { - if(argc != 2) { + if(argc < 2) { fprintf(stderr, "Please supply a xiz file\n"); return 1; } - - mode = MODE_PROFILE; - setup(); - xml(argv[1]); - load(); - memUsage(); - printf(", "); - noteOn(); - speed(); - noteOff(); - memUsage(); - printf("\n"); + if(argc == 2) { + mode = MODE_PROFILE; + setup(); + xml(argv[1]); + load(); + memUsage(); + printf(", "); + noteOn(); + speed(); + noteOff(); + memUsage(); + printf("\n"); + } else if(argc == 3) { + mode = MODE_TEST; + setup(); + xml(argv[2]); + load(); + usage_stats(); + } }