VS1005 4-channel HiRes Recorder

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.
User avatar
Henrik
VLSI Staff
Posts: 1112
Joined: Tue 2010-06-22 14:10

Re: VS1005 4-channel HiRes Recorder

Post by Henrik » Thu 2019-02-14 14:02

Hello!

Something I forgot from the previous message: here is an example config.txt file for setting up the system for the 4-channel HiRes Recorder:

Code: Select all

[0]
# Default configuration, no buttons pressed during boot.
# Sets up audio drivers and clock, then starts HiRes Recorder..
#
# Set clock to a higher value so that even the more difficult codecs can play.
RUN SETCLOCK -l100 80
# Start SD card as device D
SDSD23 D
# Start UART in/out driver
UARTIN
# New 2015 audio DAC out driver
AUODAC s
# Enough buffer for HiRes Recorder to work
RUN AUOUTPUT -s4096
# New 2015 audio ADC in driver
AUIADC s 48000 line1_1 line1_3
# Enough buffer for HiRes Recorder to work
RUN AUINPUT -s4096
# S/PDIF automatic out, parameter can be either 48000 or 96000 (default)
AUOSPDA 96000
2000
# HiRes Recorder
RUN HIRESREC
# Start the shell if HiRes Recorder is exited
S:SHELL.AP3
Kind regards,
- Henrik
Good signatures never die. They just fade away.

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

Re: VS1005 4-channel HiRes Recorder

Post by Henrik » Tue 2019-02-19 9:58

Hello!

I am extremely pleased to announce that the HiRes Recorder now also supports 4-channel 96 kHz 24-bit PCM recording. Now it is possible to create a true professional quality multichannel recorder using the VS1005! Documentation has also been updated accordingly.

4-channel recording can be tested for example using the VS1005 Developer Board expanded with VS1005 Dev Board Extension 1.
http://wwwi.vlsi.fi/en/support/evaluati ... sion1.html

lcd4ch.png
lcd4ch.png (9.34 KiB) Viewed 115 times

4-CHANNEL 96 kHz RECORDING CONSIDERATIONS

DESIGNING A DEVICE THAT RECORDS AT 96 kHz

The VS1005 Dev Board Extension 1 board contains AsahiKASEI's AK5720 analog to digital converter.

As is the case with many other ADCs, AK5720 requires a 24.576 MHz MCLK to be able to properly sample 96 kHz. VS1005 is capable only capable of outputting 12.288 MHz through its MCLK pin. While still being fully able to communicate with VS1005 through 96 kHz 32-bit I2S, AK5720 will only sample at 48 kHz, outputting each sample two times. So, while communication and recording is technically 96 kHz, for the two channels coming from AK5720, the quality will only be 48 kHz equivalent.

To design a device that would have full-quality 96 kHz input, there are two options:

Option 1:
The external ADC must be able to sample 96 kHz at 128fs (12.288 MHz clock), or...

Option 2:
The device must have a 24.576 MHz crystal which is fed directly to the ADC's MCLK pin. This clock is also divided by two, and the resulting 12.288 MHz frequency is fed to VS1005. Both clocks MUST be from the same source so as to guarantee that they stay in sync. Then, when the ADC is configured for 256fs operation it can digitize at 96 kHz. If 48 kHz is needed as an option, it must be possible to set the ADC to 512fs mode.

MEMORY CARD SPEEDS

When recording at full quality (4 channels, 96 kHz, 24 bits), the resulting data bandwidth is approximately 9.2 Mbit/s, or 1125 KiB/s. While SD and microSD cards guarantee an average write speed way faster than this, every few seconds they pause briefly to do internal bookkeeping. These write freezes that can last up to several hundred milliseconds are a fundamental feature of modern SD and microSD cards, and they are a real issue when trying to record real-time data.

To survive these bookkeeping pauses, the VS1005 Dev Board Extension 1 board contains a 4 Mbit S-RAM buffer chip VS23S040. This memory is used as a temporary buffer (by the SDSD23.DL3 driver) when data cannot immediately be written to the SD card. This ensures an uninterrupted data flow as long as no more buffer space is needed than what is offered by VS23S040.

However, there are some memory cards that pause for so long that uninterrupted recording is not possible. In this case the current software shows an error message on the LCD. Also an "n samples lost" report is sent to the UART every second. If this error message occurs, you should try another type of SD card, preferably from a well-known high-quality vendor.

Of the SD and microSD cards tested by VLSI, Transcends, Lexars and Sandisks in the 8 - 256 GB range have consistently performed well. Some Kingston cards have also worked well, while some have had speed issues at maximum recording parameters. There have also been some issues with brandless cards. All cards VLSI have tested have worked well if data flow is halved from maximum, i.e. recording is done either at 2 channels 96 kHz 24 bits, or 4 channels 48 kHz 24 bits. VLSI cannot, of course, guarantee the suitability or speed of any SD card.

