# Question about FFT and audio sample

This topic is 2594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

When I get a sample chunk, more specifically, a stream of void* and a length associated with it, for example :
 //usually void callback(void *stream, int length){ //... } 

Supposed the length is 4096 byte, and stream of data supposed to represent a stream of 16 bit data.

I am supposed to split the stream into channels like so :
[source]

//left channel
sampleData[j] = to16Bit(stream,stream[i+1])/ scaleFactor;
sampleData[j + 1] =to16Bit(stream[i+2],stream[i+3]) / scaleFactor;
[/source]

Can someone explain to me what these channels are supposed to represent? Also, the sampleData is what I should presumably run FFT on correct?

##### Share on other sites
The two samples most likely represent the left and right channel. Don't merge them into a single buffer, just take one of the channels and either ignore the other, or add it to the channel, and do the FFT on that single channel.

##### Share on other sites
Can you explain what the left/right channels represent? And why I could either sum the two or discard one?

##### Share on other sites
The left and right channels are the channels going to your left and right speaker. They are two separate audio streams, although you usually play almost the same sound in them. That is why you should not interleave them for the DFT, because your DFT expects a buffer with a single continuous set of data, not two interleaved data sets.

So if you have one DFT and two channels, you must do something; discard one channel or add them are two reasonable options. Another one is to calculate two DFTs; one for each channel.

##### Share on other sites

The left and right channels are the channels going to your left and right speaker. They are two separate audio streams, although you usually play almost the same sound in them. That is why you should not interleave them for the DFT, because your DFT expects a buffer with a single continuous set of data, not two interleaved data sets.

So if you have one DFT and two channels, you must do something; discard one channel or add them are two reasonable options. Another one is to calculate two DFTs; one for each channel.

Would averaging them two be a viable option? If I sum the two, wouldn't that affect the amplitude or some other property? Thanks.

regards, D.C

##### Share on other sites
Averaging and summing are the same, except a linear scale factor. None of them is any more correct than the other, any more than averaging or summing is any more correct than discarding one of the channels or some other method. It's all about what effect you want to achieve.

1. 1
Rutin
19
2. 2
3. 3
4. 4
5. 5
frob
12

• 15
• 13
• 9
• 12
• 10
• ### Forum Statistics

• Total Topics
631442
• Total Posts
3000102
×