[Csnd] Distortion with deltapi
Date | 2013-11-30 17:13 |
From | Jim Aikin |
Subject | [Csnd] Distortion with deltapi |
When I listen to the output of a delayr/delayw pair with a time-varying deltapi, I'm hearing major distortion artifacts. Could be a problem in my code, but I'm not seeing it. Could be a bug in deltapi. Below is the example. If you switch the output from adel, adel to asig, asig, you'll hear that the dry signal is free of distortion. sr = 44100 ksmps = 8 nchnls = 2 0dbfs = 1 giSine ftgen 0, 0, 8192, 10, 1 giCos ftgen 0, 0, 8192, 11, 1 giSeq ftgen 0, 0, 8, -2, 1, 1.5, 1.25, 1.125, 1, 1.375, 1.625, 1.5 instr 1 iamp = 0.5 ibasefreq = 300 kfreq init ibasefreq krawfreq init ibasefreq ; create a simple sequence of 8 pitches: kctr init -1 ktrig metro 2 if (ktrig == 1) then kctr = kctr + 1 if (kctr > 7) then kctr = 0 endif kstepval table kctr, giSeq krawfreq = ibasefreq * kstepval endif kfreq portk krawfreq, 0.005 ; play the pitches with an oscillator: asig gbuzz iamp, kfreq, 15, 1, 0.8, giCos ; delay the sound of the oscillator by a varying time ; interval of 0.5 to 1.5 second: adel init 0 adelt oscil 0.5, 0.1, giSine adelt = adelt + 1 adummy delayr 2 adel deltapi adelt delayw asig outs adel, adel endin |
Date | 2013-11-30 17:29 |
From | Justin Smith |
Subject | Re: [Csnd] Distortion with deltapi |
Two suggestions: you could use deltap3 instead of deltapi you should be lowpassing the signal going into the delay line, so that the highest frequency found is lower than (sr/2)/change where change is the maximum absolute value of the number of samples per second the delay time is altered (you would derive it from the amount of change in delay time and the rate at which you make that change)
On Sat, Nov 30, 2013 at 9:13 AM, Jim Aikin <midiguru23@sbcglobal.net> wrote: When I listen to the output of a delayr/delayw pair with a time-varying |
Date | 2013-11-30 17:50 |
From | Justin Smith |
Subject | Re: [Csnd] Distortion with deltapi |
Correction, change would be the maximum value of sr/((del t+1) - (del t)) where (del t) and (del t+1) are two consecutive delay times. On Sat, Nov 30, 2013 at 9:29 AM, Justin Smith <noisesmith@gmail.com> wrote:
|
Date | 2013-11-30 21:22 |
From | Jim Aikin |
Subject | [Csnd] Re: Distortion with deltapi |
I'm not sure I'm understanding you correctly, Justin, but I don't think that explains it. First, using deltap3 rather than deltapi does make a small but not, in the end, very significant difference. Still hearing lots of ring modulation. Second, the highest overtone is NOT hitting the Nyquist frequency, because I can get the same result by sending a sine wave (max frequency less than 500Hz) into the delay. Third, if I'm understanding your formula correctly, the values for (del t+1) and (del t) would be two adjacent delay times, right? Since the delay time is being modulated by an oscillator with a maximum amplitude swing of 1.0, at a frequency of 0.1Hz, in a given sample period (and by the way, I've also set ksmps = 1) the delay time is changing by 1/441000 second. That would give a value for sr/((del t+1) - del t)) of more than 19 billion (speaking American billion here). Not sure what the significance of that number would be, but I'm pretty sure a sine wave has no overtones at 19,000,000,000Hz. Can you help me understand a little better what you're suggesting? Maybe I'm just running the formula upside down or something. -- View this message in context: http://csound.1045644.n5.nabble.com/Distortion-with-deltapi-tp5730368p5730373.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-11-30 21:30 |
From | Justin Smith |
Subject | Re: [Csnd] Re: Distortion with deltapi |
I had the formula wrong. If the delay time in samples increases in 1 k period by 2*ksmps, you will get an output frequency of 1khz from your 500hz input. On Sat, Nov 30, 2013 at 1:22 PM, Jim Aikin <midiguru23@sbcglobal.net> wrote: I'm not sure I'm understanding you correctly, Justin, but I don't think that |
Date | 2013-11-30 21:57 |
From | Jim Aikin |
Subject | [Csnd] Re: Distortion with deltapi |
Still not following you, Justin. If ksmps = 1, you're saying that if the delay time increases by 2 samples in one k-period, there will be ... what? A doubling of the output signal in frequency relative to the input? First of all, I _want_ the output signal to be changing in frequency relative to the input signal. That's the whole point of sweeping the delay time with an LFO. So I have to assume you're referring to some _other_ frequency shift, because what I'm hearing is a frequency artifact (which sounds like aliasing) over and above the expected frequency shift. If you haven't run the .csd, please do so. You should hear what I'm describing. Second, with the delay time changing by a total of 1 second over the course of a 5-second LFO sweep, in each second the delay time will change, on average (because I'm using a sine wave as an LFO, not a triangle), by 8820 samples. But during that second, there will be 44100 sample periods (because, for one thing, ksmps = 1). So in each sample period the delay time will be changing by 1/5 sample (0.2 sample). 0.2 is less than 2, so I don't see how your statement applies. Am I missing something? -- View this message in context: http://csound.1045644.n5.nabble.com/Distortion-with-deltapi-tp5730368p5730376.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-11-30 22:27 |
From | Jim Aikin |
Subject | [Csnd] Re: Distortion with deltapi |
Okay, I'm getting similar artifacts while sweeping the delay time with an LFO in Reason. Reason's control rate is certainly lower than its sampling rate, but let's ignore that factor. Assuming that these pitch artifacts are inherent in a change in the delay time, I don't understand why that's the case. As a thought experiment, let's compare a delay line to a tape deck. The tape is whipping through the transport in such a way that 300 complete cycles of a sine wave pass the playback head in every second. So far, so good. We then slide the playback head gradually to the left or right. Assuming the tape is traveling from left to right, as we move the playback head to the left, slightly more cycles of the sine wave will pass the playback head per second, so the pitch will rise. (Essentially, this is a doppler effect.) When the playback head is moving to the right, fewer than 300 cycles of the sine wave will pass over it in each second. If our digital "playback head" is using zero-order interpolation (that is, dropping or adding samples), I can see that artifacts would be introduced into the output signal. But deltapi is supposed to be interpolating. The manual doesn't say how many adjacent samples are used in the interpolation, but the manual does caution the user that for delay times that are changing at a moderate-to-fast rate, an a-rate time-shift signal should be used. That's exactly what I'm doing. And I'm hearing major artifacts. One question that occurs to me is, how does the pitch-shifting process that occurs in the delay line differ from the pitch-shifting process that occurs within an oscili? Granted, by the time a 300Hz sine wave hits the delay line, each cycle is only 147 samples long, so dropping a few samples in each cycle would distort the waveform ... but the interpolation process within deltapi should smooth out the distortion, shouldn't it? -- View this message in context: http://csound.1045644.n5.nabble.com/Distortion-with-deltapi-tp5730368p5730379.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-11-30 22:37 |
From | Jim Aikin |
Subject | [Csnd] Re: Distortion with deltapi |
One more point: The sound of deltapi is, to my ears, exactly the same as the sound of deltap (see .csd below). This strongly suggests that in 6.01, deltapi is not performing any interpolation. Whether or not artifacts are inevitable in a digital delay that uses a constant clock rate, I think there may be a problem with the code for deltapi. That's my guess, anyhow. -- View this message in context: http://csound.1045644.n5.nabble.com/Distortion-with-deltapi-tp5730368p5730382.html Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2013-11-30 22:38 |
From | Jim Aikin |
Subject | [Csnd] Re: Distortion with deltapi |
Oops -- forgot the test code. Here 'tis: sr = 96000 ksmps = 1 nchnls = 2 0dbfs = 1 giSine ftgen 0, 0, 8192, 10, 1 giCos ftgen 0, 0, 8192, 11, 1 instr 1 iamp = 0.5 ifreq = 300 asig oscil iamp, ifreq, giSine ; delay the sound of the oscillator by a varying time ; interval: adel init 0 kdelt oscil 0.5, 0.1, giSine kdelt = kdelt + 1 adummy delayr 3 adel deltapi kdelt delayw asig outs adel, adel endin |