problem with round~

Era Chang's icon

I am building a 8-bit-ish oscillator. What I try is the following simple code:
cycle~ 353
|
round~ 0.5
|
gain
I found it strange that with this specific frequency 353Hz, it produces a very high pitch harmonics that does not exists for other frequency. Is this also the case in your pc and does it have anything to do with sample rate?

Roman Thilenius's icon

i only see 4 bits.

and yes you might into run into sr releated issues with square waves. but with rounding or bitrate reduction, too.

it is a different approach and might not work in all situations, but are you aware of degrade~?

Era Chang's icon

Hi Roman,

Thanks for your reply. degrade~ (with the same frequency) has the exact same issue. I am wondering what is the reason that causes this strange effect.

Roman Thilenius's icon

the higher the frequency, the shorter the cycles.

the smaller the individual "segments" of the "4-bit waveform" get, the more inaccurate their frequency gets.

when the frequency comes in the range where the are reaching 0, the output frequency will fold over into negative frequencies.

both causes inevitably what is called "aliasing".

i dont see (hear) that 353 would be special, but somewhere between 300 and 400 hz the effect clearly begins. (on the laptop. in the studio probably 1-2 octaves earlier.)

if you have 44100 samples per second and an oscillator runs at 441 hertz, one cycle has 100 samples.

after the "4-bit conversion" each of the segments of the values 0. - 0.5 -1.0 -0.5 - 0. -0.5 -1.0 -0.5 now has 12,5 samples lenght. this means that every other segment is 12 sample long, then followed by one which is 13 samples long.

at 3000 hertz oscillator frequency the 8 segments must share 14.7 samples.

this means that in cycle #1 the segment will have a lenght of roughly (for a tri i could tell offhand, but a cosine distorts that distribution further) 2 2 2 1 2 2 2 1 samples and the next cycle will have 2 2 2 2 2 2 1 2 samples.

now at the latest 95% of the spectrum you hear is aliasing and 5% is left for the base oscillator speed.^^

Roman Thilenius's icon

downsampling cosine cycles is an extreme example. you could not even properly pre-filter that.