Hell all,
I have searched around and found a few similar posts (https://sebiik.github.io/community.axoloti.com.backup/t/types-conversion-bit-shifting-and-friends/2329), but I couldn't find anything that clarified things for me, so I'm starting a new thread.
I am working on a granular audio freezer. I am using jt/granular/graintable.
I am hoping to feed a value from a table into the bipolar "pos" input on graintable. I want this to be very precise so I can play grains from a very specific position in the audio table. I am using a similar granular synth in supercollider (where I have more programming ability) to "explore" the sound file using my mouse x position. In the SuperCollider synth, the pointer into the sound file is a value from 0 to 1.0. So I need to translate this value into a very precise bipolar Axoloti voltage. (The reason I am using SuperCollider is because I like the pitch detectors in SC, and I am trying to "freeze" the granular sample player on regions of the audio file that have a clear pitch.)
I have been on a bit of a journey to try to figure out how to do this. I wrote a table with some bipolar values in axoloti, saved that tabel to a raw file, and then inspected it with a hex editor. As far as I can tell, these are the rules for writing values which can be loaded into a table to read on the axoloti to provide the bipolar voltage values:
pointer from 0..1
[0.0-0.5) corresponds to negatives on a bipolar dial
in hex string, F in first place (0xFXXXX) indicates negative
0 in pointer is (-)0, or 0xF0000 in hex string
0.5 in pointer is (-)65536, or 0xFFFFF in hex string
so take integer (0 to 65536) as Hex String + 0xF0000 to get number
take that number and write it to the binary file as a 16 bit Little Endian integer
[0.5-1.0] corresponds to positives on bipolar dial
this is simply (0-65536) as Hex String written to a binary file as a 16 bit Little Endian integer
However, when I tested my mental model in Supercollider, trying to go from values read on a bipolar dial display in Axoloti to the hex values to write in the raw file, I didn't get the expected behavior.
//testing my ability to go from desired place on bipolar knob to raw binary hex file
//test numbers: -26.70, 5.64, -4.70, 56.10
//-26.7:
64-26.7; // 37.3
(37.3/64.0)*65536; // ~38195
(38195 + 0xF0000).asHexString; // 0xF9533 or
0xF9533; // 1021235
// BUT this is actually -53.4 on the axoloti dial
(5.64/128.0)*65536; // ~5775, simpler because positive
5775.asHexString; // 0x0168F
0x0168F; //5775
// BUT this is actually 11.28 on the axoloti dial
64-4.7; // 59.3
(59.3/128.0)*65536; // ~60723
(60723+0xF0000).asHexString; // 0xFED33
0xFED33; // 1043763
// BUT this is actually -9.4 on the axoloti dial
(56.10/128.0)*65536; // ~57446
57446.asHexString; // 0x0000E066
0x0000E066; // 57446
// BUT this is actually -15.8 on the axoloti dial
Can anyone help me understand what I'm getting wrong in trying to write data to a file manually to be read into a table in the Axoloti and produce a desired voltage? Thanks!