• 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: Trying to understand frames/samples, frames within samples etc.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to understand frames/samples, frames within samples etc.


  • Subject: Re: Trying to understand frames/samples, frames within samples etc.
  • From: Aran Mulholland <email@hidden>
  • Date: Mon, 03 Sep 2012 09:19:10 +1000

It is like this.

              sample[0]      sample[1]      sample[2]
time ------------------------------------------------------------------>

Sometimes (depending on your sample format) you can get a stereo
interleaved stream where you will get

sample[0](left)  sample[0](right)  sample[1](left)  sample[1](right) etc..

If the streams are not interleaved and you have a stereo signal you
can access the left and right channels by

SInt16* samples = (SInt16*)(ioData->mBuffers[0].mData); //left channel
SInt16* samples = (SInt16*)(ioData->mBuffers[1].mData); //right channel

Also when you are doing the cast to (SInt16 *) you have to make sure
the type you are casting to is correct. Some sample formats use 32 bit
ints, some use floats, some use other formats.


On Sun, Sep 2, 2012 at 9:46 PM, Ash Gibson <email@hidden> wrote:
> In a callback function, I get the inNumberFrames and ioData args. I then
> write something like this:
>
> SInt16* samples = (SInt16*)(ioData->mBuffers[0].mData);
>
> which will give me a 16-bit signed integer which is like an array of
> integers?
>
> I can then loop through it with the inNumberFrames as the total number of
> elements e.g.
>
> for (int i=0; i < inNumberFrames; i++) {
>
> something = samples[i];
>
> }
>
>
> When looking at each of these samples that are created inside the for loop
> e.g. sample[0], sample[1], sample[2] etc. I am trying to visualise what they
> represent in terms of sound and time.
>
> Is it like this?
>
>               sample[0]      sample[1]      sample[2]
> time ------------------------------------------------------------------>
>
> or are these samples actually different parts (e.g. bass, mid range, high)
> of a sound caught at a point in time e.g.
>
>
>               sample[2]       sample[2]        sample[2]
>               sample[1]       sample[1]        sample[1]
>               sample[0]       sample[0]        sample[0]
> time ------------------------------------------------------------------>
>
>
>
>  _______________________________________________
> 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: Trying to understand frames/samples, frames within samples etc.
      • From: Ash Gibson <email@hidden>
References: 
 >Trying to understand frames/samples, frames within samples etc. (From: Ash Gibson <email@hidden>)

  • Prev by Date: Trying to understand frames/samples, frames within samples etc.
  • Next by Date: Re: Trying to understand frames/samples, frames within samples etc.
  • Previous by thread: Trying to understand frames/samples, frames within samples etc.
  • Next by thread: Re: Trying to understand frames/samples, frames within samples etc.
  • Index(es):
    • Date
    • Thread