~ubuntu-branches/ubuntu/wily/soundscaperenderer/wily

« back to all changes in this revision

Viewing changes to src/rendersubscriber.h

  • Committer: Package Import Robot
  • Author(s): IOhannes m zmölnig (Debian/GNU)
  • Date: 2014-05-08 16:58:09 UTC
  • Revision ID: package-import@ubuntu.com-20140508165809-7tz9dhu5pvo5wy25
Tags: upstream-0.4.1~dfsg
Import upstream version 0.4.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * Copyright © 2012-2014 Institut für Nachrichtentechnik, Universität Rostock *
 
3
 * Copyright © 2006-2012 Quality & Usability Lab,                             *
 
4
 *                       Telekom Innovation Laboratories, TU Berlin           *
 
5
 *                                                                            *
 
6
 * This file is part of the SoundScape Renderer (SSR).                        *
 
7
 *                                                                            *
 
8
 * The SSR is free software:  you can redistribute it and/or modify it  under *
 
9
 * the terms of the  GNU  General  Public  License  as published by the  Free *
 
10
 * Software Foundation, either version 3 of the License,  or (at your option) *
 
11
 * any later version.                                                         *
 
12
 *                                                                            *
 
13
 * The SSR is distributed in the hope that it will be useful, but WITHOUT ANY *
 
14
 * WARRANTY;  without even the implied warranty of MERCHANTABILITY or FITNESS *
 
15
 * FOR A PARTICULAR PURPOSE.                                                  *
 
16
 * See the GNU General Public License for more details.                       *
 
17
 *                                                                            *
 
18
 * You should  have received a copy  of the GNU General Public License  along *
 
19
 * with this program.  If not, see <http://www.gnu.org/licenses/>.            *
 
20
 *                                                                            *
 
21
 * The SSR is a tool  for  real-time  spatial audio reproduction  providing a *
 
22
 * variety of rendering algorithms.                                           *
 
23
 *                                                                            *
 
24
 * http://spatialaudio.net/ssr                           ssr@spatialaudio.net *
 
25
 ******************************************************************************/
 
26
 
 
27
/// @file
 
28
/// %RenderSubscriber (definition).
 
29
 
 
30
// TODO: the whole publish/subscribe-thing should be redesigned, so maybe the
 
31
// RenderSubscriber will be replaced by something else ...
 
32
// Also, the actual renderer supports only a subset of the current (r1509)
 
33
// Subscriber interface (no audio port names, no file names, ...).
 
34
 
 
35
#ifndef SSR_RENDERSUBSCRIBER_H
 
36
#define SSR_RENDERSUBSCRIBER_H
 
37
 
 
38
#include "subscriber.h"
 
39
#include <map>
 
40
 
 
41
namespace ssr
 
