• 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
Re: ExtAudioFile woes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ExtAudioFile woes


  • Subject: Re: ExtAudioFile woes
  • From: Christian Rober <email@hidden>
  • Date: Wed, 03 Jun 2015 20:21:47 -0400

Hi John,

Without trying this out, here are some quick thoughts that may help (I apologize if you have already tried these):

1) What is value range/type of _starttime?  Is it in seconds?  Milliseconds?  CPU time?  I would make sure that it is in seconds, because a really large millisecond value may generate an offset beyond the end of a small file.

2) I would use ExtAudioFileTell() as a sanity check before you call this code.  Print out the value, it should be 0 at first, if you haven't read from it already.

3) Have you been reading from the file?  Just like Unix open and its corresponding file descriptor, an ExtAudioFileRead (+Async) on this file will advance the position in the file that a seek uses.  In other words, since there is no pread() equivalent in the ExtAudioFile framework, all reads seek, and you may already be at or near the end.

4) In terms of the ChannelDescription issue... that is very perplexing.  I did see this comment in the documentation which confuses me:

When reading, the specified layout overrides the one read from the file, if one is present in the file.

Maybe the mp4 file does not have a ChannelDescription, so it reads that description correctly, but the AIFF has a ChannelDescription, as you described by cracking the file open, so you end up inadvertently creating a bogus CD.  What is really confusing, is why would a get property overwrite anything?!?

--Christian



On Wed, Jun 3, 2015 at 4:46 PM, John Weeks <email@hidden> wrote:
I hope this list is alive- I haven't seen anything since I signed up 24 hours ago!

I am using ExtAudioFile API's to extract the data from sound files (we publish a scientific data analysis application). I can open a file and read the data just fine. Core Audio makes it pretty easy to do that with a large variety of sound files.

I'm doing this on a 5k iMac running OS X 10.10.3. Writing in C++, not Objective C++, in case that's relevant.

BUT...

I can't seek. I am trying to use this:

        SInt64 seekFrames = 0;
        if (_startAndEndSet)
        {
                seekFrames = _starttime*formatDescription.mSampleRate;
                seekFrames = std::max(SInt64(0), seekFrames);
                if (seekFrames >= fileFrames)
                {
                        _error = SYNERR;                        // TODO: better errors
                        return;
                }
                if (seekFrames > 0)
                {
                        _error = ExtAudioFileSeek(_audioFileRef, seekFrames);
                        if (_error)
                                return;
                }

        ...

I always get  kExtAudioFileError_InvalidSeek no matter what value seekFrames has.

At least I get a documented error code!

I would also like to get at some of the metadata, like the channel layout. For that I use code like this:

        Boolean writable;

        AudioChannelLayout * filechannelLayout;
        _error = ExtAudioFileGetPropertyInfo (_audioFileRef, kExtAudioFileProperty_FileChannelLayout, &datasize, &writable);
        filechannelLayout = reinterpret_cast<AudioChannelLayout *>(malloc(92));
        _error = ExtAudioFileGetProperty(_audioFileRef, kExtAudioFileProperty_FileChannelLayout, &datasize, filechannelLayout);
        if (_error)
                return;
        std::cerr << "ChannelLayout struct basic size =" << sizeof(AudioChannelLayout) << "; real size:" << datasize << std::endl;
        std::cerr << "Channel layout for file:" << ChannelLayoutTagToString(filechannelLayout->mChannelLayoutTag) << std::endl;
        free(filechannelLayout);

For a .mp4 file, I get back the  kAudioChannelLayoutTag_MPEG_5_1_D tag. That's good!

For an AIFF file with four channels, I get back the  kAudioChannelLayoutTag_UseChannelDescriptions tag. That's OK- I can dump the file and I see a CHAN chunk with what appear to be good channel descriptors. But ExtAudioFileGetPropertyInfo tells me that the data size is 12 bytes (just enough for the three basic members of the structure, but not enough for the array of channel descriptors).

I've been beating my head on this wall for two days...

-John Weeks
WaveMetrics, Inc.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: ExtAudioFile woes
      • From: John Weeks <email@hidden>
References: 
 >ExtAudioFile woes (From: John Weeks <email@hidden>)

  • Prev by Date: ExtAudioFile woes
  • Next by Date: Re: ExtAudioFile woes
  • Previous by thread: ExtAudioFile woes
  • Next by thread: Re: ExtAudioFile woes
  • Index(es):
    • Date
    • Thread