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
Ruby Array Output, Loop
11 posts
• Page 1 of 2 • 1, 2
Ruby Array Output, Loop
Hi,
I’m trying to get my head around how to get data out of Ruby.
http://i.imgur.com/GnH7yzF.png
I have some code that calculates two values; SPLmax and SPLtherm for a given frequency ‘F’. At the moment the code works but I have frequency ‘F’ as an input and I have to manually drag a knob about to read off values from the output. What I want is for Ruby to auto generate a value for F in some kind of loop, starting with say the number 10, then run that through the code and add it to an array. Then F would become 11, 12, 13…20000. Each time adding the answer to an array (well 2 arrays, one for SPLmax and one for SPLtherm). I would like to then output these Arrays so I can plot them on a graph against F in either Flowstone or in Excel.
I’m sure it’s just a few lines of simple code but I have been reading online for many hours and cannot find something that works.
Cheers,
Ollie
I’m trying to get my head around how to get data out of Ruby.
http://i.imgur.com/GnH7yzF.png
I have some code that calculates two values; SPLmax and SPLtherm for a given frequency ‘F’. At the moment the code works but I have frequency ‘F’ as an input and I have to manually drag a knob about to read off values from the output. What I want is for Ruby to auto generate a value for F in some kind of loop, starting with say the number 10, then run that through the code and add it to an array. Then F would become 11, 12, 13…20000. Each time adding the answer to an array (well 2 arrays, one for SPLmax and one for SPLtherm). I would like to then output these Arrays so I can plot them on a graph against F in either Flowstone or in Excel.
I’m sure it’s just a few lines of simple code but I have been reading online for many hours and cannot find something that works.
Cheers,
Ollie
- Attachments
-
- TS Excursion Limited Power Handling.fsm
- (8.05 KiB) Downloaded 1469 times
- OllieMarshall92
- Posts: 16
- Joined: Wed Oct 26, 2011 12:22 pm
Re: Ruby Array Output, Loop
Hi Ollie,
if you are willing to prepare yor code, I could help you. There's a neccessity to follow certain rules when writing Ruby code. Your code works because you didn't use any Ruby specifics. It's currently more like a pocket calculator.
To be able to use methods, classes, modules and such, the code needs the following changes:
1) Use lower-case for all your variables. Ro -> ro, SPL -> spl, etc. For words like SPLmax I propose to use an underscore: spl_max
2) Use lower case for all of the inputs. @Dia -> @dia, @Xmax -> @x_max, etc.
3) You don't need to declare PI. Instead just use
if you are willing to prepare yor code, I could help you. There's a neccessity to follow certain rules when writing Ruby code. Your code works because you didn't use any Ruby specifics. It's currently more like a pocket calculator.
To be able to use methods, classes, modules and such, the code needs the following changes:
1) Use lower-case for all your variables. Ro -> ro, SPL -> spl, etc. For words like SPLmax I propose to use an underscore: spl_max
2) Use lower case for all of the inputs. @Dia -> @dia, @Xmax -> @x_max, etc.
3) You don't need to declare PI. Instead just use
- Code: Select all
Math::PI
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Array Output, Loop
tulamide wrote:Hi Ollie,
if you are willing to prepare yor code, I could help you. There's a neccessity to follow certain rules when writing Ruby code. Your code works because you didn't use any Ruby specifics. It's currently more like a pocket calculator.
To be able to use methods, classes, modules and such, the code needs the following changes:
1) Use lower-case for all your variables. Ro -> ro, SPL -> spl, etc. For words like SPLmax I propose to use an underscore: spl_max
2) Use lower case for all of the inputs. @Dia -> @dia, @Xmax -> @x_max, etc.
3) You don't need to declare PI. Instead just use
- Code: Select all
Math::PI
Hi Tulamide,
Yea of course I'll do that over the weekend and post an updated schematic. Thanks for the tips!
All the best,
Ollie
- OllieMarshall92
- Posts: 16
- Joined: Wed Oct 26, 2011 12:22 pm
Re: Ruby Array Output, Loop
Hi tulamide,
I've updated my code.
http://i.imgur.com/u4fjtah.png
What steps do I need to take to get Ruby to run the code for frequencies say 10Hz to 20,000Hz in 0.1Hz intervals and then to graph the two variables against frequency? I don't expect you to do it for me (unless you want to)! but a few pointers and maybe an example or two would be a great help.
All the best,
Ollie
I've updated my code.
http://i.imgur.com/u4fjtah.png
What steps do I need to take to get Ruby to run the code for frequencies say 10Hz to 20,000Hz in 0.1Hz intervals and then to graph the two variables against frequency? I don't expect you to do it for me (unless you want to)! but a few pointers and maybe an example or two would be a great help.
All the best,
Ollie
- Attachments
-
- TS Excursion Limited Power Handling2.fsm
- (8.06 KiB) Downloaded 1526 times
- OllieMarshall92
- Posts: 16
- Joined: Wed Oct 26, 2011 12:22 pm
Re: Ruby Array Output, Loop
I'm working on it. Please be patient
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Array Output, Loop
I'm so sorry it took so long!
People are probably used to the speeds of MyCo, KG or Nubeat. To my excuse I can only say that
1. it was quite a big project
2. I had to split the work on it to less than an hour per day
3. I wanted it to be useful out of the box
Things to consider:
When opening the schematic you'll see an empty graph window. First check the values used for the calculations. If you want to make changes, use the re-define trigger after the changes!
If you're fine with the values, enter the frequency range and step size, then use the "start plotting" trigger.
Now you'll see a black bar showing the progress of the calculations.
This makes it a bit slower, but using the event system it is guaranteed that Flowstone will never switch off the RubyEdit with an excessive activity error. Flowstone will be fully in control while the data is calculated.
When ready the graph is shown. You can now resize the graph view to any size you like.
If data is at least calculated once, you may also use the "export" trigger. This will generate two timestamped .csv files, one for displacement, one for thermal. They are saved to the folder where the schematic resides. Because of the timestamp, you will never overwrite those exports.
One technical aspect: When using something like 10 to 20000 Hz with a 0.1 Hz step, it will result in 200,000 values. Those will be exported, but of course you can't display 200,000 values (unless you have a monitor with a resolution of 200,000 pixels in width). Therefore, my method takes samples at calculated intervals from the array. This is good enough to have an exact curve, but there's no interpolation going on. I don't see the need for it, since interpolation is used to calculate missing values, whereas here we have way too much values.
People are probably used to the speeds of MyCo, KG or Nubeat. To my excuse I can only say that
1. it was quite a big project
2. I had to split the work on it to less than an hour per day
3. I wanted it to be useful out of the box
Things to consider:
When opening the schematic you'll see an empty graph window. First check the values used for the calculations. If you want to make changes, use the re-define trigger after the changes!
If you're fine with the values, enter the frequency range and step size, then use the "start plotting" trigger.
Now you'll see a black bar showing the progress of the calculations.
This makes it a bit slower, but using the event system it is guaranteed that Flowstone will never switch off the RubyEdit with an excessive activity error. Flowstone will be fully in control while the data is calculated.
When ready the graph is shown. You can now resize the graph view to any size you like.
If data is at least calculated once, you may also use the "export" trigger. This will generate two timestamped .csv files, one for displacement, one for thermal. They are saved to the folder where the schematic resides. Because of the timestamp, you will never overwrite those exports.
One technical aspect: When using something like 10 to 20000 Hz with a 0.1 Hz step, it will result in 200,000 values. Those will be exported, but of course you can't display 200,000 values (unless you have a monitor with a resolution of 200,000 pixels in width). Therefore, my method takes samples at calculated intervals from the array. This is good enough to have an exact curve, but there's no interpolation going on. I don't see the need for it, since interpolation is used to calculate missing values, whereas here we have way too much values.
- Attachments
-
- TS Excursion Limited Power Handling2 [tula].fsm
- (2.49 KiB) Downloaded 1439 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Array Output, Loop
Woah! Looks really good!
You've certainly spent some time on this.
Is their an easy way to access the arrays with the data in from within flowstone?
My plan is to calibrate the loudspeakers SPL@1m output with an SPL indicated inside the software. So when I set flowstone to play a 80dbSPL 500Hz tone, I can measure something close to that in the real world. Then I could create a limiter/compressor that uses the data from the array/graph to filter its control signal to limit the output to stop over-excursion. If I add a look-ahead then it should be fairly transparent too. I guess this would need some fft stuff.
I am building a tiny pair of speakers and don't want to damage them with my compensation scheme. I want to use a linkwitz transform to lower the f3 when listening at lower levels but gradually reduce the amount of compensation when you turn it right up. I'm adding a lot of gain at low frequencies with my realtime adjustable linkwitz transform (another flowstone schematic I haven't posted on the forum yet). The problem is that its response/amount of gain is only based on the volume setting in flowstone and not based on the program material, meaning that a particularly bass heavy track can break the drivers. What you have done here is really useful because it means that I can use the data to prevent the 'bass boost' from damaging stuff because the limitations of the driver at EVERY frequency are defined in terms of thermal and more importantly in my case: cone displacement.
So hopefully I will end up with a pair so tiny speakers that have semi-decent low bass when used at low levels.
Thanks for all the hard work!
You've certainly spent some time on this.
Is their an easy way to access the arrays with the data in from within flowstone?
My plan is to calibrate the loudspeakers SPL@1m output with an SPL indicated inside the software. So when I set flowstone to play a 80dbSPL 500Hz tone, I can measure something close to that in the real world. Then I could create a limiter/compressor that uses the data from the array/graph to filter its control signal to limit the output to stop over-excursion. If I add a look-ahead then it should be fairly transparent too. I guess this would need some fft stuff.
I am building a tiny pair of speakers and don't want to damage them with my compensation scheme. I want to use a linkwitz transform to lower the f3 when listening at lower levels but gradually reduce the amount of compensation when you turn it right up. I'm adding a lot of gain at low frequencies with my realtime adjustable linkwitz transform (another flowstone schematic I haven't posted on the forum yet). The problem is that its response/amount of gain is only based on the volume setting in flowstone and not based on the program material, meaning that a particularly bass heavy track can break the drivers. What you have done here is really useful because it means that I can use the data to prevent the 'bass boost' from damaging stuff because the limitations of the driver at EVERY frequency are defined in terms of thermal and more importantly in my case: cone displacement.
So hopefully I will end up with a pair so tiny speakers that have semi-decent low bass when used at low levels.
Thanks for all the hard work!
- OllieMarshall92
- Posts: 16
- Joined: Wed Oct 26, 2011 12:22 pm
Re: Ruby Array Output, Loop
OllieMarshall92 wrote:Is their an easy way to access the arrays with the data in from within flowstone?
Do you mean access from green? That should be easy to implement. Is there anything that needs to be adapted for such output, or is it just the arrays as defined by start/end/step frequency, to be used as something like a database?
I ask because I'm not very much into realtime dsp maths, but I'd suspect an array in green with 200,000+ values to be too slow to be used for a compressor? Unless it is just a database to pick a few certain values at a time, of course.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Array Output, Loop
Yea the green maths. I would only need from say 10Hz to say 300Hz in about 0.1Hz - 0.5Hz increments. If its still to slow i could just keep reducing the resolution until it works . I'm not sure quite how I'd implement the limiter but I would use the SPL value for each frequency as the limiters threshold at that frequency. Again I think it might need some sort of fft wizardry, or maybe I can offline process the results from your code, the parameters on the left won't change once the speaker is built.
- OllieMarshall92
- Posts: 16
- Joined: Wed Oct 26, 2011 12:22 pm
Re: Ruby Array Output, Loop
I've added array outputs. They just route both arrays exactly as you defined them to be calculated. See how far you come. If there are new issues coming up regarding Ruby, or if you need something (regarding Ruby), I'll try to help.
- Attachments
-
- TS Excursion Limited Power Handling2 [tula].fsm
- (163.96 KiB) Downloaded 1483 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 22 guests