Hello Mike, storing hann in an array or a window class will also help to lower the cost of computing it at a sample level. Unless you change the size at each sample... eduard On Nov 6, 2008, at 11:55 PM, mike clemow wrote:
Listees,
This is just for fun, but it's totally relevant. This is currently the state of DIY Hann (for example) envelopes for granular synthesis. You get a couple more of these trainlets running, and you'll kill the VM. I absolutely love ChucK's concurrency model, but it can't handle too much of this kind of thing. The sample-level intervention is also painful.
Also, you all might check my notably horrid math...
-----
1024 => int N; // length of grain in samples
fun float hann( int n ) { return 0.5 * (1. - Math.cos( (2*pi*n)/(N-1) )); // thank you, Wikipedia.org ;-) }
fun void hannGrain( float f ) { SinOsc s => dac; f => s.freq; 0 => int n; 0. => float h;
while( n < N-1 ) { hann( n ) => h => s.gain; n++; 1::samp => now; } }
while( true ) { spork ~ hannGrain(Math.rand2f(250.,500.)); me.yield(); 1024::samp/2 => now; // 50% grain overlap }
------
If you make the random frequency a constant, it will sound like a SinOsc. This is mostly because of the nice envelope...
Enjoy, Mike
On Thu, Nov 6, 2008 at 4:35 PM, Kassen
wrote: Rogan;
This is interesting. I have some code that does pretty cool graining / glitching on samples (that I have yet to post on the forum) that I'm currently using linear ramps for.
Cool!
What would be the optimal shape for the grain?
Well, that's a good question... it's a question like what is the best instrument or the most beautiful animal. In other words; it depends on taste and application. A envelope shape (or grain "window" if you like) that's perfect for me may be completely unsuitable for you. I do think that if we only have one the simplicity of the linear ramp is nice but more can be said on the topic.
Sine wave attack (sqare-root)?
That would be a nice one, yes. Nothing could be "the best" but something like that would be a decent bet as a starting point, I think.
And what are the effects on the spectrum?
Well, what we have is a wave-form (the section of the buffer being played back) and a envelope over it which is actually another wave-form that gets multiplied with the first. For longer grains (or loops or recordings) this is no huge issue but as grains become shorter the envelope may approach a rate where it's wave-form comes close to the audible range in frequency. If we then consider that a multiplication of two wave-forms really comes down to a ring modulator we'll see that the spectral content of the envelope will start generating side-bands for the audio.
This is not a bug, in fact it's a feature of granular (or pulselet, or....) synthesis and it gives us interesting options in sound-design. However, to make the most of those options we need to be able to talk about the curve of the ramps as the curve of the ramps will translate to harmonics of the "envelope wave-form" which will in turn end up in the sound. Hope fully we'll be able to find a way to talk about this to LiSa that doesn't make LiSa any more complicated then she needs to be; simple tools are nice.
I hope that served as a introduction. If you'd like to know a lot more about this topic I think the best thing to do is to considder getting the book "Microsound" by Roads. That book goes into considerable depth in the various properties of granular systems, how they interact and how they influence the final result.
Yours, Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://michaelclemow.com http://semiotech.org _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users