To see how close you are to the recording limits, you can follow the UART output of VS1005 while recording. Every second you will see a following report (the report below is from recording that has been going on for over 20 hours at 4 channels 96 kHz 24 bits to a high-quality 256 GB SDXC card:

Code: Select all

D:AUDIO/AUD02195.WAV: 78485s,    0 samples lost,  11/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78486s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78487s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78488s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78489s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78490s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78491s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78492s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78493s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78494s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78495s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78496s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78497s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78498s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78499s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78500s,    0 samples lost,  41/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78501s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78502s,    0 samples lost,   8/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78503s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78504s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78505s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78506s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78507s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78508s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78509s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78510s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78511s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78512s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78513s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78514s,    0 samples lost,  13/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78515s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78516s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78517s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78518s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78519s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78520s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78521s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78522s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78523s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78524s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78525s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78526s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78527s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78528s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78529s,    0 samples lost,  42/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78530s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78531s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78532s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78533s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78534s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78535s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78536s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78537s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78538s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78539s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78540s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78541s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78542s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78543s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78544s,    0 samples lost,  13/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78545s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78546s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02195.WAV: 78547s,    0 samples lost,   7/512 KiB buffer used
Because this is a very good card, the maximum amount of buffer space used during this example is 42 KiB of 512 available. If you look closely, you will notice that the freezes happen at regular intervals: approximately every 14-15 seconds, which translates to once for every 16 MiB of data written.

Usually (but not always) the biggest delays happen at the beginning of a new recording. Note how different the beginning of the next recording looks from the recording that had been going on for a long while:

Code: Select all

Continuous space 16138s (4:28:58) at 4 ch, 96000 Hz, 24 bits...
freeFrag.blocks 22a1480, reserved 0x3d00, miscData.spaceInBlocks 229d780, 241
D:AUDIO/AUD02197.WAV:    0s,    0 samples lost,   0/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    1s,    0 samples lost,  89/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    2s,    0 samples lost, 102/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    3s,    0 samples lost, 100/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    4s,    0 samples lost, 104/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    5s,    0 samples lost, 100/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    6s,    0 samples lost, 107/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    7s,    0 samples lost,  93/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    8s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:    9s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   10s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   11s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   12s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   13s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   14s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   15s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   16s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   17s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   18s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   19s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   20s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   21s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   22s,    0 samples lost,  11/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   23s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   24s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   25s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   26s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   27s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   28s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   29s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   30s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   31s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   32s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   33s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   34s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   35s,    0 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02197.WAV:   36s,    0 samples lost,  45/512 KiB buffer used
As you can see, for the first few seconds of this new recording, over 100 KiB of buffer space was needed while the card was doing internal bookkeeping. With a lower quality card, this could be much more, potentially even disastrous.

Below is an example recording with a non-disclosed 32 GB card that is too slow to record at full quality:

Code: Select all

Continuous space 26736s (7:25:36) at 4 ch, 96000 Hz, 24 bits...
freeFrag.blocks 395ee80, reserved 0x7c0, miscData.spaceInBlocks 395e6c0, 28
D:AUDIO/AUD02201.WAV:    0s,    0 samples lost,   0/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    0s,    0 samples lost,   0/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    1s, 56469 samples lost, 512/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    2s, 56469 samples lost, 492/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    3s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    4s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    5s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    6s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    7s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    8s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:    9s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   10s, 56469 samples lost,  14/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   11s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   12s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   13s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   14s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   15s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   16s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   17s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   18s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   19s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   20s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   21s, 56469 samples lost,  13/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   22s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   23s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   24s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   25s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   26s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   27s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   28s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   29s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   30s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   31s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02201.WAV:   32s, 56469 samples lost,  11/512 KiB buffer used
[...]
D:AUDIO/AUD02203.WAV: 4246s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4247s, 56469 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4248s, 91378 samples lost, 512/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4249s, 91378 samples lost, 487/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4250s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4251s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4252s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4253s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4254s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4255s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4256s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4257s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4258s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4259s, 91378 samples lost,  12/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4260s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02203.WAV: 4261s, 91378 samples lost,   7/512 KiB buffer used
[...]
D:AUDIO/AUD02204.WAV: 7065s, 91378 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02204.WAV: 7066s, 126062 samples lost, 512/512 KiB buffer used
D:AUDIO/AUD02204.WAV: 7067s, 126062 samples lost, 512/512 KiB buffer used
D:AUDIO/AUD02204.WAV: 7068s, 126062 samples lost,   7/512 KiB buffer used
D:AUDIO/AUD02204.WAV: 7069s, 126062 samples lost,   7/512 KiB buffer used
This log shows very typical behaviour of a slow card: right after recording starts, the card takes way too long to respond, and as a result 56469 samples, or in other words, 0.59 seconds of audio is left unrecorded. In the case of this particular card, recording then continues without further issues for the next 71 minutes, after which it again locks up for long enough that another 0.36 seconds of audio is lost. Exactly the same happens again close to the 118 minute mark: another 0.36 seconds of audio is lost.

Kind regards,
- Henrik

PS. Whee, my 1111th message!
Attachments
HiResRec070.zip
VSIDE Solution of the HiRes Recorder
(85.38 KiB) Downloaded 10 times
HiResRec_Ext1_v070.pdf
HiRes Recorder documentation for VS1005 DevBoard Ext1
(486.5 KiB) Downloaded 10 times
HiResRec_Bob2_v070.pdf
HiRes Recorder documentation for the brand new VS1005 breakout board 2.0
(367.42 KiB) Downloaded 9 times
Good signatures never die. They just fade away.

Post Reply