I am working on a rhythm modulation thing, where I will need to detect if a signal is currently changing in the positive or negative direction.
Usually I would do something like:
ksig (is changing and we want to know if it increases or decreases)
kprevious init 0
kdiff = ksig-kprevious
kprevious = ksig
which could also be written:
ksig (is changing and we want to know if it increases or decreases)
kdiff diff ksig
I get a problem that the diff signal is spiky even if ksig is smoothly changing. It seems like it does not update continuously. The spike I get correctly represents the expected signal change, but I get a series of zeros in between the spikes.
Hi Oeyvind,
have you tried filtering the diff signal with a lowpass filter? I tried with butterlp and was able to smooth out the signal. You could even try to also smooth out the incoming signal. But it is strange that diff on a sine oscillator produces these artefacts, because the differential is a straight cosine.
Hi Jeanette,
Thanks for the suggestion. I was thinking along those lines, but was confused, as it should not be necessary
I found a simpler and more robust solution (below), which has less flutter/spikes, but also here I need a median filter to make it completely clean.
It seems like there is some dithering going on somewhere. Could it be related to denormals somehow?
Øyvind
Hi Oeyvind,
have you tried filtering the diff signal with a lowpass filter? I tried with
butterlp and was able to smooth out the signal. You could even try to also
smooth out the incoming signal. But it is strange that diff on a sine
oscillator produces these artefacts, because the differential is a straight
cosine.
yes --- this is another interesting example which side effects the usage of oscil can have --- even for such expert expert users ......
perhaps the usage of oscil should be discouraged on the manual page?
Oh, yes I understand now.
haha, yes, as Joachim says, it can trip up even experienced users
But it is always a good lesson from such encounters.
Øyvind
I think the issue is that the signal is not changing for a few samples (so diff = 0), and then it changes. You
get the spikes when it does.
That’s what happens with truncating oscillators. If you replace oscil by oscili, then you will get a smooth
cosine wave.
HTH
Prof. Victor Lazzarini
Maynooth University
Ireland
Warning
This email originated from outside of Maynooth University’s Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
Hi
I am working on a rhythm modulation thing, where I will need to detect if a signal is currently changing in the positive or negative direction.
Usually I would do something like:
ksig (is changing and we want to know if it increases or decreases)
kprevious init 0
kdiff = ksig-kprevious
kprevious = ksig
which could also be written:
ksig (is changing and we want to know if it increases or decreases)
kdiff diff ksig
I get a problem that the diff signal is spiky even if ksig is smoothly changing. It seems like it does not update continuously. The spike I get correctly represents the expected signal change, but I get a series of zeros in between the spikes.
To demonstrate, I did the same with a-signals
instr 2
amod oscil 0.9, 0.5
adiff diff amod
outs amod, adiff*1000
endin
When inspecting the resulting sound file, one can see the spikes with zeroes in between.
Am I thinking of this completely wrong, or is Csound doing something odd here?