Re: Trying to understand frames/samples, frames within samples etc.
Re: Trying to understand frames/samples, frames within samples etc.
- Subject: Re: Trying to understand frames/samples, frames within samples etc.
- From: Admiral Quality <email@hidden>
- Date: Mon, 03 Sep 2012 13:57:15 -0400
The data in a digital audio stream represent the voltages going to the
speaker, which are transduced into air pressure. Think of the audio
data like a graph of air pressure over time.
It contains no frequency domain information (you have to extract that
by analysis, hence the FFT). Only time domain. Which again is just a
series of samples of the air pressure and/or analog voltage. That's
why they're called samples.
- Mike/AQ
On Sun, Sep 2, 2012 at 10:42 PM, Aran Mulholland
<email@hidden> wrote:
>> Each of these frames is a numeric value and depending on the data type, it
>> will be a value within a certain range. What is this numeric value? Is it a
>> result of an algorithm/formula or similar?
>
> These values are the pure waveform data, no analysis has been done on
> them. If you recorded a sine wave and then plotted the array you would
> see a sine wave on the screen.
>
>> Just to confirm, when I get an audio buffer and convert it to a 16bit
>> integer and then loop through it using the inNumberFrames, each of the
>> values are a different point in time?
>
> Yep, if you are sampling at 44100hz you get 44100 samples per second,
> each representing the waveform at that point in time. If you are using
> SInt16 your values will be in the range -32,768 to 32,767.
>
> As for actually doing the analysis, that needs to be answered by someone else.
>
> Aran.
>
>
>
>
> On Mon, Sep 3, 2012 at 10:22 AM, Ash Gibson <email@hidden> wrote:
>> Hi Aran,
>>
>> Thanks for replying. I understand about making sure you are using the
>> correct type etc. In the case of my current project, this is my setup:
>>
>> AVAssetReader with an AVAssetReaderAudioMixOutput that is configured for
>> 16-bit PCM samples. I read the buffers into a circular buffer
>> (TPCircularBuffer).
>>
>> I then have an audio graph with remoteIO and a mixer and a callback on the
>> input to the mixer where I pull the values out of the circular buffer and
>> push them into ioData. The ASBD is configured to be 16bit LPCM as well. This
>> is all working perfectly and my audio plays.
>>
>> My next step is to perform some analysis on the audio in order to draw a
>> visualisation of the data, sampled every .5 seconds for example. I also want
>> to somehow get a reading of the lower frequencies (bass) so that I can do
>> some visualisations that react to the bass only. (low pass filter?)
>>
>> In terms of the visualisation, I am not trying to build a visualisation of
>> the entire audio file from 0 secs -> 3 mins, I want to take a snapshot in
>> time and visualise the frequency range
>>
>> ----
>>
>> So, in order to progress into the complicated world of FFT and the
>> Accelerate framework I am trying to actually understand what the data in an
>> audio buffer represents. What I can gather from your reply is that if i get
>> an audio buffer at 1.00 seconds, each frame within the 16bit integer sample
>> is a moment in time from 1.00 onwards. For example, sample[0] is 0.00,
>> sample[1] is 0.01 etc.
>>
>> I come from a background in flash development where I could use
>> computeSpectrum to generate an array of values with [0] being the lowest
>> frequency(bass) and [length] being the highest frequency. I understand that
>> there is more work to be done in ios but am not sure how to bridge the gap
>> in my learning.
>>
>> Any help is greatly appreciated.
>>
>> Cheers,
>>
>> Ash
>>
>> On 3 September 2012 09:19, Aran Mulholland <email@hidden> wrote:
>>>
>>> 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
>>> >
>>
>>
>>
>>
>> --
>> Ash Gibson
>> 0410 329 355
>> www.smartface.com.au
> _______________________________________________
> 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