cancel
Showing results for 
Search instead for 
Did you mean: 

OPUS EXAMPLE

nimaltd
Senior

i have compiled opus lib on H5. but i can not decode data.

this is my init function and works fine.  
  DecConfigOpus.channels = 2;
  DecConfigOpus.ms_frame = 20;
  DecConfigOpus.sample_freq = 48000;
  uint32_t dec_size = DEC_Opus_getMemorySize(&DecConfigOpus);
  DecConfigOpus.pInternalMemory = (uint8_t *)malloc(dec_size);
  int opus_err;
  if (DEC_Opus_Init(&DecConfigOpus, &opus_err) != OPUS_SUCCESS)
  {
       printf("ERROR! DEC_Opus_Init()\r\n");
      break;
  }
and in decode function first time return 960 and then -4.
int packetSize = 80; // Adjust based on your actual packet size
for (int i = 0; i < sizeof(music); i += packetSize)
{
    int x = DEC_Opus_Decode((uint8_t*)&music[i], packetSize, DecConfigOpus.pInternalMemory);
    if (x < 0)
    {
          printf("Error decoding packet at index %d: %d\n", i, x);
         break; // Exit the loop or handle error as appropriate
    }
    else 
    {
       printf("Decoded packet at index %d, x = %d\n", i, x);
    }
}
 
1 REPLY 1
SofLit
ST Employee

Hello @nimaltd ,

A gentle reminder on how to post a thread in this community mainly on how to share a code source. I suggest to review these recommendations.

Thank your for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.