Patches and OGG Recording

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
quickshat
User
Posts: 10
Joined: Fri 2016-07-22 11:21

Patches and OGG Recording

Post by quickshat » Wed 2019-03-27 15:30

Hi,

since my last post i managed it to record and play several ogg files successfully but sometimes i am experiencing strange issues that must be solved before the product will reach production state.

First of all: Is the patching process required after each SoftReset ?

Then to the second topic: With a chance of 60-70%, after sending the stop recording signal (SciWrite(SciRegisters.AiCtrl3, 1)), the VS1053 acts like it didn't receive anything (it actually did because it stopped audio monitoring but nothing else) and your algorithm for reading ogg data from the device loops infinitely with reading the same values from HDAT0/HDAT1 over and over.

Code: Select all

while (state < 3)
                {
                    if (_stopRecording && state == 0)
                    {
                        state = 1;
                        SciWrite(SciRegisters.AiCtrl3, 1);
                    }

                    ushort waiting = ReadHdat1();

                    if (state == 1 && (SciRead(SciRegisters.AiCtrl3) & (1 << 1)) != 0)
                    {
                        state = 2;
                        waiting = ReadHdat1();
                    }

                    while (waiting >= (state < 2 ? 256 : 1))
                    {
                        var toRead = (ushort)(waiting < 256 ? waiting : 256);
                        waiting -= toRead;

                        if (state == 2 && waiting == 0)
                        {
                            toRead--;
                        }

                        for (int i = 0; i < toRead; i++)
                        {
                            ushort t = ReadHDat0();
                            w.Write((byte)(t >> 8));
                            w.Write((byte)(t & 0xFF));
                        }

                        w.Flush();

                        if (toRead < 256)
                        {
                            state = 3;

                            ushort last = ReadHDat0();
                            w.Write((byte)(last >> 8));

                            SciRead(SciRegisters.AiCtrl3);
                            if ((SciRead(SciRegisters.AiCtrl3) & (1 << 2)) == 0)
                            {
                                w.Write((byte)(last & 0xFF));
                            }
                            w.Flush();
                        }
                    }
                }
Here is my code, but this is just a 1-to-1 translation from your c-demo to c# netmf.
w is a StreamWriter instance and all dependency vars like waiting are zero initialized some lines above.

Maybe you have some ideas or already faced a similar problem.
Regards

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

Re: Patches and OGG Recording

Post by Henrik » Wed 2019-04-10 15:08

Hello!

Are you still having this issue, or has it solved itself?

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

Post Reply