Jamoma API  0.6.0.a19
TTSpatBase.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspSpatLib
4  *
5  * @brief A basic proof-of-concept spatial renderer where the audio of a source will snap to the nearest sink.
6  *
7  * @details
8  *
9  * @todo: Extend with a solution for interpolating to new matrix coefficients
10  *
11  * @authors Trond Lossius, Nils Peters, Timothy Place
12  *
13  * @copyright Copyright © 2011 by Trond Lossius, Nils Peters, and Timothy Place @n
14  * This code is licensed under the terms of the "New BSD License" @n
15  * http://creativecommons.org/licenses/BSD/
16  */
17 
18 
19 #ifndef __SPATBASE_H__
20 #define __SPATBASE_H__
21 
22 #include "TTDSP.h"
23 #include "TTSampleMatrix.h"
24 #include "TTSpatEntity.h"
25 #include "TTSpatBaseRenderer.h"
26 
27 
28 /** This class is eventually intended to provide a generalised interface for spatial renderers.
29  @todo The class might be further generalised so that it can be reused for other spatial renderers.
30  */
31 class TTSpatBase : public TTAudioObjectBase {
33 
34  // TODO: We need to store these members as pointers to vectors instead of as vectors
35  // because inheriting classes will have potentially extended versions of the sources, sinks, and renderers
36 
37  TTSpatSourceVector mSources; ///< A vector describing the geometry of the sources
38  TTSpatSinkVector mSinks; ///< A vector describing the geometry of the sinks (e.g., speakers)
39  TTSpatBaseRenderer* mRenderer; ///< Pointer to the actual spatial renderer for this class
40 
41 
42  /** A standard audio processing method as used by TTBlue objects.
43  @param inputs Incomming audio signals to process from sound sources.
44  @param outputs Processed audio signals passed to the sinks.
45  */
46  TTErr processAudio(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs);
47 
48 
49 public:
50 
51  /** Get the number of sources.
52  @param value Used to return the number of sources.
53  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
54  */
56 
57 
58  /** Set the number of sources.
59  @param value The desired number of sources.
60  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
61  */
62  TTErr setSourceCount(const TTValue& value);
63 
64 
65  /** Get the number of sinks.
66  @param value Used to return the number of sinks.
67  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
68  */
69  TTErr getSinkCount(TTValue& value);
70 
71 
72  /** Set the number of sinks.
73  @param value The desired number of sinks.
74  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
75  */
76  TTErr setSinkCount(const TTValue& value);
77 
78 
79  /** Get the position of one source.
80  @param sourceNumber The source (counting from 1) that we want to query the position of.
81  @param x Cartesian x-coordinate of the position.
82  @param y Cartesian y-coordinate of the position.
83  @param z Cartesian z-coordinate of the position.
84  */
85  void getOneSourcePosition(TTInt32 sourceNumber, TTFloat64& x, TTFloat64& y, TTFloat64& z);
86 
87 
88  /** Get the position of one source.
89  @param requestedChannel The channel (counting from 1) that we want to query the position of.
90  @param aPosition Used to return the position.
91  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
92  */
93  TTErr getSourcePosition(const TTValue& requestedChannel, TTValue& aPosition);
94 
95 
96  /** Set the position of one source.
97  @param sourceNumber The source (counting from 1) that we want to set the position of.
98  @param x Cartesian x-coordinate of the position.
99  @param y Cartesian y-coordinate of the position.
100  @param z Cartesian z-coordinate of the position.
101  */
102  void setOneSourcePosition(TTInt32 sourceNumber, TTFloat64 x, TTFloat64 y, TTFloat64 z);
103 
104 
105  /** Get the position of one source.
106  @param requestedChannel The channel (counting from 1) that we want to set the position of.
107  @param aPosition Used to return the position.
108  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
109  */
110  TTErr setSourcePosition(const TTValue& aPosition, TTValue& unused);
111 
112 
113  /** Get the position of one sink.
114  @param sourceNumber The sink (counting from 1) that we want to query the position of.
115  @param x Cartesian x-coordinate of the position.
116  @param y Cartesian y-coordinate of the position.
117  @param z Cartesian z-coordinate of the position.
118  */
119  void getOneSinkPosition(TTInt32 sinkNumber, TTFloat64& x, TTFloat64& y, TTFloat64& z);
120 
121 
122  /** Get the position of one sink.
123  @param requestedChannel The channel (counting from 1) that we want to query the position of.
124  @param aPosition Used to return the position.
125  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
126  */
127  TTErr getSinkPosition(const TTValue& requestedChannel, TTValue& aPosition);
128 
129 
130  /** Set the position of one sink.
131  @param sourceNumber The sink (counting from 1) that we want to set the position of.
132  @param x Cartesian x-coordinate of the position.
133  @param y Cartesian y-coordinate of the position.
134  @param z Cartesian z-coordinate of the position.
135  */
136  void setOneSinkPosition(TTInt32 sinkNumber, TTFloat64 x, TTFloat64 y, TTFloat64 z);
137 
138 
139  /** Set the position of one sink.
140  @param requestedChannel The channel (counting from 1) that we want to set the position of.
141  @param aPosition Used to return the position.
142  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
143  */
144  TTErr setSinkPosition(const TTValue& aPosition, TTValue& unused);
145 
146 
147 };
148 
149 
150 
151 #endif // __SPATBASE_H__
TTErr setSinkCount(const TTValue &value)
Set the number of sinks.
Definition: TTSpatBase.cpp:79
TTErr setSinkPosition(const TTValue &aPosition, TTValue &unused)
Set the position of one sink.
Definition: TTSpatBase.cpp:195
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTErr getSinkCount(TTValue &value)
Get the number of sinks.
Definition: TTSpatBase.cpp:72
A basic proof-of-concept spatial renderer where the audio of a source will snap to the nearest sink...
TTSpatEntity describes the geometry of a point, and TTSpatSource and TTSpatSink specialise this furth...
void getOneSourcePosition(TTInt32 sourceNumber, TTFloat64 &x, TTFloat64 &y, TTFloat64 &z)
Get the position of one source.
Definition: TTSpatBase.cpp:90
TTSampleMatrix holds some audio in a chunk of memory.
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
void setOneSinkPosition(TTInt32 sinkNumber, TTFloat64 x, TTFloat64 y, TTFloat64 z)
Set the position of one sink.
Definition: TTSpatBase.cpp:185
TTErr getSinkPosition(const TTValue &requestedChannel, TTValue &aPosition)
Get the position of one sink.
Definition: TTSpatBase.cpp:162
TTErr setSourcePosition(const TTValue &aPosition, TTValue &unused)
Get the position of one source.
Definition: TTSpatBase.cpp:133
std::int32_t TTInt32
32 bit signed integer
Definition: TTBase.h:177
TTErr setSourceCount(const TTValue &value)
Set the number of sources.
Definition: TTSpatBase.cpp:60
TTBoolean unused
Old var that is not used anymore, but we want to keep the struct size the same.
A simple container for an array of TTAudioSignal pointers.
std::vector< TTSpatSource > TTSpatSourceVector
Pointer to a vector of TTSpatSource points.
Definition: TTSpatEntity.h:108
std::vector< TTSpatSink > TTSpatSinkVector
Pointer to a vector of TTSpatSink points.
Definition: TTSpatEntity.h:114
TTErr getSourceCount(TTValue &value)
Get the number of sources.
Definition: TTSpatBase.cpp:54
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
void getOneSinkPosition(TTInt32 sinkNumber, TTFloat64 &x, TTFloat64 &y, TTFloat64 &z)
Get the position of one sink.
Definition: TTSpatBase.cpp:151
void setOneSourcePosition(TTInt32 sourceNumber, TTFloat64 x, TTFloat64 y, TTFloat64 z)
Set the position of one source.
Definition: TTSpatBase.cpp:123
This class is eventually intended to provide a generalised interface for spatial renderers.
Definition: TTSpatBase.h:31
TTErr getSourcePosition(const TTValue &requestedChannel, TTValue &aPosition)
Get the position of one source.
Definition: TTSpatBase.cpp:100
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
TTSpatBaseRenderer defines the basic interface from which all renderers inherit.