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] Linear Scale Transform (now with Midi Example)
2 posts
• Page 1 of 1
[Ruby] Linear Scale Transform (now with Midi Example)
1st post
This Ruby math element transforms a scale linearly from standard 0-1 scale to whatever scale you have use for.
You can hard code the min/max numbers or make them externally selectable as shown in the example.
I don't know how many greens it would take to do this function and I'm not going to try
You can of course change the numbers from any "old" scale to any "new" scale - You can scale up, down or sideways, haha - i.e 0-10 to 2-10 etc...
I scaled it back again to show accuracy - turn the knob and you'll see it's not 100% accurate all the time - but we're talking on the micro number level - nothing that's ever affected any application I've used this for.
You can use integer output instead of float if you need whole numbers as shown in the example as well.
To give an idea of more advanced uses - I've used a similar technique with float arrays for sample accurate midi velocity and CC# sequencing in a Ruby arpeggiator, but that is beyond the scope of this simple demonstration.
(See edit)
This could be done in one line if you need a hard-coded linear scale transform.
edit: I've attached a more advanced Midi example using a float array transformed to 1-127 sending velocity data
Here's the math:
This Ruby math element transforms a scale linearly from standard 0-1 scale to whatever scale you have use for.
You can hard code the min/max numbers or make them externally selectable as shown in the example.
I don't know how many greens it would take to do this function and I'm not going to try
You can of course change the numbers from any "old" scale to any "new" scale - You can scale up, down or sideways, haha - i.e 0-10 to 2-10 etc...
I scaled it back again to show accuracy - turn the knob and you'll see it's not 100% accurate all the time - but we're talking on the micro number level - nothing that's ever affected any application I've used this for.
You can use integer output instead of float if you need whole numbers as shown in the example as well.
To give an idea of more advanced uses - I've used a similar technique with float arrays for sample accurate midi velocity and CC# sequencing in a Ruby arpeggiator, but that is beyond the scope of this simple demonstration.
(See edit)
This could be done in one line if you need a hard-coded linear scale transform.
edit: I've attached a more advanced Midi example using a float array transformed to 1-127 sending velocity data
Here's the math:
- Code: Select all
new_value = ( ( old_value - old_min ) / (old_max - old_min) ) * (new_max - new_min) + new_min
- Attachments
-
- Ruby_Linear_Scale_Midi.fsm
- (20.89 KiB) Downloaded 1324 times
-
- Ruby_Linear_Scale_Example.fsm
- (11.95 KiB) Downloaded 1296 times
- mikefiction
- Posts: 1
- Joined: Wed Feb 06, 2013 1:25 am
Re: [Ruby] Linear Scale Transform (now with Midi Example)
Hi Mike, welcome to the forum.
Great to see such a nicely documented example in a first post - and thanks for the credit on the MIDI readout.
The MIDI one could be worked up into quite a nice step sequencer example, I think. Here's a step (sorry, bad pun!) in that direction, that demonstrates how to use a couple of method definitions and event scheduling - to capture only the counter changes, and also to create some note-offs...
Great to see such a nicely documented example in a first post - and thanks for the credit on the MIDI readout.
The MIDI one could be worked up into quite a nice step sequencer example, I think. Here's a step (sorry, bad pun!) in that direction, that demonstrates how to use a couple of method definitions and event scheduling - to capture only the counter changes, and also to create some note-offs...
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 93 guests