Hello dan, thanks for your advice. I haven't played with LiSa much yet, but hope to do that soon. In fact what I am trying to do can be done in many many ways: using an array and chucking it into a Step, with sndbuf and chucking buffer values to a Step (a bit roundabout), with LiSa as you pointed out, probably soon with Gen7, looping thru sndbuf and setting frequencies with playing rate, etc. Actually, the latter is probably one of the simplest and more direct way. However, I've been surprised that using sndbuf.interp( 2 ) (i.e.sync interpolation) has the same/similar results (or at least to my ears) as using sndbuf.interp(0) (i.e. drop sample). Should it be like that? I also want to take the chance to comment on a two (separate) things: 1. Arrays which are declared as floats will give compilation errors when only and only the first index is an integer. It seems as if chuck is comparing the type of the first index with the user-defined type of the array. If they differ, one gets an error something like "array[...] contains incompatible types". Example: [1, 2., 3, 4. ] => float array; // this crashes. Note that 1 and 3 are integers [1., 2, 3, 4 ] => int array; // also crashes. Note first index is a float but array is defined as int. [1., 2., 3, 4. => float array; // this doesn't crash. Note 3 is still an integer It's not a big deal, but just for correctness should be addressed in some way, I guess. 2. Regarding spectral analysis, I've noticed that assigning the window function to the ifft gives poorer results. You can check that in /examples/win.ck. Assign windowing to ifft and you'll notice a rougher (fast beating) sound especially at the beginning. eduard On Oct 21, 2007, at 3:47 AM, dan trueman wrote:
hihihi,
couple things. you can do this kind of thing with LiSa using the "track" method. i should have called this "sync" and will have it accessible that way in the future, but when you set 1 => lisa.track, the input chucked to LiSa sets the playback position. see:
http://chuck.cs.princeton.edu/doc/examples/special/LiSa-track1.ck http://chuck.cs.princeton.edu/doc/examples/special/LiSa-track2.ck http://chuck.cs.princeton.edu/doc/examples/special/LiSa-track3.ck
there is more LiSa documentation coming soon, i promise! and in the next release the "valueAt" method will allow you to algorithmically set the values in LiSa super easily.
now, regarding the gen7 problem; this appears to be a recurrence of the bug we've encountered before with arrays; for some reason dynamically generated arrays don't chuck properly to the GenX ugens and i think the problem has to do with how arrays are chucked to methods in general. i've asked Ge about this and he's looking into it. i'm also assuming there was a reason you were trying to use Gen7 that way and didn't just want to use Gen9 or Gen10 to make a sine wave table....
ok, i hope this helps, dt
On Oct 20, 2007, at 6:57 AM, eduard wrote:
hello,
Checking out the code today with a fresher mind, just realised that the second method does work. I forgot to bitmask the last int_pos. So the last line that reads: (snd.valueAt( (int_pos&bitmask) + 1 ) - snd.valueAt(int_pos&bitmask))*(pos-int_pos) + snd.valueAt (int_pos) => imp.next;
Should be: (snd.valueAt( (int_pos&bitmask) + 1 ) - snd.valueAt(int_pos&bitmask))*(pos-int_pos) + snd.valueAt (int_pos&bitmask) => imp.next;
Still think method 1 should be doable... am i missing something?
thanks
eduard
On Oct 19, 2007, at 4:40 PM, eduard aylon wrote:
Hello list,
Does anyone know if there is any UGen to store waveforms in a table? Thus, wavetable synthesis. I've come up with a few ideas, but none of them seem to work:
1. The first was to use a Gen7 together with a phasor. However, I get no sound. See the following patch which I think should synthesise a sine wave:
512 => int length; 440. => float freq; 1./ length => float step;
float coefs[ 2*length-1]; for( 1 => int i; i < coefs.cap() ; 2 +=> i ) { Math.sin((i-1)*2.*pi/511.) => coefs[i-1]; // value at pos step => coefs[i]; // duration of value, 1 samp } Math.sin( length*2.*pi/length ) => coefs[ length - 1]; // last value Phasor p => Gen7 gen7 => WvOut file => dac; coefs => gen7.coefs; freq => p.freq; while( true ) 1::samp => now;
2. The second idea was to use a sndbuf, but the results are far from satisfactory. see example:
//first you need to generate one period of a sine wave:
SinOsc s => WvOut file => blackhole; "sine_period.wav" => file.wavFilename; 1024 => int length; second/samp => float sr; sr/length => s.freq; now + length::samp => time later; while( now < later ) 1::samp=>now;
----- separate chuck file ----
// wavetable synth part: synthesise a sine wave at any freq
SndBuf snd => blackhole; Impulse imp => dac; "sine_period.wav" => snd.read; snd.samples() => int length; // must be power of 2 length - 1 => int bitmask; second/samp => float sr;
440. => float freq; freq*length/sr => float delta; delta $int => int int_delta; 0 => float pos; 0 => int int_pos; 1 => int interpolate; if( me.args() ) Std.atoi( me.arg(0) ) => interpolate; while( true ) { if( !interpolate ) { int_delta::samp => now; snd.last() => imp.next; snd.pos( snd.pos()&bitmask ); continue; }
delta + pos => pos; pos $int => int_pos; (snd.valueAt( (int_pos&bitmask) + 1 ) - snd.valueAt(int_pos&bitmask))*(pos-int_pos) + snd.valueAt (int_pos) => imp.next; 1::samp => now;
}
Could someone give me a hand?
thanks,
eduard
_______________________________________________ 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