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 PROTECTED]
http://www.neurotechnology.neu.edu/






_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to