# [chuck-users] function for creating 8 bit waveforms from expressions

Ronni Montoya ronni.montoya at gmail.com
Fri Dec 27 02:46:41 EST 2013

```Hi list, i been reading a paper that talks about an approach for
generating sound that uses functions to directly shape waveforms. The
function receives "expresions" as argument and it generates different
kind of 8 bit waveforms from the expressions.

An expression can look like this:

f(t) = t * ( t >> 8 * ( t >>15 | t >> 8) & 20 | ( t >>19) * 5 >> t | t >> 3))

The paper describes the algorithm in this way:

algorithm 1 :
Construction of an 8-bit waveform of 8000Hz  sample rate:

The function has 2 inputs :

Input 1) a functional expresion f(t)
Input  2 ) time durations in seconds (d)
Output: the waveform of an audio signal with seconds duration

for t = 1 to d8000 do
if f(t) ==NaN then
q(t)  <-- 0
else
q(t) <-- mod(f(t)), 256)
end if
s(t) <-- 2 q(t)/255 - 1
end for

If its possible to implement this approach for generating sound in chuck??

cheers

R.
```