electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
  EdisonRex Edison's Electronic Review
  Twyndyllyngs Special Monday edition of Chez Mosc
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
granular synthesis methods for ChucK
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 4 [82 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: 1, 2, 3, 4 Next
Author Message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Wed Nov 01, 2006 2:58 pm    Post subject:  granular synthesis methods for ChucK
Subject description: How do i program effectively for Granular Synthesis technics?
Reply with quote  Mark this post and the followings unread

i've been checking out some sounds of the granular synthesis methods..
and tried some
(mostly by incorporating random / chaos / fractal math in the process)
(and mostly by using sinusoids and white noise as the source -_-")

now i'm moving my ideas from csound to chuck..
so i'd like to know your technics.
how do i apply granular synthesis effectively in chuck?
i mean.. in terms of.. the source code (easy to code + understand & not too long)
cpu, ram ..
and flexibility.

i've got some ideas in my head now..
- using array of ugens to create layering grains
(hope it's cpu-friendly enough)
- function sporking
(i guess.. more flexible but can be hard on CPU / Ram?)
- any other poppular methods?

please recommend some methods..
i'll try them right away ^_^

love love.

Last edited by kijjaz on Fri Nov 03, 2006 3:17 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Wed Nov 01, 2006 3:15 pm    Post subject: Reply with quote  Mark this post and the followings unread

i don't know

but i've been thinking about this a lot.

ge?

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Wed Nov 01, 2006 4:42 pm    Post subject: Reply with quote  Mark this post and the followings unread

this is how i tried one idea today.
the function looks easy to use..
but BRUTE-FORCE... hahahah
and it sent miniAudicle to hell (dead and suffering) many times.

hahah i should try a more effective sporking idea..
so i can save RAM and CPU..
i should cut out the delay thing in the grain function
and work on that in the main program flow instead.


Code:
// connect mainmixer as a gain to waveshaper to dac
Gain mainmixer => SinOsc waveshaper => dac;
waveshaper.sync(1);
// set master gain
mainmixer.gain(0.5);

// function for playing one sinusoidish grain with sine envelope
fun void playsinegrain(dur d, float a, float f, dur delay) {
   // hey wait... err..
   delay => now;
   // main grain signal, set frequency to with's specified
   SinOsc s => mainmixer;
   s.freq(f);
   // producing an envelope which will run only 180 degree within duration d
   // so it'd be the positive half of the sine wave
   SinOsc env => blackhole;
   env.freq(1 / (d / second) * .5);
   // playing the grain
   for(0 => int i; i < 1000; i++) {
      // envelope the main signal
      s.gain(a * env.last());
      // let 1/40 of d pass
      d * 0.001 => now;
   }
   // unchuck the signal
   s =< mainmixer;
}

// now.. ready to spork things up!

// 500 grains are enough to kill my miniAudicle on MacBook
for(int i; i < 500; i++) {
   1 => float r;
   for(int j; j < 20; j++) Std.rand2f(0.5, 2) *=> r; // start out with a bell-shaped distribution random number
   spork ~ playsinegrain(2::ms, 0.2, 8 * r, r :: second * .01); // wait and play those..
}

// wait and see if your machine survive.
while(true) second => now;
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


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

PostPosted: Thu Nov 02, 2006 1:28 am    Post subject: Reply with quote  Mark this post and the followings unread

I don't have the time to look into this code in depth right now but I love the line "spork things up"!
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cebec



Joined: Apr 19, 2004
Posts: 1064
Location: Virginia
Audio files: 3
G2 patch files: 31

PostPosted: Thu Nov 02, 2006 7:20 am    Post subject: Reply with quote  Mark this post and the followings unread

man, that is quite cool!

i could get several thousand grains on my XP PC w/ miniAudicle before things started to act/sound wrong. i'm only on a single-core P4, here, too. hmmm.
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Fri Nov 03, 2006 12:36 am    Post subject: Reply with quote  Mark this post and the followings unread

i've modified the same code
mainly by removing the delay in the grainplayer.
so now the placement of the grain is controlled mainly from the main program flow.

it sounds more effective now.


Code:
// connect mainmixer as a gain to waveshaper to dac
Gain mainmixer => SinOsc waveshaper => dac;
waveshaper.sync(1);
// set master gain
mainmixer.gain(0.5);

// function for playing one sinusoidish grain with sine envelope
fun void playsinegrain(dur d, float a, float f) {

   // main grain signal, set frequency to with's specified
   SinOsc s => mainmixer;
   s.freq(f);
   // producing an envelope which will run only 180 degree within duration d
   // so it'd be the positive half of the sine wave
   SinOsc env => blackhole;
   env.freq(1 / (d / second) * .5);
   // playing the grain
   for(0 => int i; i < 1000; i++) {
      // envelope the main signal
      s.gain(a * env.last());
      // let 1/40 of d pass
      d * 0.001 => now;
   }
   // unchuck the signal
   s =< mainmixer;
}

// now.. ready to spork things up!

Noise n => LPF f => blackhole;
f.freq(.1);

while(true)
{
   spork ~ playsinegrain((n.last()+1)::ms, .5, (n.last()+1)*800);
   Std.rand2f(n.last() * n.last(), 2) * 3 :: ms => now;
}

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: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Fri Nov 03, 2006 3:29 am    Post subject: Reply with quote  Mark this post and the followings unread

Rolling Eyes but still...
the method's not so effective for me..
only a few grains would make buffer overrun here -_-"

i'll try some more effective ways
with limited number of grains.
(so i can limit the cpu / ram consumption rate)
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: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Mon Jan 08, 2007 3:11 pm    Post subject: Reply with quote  Mark this post and the followings unread

hello all again..

i still haven't tried any further Granular Synthesis on ChucK. Embarassed
i've been checking out some pdfs online from google lately,
and i've found this one: Implementing Real-Time Granular Synthesis
www.audiomulch.com/~rossb/rb-gst/BencinaAudioAnecdotes310801.pdf

i haven't read all of it but there might be some methods i should try
especially for minimizing CPU & RAM consumption while creating interesting results.

i'll try to update my progress in this regularly.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


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

PostPosted: Mon Jan 08, 2007 3:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

Somewhere in the near future we should have real garbage collection; I think that will make a HUGE difference for grains
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sun Jan 14, 2007 1:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

the granular sound generated from this simple delayline idea sounds okay.
i haven't tried with many parameters.
now it's mostly randomzied (delay time is)

but from this idea, i might be able to develop further into some kinds of granular technics.
especially simple asynchronous.

Code:
Mandolin s1 => DelayL d1 => SinOsc s2 => dac;
d1 => Gain g1 => LPF f1 => d1;
s1.gain(0.2);
s1.freq(440);
s1.stringDamping(0.01);
s1.pluckPos(1.0);
d1.max(2::second);
d1.delay(0.5::second);
s2.sync(1);

g1.gain(0.75);
f1.freq(4000.0);
f1.Q(0.4);

fun void KeepPlaying() {
   while(true)   {
      s1.noteOn(1);
      4000::ms => now;
      s1.freq(Std.rand2(4, 16) * 110);
   }
}

spork ~ KeepPlaying();

while(Std.rand2f(1,50)::ms => now) {
   d1.delay(Std.rand2f(1, 1000)::ms);}


what is the easiest way to capture one sound and manipulate?
(for example, use as a wavetable) ..

should i make a class ..
with an array of Float to sample some sounds (in chuck)
and write functions for reading / playing / speed adjustment / etc to gain more control?

i'll try to implement this.
- - -

ahhh! having fun with the above patch haahaha..
this one sounds nice & exciting:

Code:
Mandolin s1 => DelayL d1 => SinOsc s2 => dac;
d1 => Gain g1 => LPF f1 => d1;
s1.gain(0.2);
s1.freq(440);
s1.stringDamping(0.01);
s1.pluckPos(1.0);
d1.max(4::second);
d1.delay(0.5::second);
s2.sync(1);

g1.gain(0.9);
f1.freq(13000.0);
f1.Q(0.8);

fun void KeepPlaying() {
   while(true)   {
      s1.noteOn(1);
      1000::ms => now;     
   }
}

spork ~ KeepPlaying();

while(Std.rand2f(50,100)::ms => now) {
   d1.delay(Std.rand2f(2000, 4000)::ms);
   s1.freq(Std.rand2(4, 24) * 55); 
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
moudi



Joined: Oct 07, 2006
Posts: 63
Location: Bern Switzerland

PostPosted: Mon Jan 15, 2007 2:21 pm    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:
what is the easiest way to capture one sound and manipulate?
(for example, use as a wavetable) ..

should i make a class ..
with an array of Float to sample some sounds (in chuck)
and write functions for reading / playing / speed adjustment / etc to gain more control?

there was a thread some time ago about a wav recorder:
http://electro-music.com/forum/topic-13839.html
covers this basically your needs?

interesting sounds!
let us hear your ongoing experiments Smile

regards
/moudi
Back to top
View user's profile Send private message Visit poster's website
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Mon May 14, 2007 5:46 am    Post subject: synchronous granular synthesis with soundfile Reply with quote  Mark this post and the followings unread

hi there folks,

i'm quite new to chuck and having some problems...

i have to make time stretch and a pitch shift with a 2sec soundfile (like speech or so) by using the method of synchronous grains.

now, i found this thread here, but i really don't get through it... Confused
i have problems with understanding, where in the code (first code example in this thread) the grains are made and what the envelope is needed for...
furthermore it is not clear to me why the SinOsc s is chucked and then again unchucked to the Gain mainmixer..?

hopefully somebody can help me


(and sry for b00n questions Rolling Eyes )

thanks folks!
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Mon May 14, 2007 6:17 am    Post subject: Reply with quote  Mark this post and the followings unread

Hi, Fraukefroehlich! Welcome to the wonderfull and crazy world of ChucK!

As you can see here, a possible downside of ChucK is that it can be confusing at first. Fortunately, I'm in the position of showing you one of the great strengths of ChucK right here and now as well. One of the best things is that there are frequent updates that bring new toys and tricks. As luck would have it, the last update, which was released since this discussion above, has a readymade granular tool.

It's called "LiSa" for LIve SAmpling.

More bad news; it's not in the manual yet. More good news; the examples that demonstrate it are very good and kinda contain the manual to it in the comments.

I sugest you look up those examples (in your examples dir in your install, I believe the sub-dir is called "special" or something along those lines)) and work from there.

About disconecting; I'd have to look carefully at this code to get all the nuances but one of the prime advantages of disconecting unused signals is that they no longer get computed so that saves CPU time.

Anyway, you *can* do it all manually, create your own buffer out of a array and read it and so on. That's educational (I'm getting the impression you have to complete a asignment?) and of cource you get a little more freedom but it's also likely much harder on the cpu then using a readymade unit generator and a fair bit more difficult.

So; I recomend you look at the lisa examples, see how far that gets you and report back when you run into trouble.

----
Yes, I looked it up and /examples/special/ has no less then ten files detailing LISA, it's (her?) syntax and uses.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Mon May 14, 2007 7:03 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Hi, Fraukefroehlich! Welcome to the wonderfull and crazy world of ChucK!

hi there, thx for the nice welcome and thank you very much for helping! Smile

Kassen wrote:
Anyway, you *can* do it all manually, create your own buffer out of a array and read it and so on. That's educational (I'm getting the impression you have to complete a asignment?) and of cource...
well, it is in fact an assignment. it is part of an audio lecture at university and i'm not sure we are allowed to use such "tools" for completion.

the assignment says:

- a short sample (about 2 secs) should be stretched in time and (independently from speed) shifted in pitch

- in a loop play synchronous 1-5 (get value with random function) instances of the soundsample with randomly chosen parameters for time stretch and pitch shift. the length is determined by the shortest sample. after this loop wait .5 secs and again play 1-5 samples and so on...

- use chucking/unchucking method
- crossfade between grains
- use linear interpolation between grains for lower frequencies than original

as you see it seems really tricky (at least it does to me:)) and as a newbie i feel pretty stranded...

