Hi Charlie, I think I found it: .1::ms is not the same as 1::samp You do in both scripts .1 ::ms => now, but in the second variant, this means now will have increased by 4.1 samples, instead of 1 unit (depending on your samplerate). I could get the same sound from both scripts by changing .1::ms => now to samp => now; Best, Casper
On 27 Jan 2019, at 14:58, Charlie
wrote: Hey folks, I'm puzzled why these two shreds don't make the same sound. I created a simple bit crusher using an integer as an index and then using time as an index; I thought these were equivalent but they aren't. I wonder if this is because the integer increments at a different rate than the sampling rate? Any guidance on this gratefully received! Thanks,
Charlie
First shred: //---------------------------------------------
SinOsc s => dac;
110 => s.freq;
0 => int i; 250 => int iMax; 0 => int jCount;
while (true) { i++;
// if (i%130 == 0 || i%201 ==0 || i% 737 == 0) 0 =>s.gain; if (i%iMax > jCount ) 0.0 =>s.gain; jCount++; if (jCount > iMax) 0 => jCount; // 1::samp => now; .1::ms => now; 1 => s.gain;
}
//---------------------------------------------
second shred:
//---------------------------------------------
SinOsc s => dac;
110 => s.freq;
0::samp => dur jMin; 250::samp => dur iMax; 0::samp => dur jCount; 1::samp => dur jDelta;
while (true) {
if (now%iMax > jCount ) 0.0 =>s.gain; jCount+jDelta => jCount; if (jCount > iMax) jMin => jCount; .1::ms => now; 1 => s.gain;
}
//---------------------------------------------
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users