Page 1 of 1

Patches and OGG Recording

Posted: Wed 2019-03-27 15:30
by quickshat
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

Re: Patches and OGG Recording

Posted: Wed 2019-04-10 15:08
by Henrik
Hello!

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

Kind regards,
- Henrik

Re: Patches and OGG Recording

Posted: Mon 2019-06-17 17:52
by quickshat
Solved it. Thanks!