How do I round to the nearest value in a list?
I think I'm the first person to ever ask a question on the new forum haha.
Basically, I want to have some sort of list, maybe stored in an array or table, with a bunch of numbers between 1 and 127 which represent a scale e.g. Cmajor (so, therefore, it will have some gaps in the list of numbers like 1, 2, 4, 5, 8, 9 etc). How would I execute this?
P.s. just to be super clear, I am aware that the round macro in core exists, but its not what I need :(, because whilst the chromatic scale would be midi numbers 1, 2, 3, 4, 5, 6, 7 and so on without any gaps, the major and minor scales will not include all 127 midi numbers :)
Best Answer
-
this gets really hairy if you are trying to just automatically round. the surefire way to do this is to have a table of size 127, and for every entry there is an output. so, for instance in your example, reading from index position 6, there would be an entry which would give the output of 5
0
Answers
-
this gets really hairy if you are trying to just automatically round. the surefire way to do this is to have a table of size 127, and for every entry there is an output. so, for instance in your example, reading from index position 6, there would be an entry which would give the output of 5
0 -
Ah okay! Thats so smart, I will try this out, thanks!
0 -
That's a good approach, however you are just moving the tricky bit from searching for the correct value to correctly populating a lookup table. Unless the list to be searched is a fixed constant thing...
Which pproach is correct depends on the specific use case. Choose the table approach if each lookup needs to be extremely efficient.. e.g. if it's an audio process. Choose a search based approach if it's a rare thing like responding to user input.
Generally, for the search, you would use either brute force - just iterate through all possible values until you get to the position where your value fits... or use a binary search to cut down the iterations.
0 -
It has to do it 512 times per note 😅
0 -
Well, that's the kind of information that should be in your initial post ;)
Why does it do it 512 times?
Are the scales being searched fixed during runtime, or are the editable by the user? and if so, how?
0 -
I'm a reaktor newbie; but I'd want to do math to drop it down to 12 options. I mocked up an example, but can't seem to post the ensemble hereIf you do something like that, the 'base' output will be 0-11; those are the only values you need to worry about. Modify as needed and then add "shift" to get back to the right octave. If you want C# to play D, it doesn't matter if it's note 1 or 13 or 25 or 121. Find what the note would be in octave 0, modify it and then go back up to the right octave.All of that said; I'm not sure if this is horrible design in reaktor or how it would perform
0 -
darkwaves said:I'm a reaktor newbie; but I'd want to do math to drop it down to 12 options. I mocked up an example, but can't seem to post the ensemble hereIf you do something like that, the 'base' output will be 0-11; those are the only values you need to worry about. Modify as needed and then add "shift" to get back to the right octave. If you want C# to play D, it doesn't matter if it's note 1 or 13 or 25 or 121. Find what the note would be in octave 0, modify it and then go back up to the right octave.All of that said; I'm not sure if this is horrible design in reaktor or how it would perform0
-
I don't have a clue what you're up to but the LIST under panel can contain any number you like in each entry. I'm not sure if you can access it via IC send/receive from an internal source. It has 1024 entries, maybe enter the scale modes in it, major minor etc.in using 12 entries for each mode. You can also round to any area by dividing the input before the math round. Example 0 to 11 divided by 12 then rounded will produce 0 or 1 but adding .5 after the divisor will result in a 1, although .5 can go either way. So 12 to 23 will round to 2 and so on. The round out could indicate which note is in what octave, or perhaps the base of an index for a mode select if accessing the LIST module. Food for thought, about it.
0
Categories
- All Categories
- 19 Welcome
- 1.3K Hangout
- 58 NI News
- 654 Tech Talks
- 3.4K Native Access
- 14.4K Komplete
- 1.7K Komplete General
- 3.7K Komplete Kontrol
- 5K Kontakt
- 1.5K Reaktor
- 344 Battery 4
- 752 Guitar Rig & FX
- 390 Massive X & Synths
- 1K Other Software & Hardware
- 4.8K Maschine
- 6.3K Traktor
- 6.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators