IPB

Welcome Guest ( Log In | Register )

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





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



Hi,
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.
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.samplerate=SAMPLE_RATE;
    sf_in.channels=NUM_CHANNELS;
    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.samplerate=SAMPLE_RATE;
    sfinfo.channels=NUM_CHANNELS;
    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);
    return;
}
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: 18th December 2014 - 03:05