electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Help with waveforms
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
jukka_k



Joined: Sep 17, 2008
Posts: 19
Location: Finland

PostPosted: Sun Oct 05, 2008 12:16 am    Post subject: Help with waveforms Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6716
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Oct 05, 2008 7:26 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Sun Oct 05, 2008 2:30 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Mon Oct 06, 2008 8:44 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
rogan



Joined: Dec 16, 2007
Posts: 60
Location: Urbana, IL
Audio files: 4

PostPosted: Mon Oct 06, 2008 9:36 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Mon Oct 06, 2008 1:44 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Mon Oct 06, 2008 2:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
jukka_k



Joined: Sep 17, 2008
Posts: 19
Location: Finland

PostPosted: Mon Oct 06, 2008 11:00 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Tue Oct 07, 2008 3:32 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Buy N Save

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com