Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ChannelRouterNode.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014, The Cinder Project
3 
4  This code is intended to be used with the Cinder C++ library, http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22  */
23 
24 #pragma once
25 
26 #include "cinder/audio/Node.h"
27 
28 #include <list>
29 
30 namespace cinder { namespace audio {
31 
32 typedef std::shared_ptr<class ChannelRouterNode> ChannelRouterNodeRef;
33 
44 
52 class ChannelRouterNode : public Node {
53  public:
56 
58  struct RouteConnector {
60  RouteConnector( const ChannelRouterNodeRef &outputRouter, size_t inputChannelIndex, size_t outputChannelIndex );
62  RouteConnector( const ChannelRouterNodeRef &outputRouter, size_t inputChannelIndex, size_t outputChannelIndex, size_t numChannels );
63 
65  const ChannelRouterNodeRef& getOutputRouter() const { return mOutputRouter; }
67  size_t getInputChannelIndex() const { return mInputChannelIndex; }
69  size_t getOutputChannelIndex() const { return mOutputChannelIndex; }
71  size_t getNumChannels() const { return mNumChannels; }
72 
73  private:
74  ChannelRouterNodeRef mOutputRouter;
75  size_t mInputChannelIndex, mOutputChannelIndex, mNumChannels;
76  };
77 
79  RouteConnector route( size_t inputChannelIndex, size_t outputChannelIndex );
81  RouteConnector route( size_t inputChannelIndex, size_t outputChannelIndex, size_t numChannels );
82 
84  void addInputRoute( const NodeRef &input, size_t inputChannelIndex, size_t outputChannelIndex, size_t numChannels );
85 
86  virtual void disconnectAllInputs() override;
87 
88  protected:
89  virtual bool supportsInputNumChannels( size_t numChannels ) const override;
90  virtual bool supportsProcessInPlace() const override;
91  virtual void sumInputs() override;
92  virtual void disconnectInput( const NodeRef &input ) override;
93 
94  struct Route {
97  };
98 
99  std::list<Route> mRoutes;
100 };
101 
104 
105 } } // namespace cinder::audio
virtual void sumInputs() override
Definition: ChannelRouterNode.cpp:115
const ChannelRouterNodeRef & getOutputRouter() const
Returns the output ChannelRouterNode.
Definition: ChannelRouterNode.h:65
GLenum GLenum GLenum input
Definition: GLee.h:8931
ChannelRouterNode(const Format &format=Format())
Constructs a ChannelRouterNode object, with an optional format.
Definition: ChannelRouterNode.h:55
Used in conjunction with operator>> and the route() methods to make connections that conduct channel ...
Definition: ChannelRouterNode.h:58
std::list< Route > mRoutes
Definition: ChannelRouterNode.h:99
void addInputRoute(const NodeRef &input, size_t inputChannelIndex, size_t outputChannelIndex, size_t numChannels)
Adds input to the route list, routing numChannels starting at inputChannelIndex of input to outputCha...
Definition: ChannelRouterNode.cpp:75
size_t getNumChannels() const
Returns the number of channels to route in the connection.
Definition: ChannelRouterNode.h:71
RouteConnector(const ChannelRouterNodeRef &outputRouter, size_t inputChannelIndex, size_t outputChannelIndex)
Constructs a RouteConnector with no number of channels information, so the maximum possible will be u...
Definition: ChannelRouterNode.cpp:45
size_t mInputChannelIndex
Definition: ChannelRouterNode.h:96
size_t mNumChannels
Definition: ChannelRouterNode.h:96
const ChannelRouterNodeRef & operator>>(const NodeRef &input, const ChannelRouterNode::RouteConnector &route)
Enable routing connection syntax:
Definition: ChannelRouterNode.cpp:55
NodeRef mInput
Definition: ChannelRouterNode.h:95
virtual void disconnectAllInputs() override
Disconnects all of this Node's inputs.
Definition: ChannelRouterNode.cpp:107
size_t getOutputChannelIndex() const
Returns the channel index to route input channels to.
Definition: ChannelRouterNode.h:69
Node for mapping input channels to output channels.
Definition: ChannelRouterNode.h:52
std::shared_ptr< class ChannelRouterNode > ChannelRouterNodeRef
Definition: ChannelRouterNode.h:32
size_t mOutputChannelIndex
Definition: ChannelRouterNode.h:96
Definition: Node.h:72
Fundamental building block for creating an audio processing graph.
Definition: Node.h:59
size_t getInputChannelIndex() const
Returns the channel index to start routing input channels from.
Definition: ChannelRouterNode.h:67
RouteConnector route(size_t inputChannelIndex, size_t outputChannelIndex)
Used in conjunction with operator>>, specified that the routing is to map the input's inputChannelInd...
Definition: ChannelRouterNode.cpp:35
Definition: ChannelRouterNode.h:94
GLenum GLsizei GLenum format
Definition: GLee.h:969
virtual void disconnectInput(const NodeRef &input) override
Definition: ChannelRouterNode.cpp:93
std::shared_ptr< class Node > NodeRef
Definition: Node.h:39
virtual bool supportsProcessInPlace() const override
Default implementation returns true, subclasses should return false if they must process out-of-place...
Definition: ChannelRouterNode.cpp:70
virtual bool supportsInputNumChannels(size_t numChannels) const override
Default implementation returns true if numChannels matches our format.
Definition: ChannelRouterNode.cpp:65