thanks
frauke
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Mon May 14, 2007 7:39 am    Post subject: Reply with quote  Mark this post and the followings unread

I see....

Well, it's up to you as it's your asignement. It would depend on how the course is structured and what is expected but I'd say that throwing new users in at the deep end and expecting them to manually make their own buffers would be a bit much.

We also don't *need* to do that here and while it's educational in a way it's also ineficient and I think it doesn't show good style to go to great lengths to make your own when right next to it is a perfectly fine specialised tool.

Fortunately to use LiSa properly you'll still need to understand how reading from the same buffer several times results in that typical grain sound.

You'll still need to set the build-in envelopes properly to achieve the disireded crossfading and so on. LiSa (as I'm sure you saw by now) is a very versatile tool and grainular streching is only a part of what it can do; you'll still need to understand how grains work in order to get there.

If you still want to use your own buffer you'll need to start using something like this, let's asume you have a sound-source that's a ugen named "signal" (could be anything). We'll record a second of that to a little buffer.

Code:

//warning; uncecked code for demo purposes, might contain typos
//demonstrating the use of arrays as buffers, recording side.
//playback is the other way'round and left as a excersise.

//set up a buffer for one second at cd quality audio
float buffer[44100];

//this loop will run for a second and record to our buffer
for (0 => int n; n < 44100; n++)
    {
    //get value and store it in the buffer
    signal.last() => buffer[n];

    //advance time by a sample
    samp => now;
    }


To get the audio out of that buffer again you'll need to write those values to a "step" ugen, in your case you'll need to do that 5 times using paralel sporked shreds running at different speeds and treat those "steps" using envelopes. Not impossible at all but quite ineficient. I'm also not so sure how you'll demonstrate "unchucking" doing it that way.

So; what university is teaching ChucK in Germany (asuming based on your name)? It'd be good if that was on the WiKi. Part of ChucK's aims is education so if it's being taught outside of Princeton that's a real result.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Mon May 14, 2007 7:53 am    Post subject: Reply with quote  Mark this post and the followings unread

uhmm... ok.

i appreciate your help and will try to get it working. if everything fails i'll get back to LiSa which seems nice.
i'll keep you up to date...


well, it is a german name - not a german university though Smile
i'm studying media informatics at technical university of vienna (austria) and chuck is teached in the audio lecture of the master study.


so... thx very much for now, i'll be back! Cool
Back to top
View user's profile Send private message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Tue May 15, 2007 11:50 am    Post subject: Reply with quote  Mark this post and the followings unread

ok... we try getting it done manually...
so, i have that soundbuffer with my .wav in it, which i assume now corresponds to 1 sample, right?

now the prob is, how to get the grains out of that sample? i think thats the tricky part... interpolating and stuff shouldn't be that complicated....