42
{
 
43
 
 
44
template<typename Renderer>
 
45
class RenderSubscriber : public Subscriber
 
46
{
 
47
  public:
 
48
    RenderSubscriber(Renderer &renderer) : _renderer(renderer) {}
 
49
 
 
50
    // Subscriber Interface
 
51
    virtual void set_loudspeakers(const Loudspeaker::container_t& loudspeakers);
 
52
 
 
53
    virtual void new_source(id_t id) { (void) id; }
 
54
 
 
55
    virtual void delete_source(id_t id)
 
56
    {
 
57
      auto guard = _renderer.get_scoped_lock();
 
58
      _renderer.rem_source(id);
 
59
    }
 
60
 
 
61
    virtual void delete_all_sources()
 
62
    {
 
63
      auto guard = _renderer.get_scoped_lock();
 
64
      _renderer.rem_all_sources();
 
65
    }
 
66
 
 
67
    virtual bool set_source_position(id_t id, const Position& position)
 
68
    {
 
69
      auto guard = _renderer.get_scoped_lock();
 
70
      auto src = _renderer.get_source(id);
 
71
      if (!src) return false;
 
72
      src->derived().position = position;
 
73
      return true;
 
74
    }
 
75
 
 
76
    virtual bool set_source_orientation(id_t id, const Orientation& orientation)
 
77
    {
 
78
      auto guard = _renderer.get_scoped_lock();
 
79
      auto src = _renderer.get_source(id);
 
80
      if (!src) return false;
 
81
      src->derived().orientation = orientation;
 
82
      return true;
 
83
    }
 
84
 
 
85
    virtual bool set_source_gain(id_t id, const float& gain)
 
86
    {
 
87
      auto guard = _renderer.get_scoped_lock();
 
88
      auto src = _renderer.get_source(id);
 
89
      if (!src) return false;
 
90
      src->derived().gain = gain;
 
91
      return true;
 
92
    }
 
93
 
 
94
    virtual bool set_source_mute(id_t id, const bool& mute)
 
95
    {
 
96
      auto guard = _renderer.get_scoped_lock();
 
97
      auto src = _renderer.get_source(id);
 
98
      if (!src) return false;
 
99
      src->derived().mute = mute;
 
100
      return true;
 
101
    }
 
102
 
 
103
    virtual bool set_source_name(id_t id, const std::string& name)
 
104
    {
 
105
      (void) id;
 
106
      (void) name;
 
107
      return true;
 
108
    }
 
109
 
 
110
    virtual bool set_source_brir_file_name(id_t id, const std::string& name)
 
111
    {
 
112
      (void) id;
 
113
      (void) name;
 
114
      return true;
 
115
    }
 
116
 
 
117
    virtual bool set_source_model(id_t id, const Source::model_t& model)
 
118
    {
 
119
      auto guard = _renderer.get_scoped_lock();
 
120
      auto src = _renderer.get_source(id);
 
121
      if (!src) return false;
 
122
      src->derived().model = model;
 
123
      return true;
 
124
    }
 
125
 
 
126
    virtual bool set_source_port_name(id_t id, const std::string& port_name)
 
127
    {
 
128
      (void) id;
 
129
      (void) port_name;
 
130
      return true;
 
131
    }
 
132
 
 
133
    virtual bool set_source_file_name(id_t id, const std::string& file_name)
 
134
    {
 
135
      (void) id;
 
136
      (void) file_name;
 
137
      return 1;
 
138
    }
 
139
 
 
140
    virtual bool set_source_file_channel(id_t id, const int& file_channel)
 
141
    {
 
142
      (void) id;
 
143
      (void) file_channel;
 
144
      return 1;
 
145
    }
 
146
 
 
147
    virtual bool set_source_file_length(id_t id, const long int& length)
 
148
    {
 
149
      (void) id;
 
150
      (void) length;
 
151
      return true;
 
152
    }
 
153
 
 
154
    virtual void set_reference_position(const Position& position)
 
155
    {
 
156
      auto guard = _renderer.get_scoped_lock();
 
157
      _renderer.state.reference_position = position;
 
158
    }
 
159
 
 
160
    virtual void set_reference_orientation(const Orientation& orientation)
 
161
    {
 
162
      auto guard = _renderer.get_scoped_lock();
 
163
      _renderer.state.reference_orientation = orientation;
 
164
    }
 
165
 
 
166
    virtual void set_reference_offset_position(const Position& position)
 
167
    {
 
168
      auto guard = _renderer.get_scoped_lock();
 
169
      _renderer.state.reference_offset_position = position;
 
170
    }
 
171
 
 
172
    virtual void set_reference_offset_orientation(const Orientation& orientation)
 
173
    {
 
174
      auto guard = _renderer.get_scoped_lock();
 
175
      _renderer.state.reference_offset_orientation = orientation;
 
176
    }
 
177
 
 
178
    virtual void set_master_volume(float volume)
 
179
    {
 
180
      auto guard = _renderer.get_scoped_lock();
 
181
      _renderer.state.master_volume = volume;
 
182
    }
 
183
 
 
184
    virtual void set_source_output_levels(id_t, float*, float*) {}
 
185
 
 
186
    virtual void set_processing_state(bool state)
 
187
    {
 
188
      auto guard = _renderer.get_scoped_lock();
 
189
      _renderer.state.processing = state;
 
190
    }
 
191
 
 
192
    virtual void set_transport_state(
 
193
        const std::pair<bool, jack_nframes_t>& state)
 
194
    {
 
195
      (void) state;
 
196
    }
 
197
 
 
198
    virtual void set_amplitude_reference_distance(float distance)
 
199
    {
 
200
      auto guard = _renderer.get_scoped_lock();
 
201
      _renderer.state.amplitude_reference_distance = distance;
 
202
    }
 
203
 
 
204
    virtual void set_master_signal_level(float level)
 
205
    {
 
206
      (void) level;
 
207
    }
 
208
 
 
209
    virtual void set_cpu_load(float load)
 
210
    {
 
211
      (void) load;
 
212
    }
 
213
 
 
214
    virtual void set_sample_rate(int sample_rate)
 
215
    {
 
216
      (void) sample_rate;
 
217
    }
 
218
 
 
219
    virtual bool set_source_signal_level(const id_t id, const float& level)
 
220
    {
 
221
      (void) id;
 
222
      (void) level;
 
223
      return true;
 
224
    }
 
225
 
 
226
    virtual bool set_source_properties_file(ssr::id_t, const std::string&)
 
227
    {
 
228
      return 1;
 
229
    }
 
230
 
 
231
    virtual bool set_source_position_fixed(ssr::id_t id, const bool& fix)
 
232
    {
 
233
      (void) id;
 
234
      (void) fix;
 
235
      return true;
 
236
    }
 
237
 
 
238
  private:
 
239
    Renderer& _renderer;
 
240
};
 
241
 
 
242
template<typename Renderer>
 
243
void
 
244
RenderSubscriber<Renderer>::set_loudspeakers(
 
245
    const Loudspeaker::container_t& loudspeakers)
 
246
{
 
247
  (void)loudspeakers;
 
248
 
 
249
  // TODO: handle loudspeakers differently. Maybe remove them from the Scene?
 
250
}
 
251
 
 
252
}  // namespace ssr
 
253
 
 
254
#endif
 
255
 
 
256
// Settings for Vim (http://www.vim.org/), please do not remove:
 
257
// vim:softtabstop=2:shiftwidth=2:expandtab:textwidth=80:cindent
 
258
// vim:fdm=expr:foldexpr=getline(v\:lnum)=~'/\\*\\*'&&getline(v\:lnum)!~'\\*\\*/'?'a1'\:getline(v\:lnum)=~'\\*\\*/'&&getline(v\:lnum)!~'/\\*\\*'?'s1'\:'='