Kyma Forum
  Tips & Techniques
  Please help : Trying to detect zero crossings

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Please help : Trying to detect zero crossings
tuscland
Member
posted 11 April 2006 17:33         Edit/Delete Message   Reply w/Quote

ZeroCrossingPlayer.kym

 
Hello,

I am trying to make a sound that detects zero-crossings and play back the detected one-period waves. Right now, this sound does actually nothing : the input must be the same as the output.

The problem here is that I must record and play back the wavetable very precisely, which involves triggers at sample rate, not at control rate.

I have a sound here which works almost as I would want, but there is a glitch I can't solve : when the test oscillator (which may be replaced later with a sample or live input) goes higher in frequency strange artefacts are induced, and I can't figure out why.

Is there a guru that can help me and try to see what is wrong with my Sound?

Best Regards,
Camille

PS: regarding my previous post, I solved the problem of the SetableRamp with a Up/Down Counter ...

IP: Logged

tuscland
Member
posted 12 April 2006 03:00         Edit/Delete Message   Reply w/Quote
I found the solution!
A OneSampleDelay was needed between the prototype named 'Index Ramp' and 'Playback'.
The value -1 in FirstStepOffSet was not needed, 0 was OK.

I guess I needed the night to think about this ... I am still learning to be wise.


xc
Cam

[This message has been edited by tuscland (edited 12 April 2006).]

IP: Logged

pete
Member
posted 12 April 2006 06:08         Edit/Delete Message   Reply w/Quote

ZeroCrossingPlayer2.kym

 
Hi Camille

You beat me to it.
The problem is that the same memory cell is being written to and read from at the same time and in this case the kyma scheduler has chosen to read first , hence we are always hearing the previous cycle. This wouldn't be a problem if the frequency was an exact sub division of the sample rate as every cycle would have the same number of sample ticks. Instead We have frequencies which may have cycle lengths something like this. 10 samp 10 samp 10 samp 11 samp 10 samp 10 samp 10 samp 11 samp. So what we are hearing is the signal delayed by 10 samples and then jumping to an eleven sample delay and back again, hence clicks. one solution (Option one attached is to add a one sample delay to the index to force the reader to read one sample latter ( a fixed delay of one sample). Another method (method Two) with no delay, is to conn the Kyma scheduler into thinking that the reader needs info from the writer (even though we are only sending silence) and it will force the writer to do it's bit first.

BUT

This is only masking the problem. I believe you intend to swap cycles around and join them together in different orders which will bring the problem straight back again. This is because, although you are slicing the cycles on the zero crossing point it is really only being sliced to the nearest whole sample. Hence cycle lengths that may really be 10.25 samples long, fall on the nearest border. Thats why we get 10 10 10 11 and not 10.25 10.25 10.25 10.25. A bit like the extra day in a leap year. So how do you over come this. One way would be to measure the the values of the sample immediately before and after the zero crossing and estimate where in the sample the zero actually happened. This would require a bit of maths including a division. There is a SR rate division module in petes DSP but it is pro hunger. Then you would have to play back cycles shifted by that fraction of a sample by using interpolation of adjacent samples.

Another method would be Option Three, which is to recored more than just one cycle (in this case two) and then overlap them using two readers and writers each working on every other cycle. Then you cross-fade between them on play back. This will get rid of the click but it won't solve the problem that different cycles will be in very slightly different phases and durations. This will be less of a problem at lower frequencies but there will still be a sort of FM especially at higher frequencies. It may not be such a problem when the cycles used are not sine waves as the lack of harmonics allow any artifacts to be easily heard.

Hope this helps

Pete

IP: Logged

tuscland
Member
posted 12 April 2006 06:42         Edit/Delete Message   Reply w/Quote
Pete, thank you very much for your insight.
I will try to enhance the algorithm, taking in account the problem of inter-sample crossing, which I have not thought about beforehand.

I will get a look at your file, as soon as I have a hand on my Capy.


Cheers,
Camille

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c