CSL
6.0
|
#include <SpeakerLayout.h>
Public Member Functions | |
SpeakerLayout (const char *filePath=NULL) | |
Creates an empty speaker layout. Optionally reads loudspeaker layout from file. More... | |
virtual | ~SpeakerLayout () |
destructor More... | |
void | readSpeakerFile (const char *filePath) |
Reads the speaker listing file according to the specification. More... | |
void | addSpeaker (float azimuth, float elevation=0.0, float radius=1.0) |
Add a speaker specifying its position in degrees from the center of the listening space. More... | |
void | addSpeaker (float x, float y, float z, float xNorm, float yNorm, float zNorm, float gain) |
Add a WFS speaker. More... | |
unsigned | numSpeakers () const |
void | normalizeSpeakerDistances (float radius=0) |
Returns the number of loudspeakers in the layout. More... | |
Speaker * | speakerAtIndex (unsigned speakerIndex) const |
Returns the speaker at the specified index. More... | |
bool | isPeriphonic () |
void | dump () |
If any of the speakers in the layout has an elevation other than 0, it returns true. More... | |
SpeakerLayout & | operator= (const SpeakerLayout &layout) |
Overloaded "=" operator allows copying the layout. More... | |
void | attachObserver (Observer *) |
(possibly notify obersvers on my death) More... | |
void | detachObserver (Observer *) |
void | changed (void *argument) |
this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map More... | |
virtual int | evaluate (void *argument) |
Static Public Member Functions | |
static SpeakerLayout * | defaultSpeakerLayout () |
Returns a pointer to the default layout. If no default exists, it creates one. More... | |
static void | setDefaultSpeakerLayout (SpeakerLayout *defaultLayout) |
Use it to set a layout as default. Clients (e.g. a Panner) can then make use of this layout. More... | |
Protected Attributes | |
vector< Speaker * > | mSpeakers |
Vector of pointers to the loudspeakers. More... | |
Private Attributes | |
unsigned | mDimensions |
float * | mSpeakerDistanceDeltas |
Holds the diference of the optimal speaker distance and the real one. Only used if distances are normalized. More... | |
Static Private Attributes | |
static SpeakerLayout * | sDefaultSpeakerLayout = 0 |
A speaker layout holds a set of loudspeakers. Each speaker has a position (in a space, where measurements are assumed to be from the center point of the space (also the center of the coordinate system). To simplify usage, a default layout will be created when instantiating any object that uses the speaker layout. If the user does not specify a layout then the default layout is used. Any layout can be set to become default (by calling setDefaultSpeakerLayout()) so new objects that require a SpeakerLayout make use of this prefered layout without the need of passing it explicitly per instance. Using multiple layouts is still possible by passing the desired layout to the object that will use it. In that case, this object will go with this layout instead of the default.
Conventions used in this code: Coordinate system:
the layout is a passive object, meaning that it doesn't deal with processing any audio data. It only provides speaker positions. An "ActiveSpeakerLayout" is active and can be used as a UnitGenerator that compensates for speaker positions, etc.
Definition at line 39 of file SpeakerLayout.h.
SpeakerLayout::SpeakerLayout | ( | const char * | filePath = NULL | ) |
Creates an empty speaker layout. Optionally reads loudspeaker layout from file.
Reads loudspeaker layout from a text file. Loudspeaker layouts provided as textfiles should folow the format below: -> A / indicates the start of a comment, which lasts until the end of the line (??????????????????????). -> The Keywords CARTESIAN, SPHERICAL-DEGREES, SPHERICAL-RADIANS are used to specify the format of the provided speaker positions. The class will do necessary conversions to the internal representation in spherical radians. If no keyword is specified, spherical radians are assumed(??????????????????????). -> Non-comment or non-keyword lines should contain speaker position information as three tab-separated coordinates. Each line will be interpreted as a new speaker. Examples of parsable speaker layout files are provided with the code (.dat files).
—> needs .wfs file description
Definition at line 70 of file SpeakerLayout.cpp.
References readSpeakerFile().
|
virtual |
void SpeakerLayout::readSpeakerFile | ( | const char * | filePath | ) |
Reads the speaker listing file according to the specification.
Definition at line 84 of file SpeakerLayout.cpp.
References addSpeaker(), dump(), csl::kLogError, csl::logMsg(), csl::CPoint::x, csl::CPoint::y, and csl::CPoint::z.
Referenced by SpeakerLayout().
|
static |
Returns a pointer to the default layout. If no default exists, it creates one.
Returns a reference to the default layout. If no layout has been set, it creates a stereo speaker layout.
Definition at line 29 of file SpeakerLayout.cpp.
References sDefaultSpeakerLayout.
Referenced by setDefaultSpeakerLayout(), and csl::SpatialPanner::update().
|
static |
Use it to set a layout as default. Clients (e.g. a Panner) can then make use of this layout.
The default speaker layout is used by Panners, when not specified otherwise. If using multiple Panners, but only one speaker setup, is best to set the layout as default, and then forget about that; Panners will know to use such layout.
Definition at line 41 of file SpeakerLayout.cpp.
References csl::Model::changed(), defaultSpeakerLayout(), and sDefaultSpeakerLayout.
void SpeakerLayout::addSpeaker | ( | float | azimuth, |
float | elevation = 0.0 , |
||
float | radius = 1.0 |
||
) |
Add a speaker specifying its position in degrees from the center of the listening space.
Add a speaker to the layout. Parameters should be specified in degrees.
Definition at line 150 of file SpeakerLayout.cpp.
References csl::Model::changed(), CSL_PI, mDimensions, and mSpeakers.
Referenced by csl::HeadphoneSpeakerLayout::HeadphoneSpeakerLayout(), readSpeakerFile(), and csl::StereoSpeakerLayout::StereoSpeakerLayout().
void SpeakerLayout::addSpeaker | ( | float | x, |
float | y, | ||
float | z, | ||
float | xNorm, | ||
float | yNorm, | ||
float | zNorm, | ||
float | gain | ||
) |
Add a WFS speaker.
Add a speaker to the layout. Parameters should be specified in x,y,z.
Definition at line 164 of file SpeakerLayout.cpp.
References csl::Model::changed(), and mSpeakers.
|
inline |
Definition at line 58 of file SpeakerLayout.h.
References mSpeakers.
Referenced by csl::AmbisonicDecoder::asProjection(), csl::AmbisonicDecoder::asPseudoInverse(), csl::SpeakerLayoutExpert::findPannerFromLayout(), csl::SpeakerSetLayout::findSpeakerPairs(), csl::SpeakerSetLayout::findSpeakerTriplets(), csl::AmbisonicDecoder::initialize(), csl::AmbisonicDecoder::makeInPhase(), csl::AmbisonicDecoder::makeMaxRE(), csl::AmbisonicDecoder::makeTransposedReEncodingMatrix(), operator=(), csl::VBAP::speakerLayoutChanged(), csl::VBAP::VBAP(), and csl::AmbisonicDecoder::~AmbisonicDecoder().
void SpeakerLayout::normalizeSpeakerDistances | ( | float | radius = 0 | ) |
Returns the number of loudspeakers in the layout.
When speakers are not placed at the same distance from the "sweet spot" (the center of the listening space) it's common to assume they are at a fixed distance by setting all of them as if they were, and then the output data is delayed to compensate for this difference. See: ActiveSpeakerLayout.
Sets speaker distances to a fixed distance from the center of the listening space.
radius | is optional. If not set, it finds the best radius by analyzing the layout. |
Definition at line 178 of file SpeakerLayout.cpp.
References mSpeakerDistanceDeltas, and mSpeakers.
|
inline |
Returns the speaker at the specified index.
Definition at line 65 of file SpeakerLayout.h.
References mSpeakers.
Referenced by csl::SpeakerSetLayout::findSpeakerPairs(), csl::SpeakerSetLayout::findSpeakerTriplets(), csl::SpeakerSetLayout::invertTripleMatrix(), csl::AmbisonicDecoder::makeTransposedReEncodingMatrix(), and operator=().
|
inline |
Definition at line 67 of file SpeakerLayout.h.
References mDimensions.
Referenced by csl::SpeakerSetLayout::SpeakerSetLayout(), and csl::VBAP::VBAP().
void SpeakerLayout::dump | ( | void | ) |
If any of the speakers in the layout has an elevation other than 0, it returns true.
Prints the number of speakers in the layout and their position.
Definition at line 204 of file SpeakerLayout.cpp.
References mSpeakers.
Referenced by readSpeakerFile().
SpeakerLayout & SpeakerLayout::operator= | ( | const SpeakerLayout & | layout | ) |
Overloaded "=" operator allows copying the layout.
Definition at line 215 of file SpeakerLayout.cpp.
References mSpeakers, numSpeakers(), and speakerAtIndex().
|
inherited |
(possibly notify obersvers on my death)
register/remove observers
Definition at line 502 of file CGestalt.cpp.
References csl::logMsg(), csl::Observer::mKey, and csl::Observer::mPeriod.
Referenced by CSLMIDIComponent::CSLMIDIComponent(), and csl::SpatialPanner::setSpeakerLayout().
|
inherited |
Definition at line 518 of file CGestalt.cpp.
References csl::logMsg().
Referenced by csl::SpatialPanner::setSpeakerLayout(), and csl::SpatialPanner::~SpatialPanner().
|
inherited |
this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map
Definition at line 540 of file CGestalt.cpp.
References csl::logMsg().
Referenced by addSpeaker(), csl::MIDIIn::handleIncomingMidiMessage(), and setDefaultSpeakerLayout().
|
inlinevirtualinherited |
Reimplemented in csl::MIDIIn.
Definition at line 270 of file CGestalt.h.
|
protected |
Vector of pointers to the loudspeakers.
Definition at line 71 of file SpeakerLayout.h.
Referenced by addSpeaker(), dump(), normalizeSpeakerDistances(), numSpeakers(), operator=(), speakerAtIndex(), and ~SpeakerLayout().
|
private |
Definition at line 75 of file SpeakerLayout.h.
Referenced by addSpeaker(), and isPeriphonic().
|
staticprivate |
Definition at line 77 of file SpeakerLayout.h.
Referenced by defaultSpeakerLayout(), and setDefaultSpeakerLayout().
|
private |
Holds the diference of the optimal speaker distance and the real one. Only used if distances are normalized.
Definition at line 78 of file SpeakerLayout.h.
Referenced by normalizeSpeakerDistances().