| Author |
Message |
jukka_k

Joined: Sep 17, 2008 Posts: 19 Location: Finland
|
Posted: Sun Oct 05, 2008 12:16 am Post subject:
Help with waveforms |
 |
|
Hi,
I'm studying waveforms which are generated for instance by nonlinear chaotic systems, so far I've used Step UGen, like:
| Code: |
Step s => dac;
while(true) {
//some function x mapped to [-1,1]
x => s.next;
40::samp => now;
}
|
I'm sure there are other (better ?) ways to do job, any advices would be appreciated ! Especially ways to control frequency and gain (other than sampling rate and function coefficients), perhaps also FM syncing of these waveforms.
Thanks for advance !
-Jukka |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6716 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sun Oct 05, 2008 7:26 am Post subject:
|
 |
|
That's a good question... so good in fact that I don't have a straight answer. It depends on the type of chaotic system, for one thing. FM feedback is another method... especially for cross modulation but because of the nature of chaos predicting the perceived frequency of a given chaotic system simply *is* very hard.
I wouldn't start looking for very predicable chaos, at least not on this side of meditation exercises, I'd play it by ear. _________________ Modern technology offers an endless field day to any deviant strains in our personalities. --J.G.Ballard |
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Sun Oct 05, 2008 2:30 pm Post subject:
|
 |
|
| Can you model your system as a circuit of UGens? That way you could pass your input signal into a circuit which calculates your equation, and you wouldn't have to define a control rate. |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 568 Location: bangkok, thailand
Audio files: 2
|
Posted: Mon Oct 06, 2008 8:44 am Post subject:
|
 |
|
I think that is a really nice idea to start with.
just chuck x to a Step UGen.
and experiment with fuction / feedback system.
I love that also heheh. |
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 60 Location: Urbana, IL
Audio files: 4
|
Posted: Mon Oct 06, 2008 9:36 am Post subject:
|
 |
|
Moi Jukka,
If you want to control frequency, you could watch the output of Step with a UANA FFT unit, then drive your system at the peak frequency. I'm not sure if this is a good idea or not (as it might cause it to blow up), but it could be fun to try.
As with any feedback system, keep one hand on the volume knob! |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 568 Location: bangkok, thailand
Audio files: 2
|
Posted: Mon Oct 06, 2008 1:44 pm Post subject:
|
 |
|
i'm gonna join with the party.
let me try some simple ideas on this.
and might come up with some chaotic things.
as a one-liner, let me start by this nice filtered noise
| Code: | | Step s => dac; float x; while(samp => now) Std.rand2f(-1, 1) * .01 + x * .99 => x => s.next; |
defenitely not good for human ears:
| Code: | | Step s => dac; int i; while(samp => now) Math.sin(s.last() + i++) => s.next; |
that's better:
| Code: | | Step s => dac; int i; while(samp => now) Math.sin(s.last() + i++/8) => s.next; |
video game tank:
| Code: | | Step s => dac; int i; while(samp => now) Math.sin(s.last() - i++/200) => s.next; |
rhythmiglitchi:
| Code: | | Step s => dac; int i; while(samp => now) Math.sin(s.last()*pi + i++/5000) => s.next; |
chirping hum:
| Code: | | Step s => dac; int i; while(samp => now) Math.sin(s.last()*pi + i++/256) => s.next; |
At the edge:
| Code: | | Step s => dac; while(samp => now) Math.sin(Math.tan(s.last()-pi/2.1884173)*pi/2) => s.next; |
Tappin' Groovin':
| Code: | | Step s => dac; int i; while(samp => now) Math.sin(i++/4000 - s.last()*pi/2) => s.next; |
Computer! :
| Code: | | Step s => dac; int i; while(samp => now) Math.sin((maybe+=>i)/2000 - s.last()*pi) => s.next; |
wow.. i'm getting addicted to trying things -_-"
All these codes I'm writting is licenced under GNU General Public License version 3.
http://www.gnu.org/licenses/gpl-3.0.html
Copyright 2008 by Kijjasak Triyanond (kijjaz@yahoo.com) |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 568 Location: bangkok, thailand
Audio files: 2
|
Posted: Mon Oct 06, 2008 2:20 pm Post subject:
|
 |
|
An attempt to use the idea for basic waveforms:
(not optimized, quite straight-forward)
Square Wave:
| Code: | Step s => dac; // connect step to dac
1 => s.next; // initilize the signal at 1.0
440.0 => float freq; // set frequency value (can be changed any time, positive only)
float index; // index to store phase
while(samp => now)
{
freq +=> index; // add frequency to index
if (index > second/samp) // if index exceeds sample rate,
{
second/samp -=> index; // reset index
1 - s.last() => s.next; // negate the signal value (to make it alternate between -1 and 1
}
} |
Saw Wave:
| Code: | Step s => dac; // connect step to dac
440.0 => float freq; // set frequency value (can be changed any time, positive only)
float index; // index to store phase
while(samp => now)
{
freq +=> index; // add frequency to index
if (index > second/samp) second/samp -=> index; // if index exceeds sample rate, reset index
(index * 2 - 1) / (second/samp) => s.next; // scale value to -1 to 1 for use as audio signal
} |
edited: add this ..
Triangle Wave:
| Code: | Step s => dac;
440.0 => float freq;
float index;
1 => int direction;
while(samp => now)
{
2 * direction * freq +=> index;
if (Math.fabs(index) > second/samp) -1 *=> direction;
index / 48000 => s.next;
} |
All these codes I'm writting is licenced under GNU General Public License version 3.
http://www.gnu.org/licenses/gpl-3.0.html
Copyright 2008 by Kijjasak Triyanond (kijjaz@yahoo.com) |
|
|
Back to top
|
|
 |
jukka_k

Joined: Sep 17, 2008 Posts: 19 Location: Finland
|
Posted: Mon Oct 06, 2008 11:00 pm Post subject:
|
 |
|
Thanks guys of these great advices, and kijjaz of codes, I will definetely try them !
I've studied this system, a logistic map, in ChucK like this:
| Code: |
Step s => dac;
// set initial value to x
Std.rand2f(0,1) => float x;
//parameter a, between [3.0,4.0]
3.8788 => float a;
while(true) {
//logistic map
x*a*(1-x) => x;
x => s.next;
8::samp => now;
}
|
Varying parameter a changes the system from periodic to chaotic,
there is some interesting behaviour in this system, especially areas near the chaotic patterns.
Thanks !
-Jukka |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 568 Location: bangkok, thailand
Audio files: 2
|
Posted: Tue Oct 07, 2008 3:32 am Post subject:
|
 |
|
Oh yes.
The sound might be too digitally high-pitched if you run that kind of chaotic system directly iteration by iteration..
one way to bring that down is to calculate it less slowly.
for example, use this:
Step s => LPF f => dac;
to remove some high frequency and make it sound somewhat warmer and more pleasing to normal ears.
(for example, by f.set(10000, .5); )
The delay time can be adjust according to x or other variables in the loop.
for example:
| Code: | Step s => LPF f => dac;
// set initial value to x
Std.rand2f(0,1) => float x;
//parameter a, between [3.0,4.0]
3.8788 => float a;
f.set(10000, 1);
while(true) {
//logistic map
x*a*(1-x) => x;
x => s.next;
Math.pow(2, x * 3.5 + 1)::samp => now;
} |
.. can produce another distictive sound from the same set of values. |
|
|
Back to top
|
|
 |
|