DataFFT:
Filter:
OpenBCI-SuperCollider/Classes (extension) | External Control

DataFFT
ExtensionExtension

collect data and perform fft

Description

Collects data from any OpenBCI board and calculate FFT.

Remember that FFT only analyse frequencies up to half of the current sample rate.

Class Methods

.new

create a new instance

Arguments:

board

an instance of a OpenBCI subclass (for example a CytonSerial or GanglionWifi).

fftSize

the FFT window size. Should be a power-of-two.

windowType

By default this will be Signal: fftCosTable. Use one of the following symbols to specify other types:

Instance Methods

.board

get the board instance

.fft

perform FFT calculation.

Arguments:

data

an Array of data to be analysed.

Returns:

the FFT data (magnitudes only) as an Array. The size of the array is half the fftSize + 1.

.fftSize

the FFT window size

.fftSize2

half the FFT window size

.bw

width of each frequency band in Hz. The first and last bands is half as large as this value.

.indexToFreq

convert from fft index to frequency (in Hz).

Arguments:

index

band index

Returns:

a Float that is the middle frequency of the band.

.freqToIndex

convert from frequency (in Hz) to fft index.

Arguments:

freq

frequency

Returns:

an Integer that is the index of the band that contains the requested frequency.

Examples