/me is thankful for any help...

greets
Back to top
View user's profile Send private message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Wed May 16, 2007 1:54 am    Post subject: Reply with quote  Mark this post and the followings unread

ok, now i know i was wrong... Smile

one .wav in the SndBuf is not one sample, but its 44100 samples/second as the .wav is in cd-quality...

so... well then i thougt... if i have 44100 samples/second i can stretch time by a factor of 2 if i just play 1000 samples, then set the buf.pos() back by 500 samples and play again... so on in a loop.

now if i want to shorten the length, i just overpass some samples... i.e. i play 1000 samples then set the buf.pos() to +1000 and continue playing from there, so there were left 1000 samples unplayed and the length shortens...

ok... this seems to be working to me, but i'm not really sure if it leaves the frequency untouched... maybe someone can answer this question?

so for better understanding, here comes my code:

Code:
//get file
"./theFile.wav" => string filename;
if(me.args()) me.arg(0) => filename;  // if there comes a different filename as parameter from command line...

// patch
SndBuf buf => dac;

//load file to buffer
filename => buf.read;

Event finish;
float a;
float b;
int c;
now + buf.length() => time later;

//4 => float stretch;                just for testing purpose...
Std.rand2f(.25, 4) => float stretch;

fun void timeStretch(float factor){
   if(factor < 1){                  // contract length
         1 - factor => a;
          1000 * a => b;
         b $ int => c;
         <<<stretch>>>;           // so we can see the stretching factor
         while(now < later){      
            1000::samp => now;
            buf.pos() => int tmp;
            buf.pos(tmp - c);
         }
         finish.broadcast();
   }else{                           // stretch length
      1000 * (factor - 1) => b;
       b $ int => c;
      <<<stretch>>>;               // so we can see the stretching factor
      while(now < later){      
            1000::samp => now;
            buf.pos() => int tmp;
            buf.pos(tmp + c);
         }
         finish.broadcast();   
    }
}
spork ~ timeStretch(stretch);
finish => now;


