04-23-2016 11:47 AM
Hey i've posted a topic on a similar problem for this project but here the problem is a bit different.
I've wanted to make an EQ prototype, so far it work but reading the modded sound does'nt.
I mean if i write the outdata in a wav file, the filter stuff work, i can cut and boost frequency more or like i want.
However reading the data inside labview does'nt work.
I've used https://decibel.ni.com/content/docs/DOC-14630 this as comparison, and for what i've looked my configuration is almost the same, with less "moddability" though
The only difference i see is that my "offset position" in the right side of my Read VI goes straight from 0 to the end, i can't find where i've missed something and lost already 2 hours on this stupid problem ><
If someone can help, i think some people might know straight was is wrong, so thank for any help
04-23-2016 02:36 PM
Whenever you see "doing the same thing N times", you should think of an Array and a For Loop. Whenever the "thing" involves the same three parameters, you should think of a Cluster (and should save the Cluster as a TypeDef).
I built such a TypeDef (which I called "Filter Settings) that had three numeric parts -- Atten (which you called "Numérique", the default name, in French, for a "numeric"), Low Cut, and High Cut. It is always a good idea to name your variables -- I called this "Atten" (to remind me of Attenuation, or a "dividing down" of something, as you use this as the divisor for your Waveform Array). I then created an array of these clusters and populated them with the values I found on your Front Panel. Here it is:
Several things to notice (besides how much neater and more organized this looks). First, two Attens are 0, which means you are dividing by zero, usually a Bad Idea. This organization makes it easy to see the various filter ranges, and to spot that possibly the final filter is mis-specified (looks like Low and High are backwards). When you go to use it, you can wire this array into a For loop inside of which is a single Filter that gets called multiple times.
Now, some will notice that calling the same Filter function in a For loop might be "slow". Say it takes 1 second for the Filter function to return an output. Well, if called 6 times, it will take 6 seconds. However, if you use your non-loop code, you can say "I'm calling the six functions in parallel, so they can all run simultaneously and (potentially) take less than 6 seconds". Well, it is still the same function, unless the function is coded as reentrant (and I don't know if this is true or not). Even so, if it is largely "compute bound", there might not be much savings in trying to run it in parallel unless LabVIEW assigns different cores to different Filters.
Finally, it is possible to have the best of both worlds -- have a For loop and call a reentrant function multiple times, each time using a different "clone" to take advantage of parallelism. In fact, there was a post on this forum doing this within the past week (don't think it was you ...).
I know this doesn't deal with your question, for which I apologize. I hope my "off-the-topic" comment is useful to you.
Bob Schor
04-26-2016 01:32 AM
aaaah tought i've answered that 😞 don't know why message did'nt posted.
Thanks for cluser defenitely better and much clearer.
For the parrallel/reentrant fonction, i admit this project does'nt count enough for me for bothering with such optimisation,thanks for the info still, always good to know how such things works.
For the 2 end filters, they are set correctly,they are working so i want them to filter... nothing for now ^^so LP 20hz HP 20khz
I've reorganised all the stuff, if someone could take a look! Im sure the problem come from reading wav file VI, since the .wav i wrote with my filtered data works.
04-26-2016 09:06 AM - edited 04-26-2016 09:07 AM
@Kenny_mk wrote:
Thanks for cluser defenitely better and much clearer.
For the parrallel/reentrant fonction, i admit this project does'nt count enough for me for bothering with such optimisation,thanks for the info still, always good to know how such things works.
For the 2 end filters, they are set correctly,they are working so i want them to filter... nothing for now ^^so LP 20hz HP 20khz
I've reorganised all the stuff, if someone could take a look! Im sure the problem come from reading wav file VI, since the .wav i wrote with my filtered data works.
Go back and take a look at my Front Panel Control (and read carefully the paragraph I wrote about it). It is an array. An array of what? An array of clusters. And the Clusters have been saved as a Type Def. (If you don't know how to do this, please ask -- it is a pretty important idea to use TypeDefs when making composite data structures such as Enums and Clusters).
Assume you were designing an Equalizer, and built it with, say, 7 "stages", each with a Upper/Lower Cut setting, and wanted people to use it. I come along and only want to use three banks. Are you expecting me to "turn off" the other four by setting Upper to 20 and Lower to 20K? No, you'd add an Enable/Disable (or On/Off) switch to each bank. How to do that? Simple, add a Boolean to your Cluster.
Finally, you completely missed the point of building the Array of Clusters in the first place. The idea was to replace the six identical pieces of code with wires running all over the place with a single For Loop that receives the Array of Controls as its input and returns the Array of Signals as its output.
So I'm violating my own rule about posting Code, and not a Picture -- this is, indeed, a "picture" of code because if you want to use this, you need to do the (minor) work of creating this and seeing how/why it works. Before doing this, I modified your (un-type-def'ed) Cluster by adding an Enable boolean (the Control on the Front Panel looks very similar to the Control I posted earlier, it just has a column of Enable switches). Here's the code, comments to follow:
"Filters" is my Front Panel Array of Filters. Note that the size of the Array (= number of Filters) appears nowhere -- it doesn't have to, as the input Array tunnel is "auto-indexing", running once for each array element (look at the picture of the tunnel -- it is an empty square with a pair of array brackets, [], inside it). The top input is the Waveform wire that you get from the first element of the Wave output array.
When working with Clusters, you should (almost) always use "Unbundle by Name" and "Bundle by Name" -- it makes your code more self-documenting, and reduces the chances for Stupid Wiring Mistakes (though, believe me, they will still occur). I use the Enable setting to decide whether or not to Filter (why waste time and CPU cycles if you are not using a Filter Bank?) -- the False case just wires the Enable and Waveform inputs to the corresponding Case Output tunnels. I do the Attenuation division after the Filtering (it doesn't matter when you do it). Because Dynamic Signals can be problematic, I convert the output of the Filter back to a simple Waveform. Finally, if Enable is not True, we don't want to use this value, so the output Tunnel has been made a Conditional Tunnel -- if Enable is False, this component will not be used.
One thing that simplifying this code should show you is another strange feature of your code -- after doing all of this filtering using Filter Banks that you specify, you refilter the Merged Signal (or, in our case, the Array of Waveforms) with another 20-20K (a very wide bandwidth) Filter. Why filter twice? Each of your signals (presumably) is already filtered over a narrower bandwidth. If you did want to do this, I'd do it first on the Waveform going into the Filter Bank (it would save you a significant amount of time, as you would only have to filter 1/(number of filters in your wavebank) signals).
Oops -- I didn't even notice that you do something even stranger -- you filter twice, using 20 as both Low and High Cut (what does this do?) and following it with using 20K the same way. I really don't understand this, but now that I've simplified your code, I can begin to "see the forest for the trees" ...
I hope this is clearer than my previous post. If you have any questions, don't hesitate to ask.
Bob Schor
04-26-2016 12:38 PM - edited 04-26-2016 12:42 PM
I give you a quick answer now, but i just stopped studying so i will not get back into Labview Right Now. Thanks for the develloppement, and your time. I will get into this after lunch (7h30 pm here)
I've forgot to set precision about about the last 2 serial filter, they are meant to be a LP and HP by default but i can't get them having those value per default again.
Even then, they will have Wide Frequency, because i don't want them to do anything right now, but Filtering all frequency below/above a frequency can be usefull in an EQ.
This EQ ( while not making for being truely used) is maked with an "Electronic Music EQ" in mind. The feature of the most used (FabFilter pro-Q) are quite simple to use.
In a "user" way.
You have "bells" who looks like BP filters but with Resonance, you set the center frequency, the width, and the gain (who is decreasing quite fast once you get off the centered frequency,depending on width). However (in the soft) they don't do anything to frequency out of their range.
The "Low/ high shelf" who are decreasing (or increasing) above a certain frequency, in a constant way, except in the space around the center frequency. (i've skipped that one, the curve and such suggest those are the much complex of the lot i think)
I think those above are (more particulary than the one i'm using) Filters in parrallel (almost sure for the Bell)
"Notch" Who are basically Band Reject filters, and "Low Cut" and "High cut" who are just LP HP filter. And i think those are in serial. (well almost sure)
Having those Low Cut, High Cut are usefull since you might want to be sure that this synth will not bother at all this kick in the 130hz (for example), and pure filter in Electronic Music are more often tool for effect with high modulations setting and a "nice" filtering (CPU-eating), rather than being use for "frequency reason".
Im far from being good in this domain though, but i think it's that way most people go