VS1053 real time audio pitch

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
benjavita
User
Posts: 5
Joined: Thu 2020-01-02 16:56

VS1053 real time audio pitch

Post by benjavita » Thu 2020-01-02 17:58

Hello, and happy new year :)

I am pretty new to programming microchips, so please accept my apologies in advance for simple question.

I am controlling the VS1053 with an ESP32, and have managed to read mp3 files from sd card (using Adafruit library), and also used the audio pitch plugin to change the pitch of the music and this works great.

Now my goal is to change the pitch not from a file but from the line in/microphone input and output in real time, and I'm not too sure where to start...

I don't understand how the plugin works and can't find any source code for it.

Any help would be much appreciated to get me started in the right direction :!:

Many thanks, Ben

User avatar
pasi
VLSI Staff
Posts: 1702
Joined: Thu 2010-07-15 16:04

Re: VS1053 real time audio pitch

Post by pasi » Fri 2020-01-03 12:36

The pitch/temposhifter of the vs1053b patches package only works with decoding. It uses the DAC FIFO and DAC interrupts in a way that conflicts with the encoding mode.

Pitch-shifting from a real-time source has some unique problems. The playback needs to stay in (approximate) synchronization with the input, so some additional automatic adjustment would be needed.

Synchronization is easier to arrange with a fixed ratio.

What kind of pitch shift values do you need?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

benjavita
User
Posts: 5
Joined: Thu 2020-01-02 16:56

Re: VS1053 real time audio pitch

Post by benjavita » Sat 2020-01-04 13:02

Hi Pasi,

The plugin I was using was the "VS1003b & VS1053b Pitch Shifter Plugin" from the page at http://www.vlsi.fi/en/support/software/ ... ugins.html

Is it different from the one in the vs1053b patches package, which I haven't tried?

My aim is to transpose music so there would be a button to adjust the key (12 semitones), and therefore a fixed ratio will not help in this case...

Are you saying this is not possible when recording from line in/mic (encoding PCM)?
How does the DAC conflict with the recording mode, and is there no workaround?

Thanks so much for your help, much appreciated.

benjavita
User
Posts: 5
Joined: Thu 2020-01-02 16:56

Re: VS1053 real time audio pitch

Post by benjavita » Thu 2020-01-09 15:23

Hi again!

I suppose if it is not possible to use the VS1053b for both encoding and encoding, I could record the PCM with another DAC connected to the esp32, and send it to the VS1053's output buffer configured with the audio pitch plugin, and that it would work the same way as when it reads mp3 files.

Could you please confirm that this should work this way?
If so could you give me some hints on how to send the data to the VS1053b's DAC buffer?

And also is there any difference between the audio pitch plugin that's on the plugins page, and the one included in the VS1053b patches package?

Many thanks, Ben

User avatar
pasi
VLSI Staff
Posts: 1702
Joined: Thu 2010-07-15 16:04

Re: VS1053 real time audio pitch

Post by pasi » Mon 2020-01-13 12:57

It's the same code.

I'll try to take a look this week at how at odds the encoding mode actually is with the pitch shifter. If their core routines do not interfere with each other, then it would 'only' need some ratio finetuning to keep the output latency relatively constant. (Not to say it would be easy.)

(In vs1063 the DAC FIFO size is reduced in encoding mode to free some memory. If this doesn't happen in vs1053, then the pitch shifter could be used.)
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

benjavita
User
Posts: 5
Joined: Thu 2020-01-02 16:56

Re: VS1053 real time audio pitch

Post by benjavita » Mon 2020-01-13 16:12

Thanks Pasi,

It would be amazing if we could use the line in for pitch shifting without the need for an external ADC!

If it's not the case, could I ask what kind of algorithm you use to do the job, is it based on FFT? Or did you develop your own algorithm?

I'm asking as I'm wondering if we could try to use the function written in C by S. Bernsee at http://blogs.zynaptiq.com/bernsee/pitch ... ng-the-ft/

Cheers :)

User avatar
pasi
VLSI Staff
Posts: 1702
Joined: Thu 2010-07-15 16:04

Re: VS1053 real time audio pitch

Post by pasi » Tue 2020-01-14 10:16

This version of the pitch shifter is very simple and low quality. There just isn't enough processing power reserve to do anything complex. (But we have a better version somewhere.)
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

User avatar
pasi
VLSI Staff
Posts: 1702
Joined: Thu 2010-07-15 16:04

Re: VS1053 real time audio pitch

Post by pasi » Thu 2020-01-16 14:00

Hi,
I noticed we have a suitable starting point - the vs1053b AD Monitor with Bass/Treble control. So, I added the pitch shifter function there.

The packet attached, let me know how it works.
Attachments
vs1053-admoneq12.zip
(93.03 KiB) Downloaded 102 times
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

benjavita
User
Posts: 5
Joined: Thu 2020-01-02 16:56

Re: VS1053 real time audio pitch

Post by benjavita » Mon 2020-01-20 17:46

Thank you so much Pasi, that works really well :)

You say
This version of the pitch shifter is very simple and low quality. There just isn't enough processing power reserve to do anything complex. (But we have a better version somewhere.)
What is the better version??
And is it for the VS1053, or another chip?

Cheers, Ben

User avatar
pasi
VLSI Staff
Posts: 1702
Joined: Thu 2010-07-15 16:04

Re: VS1053 real time audio pitch

Post by pasi » Wed 2020-01-22 11:05

Great to hear it works for you.

The better version exists for vs1005.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Post Reply