# [chuck-users] 8-bit?

Tom Lieber tom at alltom.com
Sat Nov 27 22:42:00 EST 2010

```On Thu, Nov 18, 2010 at 10:44 AM, Andrew Turley <aturley at acm.org> wrote:
> You could build a generator using Gen7 or CurveTable. That might be a
> little more efficient, but maybe not worthwhile.

2010/11/18 Kassen <signal.automatique at gmail.com>:
> How about a Lisa set to sync? If you feed that with a arbitrary signal at
> gain .5 mixed with a step set to a value of .5, (which would turn a signal
> from range -1 to 1 into one from 0 to 1) you can set any mapping you'd like.
> Filling that LiSa with a line from -1 to 1 would get you your original
> signal back, a "staircase" would give bit-depth reduction, etc.
> Multiple mappings could be made and by changing the loop start and end these
> could be selected.

I'm grateful that Kassen dropped some code for LiSa, because I didn't
understand his description until I was knee deep in CurveTables and
had finally worked through all the problems Kassen's succinct proposal
addresses. While I got the CurveTable working, I can't get real sharp
transitions between the quantization levels because CurveTable crashes
if I give it a coefs array with more than 35 points.

So I think I'll be using LiSa because it doesn't crash with longer
buffers to get around the linear interpolation. Thanks everybody,
especially Kassen and Andrew.

(here's the CurveTable code:

SinOsc s;
CurveTable c;
Step dc;

s => c => dac;
dc => c;

.49 => s.gain;
.5 => dc.next;

35 => int res; // # of CurveTable points
4 => int levels; // # of quantization levels (/ 2)

// build CurveTable coefs
levels => float flevels;
float coefs[res * 3 + 2];
for( 0 => int r; r < res; r++ ) {
((r \$ float) / res) * 2 - 1 => float f; // [0, res) -> [-1, 1)

// the triplet
r => coefs[r * 3]; // time
((f * levels) \$ int) / flevels => coefs[r * 3 + 1]; // value
0 => coefs[r * 3 + 2]; // curvature (linear)
}
res => coefs[res * 3]; // time
1 => coefs[res * 3 + 1]; // value
coefs => c.coefs;

day => now;

)

--
Tom Lieber
http://AllTom.com/
http://favmusic.net/
```