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 protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to