[chuck-users] wavetable synthesis

dan trueman dtrueman at Princeton.EDU
Sat Oct 20 21:47:19 EDT 2007


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 at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



More information about the chuck-users mailing list