Skip to content

Some help in correctly using the audio player needed (troubleshooting crashes, skeleton code?) #305

Answered by pschatzmann
mbariola asked this question in Q&A
Discussion options

You must be logged in to vote

I suggest that you try

int32_t get_sound_data(Frame* frames, int32_t count) {
    uint8_t *data = (uint8_t*)frames;
    int framesize = 4;
    size_t result_len = wfh.readBytes(data, count*framesize) / framesize;   
    if (result_len == 0){
       // if no more data, just return silence
       memset(data, 0, count*framesize);
       result_len = count;
    }
    return result_len;
}

And dont't forget: if you open a wav file first read 44 bytes which are the header which must be ignored.

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@mbariola
Comment options

@pschatzmann
Comment options

@mbariola
Comment options

Answer selected by pschatzmann
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants