function for creating 8 bit waveforms from expressions
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.
Ronni,
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
function.
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.
https://ccrma.stanford.edu/~spencer/publications/CCC2012.pdf
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.
-steve
On Fri, Dec 27, 2013 at 2:46 AM, Ronni Montoya
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Sorry the example I was looking at when I mentioned that was not really a
function reference but it gets the same result. It does so by using ChucK
class functionality that in other languages is called polymorphism. It is
described in ChucK language documentation.
http://chuck.cs.princeton.edu/doc/language
See the example class Xfunc in the inheritence section. What is done is to
create a base class with a standard class function (in the example called
doSomething().) For each different version of function that is needed a new
class is created which inherits the base class and overrides doSomething()
with the new code. The "calling function" is then declared with a base
class object as an argument. You can pass it any object that inherits the
base class (in this case Xfunc.) When it calls the doSomething() method it
invokes the overridden version from the derived class.
The example doesn't create a function to do this but it shows an example of
common code calling different functions from different classes. It does
this by creating an array containing objects from different classes and
then calling the different versions in a loop using the array. Clearly the
common code in the loop could have been a function.
I'm away from my ChucK machine at the moment but if anyone is interested I
could try to create a simple example which does the inner work (calling a
passed in function) in a function. As usual the documentation is vague but
I believe the function version of the example would look something like:
fun int callFunc(Xfunc @ in, int a, int b)
{
return in.doSomething(a,b);
}
// loop over the Xfunc
for( 0 => int i; i < operators.cap(); i++ )
{
// doSomething, potentially different for each Xfunc
<<< callerFunc(operators[i], 4, 5 ) >>>;
}
-steve
On Fri, Dec 27, 2013 at 7:03 PM, Dealga McArdle
re: Steve Morris
3) You can pass a reference to a function as an argument to another
function.
how? :) I haven't found how to do that anywhere.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 12/27/2013 05:08 PM, Steve Morris wrote:
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.
There is a ChuGen example in the examples/extend folder; it's extremely straight-forward. I know the devs read this list, but honestly this is exactly the kind of question we as a community should be able to help with. Let's light some candles rather than curse the darkness. Now, ChuGen takes floats in the range [-1,1] for its calculations, but you want to work on 8-bit ints, so you'll have to have functions that convert itof and ftoi. Then you can write your expression to work on those samples directly. A Phasor UGen then provides the 0-1 samples in. Try this: -- // ChuGen // Create new UGens by performing audio-rate processing in ChucK class MyFunc extends Chugen { 8 => int _b; // default 8 bits fun float tick(float in) { ftoi (in, _b) => int ival; // convert in sample to int my_expression(ival) % (1 << _b) => int fval; //calculate and mod into range return (itof (fval, _b)); // convert back to float } // your custom expression goes here fun int my_expression (int t) { return t * ( t >> 8 * ( t >>15 | t >> 8) & 20 | ( t >>19) * 5
t | t >> 3); }
// helper function to convert float [0,1] to b bits fun int ftoi (float in, int b) { return (in * (1 << b)) $ int; } // helper function to convert b bit integer to float [-1,1] fun float itof (int in, int b) { return (in * 1.0 / (1 << (b-1))) - 1; } // allow user to set number of bits fun void bits (int b) { b => _b; } } // phasor powers the function with numbers ascending 0-1 Phasor p => MyFunc f => dac; 1 => p.freq; while(true) 1::second => now; /// END /// Joel
Of course this isn't exactly what you asked about, since it takes in an 8-bit number and you want to take in a number [0-8000], but maybe this will get you started. Maybe Steve can help with how to pass an expression as a reference, which would make it possible to change the expression on the fly. Joel On 12/27/2013 06:13 PM, Joel Matthys wrote:
On 12/27/2013 05:08 PM, Steve Morris wrote:
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.
There is a ChuGen example in the examples/extend folder; it's extremely straight-forward. I know the devs read this list, but honestly this is exactly the kind of question we as a community should be able to help with. Let's light some candles rather than curse the darkness.
Now, ChuGen takes floats in the range [-1,1] for its calculations, but you want to work on 8-bit ints, so you'll have to have functions that convert itof and ftoi. Then you can write your expression to work on those samples directly. A Phasor UGen then provides the 0-1 samples in. Try this:
-- // ChuGen // Create new UGens by performing audio-rate processing in ChucK
class MyFunc extends Chugen { 8 => int _b; // default 8 bits
fun float tick(float in) { ftoi (in, _b) => int ival; // convert in sample to int my_expression(ival) % (1 << _b) => int fval; //calculate and mod into range return (itof (fval, _b)); // convert back to float }
// your custom expression goes here fun int my_expression (int t) { return t * ( t >> 8 * ( t >>15 | t >> 8) & 20 | ( t >>19) * 5
t | t >> 3); }
// helper function to convert float [0,1] to b bits fun int ftoi (float in, int b) { return (in * (1 << b)) $ int; }
// helper function to convert b bit integer to float [-1,1] fun float itof (int in, int b) { return (in * 1.0 / (1 << (b-1))) - 1; }
// allow user to set number of bits fun void bits (int b) { b => _b; } }
// phasor powers the function with numbers ascending 0-1 Phasor p => MyFunc f => dac; 1 => p.freq;
while(true) 1::second => now;
/// END ///
Joel _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hi , i been trying to run the code Joel posted.
Im still noobie and i havent worked with classes before on chuck.
I created 2 .ck files, one called MyFunc.ck with the class and another
called Phasor.ck with the rest of the code.
ive tried "chuck MyFunc.ck Phasor.ck" in my commnand line but im
getting this error message:
[Phasor.ck]:line(1): undefined type 'MyFunc'...
[Phasor.ck]:line(1): ... in declaration ...
any idea what am i doing wrong?
2013/12/27, Joel Matthys
Of course this isn't exactly what you asked about, since it takes in an 8-bit number and you want to take in a number [0-8000], but maybe this will get you started.
Maybe Steve can help with how to pass an expression as a reference, which would make it possible to change the expression on the fly.
Joel
On 12/27/2013 06:13 PM, Joel Matthys wrote:
On 12/27/2013 05:08 PM, Steve Morris wrote:
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.
There is a ChuGen example in the examples/extend folder; it's extremely straight-forward. I know the devs read this list, but honestly this is exactly the kind of question we as a community should be able to help with. Let's light some candles rather than curse the darkness.
Now, ChuGen takes floats in the range [-1,1] for its calculations, but you want to work on 8-bit ints, so you'll have to have functions that convert itof and ftoi. Then you can write your expression to work on those samples directly. A Phasor UGen then provides the 0-1 samples in. Try this:
-- // ChuGen // Create new UGens by performing audio-rate processing in ChucK
class MyFunc extends Chugen { 8 => int _b; // default 8 bits
fun float tick(float in) { ftoi (in, _b) => int ival; // convert in sample to int my_expression(ival) % (1 << _b) => int fval; //calculate and mod into range return (itof (fval, _b)); // convert back to float }
// your custom expression goes here fun int my_expression (int t) { return t * ( t >> 8 * ( t >>15 | t >> 8) & 20 | ( t >>19) * 5
t | t >> 3); }
// helper function to convert float [0,1] to b bits fun int ftoi (float in, int b) { return (in * (1 << b)) $ int; }
// helper function to convert b bit integer to float [-1,1] fun float itof (int in, int b) { return (in * 1.0 / (1 << (b-1))) - 1; }
// allow user to set number of bits fun void bits (int b) { b => _b; } }
// phasor powers the function with numbers ascending 0-1 Phasor p => MyFunc f => dac; 1 => p.freq;
while(true) 1::second => now;
/// END ///
Joel _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
See my post about polymorphism. To "pass in an expression in on the fly"
you need to wrap the function in a polymorphic class and "on the fly" pass
a reference to that class instead. For example if you are doing this in a
ChuGen you can create a class variable to hold a reference to the "current"
expression object. At the appropriate time you can assign a new class to
the reference variable in much the same way you would change the gain or
frequency on the fly. The tick() method would call the current function
through the reference variable. You can then put the common code directly
in the ChuGen and code you want to change at run time in the referenced
object.
This is all simpler if all classes are defined in the same file and thread
but I believe that if you are clever the new code doesn't even need to be
defined when the ChuGen is started. All it needs is for the base class to
be defined. You could connect and start up the ChuGen and then weeks later
write new code and put it into the reference variable of the running
ChuGen. The tricky part is how to pass the new object from a different
thread. This requires using static class variables which is a subject for a
different post.
-steve
PS all the helper functions you can imagine are probably already written
and available in the LiCK Library for ChucK. If you don't have it already
you should get it immediately. Half the things I was originally planning of
writing in ChucK I found already implemented in LiCK. It is also a great
thing to read if you want to see how complex things can be done in ChuCK.
On Fri, Dec 27, 2013 at 7:16 PM, Joel Matthys
Of course this isn't exactly what you asked about, since it takes in an 8-bit number and you want to take in a number [0-8000], but maybe this will get you started.
Maybe Steve can help with how to pass an expression as a reference, which would make it possible to change the expression on the fly.
Joel
On 12/27/2013 06:13 PM, Joel Matthys wrote:
On 12/27/2013 05:08 PM, Steve Morris wrote:
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.
There is a ChuGen example in the examples/extend folder; it's extremely straight-forward. I know the devs read this list, but honestly this is exactly the kind of question we as a community should be able to help with. Let's light some candles rather than curse the darkness.
Now, ChuGen takes floats in the range [-1,1] for its calculations, but you want to work on 8-bit ints, so you'll have to have functions that convert itof and ftoi. Then you can write your expression to work on those samples directly. A Phasor UGen then provides the 0-1 samples in. Try this:
-- // ChuGen // Create new UGens by performing audio-rate processing in ChucK
class MyFunc extends Chugen { 8 => int _b; // default 8 bits
fun float tick(float in) { ftoi (in, _b) => int ival; // convert in sample to int my_expression(ival) % (1 << _b) => int fval; //calculate and mod into range return (itof (fval, _b)); // convert back to float }
// your custom expression goes here fun int my_expression (int t) { return t * ( t >> 8 * ( t >>15 | t >> 8) & 20 | ( t >>19) * 5 >> t | t >> 3); }
// helper function to convert float [0,1] to b bits fun int ftoi (float in, int b) { return (in * (1 << b)) $ int; }
// helper function to convert b bit integer to float [-1,1] fun float itof (int in, int b) { return (in * 1.0 / (1 << (b-1))) - 1; }
// allow user to set number of bits fun void bits (int b) { b => _b; } }
// phasor powers the function with numbers ascending 0-1 Phasor p => MyFunc f => dac; 1 => p.freq;
while(true) 1::second => now;
/// END ///
Joel _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
For the record I don't mean to "Curse the Darkness". I am merely helping to
set expectations. I think the developers have done more than enough by
releasing ChucK open source. It is a wonderful tool and it is pretty high
quality bug wise. There is no reason however to pretend that ChucK is well
supported, at least where advanced functionality is concerned, and it is
not a criticism of the authors and developers to say so. This is not
unusual with open source software. The developers have their priorities and
their own lives to lead and are under no obligation to do anything
different. It's not like they get paid for this. The level of support is
just an important piece of information to have when you are considering
using Chuck. If you need a lot of support you might do better to consider
other similar tools. There are many available and some have more extensive
support.
-steve
On Fri, Dec 27, 2013 at 7:13 PM, Joel Matthys
On 12/27/2013 05:08 PM, Steve Morris wrote:
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.
There is a ChuGen example in the examples/extend folder; it's extremely straight-forward. I know the devs read this list, but honestly this is exactly the kind of question we as a community should be able to help with. Let's light some candles rather than curse the darkness.
Now, ChuGen takes floats in the range [-1,1] for its calculations, but you want to work on 8-bit ints, so you'll have to have functions that convert itof and ftoi. Then you can write your expression to work on those samples directly. A Phasor UGen then provides the 0-1 samples in. Try this:
-- // ChuGen // Create new UGens by performing audio-rate processing in ChucK
class MyFunc extends Chugen { 8 => int _b; // default 8 bits
fun float tick(float in) { ftoi (in, _b) => int ival; // convert in sample to int my_expression(ival) % (1 << _b) => int fval; //calculate and mod into range return (itof (fval, _b)); // convert back to float }
// your custom expression goes here fun int my_expression (int t) { return t * ( t >> 8 * ( t >>15 | t >> 8) & 20 | ( t >>19) * 5 >> t | t >> 3); }
// helper function to convert float [0,1] to b bits fun int ftoi (float in, int b) { return (in * (1 << b)) $ int; }
// helper function to convert b bit integer to float [-1,1] fun float itof (int in, int b) { return (in * 1.0 / (1 << (b-1))) - 1; }
// allow user to set number of bits fun void bits (int b) { b => _b; } }
// phasor powers the function with numbers ascending 0-1 Phasor p => MyFunc f => dac; 1 => p.freq;
while(true) 1::second => now;
/// END ///
Joel _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hello Ronni,
Might you have a link to the paper you are referring to? Something is
lost to me in the specification of the algorithm.
I am reminded of this
http://createdigitalmusic.com/2011/10/entire-musical-compositions-made-from-...
http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-l...
http://countercomplex.blogspot.com/2011/10/some-deep-analysis-of-one-line-mu...
Cheers,
michael
On Fri, Dec 27, 2013 at 1:46 AM, Ronni Montoya
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
hey, i found a link to the paper, i hope you enjoy it:
http://cilab.math.upatras.gr/mikeagn/sites/cilab.math.upatras.gr.mikeagn/fil...
2013/12/28, Michael Heuer
Hello Ronni,
Might you have a link to the paper you are referring to? Something is lost to me in the specification of the algorithm.
I am reminded of this
http://createdigitalmusic.com/2011/10/entire-musical-compositions-made-from-...
http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-l...
http://countercomplex.blogspot.com/2011/10/some-deep-analysis-of-one-line-mu...
Cheers,
michael
On Fri, Dec 27, 2013 at 1:46 AM, Ronni Montoya
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hi again, these days i been experimenting with the code Joel posted, i
discovered some things and got some questions.
where is the time of the waveform defined?
i experimented changing all values and also with many expression and
the length of the waveform remains the same ( there is a waveform that
loops for ever) .
do anybody have an idea where the length of the waveform is defined
and how to change it?
Other thing i noticed is that changing the values in the expressions
changes the timbre ( or texture ? ) of the sound in a subtle way while
the structure remains the same.
So i was thinking that instead of having values in the expression, Is
it possible to have an oscilator or brown noise generator?
.......having a brown noise generator instead of a value will allow
that the texture of the sound will change all the time.
Other thing i noticed is that the paper is posted before and the
algorithm for generating this kind of functions is based on the
implementation from the links Michael posted before.
If you listen those examples you will notice that the sound changes
all the time, there is no repetitiveness , it creates sound structures
at different time scale and this is the potential in this way of
sonifying expression.
any idea why Joels implementation only generate a sound withouth
variability as the examples posted by Michael?
and my last question:
I been working with other programming languages for sound as
supercollider and there are different ways of generating waveforms
from functions, basically the way i was doing this is that first i
create the function and then i call the function that creates the
whole waveform and then i just read my waveform but i see in the code
posted by Joel that it works in a different way : first i generate the
function and then i generate the waveform at the same time I generate
the sound calling the function each sample .
I was wondering is this something specific to chuck? I mean calling
the function each sample while it generates the sound.... is this
approach possible with other programming languages?
2013/12/29, Ronni Montoya
hey, i found a link to the paper, i hope you enjoy it:
http://cilab.math.upatras.gr/mikeagn/sites/cilab.math.upatras.gr.mikeagn/fil...
2013/12/28, Michael Heuer
: Hello Ronni,
Might you have a link to the paper you are referring to? Something is lost to me in the specification of the algorithm.
I am reminded of this
http://createdigitalmusic.com/2011/10/entire-musical-compositions-made-from-...
http://countercomplex.blogspot.com/2011/10/algorithmic-symphonies-from-one-l...
http://countercomplex.blogspot.com/2011/10/some-deep-analysis-of-one-line-mu...
Cheers,
michael
On Fri, Dec 27, 2013 at 1:46 AM, Ronni Montoya
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (5)
-
Dealga McArdle
-
Joel Matthys
-
Michael Heuer
-
Ronni Montoya
-
Steve Morris