Can VS1000 do pitch shifting?
Can VS1000 do pitch shifting?
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?
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?
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?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Re: Can VS1000 do pitch shifting?
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.
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?
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.
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.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Re: Can VS1000 do pitch shifting?
OK. Thanks for the info.
Re: Can VS1000 do pitch shifting?
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.
Are you using SD card or SPI memory for storage? I might be able to give you example code.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Re: Can VS1000 do pitch shifting?
Hi Pasi,
I'm using SPI memory.
I'm using SPI memory.
Re: Can VS1000 do pitch shifting?
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.)
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.)
- Attachments
-
- sdplayer.c
- sdplayer with pitch shifting.
- (54.19 KiB) Downloaded 374 times
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Re: Can VS1000 do pitch shifting?
Thanks for the source code Pasi.
Re: Can VS1000 do pitch shifting?
Hi Pasi,
I've based a custom program off the sdplayer.c with USE_PITCH_SHIFT source code shared in this thread.
I have the player setup so that it is playing a .ogg file on loop using the gapless looping player function from the spi_loop.c example code.
I am then streaming volume and frequency shift values over the UART from another MCU which is trying to modify this base sound in real time. The .ogg file is stereo with a 16Khz sample rate.
The below code is where I am updating the clock prescaler to pitch shift the audio. At values of extClock4KHz below 2500 the audio starts to sound very grainy - is this an issue with the code or just the audio file itself?
I am unsure if I need to be updating hwSampleRate manually - can you please advise if there is anything I'm missing?
This code is called from inside the IdleHook if a 'C' char has been RX'd over UART. The program project is based on spiuart.c using SBFS with SPI Flash memory.
Thanks!
I've based a custom program off the sdplayer.c with USE_PITCH_SHIFT source code shared in this thread.
I have the player setup so that it is playing a .ogg file on loop using the gapless looping player function from the spi_loop.c example code.
I am then streaming volume and frequency shift values over the UART from another MCU which is trying to modify this base sound in real time. The .ogg file is stereo with a 16Khz sample rate.
The below code is where I am updating the clock prescaler to pitch shift the audio. At values of extClock4KHz below 2500 the audio starts to sound very grainy - is this an issue with the code or just the audio file itself?
I am unsure if I need to be updating hwSampleRate manually - can you please advise if there is anything I'm missing?
This code is called from inside the IdleHook if a 'C' char has been RX'd over UART. The program project is based on spiuart.c using SBFS with SPI Flash memory.
Thanks!
Code: Select all
/* Configuration */
case 'C':
// Decode Clock Prescaler
// 12.000 MHz / PSC = 4 kHz
// 3000 = Normal Speed (Lower Values Increase Speed)
extClock4KHz = (0xFF00 & (MyGetChar() << 8)) | (MyGetChar() & 0xFF);
playSpeed = (f_int16)extClock4KHz / (f_int16)(12000/2);
// Decode Channel Volumes
// 0 = Max Volume, 255 = Mute
sysVolume = (0xFF00 & (MyGetChar() << 8)) | (MyGetChar() & 0xFF);
volumeReg = sysVolume;
// Echo Parameters
puthex16(extClock4KHz);
puthex16(volumeReg);
putch2('\n');
// Update HW Registers
NewSpeedShiftFract(playSpeed);
SetRate(hwSampleRate);
SetVolume();
break;