objects\gpio\in\analog

28 views
Skip to first unread message

DIY DSP

unread,
Apr 22, 2015, 11:42:48 PM4/22/15
to axolot...@googlegroups.com
Hi!  I have a question about analog.axo:

The krate code is:

%out%= adcvalues[%channel%]<<15;

And the values, when I send them to a disp/i object, range from 0-127.

So how does a value get left-shifted by 15 bits, then have a value from 0-127?

Thank you very much,
DIYDSP!

Evgeniy Chernyh

unread,
Apr 23, 2015, 12:33:17 AM4/23/15
to axolot...@googlegroups.com
as i understand, it's fixed point representation of int.

четверг, 23 апреля 2015 г., 8:42:48 UTC+5 пользователь DIY DSP написал:

Johannes Taelman

unread,
Apr 23, 2015, 4:38:38 AM4/23/15
to DIY DSP, axolot...@googlegroups.com
the long answer:

The "gpio/in/analog" object has a fractional output.
Fractional data (blue for control rate, red for audio rate) are integers indeed.
To the user, fractionals are represented as -64.0 to 64.0 range. This allows for 1 unit per semitone scaling. If it had been -1.0 to 1.0 users would need to deal with 0.00

Internally, the -64 to 64 range uses -0x08000000 to 0x07FFFFFF. Note that this is not using the upper 4 bits of the 32 bit integer. The upper 4 bits are "arithmetic headroom". Without arithmetic headroom, two fractionals cannot be added or subtracted with 32bit integer operations without the risk of overflow. With 4 bits "arithmetic headroom", 16 fractionals can be added without overflow.

The "disp/hex" exposes this internal representation.

The ADC is setup for 12 bit right-aligned conversion results. Left-shifting this by 15 places converts this into the 0 to 64 "user unit" range. A fractional output on the "gpio/in/analog" object abstracts the actual resolution of the conversion.

Connecting a blue outlet (fractional) to the green (integer) inlet of "disp/i" implies converting (truncating) to -64..64 range.

More details: 64.0 is not legal, 63.999999523... is the legal maximum.
When MIDI-mapped 63.5 is the practical maximum. In future, a midi-mapped parameter should be constrained to values that can be transmitted too over midi - so that sequencer-recorder MIDI reproduces the same result. Non midi mapped parameters should be able to reach 63.999...
A trick the Nord Modular did is substituting midi value 127 with 127.99... to reach a more complete range, far closer to "preserving unity" when multiplying with a full scale midi value. It is a dirty trick to remap the midi range of 0-127 to 0.0...64.0 bipolar or -64..64 for bipolar. The alternative is scaling midi with 128.0/127.0 but that deviates from 1 unit/semitone scaling.
I filed issue #27 on github to keep track of this future change.

--
You received this message because you are subscribed to the Google Groups "axoloti-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axoloti-user...@googlegroups.com.
To post to this group, send email to axolot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/axoloti-users/e834f419-66a0-400c-ac8a-8c293c0ba312%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages