Page 1 of 1

Can VS1000 do pitch shifting?

Posted: Thu 2019-09-12 14:46
by cjh
We have an existing product that makes use of the VS1000. However, we now have a new application that needs playback to be pitch shifted without changing tempo. Is there any way to get the VS1000 to do this? I've seen elsewhere on this forum that the VS1005 can do so, but we can't justify the cost of redesigning our existing product to meet this new application.

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 10:16
by pasi
Hi,
What kind of files are you playing? Mono or stereo Ogg Vorbis? Samplerate?

How good would the pitch-shifting need to be? How much of a shift up and down is needed?

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 10:59
by cjh
Hi,

The files are mono Ogg Vorbis. Sample rate would ideally be 44100, but around 22050 might be OK.

Maximum required pitch shift would be a factor of approx. two with the ability to step in approx. 1% increments. The resultant audio would need to sound pretty good with minimal artifacts.

Thanks for your response.

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 11:10
by pasi
There is a speed shifter in libdev1000.a, see dev1000.h for the documentation and prototypes. There is also a mono-specific version.

To make a pitch shifter out of a speed shifter, you would "just" need to adjust the playback samplerate in the other direction.

If you don't care about accurate playtime, for Ogg Vorbis you could modify the cs->sampleRate field. Alternatively you can install your own SetRate() function which calculates the DAC control value taking the pitch shifting into account. (We'll probably need to help you there a bit.) Edit: Actually, adjusting the extClock4KHz variable is probably the easiest.

However, if you play 44.1kHz material with 12MHz crystal, without further tricks you can only adjust the playback rate about +6% (one semitone). 22kHz gives you the one octave up/down range.

You would need to test whether the result is good enough for your use. It is not as good as the VS1005 version.

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 12:14
by cjh
OK. Thanks for the info.

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 12:51
by pasi
My old test code seems to be limited between 0.75x and 1.5x, but I'm not sure if that's the limit of the pitch shifter itself.

Are you using SD card or SPI memory for storage? I might be able to give you example code.

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 14:12
by cjh
Hi Pasi,

I'm using SPI memory.

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 15:18
by pasi
Here's sdplayer with pitch shifting 0.75..1.5 (if samplerate is low enough). UART control 'u' / 'd' / 's' for pitch down, pitch up, and set to 1.0x. (Pitch up is 'd', and down is 'u', you can reverse them.)

The added code is inside #ifdef USE_PITCH_SHIFT sections, so you can integrate into your code.

I might fiddle with spiplayer tomorrow.

(Remove the assignment to extClock4kHz to get speedshifter instead.)

Re: Can VS1000 do pitch shifting?

Posted: Mon 2019-09-16 16:22
by cjh
Thanks for the source code Pasi.