Looking to write a sample rate reduction/downsampling opcode/effect. I have been messing with the ‘fold’ opcode for this purpose, and it sounds pretty good(or bad depending on your taste), but I am curious to see if there is any noticeable difference between that and a true downsample -> upsample, sample rate reducer. My processing with fold is this:
adsL fold aL, 44100 / kfold
Here, kfold Hz from 1 to 44100.
From some tests I have been doing, it looks as though a significant amount of high frequency content is still there after the signal is run through the ‘fold’ opcode, see the attached screen shot. My DSP knowledge is only so-so, but I would assume that there would not be any content above kfold / 2, or even kfold… I have tried a few SoX commands (both downsample and -r/rate) and it seems like there is a pretty steep lowpass filter prior to the rate reduction in both of those commands… that being said, it looks as though there is only minor high frequency leakage above the downsampled Nyquist…
So, I guess my question is: Is it possible to create an opcode that downsamples and then upsamples a given signal? From what I could tell this would require a modifiable local ksmps as the downsample opcode outputs a k signal… can we do this? I have seen some other forum posts that suggest changing the global ksmps after the program has started running may cause problems… Here is what I’ve got so far, but the setksmps opcode does not seem to do anything, changing the global ksmps does though, but not really what I am after…
aL inch 1
kfreq chnget “freq”
kdsL downsamp aL
ausL upsamp kdsL
outch 1, ausL
Any help and/or opinions is greatly appreciated, thanks!