• 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: Getting raw audio data from an AIFF file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting raw audio data from an AIFF file


  • Subject: Re: Getting raw audio data from an AIFF file
  • From: Kurt Revis <email@hidden>
  • Date: Mon, 17 Feb 2003 10:58:16 -0800

On Monday, February 17, 2003, at 08:47 AM, Peter wrote:

I want to skip all headers after the FORM chunk is read and go to the SSND chunk so I can start playing the audio. While my chunkID is 'SSND' (a four char array), I print it out and get 'SSND\277\260' instead. Why would there be more than the four chars printing out?

Strings in C are terminated with a null character (0 or '\0'). You are trying to use these 4-character values as strings, but they aren't real strings because they don't end in a 0. So strcmp() and printf() merrily traipse on through memory until they do find a 0 (or until they hit unallocated memory and crash).

The easy way to fix this is to treat these values as single numbers, not arrays of characters. In standard C you can use the type uint32_t. If you are including any of Apple's headers you can use UInt32 instead.

UInt32 kSomeConstant = 'AIFF';
UInt32 myVariable;
if (myVariable == kSomeConstant)
// do whatever you like

Here's some _optional_ weirdness that I have; it involves the debugger. See that AIFC type check? When I run my program, strcmp evaluate to true but when I debug, that if statement evaluates to true, and the program returns an error.

It helps a lot more if you tell us what error you experienced exactly. Anyway, I imagine doing things the right way will clear this up. Since the behavior of the program is essentially undefined (since you're wandering through memory looking for a 0) just about anything can happen.

Since I have no idea what to do, I tried swapping "#import <Foundation/Foundation.h>" with "#include <string.h>" and had nothing change.

You shouldn't import the Foundation headers if you're not using any Foundation classes (Objective-C). You aren't in the example below.

--
Kurt Revis
email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: Getting raw audio data from an AIFF file
      • From: Brian Willoughby <email@hidden>
References: 
 >Re: Getting raw audio data from an AIFF file (From: Peter <email@hidden>)

  • Prev by Date: when to set kAudioUnitProperty_MaximumFramesPerSlice
  • Next by Date: RE: Getting raw audio data from an AIFF file
  • Previous by thread: Re: Getting raw audio data from an AIFF file
  • Next by thread: Re: Getting raw audio data from an AIFF file
  • Index(es):
    • Date
    • Thread