furthermore i have to play 1-5 instances synchronous and the shortest instance should determine the length of all instances (by just cutting longer instances).
the prob is that i have the loops going from now to later (which is: now + buf.length() => later;) and i would need to update this time "later" to now + buf.length() of shortest instance... Confused no plan about that issue...

hopefully somebody can help my with this concern... next i've gotta try to somehow pitch the file without shortening or stretching its length... *gasp*

thanks!

so long,
frauke
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Wed May 16, 2007 2:43 am    Post subject: Reply with quote  Mark this post and the followings unread

fraukefroehlich wrote:

one .wav in the SndBuf is not one sample, but its 44100 samples/second as the .wav is in cd-quality...


Exactly. A "sanple" could mean one recording, for example "piano.wav" or it could be a 44100th of a second (as a period of time) or in this case it's one value in a recording. Such values are in floating point in ChucK.

Quote:
so... well then i thougt... if i have 44100 samples/second i can stretch time by a factor of 2 if i just play 1000 samples, then set the buf.pos() back by 500 samples and play again... so on in a loop.



Yes, that would be a option. That's technique that works, it's how people used to strech in trackers in the old days. It works but there are many artefacts. Because you don't use the ramps we talked about before there can be clicks when the readpoint skips back as well because there the output value of the SndBuf will skip from some value to another.

Quote:
now if i want to shorten the length, i just overpass some samples... i.e. i play 1000 samples then set the buf.pos() to +1000 and continue playing from there, so there were left 1000 samples unplayed and the length shortens...


yes, you can.

Quote:
ok... this seems to be working to me, but i'm not really sure if it leaves the frequency untouched... maybe someone can answer this question?


Well, one issue in this technique is that you will have a artefact in the sound when the value jumps every 1000 samples. Since you have 44.1 thousand samples per second you'll have 44 of those jumps each second so your output will have a spectral component at 44Hz.

Quote:
so for better understanding, here comes my code:


I get it and haven't had enough coffee yet so if you don't mind I'll leave the code be for now and talk about the principle.

Quote:
furthermore i have to play 1-5 instances synchronous and the shortest instance should determine the length of all instances (by just cutting longer instances).
the prob is that i have the loops going from now to later (which is: now + buf.length() => later;) and i would need to update this time "later" to now + buf.length() of shortest instance... Confused no plan about that issue...


Yes, right. This is where the core of the asignment pops up again.

If it were just about time-streching I'd recomen that you take a simple SndBuf, set it's playback rate to 0.5 and then use the build-in pitch-shifter to shift it up again by a octave. Easy, cheap time-streching, sounds like early UK jungle, I imagine it's what old samplers did.

Here that won't do, because of your asignment.

The issue is; we need to do the same thing five times with crossfading but SndBuf only has one read-pointer, meaning it can only read from the same buffer once at the same time. Now you can probably understand why LiSa is there. LiSa is exactly like SndBuf but it has multiple read-pointers so it can play from the same file multiple times.

The good bit there is that if you use your original strategy and instead of skipping back 1000 samples you fade-out and then skip back, then fade in again (hiding the jump) you can have one or more of the other voices play in the meantime to avoid the bit of silence.

This is, BTW, what a pitch-shifter does as well but with a pitch-shifter it happens internally and so you can't change how it works and it's not of much educational value. You can still hear that a pitch-shifter at extreme settings (especially cheap ones) has some aspect of ring-modulation which is because of the fading in and out creating a quick modulation in volume.

Hope that explains some of these matters. Don't feel bad if you don't get all of it right away; this is a very complicated matter that involves many aspects of how sound works.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Wed May 16, 2007 3:37 am    Post subject: Reply with quote  Mark this post and the followings unread

hmmm ok i see....

tricky though - anyway, what alternative solutions for crossfading do we have instead of the ramp? or which ugens do support the ramp?

