• 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
Data Types for Extracting samples from Audio Buffer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Data Types for Extracting samples from Audio Buffer


  • Subject: Data Types for Extracting samples from Audio Buffer
  • From: Joseph Ayers <email@hidden>
  • Date: Sun, 05 Oct 2008 12:47:35 -0400

I'm trying to extract the audio samples from an audio buffer returned from the QuickTime Audio extraction API into a NSMutableArray of NSNumbers.

The audio extraction API indicates that the samples are two byte integers (unsigned short?) and the buffers are extracted without error.
2008-10-05 12:37:16.993 Roboplasm[2877:813] format flags = 41
2008-10-05 12:37:16.994 Roboplasm[2877:813] sample rate = 48000.000000
2008-10-05 12:37:16.996 Roboplasm[2877:813] bytes/packet = 4
2008-10-05 12:37:16.997 Roboplasm[2877:813] frames/packe = 1
2008-10-05 12:37:16.997 Roboplasm[2877:813] bytes/frame = 4
2008-10-05 12:37:16.997 Roboplasm[2877:813] channels/frame = 2
2008-10-05 12:37:16.998 Roboplasm[2877:813] bits/channel = 32
2008-10-05 12:37:17.000 Roboplasm[2877:813] format flags = 41
2008-10-05 12:37:17.000 Roboplasm[2877:813] sample rate = 48000.000000
2008-10-05 12:37:17.001 Roboplasm[2877:813] bytes/packet = 4
2008-10-05 12:37:17.001 Roboplasm[2877:813] frames/packet = 1
2008-10-05 12:37:17.002 Roboplasm[2877:813] bytes/frame = 4
2008-10-05 12:37:17.003 Roboplasm[2877:813] channels/frame = 2
2008-10-05 12:37:17.003 Roboplasm[2877:813] bits/channel = 32


The code I am using is:

	AudioBufferList* abl;
        NSMutableArray * ipbuf;
	NSMutableArray * idbuf;
	NSNumber* ipsamp;
        NSNumber* idsamp;
	unsigned short *ippointer =  (unsigned short *)abl->mBuffers[0].mData;
	unsigned short *idpointer =  (unsigned short *)abl->mBuffers[1].mData;

	for (isamp = 1; abl->mBuffers[0].mDataByteSize;isamp++){
		[ipsamp initWithUnsignedShort:(unsigned short)ippointer[isamp]];
		     [ipbuf insertObject:ipsamp atIndex:isamp];
		[idsamp initWithUnsignedShort:(unsigned short)idpointer[isamp]];
		     [idbuf insertObject:idsamp atIndex:isamp];
	}
The program crashes on the line
		[ipsamp initWithUnsignedShort:(unsigned short)ippointer[isamp]]; with
Program received signal:  “EXC_BAD_ACCESS”.

isamp is 1.

Am I using the wrong data types?

thanks,

Joseph Ayers, Professor
Department of Biology and
Marine Science Center
Northeastern University
East Point, Nahant, MA 01908
Phone (781) 581-7370 x309(office), x335(lab)
Boston: 444 Richards Hall (617) 373-4044
Cellular (617) 755-7523, FAX: (781) 581-6076
eMail: email@hidden
http://www.neurotechnology.neu.edu/






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Data Types for Extracting samples from Audio Buffer
      • From: Jacob Lukas <email@hidden>
    • Re: Data Types for Extracting samples from Audio Buffer
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Cocoa Programming for Mac OsX Third Edition eBook search
  • Next by Date: Re: wasting space?
  • Previous by thread: [MEET] CocoaHeads Frankfurt, Mon Oct 6th 8pm
  • Next by thread: Re: Data Types for Extracting samples from Audio Buffer
  • Index(es):
    • Date
    • Thread