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

Steve Morris steve at judgement.com
Fri Dec 27 18:08:54 EST 2013


It is hard to answer because it is hard to know what question you are
asking. Here are some possible answers:

1) The code examples can be translated to ChucK. Without context it is hard
to understand the point of the examples but all of the math is standard
stuff; supported by any programming language including ChucK.
2) ChucK supports calculated output, i.e. where the output data stream is a
mathematical function of time. That's pretty much what ChucK does.
3) You can pass a reference to a function as an argument to another

Note: Turing proved that all programming languages complex enough to be
useful are basically equivalent. In other words you can translate an
algorithm written in one programming language into any other language. "Can
you do it" is therefore not a really useful question because the answer is
generally yes. That doesn't mean all languages are the same. Some are
clearer than others or are useful for organizing code in a particular way.
More interesting questions might be "Does ChucK running on my computer have
enough horsepower to do algorithm XYZ in real time?" Or maybe "Does the
expressive power of ChucK fit well with algorithm style XYZ or will the
result be hacky and hard to read?"

All of that said the real problem in ChucK is that the capability is there
but almost totally undocumented. In ChucK a chunk of code that generates
sound is called a ugen. There is plenty of documentation about how to use
the builtin ugens but almost no documentation about how to make your own in
ChucK. The most likely approach seems to be what is called a ChuGen. A
ChuGen is an extensible class which is a ugen. You can add your own code
(by overriding the tick() method) to generate sound samples. There are
three kinds of documentation about this. 1) The release notes barely admit
the existence of ChuGens. 2) The following paper discusses them briefly. 3)
ChucK is open source. You can download the source code and try to figure it
out on your own.


It is a mystery to many of us exactly why users are not allowed to know how
to do this. Questions to this list are basically ignored except by other
users. I suspect that ChucK developers don't read this list and the real
point of this list is to hope users will support each other and stop
bothering the developers. It is also possible that there are no real
developers, that ChucK development consists of an occasional  grad student
who shows interest for a while then moves on to more productive endeavors.

I hope this helps. If you learn anything useful pass it along.


On Fri, Dec 27, 2013 at 2:46 AM, Ronni Montoya <ronni.montoya at gmail.com>wrote:

> 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.
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20131227/714d85e9/attachment.htm>

More information about the chuck-users mailing list