Welcome Guest ( Log In | Register )

ogg parameters problem libsndfile
post Jan 15 2013, 19:34
Post #1

Group: Members
Posts: 3
Joined: 7-January 13
Member No.: 105674

I made a function using libsndfile that should encode RAW PCM 16-bit file to OGG Vorbis file.Function that checks format says that something is wrong with parameters but when i tried to check what's wrong in this function manually i haven't found what's wrong.Could you tell me what's wrong here.
Here's my code.
static void encodeOgg (const char *infilename, const char *outfilename, int filetype)
{    static SAMPLE buffer [BUFFER_LEN];

    SNDFILE        *infile, *outfile;
    SF_INFO        sfinfo,sf_in;
    int            readcount;

    fflush (stdout);
    sf_in.format=SF_FORMAT_RAW | SF_FORMAT_PCM_16;
    if (! (infile = sf_open (infilename, SFM_READ, &sf_in))){
        error("Could not open input file");
        exit (1);
    sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;

    if (! sf_format_check (&sfinfo)){    
        sf_close (infile);
        error("Invalid encoding\n");
        exit (1);
    if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo))){
        error("Error : could not open output file");
        exit (1);

    while ((readcount = sf_read_short (infile, buffer, BUFFER_LEN)) > 0)
        sf_write_short (outfile, buffer, readcount);
    sf_close (infile);
    sf_close (outfile);
Go to the top of the page
+Quote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 26th November 2015 - 20:23