Skip to main content
Graduate
July 3, 2024
Solved

OPUS EXAMPLE

  • July 3, 2024
  • 2 replies
  • 1349 views

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);
 }
}
 
    This topic has been closed for replies.
    Best answer by nimaltd

    i think i found the problem, my start point of data was wrong. ( skip header/tag did not work property)

    how to find the packetSize? 

     

    2 replies

    Technical Moderator
    July 3, 2024

    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.

    nimaltdAuthorAnswer
    Graduate
    July 4, 2024

    i think i found the problem, my start point of data was wrong. ( skip header/tag did not work property)

    how to find the packetSize?