Is there an approved way to acquire the data offset?

Asked By 30 points N/A Posted on -
qa-featured

 

Hi experts,

I’m constructing a few progresses on getting a compressed (mp3) sound and I am saving it as PCM.

Also, I tried to split the main file in the same process into chunks and it is 2 seconds long.

I look like to be successful; however I am a bit confused.

As I convert blocks of audio as well as write the files out, I make sure to make out if I am ready to write a chunk that would build my file go beyond my 2 second bound.

If thus, I write sufficient to acquire to 2 seconds, and then shut the file, and after that, open a fresh file and also write the rest into the fresh file, and next read extra data.

Like this:

framesInTimedSegment += numFrames;
if ((framesInTimedSegment  > (2.0 * sampleRate)) && (j < 5)) {
    UInt32 newNumFrames = numFrames;
    numFrames = framesInTimedSegment – (2.0 * sampleRate);
    newNumFrames -= numFrames;
// Question A
    UInt32 segmentOffset = newNumFrames * numChannels * 2;
    error = ExtAudioFileWrite(segmentFile, newNumFrames, &fillBufList);
// Question B
       // handle this error!  We might have an interruption
    if (segmentFile) ExtAudioFileDispose(segmentFile);
    XThrowIfError(ExtAudioFileCreateWithURL(urlArray[++j], kAudioFileCAFType, &dstFormat, NULL, kAudioFileFlags_EraseFile, &breakoutFile), "ExtAudioFileCreateWithURL failed! – segmentFile");
    size = sizeof(clientFormat);
    XThrowIfError(ExtAudioFileSetProperty(segmentFile, kExtAudioFileProperty_ClientDataFormat, size, &clientFormat), "couldn't set destination client format");
    fillBufList.mBuffers[0].mData = srcBuffer + segmentOffset;
    fillBufList.mBuffers[0].mDataByteSize = numFrames * fillBufList.mBuffers[0].mNumberChannels * 2;
    framesInTimedSegment = numFrames;
}
error = ExtAudioFileWrite(segmentFile, numFrames, &fillBufList);

Anyways, my question is:

A: Is there any improved technique to get the offset in my buffer by which, I don't hard code incorrectly a few value in there? I mean, is there an approved way to acquire the data offset?

B: ExtAudioFileWrite is performing the exchange from compressed to decompressed. After that, the information I am writing hasn't so far been decompressed (right?). Therefore, shouldn't I have to be anxious about playing with frame digits as well as offsets when I am contracting with compressed data? Should I convert the file first, and then divide that PCM?

I am not sure. Please help me.

Thanks a lot.

SHARE
Answered By 0 points N/A #147768

Is there an approved way to acquire the data offset?

qa-featured

Offset data are used exclusively with area variables. The value of an offset variable indicates the location of a based variable within an area variable relative to the start of the area.

Because the based variables are located relatively, if the area variable is assigned to a different part of main storage, the offset values remain valid. A deluge of data is being made available for public use. In the raw-form, large complex data sets is difficult to understand and interpret.

Having the tools and techniques to present illustrated data to your audience with aesthetic form and functionality are critical for conveying ideas effectively.

You'll enjoy personalized small class instruction in a state of the art Mac lab. This program is a skill-based learning experience.

Login/Register to Answer

Related Questions