• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reversing ReverseOfflineUnit problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reversing ReverseOfflineUnit problems


  • Subject: Reversing ReverseOfflineUnit problems
  • From: "Asher Vander Heiden" <email@hidden>
  • Date: Mon, 31 May 2004 14:28:36 +1000

Hey Robert,

Thanks for your help so far. We would be lost with out it....

There is a new problem regarding the ReverseOfflineUnit. We have been attempting to use the unit to produce an audio file that is not reversed but is processed in the correct order.

After discovering exactly how the ReverseOfflineUnit does its processing we have attemped to re-write the render to process the file forward. However, with what we have written we get a 'signal 11' error.

Here is the render we have changed. It would be much appreciated if you could tell us what is going wrong ...

/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ReverseOfflineUnit::StreamFormatWritable
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ComponentResult ReverseOfflineUnit::Render( AudioUnitRenderActionFlags &ioActionFlags,
const AudioTimeStamp & inTimeStamp,
UInt32 nFrames)
{
outCount = 0;

if (!HasInput(0))
return kAudioUnitErr_NoConnection;

// first we have to make sure that the rendering flag matches our internal state...
bool preflight = (ioActionFlags & kAudioOfflineUnitRenderAction_Preflight);
bool doRender = (ioActionFlags & kAudioOfflineUnitRenderAction_Render);

// one of these two flags have to be provided
if (!preflight && !doRender)
return kAudioUnitErr_InvalidOfflineRender;

if (preflight)
return kAudioOfflineUnitRenderAction_Complete;

// OK - now we have to figure out which input we want based on the output time
// we're asked for

// in this case, as we're a reverse unit this is a simple calculation...
// we need a new time stamp based on the one we were given.

AudioTimeStamp ts (inTimeStamp);
ts.mSampleTime = inTimeStamp.mSampleTime;

UInt32 numFramesToPull = nFrames;
bool renderPhaseComplete = false;

if ((ts.mSampleTime) > (mNumInputSamples-nFrames)) {

// one word of caution.. if we're preflighting we need to change that state to be ready to render
// as to get here we're basically done with our sample processing

// do we have a partial buffer to fill
ts.mSampleTime -= nFrames;
if ((ts.mSampleTime) < (mNumInputSamples-nFrames)) {
numFramesToPull = mNumInputSamples - (UInt32)(ts.mSampleTime);
ts.mSampleTime = mNumInputSamples;
renderPhaseComplete = true;
} else {
// this is just a protection if someone pulls us for data past what we have...
ioActionFlags |= kAudioOfflineUnitRenderAction_Complete;
}
}


// OK - now we are good to go...

AUOutputElement *theOutput = GetOutput(0); // throws if error
AUInputElement *theInput = GetInput(0);


ComponentResult result = theInput->PullInput (ioActionFlags, ts, 0 /* element */, numFramesToPull);

if (result)
return result;

// ok - now we reverse our input data
// if we have a remainder we need to zero out the output buffer

AudioBufferList &inputBuffer = theInput->GetBufferList();
AudioBufferList &outputBuffer = theOutput->GetBufferList();


// we'll do the reverse one channel at a time...
for (UInt32 i = 0; i < inputBuffer.mNumberBuffers; ++i)
{
Float32* inSampleData = (Float32*)inputBuffer.mBuffers[i].mData;
Float32* outSampleData = (Float32*)outputBuffer.mBuffers[i].mData;

out = 0;
for (SInt32 in = 0; in < numFramesToPull ; in++ )
{
// OUR FORWARD PROCESS
}
}
if (renderPhaseComplete) {

UInt32 numValidBytes = (numFramesToPull - 0) * sizeof (Float32);
// we just need to reset the numbytes field as that indicates the valid portion of the buffer
for (UInt32 i = 0; i < outputBuffer.mNumberBuffers; ++i) {
outputBuffer.mBuffers[i].mDataByteSize = numValidBytes;
}

ioActionFlags |= kAudioOfflineUnitRenderAction_Complete;
}


return noErr;
}



Thank you in advance,

Asher Vander Heiden

_________________________________________________________________
Find love today with ninemsn personals. Click here: http://ninemsn.match.com?referrer=hotmailtagline
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Reversing ReverseOfflineUnit problems
  • Previous by thread: Reversing ReverseOfflineUnit problems
  • Index(es):
    • Date
    • Thread