'cause i'd really like to avoid LiSa (not because i want to, but i think the assignment wants to...Smile and i wondered how you would do a fade in or out (having in mind that you just mix them for crossfading...)

thx
frauke
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Wed May 16, 2007 6:35 am    Post subject: Reply with quote  Mark this post and the followings unread

The asignment want to avoid LiSa? Are you sure of that? I bet the asignment is written around the LiSa tutorials/examples and I bet it was made that way because;

A) LiSa is brand new and so interesting to somebody making a asignment like that because that's likely a person who's interested in ChucK.
B)Grains are relatively hip and make people feel something modern and experimental is going on (good for making student enthousiastic).
C) it demonstrates how timing (ChucK's specialty) can result in spectral changes.

This makes perfect sense; I'd probably do the same for a asignment in a ChucK course. I'm willing to wage a quality beer on this bet.

Anyway; as should be clear by now; we can do the same thing in a lot of ways.

We can for example also set up a set of SndBufs's each with it's own envelope and use that. Controll-wise that will almost be the same, it will just be less eficient. It would go something like this;

Code:
5 => int maxvoices;

.5::second => dur ramptime;

"voice.wav" => string my_file;

//initiate buffers
//we actually create a array here of byffers for easy adressing later
SndBuf my_buffers[maxvoices];
//initiate ramps (see manual for this Ugen)
//envelope works exactly like ramp,
//also see my note about crossfaders elsewhere for a hint on how to controll them
Envelope my_ramps[maxvoices];

//hook all of this up
for (0 => int n; n < maxvoices; n++)
    {
    my_buffers[n] => my_ramps[n] => dac;
    my_file => my_buffers[n].read;
    ramptime => my_ramps[n].duration;
    }
//controlling code goes here


So there you have it; a sort of "roll your own" version of LiSa without the live sampling. Making arrays of Ugens makes controll of this whole thing a lot easier but as you can see; it uses some more advanced techniques. I can't imagine you're expected to do things like that as a sort of introduction to ChucK.

Still; you can do it like this and from here on the question of how to controll it all is the same. Basically what we have here is the same as what LiSa does, they are different buffers but they all hold the same file so in practice you get a "maxvoices" number of read-pointers.

Oh, and if you do decide to make something that includes the above code, make sure you understand it because if I had a student who was new to ChucK and who would suddenly turn in something involving arrays of Ugens I'd suspect they had help. That's fine; I myself learned to ChucK by asking questions and borowing ideas from people on the list but it's important to know how things work if you want to use them yourself.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


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

PostPosted: Wed May 16, 2007 11:22 am    Post subject: Reply with quote  Mark this post and the followings unread

Frouke, I hope it doesn't betray your trust but I took the liberty of mailing Joerg.

So; indeed, no LiSa, you were right. Also; I can help but I can't write it out for you. I didn't want to write it out anyway because that's not so exciting for either of us. There can be hints if you would get terribly stuck. Getting stuck isn't so exciting either.

I think we'll turn that into policy here because chances are there will be more people with ChucKian home-work in the future.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Wed May 16, 2007 1:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

no, no prob at all.

i'm not looking for ready-for-use-code-snippets, so i'm perfectly okay with that policy.

however, i'll be back to get some advice on further assignments Smile

thx and greets
frauke
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Wed May 16, 2007 2:32 pm    Post subject: Reply with quote  Mark this post and the followings unread

Cool.

I saw, btw, that Joerg listed "Microsound" by Roads as optional reading material for this cource. That's a excelent book that I warmly recomend if you'd like to know more about "rolling your own" granular things.

Microsound has no code snipets at all, in fact it hardly makes any reference to any concrete software, it's just about how you can work with grains. This means it's quite valuable as stimulation, as far as I've seen only a small percentage of what that book talks about is out there as ready-made plugins so that's a very good target for some DIY. As I see it; it's no use coding stuff that's already available.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Fri May 18, 2007 3:12 am    Post subject: Reply with quote  Mark this post and the followings unread

oh i see... i'll have a look at that, thx!

i know, it's not very useful to code something that has already been optimized and automated if you need it as part of a larger project, but i think it's not bad to re-code modules for learning purposes as you get to know the logic and the mechanisms behind it and of course you get a better feeling for it.
so, it is tough, though solid learning too... Smile

brummbrumm
frauke
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 4 [82 Posts]
View unread posts
View new posts in the last week
Goto page: 1, 2, 3, 4 Next
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
e-m mkii

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 through 2009 by electro-music.com - Conditions Of Use