Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

How to use a unit delay in DSP code? and knobs not working..

For general discussion related FlowStone

How to use a unit delay in DSP code? and knobs not working..

Postby zoobooboozoo » Wed Sep 24, 2014 10:47 pm

Hi all.

I have the input audio go through a ruby module.
I'm writing a filter schematics into ruby(seems easier to write in code for me, much faster...).
I need to know two things:
1) How can I express unit delay in ruby? like:
Audio in of ruby -> ruby process the audio by simply delaying it by one unit delay -> audio out put

2) Why doesn't the built-in knobs in flowstone correspond properly with ruby? I have:
Knob - > float input of ruby -> float output of ruby
and when I fiddle with the knob the output float doesn't change its value. why is that? I tried some alternative knob I found here on the forums and it works fine but I still wonder what's the deal with the built-in ones

thx in advance for the help guys.
Last edited by zoobooboozoo on Thu Sep 25, 2014 1:00 pm, edited 1 time in total.
zoobooboozoo
 
Posts: 32
Joined: Tue Sep 23, 2014 12:14 pm

Re: Qs about Ruby - Unit Delay, Knobs Input

Postby KG_is_back » Wed Sep 24, 2014 11:17 pm

zoobooboozoo wrote:I have the input audio go through a ruby module.I'm writing a filter schematics into ruby(seems easier to write in code for me, much faster...).


In this particular case use DSP code component instead of ruby. You can add code component by hotkey "c". It has very simple syntax and it is much much faster than ruby (CPU wise). It is best for things like filters, delays, distortions, saturations etc. It however doesn't contain classical if/else branching and unfortunately only fixed sized loops and hops.
See the flowstone manual, it has a section dedicated to the DSP code component.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Qs about Ruby - Unit Delay, Knobs Input

Postby zoobooboozoo » Thu Sep 25, 2014 11:20 am

giving DSP a try.
1) I'm wondering about the inputs: should I use streamin/polyin/monoin for incoming audio to the filter? and what should I use for a float value input? (for freq of the filter for example)
2) what's the most efficient way of writing a code that makes the audio go through 5 different filters(each is the same but with different parameters and each of them is gonna be writting in dsp) times 2(since I need one cascade of filters for left and one for right)
3) and what about unit delay? how do I implement it in the DSP code? I went over the manual and couldn't find an answer...
4)is there a expononent function? couldn't find it.
5) what about the knob?

thx a lot for the help
zoobooboozoo
 
Posts: 32
Joined: Tue Sep 23, 2014 12:14 pm

Re: How to use a unit delay in DSP code? and knobs not worki

Postby KG_is_back » Thu Sep 25, 2014 4:33 pm

zoobooboozoo wrote:giving DSP a try.
1) I'm wondering about the inputs: should I use streamin/polyin/monoin for incoming audio to the filter? and what should I use for a float value input? (for freq of the filter for example)
2) what's the most efficient way of writing a code that makes the audio go through 5 different filters(each is the same but with different parameters and each of them is gonna be writting in dsp) times 2(since I need one cascade of filters for left and one for right)
3) and what about unit delay? how do I implement it in the DSP code? I went over the manual and couldn't find an answer...
4)is there a expononent function? couldn't find it.
5) what about the knob?

thx a lot for the help


1.Generally use streamin. They simply turn into any type of connector you connect them to. You can only pass values inside using streamin and out for streamout. In both cases the values are floats (or automatically converted to floats). There is no difference in the code between inputing signal and parameters (they both are just stream of floats).
2. The most effective way is, to write code for one filter. Copy the module 5 times and chain them. You can then use mono4 (pack/unpack primitives do that), to compute both Left and right channel simultaneously. DSP code uses SSE so it can preform the same computations on 4 channels at the same time (without increasing CPU).
3. simply use intermediate variables. the variables keep their values until you change them or reset the audio stream
Code: Select all
streamin x;
streamout y;
float previousX=0;

y=previousX;
previousX=x; //the values of variables persist - they do not get reset each sample

4. for some reason it is missing in the manual. Here is the expresion for it:
Code: Select all
v=pow(x,y) //x^y

For better CPU performance use it only when you need to rise a number to a noninteger, because the power uses quite a lot of CPU. For rising number to fixed integer exponent rather chain the multiplications.
The manual is also missing some other operations:
Code: Select all
a=b|c; //bitwise or operation
a=sqrt(b) //square root



5. Unfortunately I do not know nothing about this problem.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: How to use a unit delay in DSP code? and knobs not worki

Postby zoobooboozoo » Fri Sep 26, 2014 8:53 pm

Thx for deatiled reply KG.

2. Can you explain more about mono4 and the stereo mechanism you suggested? I didn't understand exactly what I should do to implement it.

3. so even if there's a a line in your code that defines and set a value: "float previousX=0" the value wouldn't change to 0 in the next run of the code on the next sample?
zoobooboozoo
 
Posts: 32
Joined: Tue Sep 23, 2014 12:14 pm

Re: How to use a unit delay in DSP code? and knobs not worki

Postby KG_is_back » Fri Sep 26, 2014 10:00 pm

zoobooboozoo wrote:Thx for deatiled reply KG.

2. Can you explain more about mono4 and the stereo mechanism you suggested? I didn't understand exactly what I should do to implement it.

3. so even if there's a a line in your code that defines and set a value: "float previousX=0" the value wouldn't change to 0 in the next run of the code on the next sample?


2. streams in Flowstone can process 4 channels at the same time. The example in the schematic should make it clear enough.

3. No. The variable is initialized only before the first sample when you turn on the ASIO or the schematic gets recompiled. You may force this to happen using "Clear Audio" primitive. Otherwise the variable holds the value until you change it, even to next samples - that is the whole idea of DSP processing - only variable that changes it's value automatically is the input.
Attachments
mono4tutorial.fsm
(4.53 KiB) Downloaded 891 times
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: How to use a unit delay in DSP code? and knobs not worki

Postby zoobooboozoo » Sat Sep 27, 2014 2:02 am

Got it.

another question: I want to control a simple filter cutoff with an exact frequency.
set the cutoff to 440hz for example. how can I log the linear frequncy so that the builtin filter can "understand" what I want?
zoobooboozoo
 
Posts: 32
Joined: Tue Sep 23, 2014 12:14 pm

Re: How to use a unit delay in DSP code? and knobs not worki

Postby Xtinct » Sat Sep 27, 2014 4:09 am

If you look inside the stock filters there's a switch for setting cutoff in hz
Xtinct
 
Posts: 106
Joined: Fri Feb 11, 2011 12:06 am

Re: How to use a unit delay in DSP code? and knobs not worki

Postby KG_is_back » Sat Sep 27, 2014 8:47 am

zoobooboozoo wrote:Got it.

another question: I want to control a simple filter cutoff with an exact frequency.
set the cutoff to 440hz for example. how can I log the linear frequncy so that the builtin filter can "understand" what I want?


In the toolbox there is a module called "Hz to 0-1" - it converts Hz frequency representation into 0-1 representation (where 0 is DC and 1 is Nyquist. In DSP terminology it is called normalized frequency ). the equation goes like this:

f(0-1)=f(Hz)*2/samplerate

There is a primitive in Flowstone that outputs current sample rate.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: How to use a unit delay in DSP code? and knobs not worki

Postby zoobooboozoo » Sat Sep 27, 2014 3:17 pm

Thanks a lot KG, you're incredibly helpful. and quick too :)
zoobooboozoo
 
Posts: 32
Joined: Tue Sep 23, 2014 12:14 pm


Return to General

Who is online

Users browsing this forum: No registered users and 37 guests