
              VS1005 SPI Streaming Example
              ----------------------------
                 for VSOS 3.67 or higher
                2023-07-14  VLSI Solution



The BFXSPI drivers offer buffered SPI operations for VS1005.

To test this driver pair you need current as of 2023-07-14 versions of:
audiodec.dl3
BfISpiS.dl3
BfOSpiM.dl3

For this demonstration two VS1005 Developer Boards are needed.
They will be called Board 1 and Board 2. Our intent is to send
encoded audio data from Board 1 to Board 2.

1) Copy all .dl3 files in this package to the SYS folder of both
Board 1 and Board 2.

2) Connect two VS1005 Developer Boards B1 and B2 to each other.
Alternatively you may use VS1005 Break-out Boards but then pin names
are slightly different. Connect the following pins together:

Board 1    GND <-> Board 2    GND
Board 1 X2 SC1 <-> Board 2 X2 SC1 (SPI 1 Clock)
Board 1 X2 MO1 <-> Board 2 X2 MO1 (SPI 1 MOSI)
Board 1 X2 MI1 <-> Board 2 X2 MI1 (SPI 1 MISO)
Board 1 X2 XC1 <-> Board 2 X2 XC1 (SPI 1 xChip Select)



3) Prepare receiver Board 2
---------------------------

Connect headphones to Board 2 Headphones connector or an amplifier to
the Line Out connector.

Boot up Board 2. After boot-up, run the following commands:

S:>driver +bfispis p
CALL RESTART FOR 0x23f1
S:>::
Currently installed system devices are:
- D:  476G SD/SD Card, handled by FAT.
- P:        BfISpiS.
- S: 1920K SPI Flash c814, handled by FAT.
S:>playfile p:
Playing 'BfISpiS'


4) Prepare transmitter Board 1
------------------------------

We are going to use the microphones provided on VS1005 Developer Board.
If you are using the VS1005 Break-Out Board, you will need some other
way to feed audio to its analog inputs.

Boot up Board 1. After boot-up, run the following commands. Note that
if you didn't have an audio input driver loaded, the first command
will give an error message. This is not a problem.

S:>driver -auiadc
S:>driver +auiadc s mic1 mic2 dec6 8000
  Input 0xa200  Rate 8000S:>driver +bfospim p
S:>rec +f -b32 -cm -fm -r8000 p:
Recording MP3: 8000 Hz mono at 32 kbit/s
~050a'p:
Open(c92, , wb)
~030a=1

You should now see a time counter running on both boards, and you
should hear the sound of the microphones on Board 1 coming from the
headphones on Board 2. Note that the sound may be faint in volume,
so to test that the system works, you may gnetly touch the microphones
on Board 1.


5) Testing other MP3 encoding parameters

To test other parameters, you may push 'q' or Ctrl-C on Board 1 to
stop encoding MP3. Then, enter for instance the following command
for MP3 encoding with different parameters:
S:>rec +f -b64 -cm -fm -r32000 p:
Recording MP3: 32000 Hz mono at 64 kbit/s

For this demonstration, sample rates 8 kHz, 16 kHz, and 32 kHz are
suppported. Bit-rates up to 64 kbit/s are supported.

MP3 is a format intended for streaming. As such it is resilient to
errors. You may disconnect and reconnect any of the SPI wires and
playback will resume.


6) Testing Opus.

To test Opus, first reset both Board 1 and Board 2. Then enter the
same commands for Board 2 as shown earlier in (3). Then do the same
for Board 1 as shown in (4) except the recording command is as
follows:

S:>rec +f -b8 -cm -fo -r8000 p:
IMEM: only 2708w free!
IMEM: only 742w free!
Recording Opus: 8000 Hz mono at 8 kbit/s

At this early demonstration stage, playing back Opus format will
cause a short burst of noise, then audio starts playing.

Opus encoding is supported at 8 and 16 kHz.




Version History:
2023-07-14 HH v0.01 - First prerelease.
