
This is a CLAM plugin which contains some processings to simulate 3D acoustics.
That means simulating moving sound emitters and receptor within a virtual 3D scenario.
It works by having a database of impulse responses (pressure and velocities) for
each receiver and emitter position within a discrete position grid.

Of course you can reuse the building blocks for simpler or more complex systems:
- Simpler spectral processing (FFT, IFFT, arithmetic operation and conversions)
- Processing of impulse response representation in DFT (computation, interpolation, DB's)
- Low latency real-time convolution
- Processings to map receiver acoustic magnitudes to a surround system.

Some examples (.clamnetwork files) needs external databases. You should have them in your disk and link (ln -s) the following directories:
- HRTFs
- wavs

Included Processings:
=====================

AudioBuffer2Stream:
	Generates a continuous samples stream by overlapping audio buffers.

AudioBufferCrossFader:
	Generates an audio buffer by cross fading the input audio
	buffers using a linear ramp. The cross fade occurs every frame.
	This processing is thought to be fed the following way.
	In steady state, both inputs are fed with the same input.
	When the source changes, just for a frame, the old source
	is fed on the fadeout input, while the new one is fed on the
	fadeout input. After that frame, the new source is fed on both.

MyFFT
	Takes an audio buffer (n samples) and returns the complex spectrum
	of n/2+1 complex bins.
	Uses FFTW internally.
MyIFFT
	Takes a complex spectrum (n/2+1 bins) and returns an audio buffer
	of n samples.
	Uses FFTW internally.

ComplexSpectrumMixer
	Does the ponderated sum of two complex spectra.

ComplexSpectrumProduct
	Multiplies two complex spectra.

ComplexSpectrumSum
	Adds two complex spectra

ConstantSpectrum
	Takes the N first samples of an audio file and takes it as constant
	spectrum on the output.



ImpulseResponseLoader
	Feeds a constant impulse response (DFT stream representation
	of an audio file).

ImpulseResponseDatabaseFetcher
	Given source and emitter normalized positions (0..1 for each dimension)
	it returns the closer impulse response within the 6D grid.
	The second port is a single frame delayed one so one can do crossfading.
	To load the database it takes a path, a prefix and constructs the
	wave file names $(path)/$(prefix)_emissor_x-y-z_receptor_x-y-z.wav
	x,y,z are integer positions on the grid starting at 0.
	Every dimension for separate emitter and receptor goes as far as wav
	are found from 0,0,0,0,0,0.

ImpulseResponseInterpolator
	Given two impulse responses returns the ponderated sum of both of them.


AudioBufferCrossFader
	Every execution it does a crossfading by ramping and adding both
	input buffers. Every execution the crossfade is done so you can
	control the delay by feeding each port with the same audio source
	but on the crossfading period.

LowLatencyConvolution
	Does the partitioned convolution of a stream of DFT spectrums.

MagPhaseSpectrumProduct
	Multiples two MagPhaseSpectrum's

Complex2MagPhaseSpectrum
	Converts spectra represented as complex vector (ComplexSpectrum)
	into spectrum represented as polar fasors (MagPhaseSpectrum).

MagPhase2ComplexSpectrum
	Obtain the equivalent ComplexSpectrum from an input MagPhaseSpectrum

Complex2MagPhaseSpectrum
	Obtain the equivalent MagPhaseSpectrum from an input ComplexSpectrum

Spectrum2MagPhaseSpectrum
	Converts the deprecated CLAM::Spectrum into a MagPhaseSpectrum representation

MagPhaseSpectrum2Spectrum
	Converts a MagPhaseSpectrum to a deprecated CLAM::Spectrum representation

DebugImpulseResponse
	Helper processing that takes the first DFT spectrum of an impulse response.
	Normally required to visualize it.

HRTFDatabaseFetcher
	Imports a database of impulse response with the following layout:
	TODO: Describe HRTF database layout


Example Networks:
=================

double_size_spectrum_product.clamnetwork
fft_spectrum_product.clamnetwork
spectrum_mixer.clamnetwork
spectrum_product.clamnetwork
windowing-and-overlap.clamnetwork

complex_fourier_transforms.clamnetwork
	This network measures the error of a successive FFT-IFFT tranformation
	by substracting the output to the input.
	A perfect transformation should give absolute silence.
	The windowing affects by a factor the output of the transformations.
	You can change it on the mixer processing.

spectrum_representation_benchmark.clamnetwork
	This benchmark is used to compare with profilers such as callgrind
	the performance of spectrum multiplication in different spectrum
	representations (complex and polar) considering also the needed
	conversions.

constant_spectrum.clamnetwork
	A test for the ConstantSpectrum processing that keeps at the output
	the spectrum of the first frame of an audio file.
	The example resynthesizes and visualizes such spectrum each frame.

lowlatencyconvolution.clamnetwork
	An example effect of LowLatencyConvolution which is able to apply
	a reverb using a recorded impulse response with a very long tail
	faster than time domain convolution (logarithmic time to the frame)
	and with lower latency than spectrum domain convolution (indeed
	the latency is just the input block size).

lowlatencyconvolution-withdoubleframesize.clamnetwork
	The same as lowlatencyconvolution but using 1024 hops instead of 512.


IR and HRTFs Databases:

single-impulse-response-surround.clamnetwork
	Convolves the input sound with p, vx and vy components of an
	impulse response and obtains the surround output.

single-impulse-response-surround-to-stereo.clamnetwork
	Convolves the input sound with p, vx and vy components of an
	impulse response, obtains the surround output and turns it
	into stereo using hrtf's for the speakers positions.

impulse-response-database-only-pressure.clamnetwork
	Virtual room navigation with a single component (p).
	Simulates emitter and receiver moving on a room by convoluting
	the source with impulse responses at different emitter-receiver
	positions combinations. Crossfading is used when the dominant
	impulse response changes.

impulse-response-database-surround.clamnetwork
	Virtual room navigation with direccionality (vx, vy) and surround output.
	Simulates emitter and receiver moving on a room by convoluting
	the source with impulse responses at different emitter-receiver
	positions combinations. Crossfading is used when the dominant
	impulse response changes.
	p, vx and vy components is considered so we can later compute the
	surround output.

impulse-response-database-surround-to-stereo.clamnetwork
	Extends the room simulation by turning the 5 surround channels
	into stereo using specific hrtf impulse responses for the locations
	of the surround speakers.

hrtf-database.clamnetwork
	Places the input sound at a given azimut and elevation using
	an HRTF database.


IR-Interpolation:
	
interpolate-between-two-points.clamnetwork
	Simulates receiver movements between two points where we
	have recorded the impulse response from a fixed emitter point.
	It does such simulation by interpolation (poderated sum) of
	both impulse responses. It does just for the p component.

interpolate-between-two-points-surround.clamnetwork
	Simulates receiver movements between two points where we
	have recorded the impulse response from a fixed emitter point.
	It does such simulation by interpolation (poderated sum) of
	both impulse responses. By processing p, vx and vy components
	in parallel we can get the surround output.




