VS1000 Module Player with Seamless Looping

Writing software that inputs and/or outputs audio and performs DSP algorithms such as filters, new codecs or audio effects.
Post Reply
Alona
User
Posts: 1
Joined: Wed 2016-11-23 7:16

VS1000 Module Player with Seamless Looping

Post by Alona »

Hello.
I have VS1000 Module with UartAudioModule code (VS1000UartVoiceMailSoftware120).
My goal is to play one short .ogg music file in endless loop without gap. I found Player with Seamless Looping code.
I simply copied gapless looping part of the code to UartAudioModule code and changed the PlayCurrentFile() function by MyPlayCurrentFile().
The project compiled without problems. But when Play is started I don't hear the music playing.
Could you help me to solve this problem?

Code: Select all

// ------------ Gapless looping functionality --------------
// Expose some ROM functions...
auto s_int16 CodVorbisGoTo(register struct CodecVorbis *cv,
			   register u_int16 seconds);
extern struct Codec *cod;
struct Codec *CodVorbisCreate(void);
extern struct CodecServices cs;
extern u_int16 ogg[];
extern s_int16 vFirstFrame;
// PlayCurrentFile with gapless looping
u_int16 MyPlayCurrentFile(void) {
  register enum CodecError ret = ceFormatNotFound;
  LoadCheck(NULL, 0); // set higher clock
  if ((cod = CodVorbisCreate())) {
    const char *eStr;
    ret = cod->Decode(cod, &cs, &eStr); // play Ogg Vorbis
    // if played to the end, start over
    while (cs.fileLeft < 5) {
      LoadCheck(NULL, 0);    // set higher clock
      CodVorbisGoTo(cod, 0); // go to beginning of file
      ogg[1] = 0;            // ogg.headerTypeFlag: reset lastFrame
      ogg[14] = 0;           // ogg.cont: set vorbis continuation
      vFirstFrame = 1;       // first ogg frame in file
      cs.playTimeSamples = 0; 
      cs.playTimeSeconds = 0;
      ret = cod->Decode(cod, &cs, &eStr); // play Ogg Vorbis
    }
    cod->Delete(cod);
  }
  return ret;
}
User avatar
pasi
VLSI Staff
Posts: 2123
Joined: Thu 2010-07-15 16:04

Re: VS1000 Module Player with Seamless Looping

Post by pasi »

I copied the routine to the current version of the voicemail software, and with the addition of #include <codec.h> it seems to work as expected. However, you need to disable some options so that the code fits into memory.

What kind of Ogg Vorbis file are you trying?

There is a bug in the vs1000 decoder that mutes both channels if there's only audio in the right channel. Use PatchPlayCurrentFile() / PatchCodVorbisDecode() instead (from dev1000.h / libdev1000.a ). But using the latter with MyPlayCurrentFile() requires you to disable some other functionality from the Voicemail software.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply