Is there a way to condense this code into 1 or 2 nested for loops? The array converted sometimes contains repetitions that I have to discount before adding the array elements to obtain a single ID for their source. Thank you in advance.
The last one "currentChord += converted [5]" is also executed, because 'j' will be '6'. For number '6' the 'j'-loop is not run and the converted [5] is added to currentChord.
Think again. The [ i + 1 ] for index 5 will test against something outside the array.
You would have to add an extra seventh number with a very high value to the array to make this work.
No, but I might be able to rewrite other sections of the program to make that work. The elements of converted are always 2 raised to a power between 1 & 12.
A typical example would be {2^5, 2^8, 2^1, 2^5, 0} or {2^4, 2^8, 2^1, 2^4, 2^8). Data type is float.
Probably no good reason. I haven't really looked into how to cast.
converted is generated by consulting an array of floats that looks like {1, 1.067, 1.125, 1.2, 1.25, 1.33, 1.5, 1.4, 1.6, 1.7, 1.8, 1.875}. The index value of a float in play becomes the exponent.
When I declared converted as an array of ints, I got a weird error from the compiler about being out of registers.
I got a weird error from the compiler about being out of registers.
So, you fooled it by creating a bunch of additional work for it to do (and for the Arduino to do each and every time it access the array), instead of fixing the problem. I see...
Are you trying to do musical intervals? In that case the exponent is divided by 12. So converted seems to have values of 2n/12. Are your arrays intended to contain that kind of number?