I2S Slave Input to MP3 Encoder

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
bill
User
Posts: 6
Joined: Sun 2015-12-13 22:41

I2S Slave Input to MP3 Encoder

Post by bill » Fri 2016-01-08 8:17

Gentlemen,

i am using a VS1005g Development Board and wish to input stereo I2S data (slave mode) at 16000 Hz sample rate with 16-bit depth on each of the left and right samples. My project is to mp3 encode this data stream and save it to files on the SD card.

My query applies to the Shell Application (S2/Reset) which is part of the VSOS 3.25 kernel and suite of applications.

Config.txt is modified to substitute AUXI2SS s for AUIADC s 48000 line1_1 line1_3. I have also replaced the I2S drivers with 'I2S Audio Drivers v1.02, 2015-12-21'.

Encoding and storage begins when UART command REC -r16000 F1.MP3 is sent. But then:

1. The second-by-second counts on the UART output run at twice normal speed.
2. When the resulting MP3 file is played with WMP (or with ClassicPlayer) the sound is very slow, less than 1/2 normal. Note: The file playback length matches the 2x recording counts.
3. Otherwise, the playback sound is very clean.
4. There is no sound on the left channel - both left and right inputs appear on the right side.

I tried AUII2S s in config.txt with different results:
1. Now the second-by-second counts on the UART output are at normal speed.
2. The resulting MP3 file still sounds slower than normal, but the playback length is true.
3. The sound is distorted.
4. Again, no sound on the left channel - both left and right inputs contribute to the right output.

I'm confident my I2S data are good. The waveforms match Figure 27, VS1005g Data Sheet, Version: 0.63, 2014-12-19. The signal works very well as input to other devices.

There must be somethings I need to learn! Perhaps there is an mp3 encoding parameter set incorrectly. Any help will be much appreciated.

Kind Regards,

Bill

User avatar
Henrik
VLSI Staff
Posts: 1149
Joined: Tue 2010-06-22 14:10

Re: I2S Slave Input to MP3 Encoder

Post by Henrik » Mon 2016-01-18 14:34

Hello Bill,

sorry for the delay. What you are trying to do is very interesting. I will try to reproduce what you have done and get back to you.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

bill
User
Posts: 6
Joined: Sun 2015-12-13 22:41

Re: I2S Slave Input to MP3 Encoder

Post by bill » Wed 2016-01-20 7:22

Henrik,

Thank you very much for taking the trouble to check out my configuration.

I can experiment with other sampling rates and will do so tomorrow.

Best Regards,

Bill

User avatar
Henrik
VLSI Staff
Posts: 1149
Joined: Tue 2010-06-22 14:10

Re: I2S Slave Input to MP3 Encoder

Post by Henrik » Wed 2016-01-20 10:10

Hello Bill,

no need for you to try different things. I am now building my own setup to verify (and correct) your issue. I am almost certain I already know what the issue is, but I still need to prepare my own setup so that I can verify the solution. Expect news from me today, or if there are more issues than I thought of, at least by Friday.

One thing that might help me though: could you upload and attach a problematic MP3 file for me? Just a few seconds would be enough for me to be able to better analyze the problem.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

User avatar
Henrik
VLSI Staff
Posts: 1149
Joined: Tue 2010-06-22 14:10

Re: I2S Slave Input to MP3 Encoder

Post by Henrik » Wed 2016-01-20 13:21

Hello again, Bill!

I think I have the solution for you. I tried it with the AUII2SS.DL3 audio driver, but it should work with the other I2S Slave drivers, too.

I've attached to this message a new package called AuControl.zip which contains AuInput.dl3 and AuOutput.dl3. While AuInput has been a part of the VSOS Libraries package before, this is a new version 1.01, which has a control you are going to need.

So, copy AuInput.dl3 and AuOutput.dl3 to the SYS/ folder of your system disk. Then you can either:

1) Add the following line to config.txt, after loading all audio drivers:

Code: Select all

run auinput 16
run auoutput 16 16000
2) or, run the following line in the VSOS Shell environment:

Code: Select all

auinput 16
auoutput 16 16000
The issue is that the I2S slave driver AUII2SS.DL3 starts by default in 32-bit mode, and unfortunately the MP3/Ogg Vorbis encoder requires for the data to be in 16-bit format. What these lines do is they tell both drivers to go to 16-bit mode, and sets the analog output driver to 16 kHz. After that, and assuming the I2S audio input actually is 16 kHz, you should be able to run the MP3 encoder with:

Code: Select all

rec -r16 file.mp3
I don't have a 16 kHz I2S source, but I tested this with 24 kHz. I think it should work with 16 kHz, too.

Kind regards,
- Henrik
Attachments
AuControl101.zip
Contains AuInput.dl3 and AuOutput.dl3 with source code to control stdaudioin and stdaudioout
(44.08 KiB) Downloaded 77 times
Good signatures never die. They just fade away.

User avatar
Henrik
VLSI Staff
Posts: 1149
Joined: Tue 2010-06-22 14:10

Re: I2S Slave Input to MP3 Encoder

Post by Henrik » Wed 2016-01-27 15:15

Hello Bill!

Did you get recording working?

I have updated the VSOS audio drivers, including a synchronization driver that lets the user automatically synchronize e.g. an I2S slave source with our DAC's Sample Rate Converter. You might want to try it out, as using the automatic sample rate conversion should guarantee that you will end up with good recordings, without glitches or other kinds of distortion.

To try the new system, first install the v1.02 Audio Drivers and tools attached to this message:
viewtopic.php?f=13&t=1655&start=10#p8828

Then you can create a config.txt file that has lines like this:

Code: Select all

# New 2015 audio DAC out driver
AUODAC s
# Slave mode I2S input driver
AUII2SS s
# Synchronize slave input driver with analog output driver and connect it
# to stdaudioin & stdaudioout
AUXSYNCS s
Now you should be able to e.g. see the sample rate of the I2S Slave input by saying on the command line:

Code: Select all

S:>auinput
In this case recording should be as easy as saying:

Code: Select all

S:>rec out.mp3
You can, if you want, still use the form you used earlier:

Code: Select all

S:>rec -r16 out.mp3
Kind regards,
- Henrik
Good signatures never die. They just fade away.

bill
User
Posts: 6
Joined: Sun 2015-12-13 22:41

Re: I2S Slave Input to MP3 Encoder

Post by bill » Wed 2016-01-27 18:51

Hello Henrik,

I'm sorry I have not been able to work on this project during the last weeks. I will return to it soon.

Thank you very much for the attention you have given this question. The project is important to us and VLSI's contribution is very much appreciated.

Warm Regards,

Bill

User avatar
Henrik
VLSI Staff
Posts: 1149
Joined: Tue 2010-06-22 14:10

Re: I2S Slave Input to MP3 Encoder

Post by Henrik » Thu 2016-01-28 12:29

Hello Bill,

happy to help! This synchronization software was on my to-do list anyway; your question just prompted me to implement it a bit earlier than originally scheduled.

I'd be happy to hear of your progress when you have time to get back to your project. Of course, if new issues arise, that would also be good to know.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

Post Reply