Blue Cat's Plug'n Script 3.3 Released - DSP DIY Summer?

Official support for: bluecataudio.com
Post Reply New Topic
RELATED
PRODUCTS
Crafters Pack$399.00Buy Plug'n Script$99.00Buy

Post

ilyaorlov wrote: Wed Jul 22, 2020 2:13 pm Hey, Eric!
ericbridenbaker wrote: Mon Jul 20, 2020 7:06 pm What I'd like to try next is to chain a few different effects in the same code. Example, compressor into a delay, or a filter into a clipper etc. So I'm trying to get a handle on how to route the serial processing. If I'm using processSample, and ioSample, do I need to define intermediate audio streams for each effect? And would I need to use void processSample more than once in the same code?
I'd say you probably just process each sample by your compressor function first, then by delay function, they by filter, etc. Just like if you had multiple plugins, they'd work one after another. You definitely use processSample (or processBlock) just once in your code and do your processing inside it.
Hi Ilya!

Thanks very much. Success!

One thing I've noticed in the example codes would be to assign a variable for the current sample and use that for each process.

Example:
At the beginning of the processing loop.

sample=ioSample[channel];

Then "sample" is used in place of ioSample throughout until the end of the processing loop.

And the value is returned back at the end of the loop using
ioSample[channel]=sample;

Understanding how this works made things a lot easier for me. But I also noticed that the code will still work without doing this. My guess is that there must be a CPU advantage to not using ioSample[channel] all the time. Will investigate.

Thanks again!

Post

It's working out well, just finished my first PNS project. The Letimix skin is fantastic!
You do not have the required permissions to view the files attached to this post.

Post

Very nice!

Post

Great!!! Glad to see this! Congratulations! :party: :tu:

Post

ericbridenbaker wrote: Sat Jul 25, 2020 6:47 pm sample=ioSample[channel];
Then "sample" is used in place of ioSample throughout until the end of the processing loop.
And the value is returned back at the end of the loop using
ioSample[channel]=sample;
Understanding how this works made things a lot easier for me. But I also noticed that the code will still work without doing this. My guess is that there must be a CPU advantage to not using ioSample[channel] all the time. Will investigate.
Yes! The main reason is that in AngelScript every call to array is very CPU consuming, cause under the hood it is a function call. So we try to call arrays while doing DSP via AngelScript as little as possible. That's why a regular variable is used instead.

Post

Just added a few new articles to Plug'n Script site.
This one is about a very cool way to add params:
https://pns.letimix.com/how-to/add-para ... nveniently

There is more in-depth info about some DSP API functions. List of updated articles here: https://pns.letimix.com/news/post14445

Post

Just finished a second plugin, it's a fun envelope tracking SVF with distortion. Got it working pretty well, except it puts everything in Mono, so I have to learn what's going on there. A bit of a learning curve but PNS is way more accessible than any other environment I've tried to program in. Many thanks to Blue Cat and Ilya! Here is the plugin, and the script.

http://www.mixorcist.com/dl/Gurgle.Filter.1.MacOSX.zip
http://www.mixorcist.com/dl/Gurgle.Filter.1.Win-x64.zip
Gurgle-Filter.jpg
----------------- Script Starts Here ---------------

/** \file
* Gurgle Filter effect.
* An envelope follower modulates the cutoff and distortion gain, Gurgle and Env Distortion controls control the respective amounts.
*/

#include "../library/Constants.hxx"

string description="Gurgle Filter";

/* Define our parameters.
*/
array<string> inputParametersNames={"IN","CUTOFF","RES","SLOW","GURGLE","DIST","ENV DIST","OUT"};
array<double> inputParameters(inputParametersNames.length);
array<double> inputParametersMin={0.01,200,0.4,0.01,0.3,0.01,0.01,0.01}; // min value
array<double> inputParametersMax={2,2000,0.95,0.3,1,80,60,0.9}; // max value

array<double> inputParametersDefault={1,700,0.5,0.1,0.3,40,10,0.5};

// internal variables
double f=0;
double band=0;
double low=0;
double high=0;
double q=0;
double notch=0;
double slow=0;
double gurgle=0;
double gf=0;
double env=0;
double sample=0;
double abv=0;
double dist=1;
double outlev=1;
double envdist=0;
double inlev=1;


/* per-sample processing function: called for every sample with updated parameters values.
*
*/

void processSample(array<double>& ioSample)
{
for(uint channel=0;channel<audioInputsCount;channel++){

sample=ioSample[channel]*inlev;
abv=abs(sample);

env+=slow*(abv-env);

gf=f+(gurgle*env-(env*0.5));

low = low + gf * tanh(band);
high = sample - low - q*band;
band = gf * high + band;
notch = high + low;
sample=outlev*(tanh(dist*low*(0.99+(env*envdist))));
ioSample[channel]=sample;

}
}


void updateInputParameters()
{
inlev=inputParameters[0];
f = 2*sin(PI*inputParameters[1]/sampleRate);
q = 1-inputParameters[2];
slow=pow(10,1.0/(50+.5*sampleRate*inputParameters[3]))-1;
gurgle=inputParameters[4];
dist=inputParameters[5];
envdist=inputParameters[6];
outlev=inputParameters[7];
}
You do not have the required permissions to view the files attached to this post.

Post

You do not have the required permissions to view the files attached to this post.

Post

Congratulations! Well done!

Post

I've got a question for Blue Cat Audio: where are persistent params kept (the data)? Can we clear it somehow manually?

Post

It depends :-). When saved into a preset they are stored in the preset file (that you can edit manually as it is an xml file), and when in a session they are stored in the session (which I doubt you can edit manually for most host applications).

Post

Thanks!

I've got a crashing experience in Reaper that was very difficult to find. There's a project with two instances of Plug'n Script loading the same script with custom kuiml. And on some loading it crashes, on some it doesn't.

Seems like removing all " async="true" " on ACTION_TRIGGERS on custom knobs solved it.

This is not the first time I meet random hard to find crashes when using async=true. Though it's sometimes very useful.

What can that be the reason for that? (maybe the reason is it's in custom kuiml, not in main skin)

Post

You need to be careful with async actions if you are also modifying the content of the skins or sub-skins: async actions are triggered later, but if in the meantime you have modified the content of the skin, the action may refer to objects that do not exist anymore, hence the crash. This is the only case where I have encountered such issues so far.

Post

Please, here's a piece of code that causes (sometimes onloading) crash:

Code: Select all

<ACTION_TRIGGER event_id="custom_param2.value_changed" script="/* */" async="true" />
The code is in custom .kuiml. Crashes stop when removing async="true" or replacing "custom_param2" with something else, like "window.onload" or "test_param".

Crashes also seem to stop when using refresh_priority="idle" in the main skin. With refresh_priority="normal" they sometimes happen.

Post

ilyaorlov wrote: Mon Aug 10, 2020 10:48 am The code is in custom .kuiml. Crashes stop when removing async="true" or replacing "custom_param2" with something else, like "window.onload" or "test_param".
I am not sure I fully understand. Can you maybe share the skin so that I can have a look with the debugger. It could be a bug in the KUIML engine.

Post Reply

Return to “Blue Cat Audio”