I had some time to think about the input stage. My main intention was to capture the Serato NoiseMap signal and decode it. I made some experiments with my MixVibes vinyls, as I did not have Serato. I have Torq vinyls also, but I don’t really like and use them.
First I captured the sine wave while scratching fast and with very slow record movements. I then made a spectrum plot to see the highest and lowest frequencies during scratching.
I realized that the base frequency is 1300Hz for Mixvibes vinyls, which I did know in advance of course. During scratching I could only acheive duoble the base frequency, so around 2500-2600 Hz, maybe 2900 Hz with very hard scraching.
The lowest frequency obviously could be 0 Hz, but while I still moving the record it hardly went below 200Hz. The highest frequency is around 2.5 times the base. The lowest ones are around 6.5 times slower than the base.
I can see very big differences in the amplitude of the signal. Slow movements results in a very low amplitude, while fast scratching can be 4 times higher.
It does not seem to be a trivial work. I think I should maintain variables to keep tracking the current scale of the amplitude. I’m going to study the timecode part of the xwax project. It is an open source DVS software for linux, and is used by for example Mixxx.
I was thinking of doing FFT analyzis to get the current frequency of the signal. But after some calculations, it proved to be too slow. I need to collect at least 256 samples, which takes almost 6ms with 44.1KHz sampling plus doing the FFT. And the resolution is still not good enough, it is 172Hz. I need a resolution around 10Hz and 1-2ms latency maximum. I could go up with the sampling frequency to shorten the collection time of 256 samples. In 256KHz it would be only 1 ms, but in that case the resoulution of the FFT would be 1000Hz which is useless. So the standard zero-crossing method would be a better way.
For emulating a MIDI jogwheel I don’t really need to decode the absolute positions. I just need to provide the angular velocity in a timely basis. For example in every 1-2 ms. In this case I can be more forgiving with the amplitudes of the sine wave. I can detect zero-crossing at the minimal amplitude as well.
To decode the Serato timecode, I need to build a lookup table with a Linear Feedback Shift Register they use, with the right feedback function and the right seed. Which is also documented in xwax source. But It might consume a lot of space in the microcontroller. I didn’t really calculate it so far.
For a conclusion, I have to measure the frequency mostly in 150-2500 Hz range. But be prepared for the DC or 0Hz. For that range 5KHz sampling would be enough theoretically, but I think this would make an unacceptable jitter in my zero-crossing detection. Maybe 10 or 20KHz sounds better.
I run through the ADC modes of STM32. I think I have to measure L,R channels for each input at the same time to measure the proper phase difference. But this is a supported mode. STM32 can do conversion on ADC1 and ADC2 at the same time. I have to interleave Deck A and Deck B measurements. It seems to be doable with the STM32 ADC and with DMA.