yea I was going to suggest that but if you need it precisely you will need to add a small amount for each value such that at 127 you add 2, and at 0 you add 0. This, more or less, you can tinker with it if you want to.
1 2 3 4 5 6 7 8 9
for(a = 0; a < 128; a++)
{
b = (a-128) + a + (a+1)/64; //edit: I like a+1 a little better here
//but the +1 depends on whether you want the roundoff on the low or high end.
//or you can try to add even more junk to it so both ends match a little better.
//one cheesy way is to do BOTH the +1 and not, and make a lookup table where you take
//half of each result.
cout << a << " " << b << endl;
}
doing it on both ends, then, like the lookup table I mentioned but via computations:
b = (a-128) + a + (a+(a-64>0))/64;
Hey, in the mean time I found out that I don't need negative values, so the conversion would be from 0to120 -> 0to255 do the math would be *2,125 I think? but i can't have digit values so i guess it needs to be rounded, i don't know the syntax for that
yea the math side is just round(a/127.0 * 256 -128).
that is simple: you take the percent of what you have * the percent of the RANGE-DISTANCE you want and then shift the result to fit in the range you wanted.
but the midi/music side isnt, and I was trying to account for it (very badly) above.
I am starting to think you really are going to just want a lookup table.
Are these the correct numbers you are looking for?
1 2 3 4 5 6 7 8 9
#include <iostream>
int main() {
for (unsigned a {}; a <= 120; ++a) {
constauto b {static_cast<unsigned>(a * 2.125 + 0.5)};
std::cout << a << " " << b << '\n';
}
}
so the thing is the midi note does'nt needs to be translated to hertz, a piano indeed has 88 keys as againtry's link. but a midi synth can go from 0 to 120, this will then be outputted to a tuning knob that goes from -128 to 127. So I think that will work with basic math, I'm only receiving the synth tonight so I can't test for the moment, will keep you guys updated how it goes!!!