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 *
6
* This file is part of the SoundScape Renderer (SSR). *
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. *
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. *
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/>. *
21
* The SSR is a tool for real-time spatial audio reproduction providing a *
22
* variety of rendering algorithms. *
24
* http://spatialaudio.net/ssr ssr@spatialaudio.net *
25
******************************************************************************/
28
/// %RenderSubscriber (definition).
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, ...).
35
#ifndef SSR_RENDERSUBSCRIBER_H
36
#define SSR_RENDERSUBSCRIBER_H
38
#include "subscriber.h"
44
template<typename Renderer>
45
class RenderSubscriber : public Subscriber
48
RenderSubscriber(Renderer &renderer) : _renderer(renderer) {}
50
// Subscriber Interface
51
virtual void set_loudspeakers(const Loudspeaker::container_t& loudspeakers);
53
virtual void new_source(id_t id) { (void) id; }
55
virtual void delete_source(id_t id)
57
auto guard = _renderer.get_scoped_lock();
58
_renderer.rem_source(id);
61
virtual void delete_all_sources()
63
auto guard = _renderer.get_scoped_lock();
64
_renderer.rem_all_sources();
67
virtual bool set_source_position(id_t id, const Position& position)
69
auto guard = _renderer.get_scoped_lock();
70
auto src = _renderer.get_source(id);
71
if (!src) return false;
72
src->derived().position = position;
76
virtual bool set_source_orientation(id_t id, const Orientation& orientation)
78
auto guard = _renderer.get_scoped_lock();
79
auto src = _renderer.get_source(id);
80
if (!src) return false;
81
src->derived().orientation = orientation;
85
virtual bool set_source_gain(id_t id, const float& gain)
87
auto guard = _renderer.get_scoped_lock();
88
auto src = _renderer.get_source(id);
89
if (!src) return false;
90
src->derived().gain = gain;
94
virtual bool set_source_mute(id_t id, const bool& mute)
96
auto guard = _renderer.get_scoped_lock();
97
auto src = _renderer.get_source(id);
98
if (!src) return false;
99
src->derived().mute = mute;
103
virtual bool set_source_name(id_t id, const std::string& name)
110
virtual bool set_source_brir_file_name(id_t id, const std::string& name)
117
virtual bool set_source_model(id_t id, const Source::model_t& model)
119
auto guard = _renderer.get_scoped_lock();
120
auto src = _renderer.get_source(id);
121
if (!src) return false;
122
src->derived().model = model;
126
virtual bool set_source_port_name(id_t id, const std::string& port_name)
133
virtual bool set_source_file_name(id_t id, const std::string& file_name)
140
virtual bool set_source_file_channel(id_t id, const int& file_channel)
147
virtual bool set_source_file_length(id_t id, const long int& length)
154
virtual void set_reference_position(const Position& position)
156
auto guard = _renderer.get_scoped_lock();
157
_renderer.state.reference_position = position;
160
virtual void set_reference_orientation(const Orientation& orientation)
162
auto guard = _renderer.get_scoped_lock();
163
_renderer.state.reference_orientation = orientation;
166
virtual void set_reference_offset_position(const Position& position)
168
auto guard = _renderer.get_scoped_lock();
169
_renderer.state.reference_offset_position = position;
172
virtual void set_reference_offset_orientation(const Orientation& orientation)
174
auto guard = _renderer.get_scoped_lock();
175
_renderer.state.reference_offset_orientation = orientation;
178
virtual void set_master_volume(float volume)
180
auto guard = _renderer.get_scoped_lock();
181
_renderer.state.master_volume = volume;
184
virtual void set_source_output_levels(id_t, float*, float*) {}
186
virtual void set_processing_state(bool state)
188
auto guard = _renderer.get_scoped_lock();
189
_renderer.state.processing = state;
192
virtual void set_transport_state(
193
const std::pair<bool, jack_nframes_t>& state)
198
virtual void set_amplitude_reference_distance(float distance)
200
auto guard = _renderer.get_scoped_lock();
201
_renderer.state.amplitude_reference_distance = distance;
204
virtual void set_master_signal_level(float level)
209
virtual void set_cpu_load(float load)
214
virtual void set_sample_rate(int sample_rate)
219
virtual bool set_source_signal_level(const id_t id, const float& level)
226
virtual bool set_source_properties_file(ssr::id_t, const std::string&)
231
virtual bool set_source_position_fixed(ssr::id_t id, const bool& fix)
242
template<typename Renderer>
244
RenderSubscriber<Renderer>::set_loudspeakers(
245
const Loudspeaker::container_t& loudspeakers)
249
// TODO: handle loudspeakers differently. Maybe remove them from the Scene?
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'\:'='