Blender V5.3
blender::bke::bSoundFrequencySampler Class Reference

#include <BKE_sound_sample.hh>

Classes

struct  Key
struct  WindowWeights

Public Types

enum class  WindowFunction { Hann , Hamming , Blackman , Rectangular }
enum class  InterpolationMethod { Linear , CatmullRom , BSpline }

Public Member Functions

float sample (float time, float low, float high, InterpolationMethod time_interpolation, InterpolationMethod frequency_interpolation) const

Static Public Member Functions

static std::shared_ptr< const bSoundFrequencySampler > get_cached (const bSound &sound, const Key &key)

Detailed Description

This class allows efficiently sampling an arbitrary frequency range at an arbitrary point in time. This is achieved by caching the result of the fourier transform for various windows and interpolating between the cached values.

Used by the Sample Sound node in Geometry Nodes.

Definition at line 33 of file BKE_sound_sample.hh.

Member Enumeration Documentation

◆ InterpolationMethod

Enumerator
Linear 

Fastest method but a resulting spectrum visualization may not be continuous, especially for lower frequencies.

CatmullRom 

Slower but produces a continuous spectrum. It may not be entirely smooth though.

BSpline 

Yet slower but produces a continuous spectrum that is smooth.

Definition at line 47 of file BKE_sound_sample.hh.

◆ WindowFunction

Window function that is applied before computing the FFT. It avoids spectral leakage and generally leads to better results. Using #Rectangular mode is the same as not using any window function.

Enumerator
Hann 
Hamming 
Blackman 
Rectangular 

Definition at line 40 of file BKE_sound_sample.hh.

Member Function Documentation

◆ get_cached()

std::shared_ptr< const bSoundFrequencySampler > blender::bke::bSoundFrequencySampler::get_cached ( const bSound & sound,
const Key & key )
static

◆ sample()

float blender::bke::bSoundFrequencySampler::sample ( float time,
float low,
float high,
InterpolationMethod time_interpolation,
InterpolationMethod frequency_interpolation ) const

Sample the amplitude a the given time and frequency range.

Definition at line 2421 of file blenkernel/intern/sound.cc.

References BSpline, blender::bke::bspline_interpolation(), blender::bke::catmul_rom_interpolation(), CatmullRom, floorf, blender::fractf(), blender::math::interpolate(), and Linear.


The documentation for this class was generated from the following files: