Skip to content

Commit

Permalink
FxMixer: rewrite mixer routing
Browse files Browse the repository at this point in the history
  • Loading branch information
diizy committed Jun 27, 2014
1 parent 5659aa1 commit d9d085d
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 153 deletions.
55 changes: 50 additions & 5 deletions include/FxMixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
#include "ThreadableJob.h"



class FxRoute;
typedef QVector<FxRoute *> FxRouteVector;

class FxChannel : public ThreadableJob
{
Expand All @@ -58,11 +59,10 @@ class FxChannel : public ThreadableJob
bool m_queued; // are we queued up for rendering yet?

// pointers to other channels that this one sends to
QVector<fx_ch_t> m_sends;
QVector<FloatModel *> m_sendAmount;
FxRouteVector m_sends;

// pointers to other channels that send to this one
QVector<fx_ch_t> m_receives;
FxRouteVector m_receives;

virtual bool requiresProcessing() const { return true; }

Expand All @@ -71,6 +71,43 @@ class FxChannel : public ThreadableJob
};


class FxRoute : public QObject
{
public:
FxRoute( FxChannel * from, FxChannel * to, float amount );
virtual ~FxRoute();

fx_ch_t senderIndex() const
{
return m_from->m_channelIndex;
}

fx_ch_t receiverIndex() const
{
return m_to->m_channelIndex;
}

FloatModel * amount() const
{
return m_amount;
}

FxChannel * sender() const
{
return m_from;
}

FxChannel * receiver() const
{
return m_to;
}

private:
FxChannel * m_from;
FxChannel * m_to;
FloatModel * m_amount;
};


class EXPORT FxMixer : public JournallingObject, public Model
{
Expand Down Expand Up @@ -100,13 +137,16 @@ class EXPORT FxMixer : public JournallingObject, public Model
// it is safe to call even if the send already exists
void createChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel,
float amount = 1.0f);
void createRoute( FxChannel * from, FxChannel * to, float amount );

// delete the connection made by createChannelSend
void deleteChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel);
void deleteChannelSend( FxRoute * route );

// determine if adding a send from sendFrom to
// sendTo would result in an infinite mixer loop.
bool isInfiniteLoop(fx_ch_t fromChannel, fx_ch_t toChannel);
bool checkInfiniteLoop( FxChannel * from, FxChannel * to );

// return the FloatModel of fromChannel sending its output to the input of
// toChannel. NULL if there is no send.
Expand All @@ -129,11 +169,16 @@ class EXPORT FxMixer : public JournallingObject, public Model
// reset a channel's name, fx, sends, etc
void clearChannel(fx_ch_t channelIndex);

// rename channels when moving etc. if they still have their original name
void validateChannelName( int index, int oldIndex );

inline fx_ch_t numChannels() const
{
return m_fxChannels.size();
}

FxRouteVector m_fxRoutes;

private:
// the fx channels in the mixer. index 0 is always master.
QVector<FxChannel *> m_fxChannels;
Expand All @@ -142,7 +187,7 @@ class EXPORT FxMixer : public JournallingObject, public Model
void allocateChannelsTo(int num);
QMutex m_sendsMutex;

void addChannelLeaf( int _ch, sampleFrame * _buf );
void addChannelLeaf( FxChannel * ch, sampleFrame * buf );

friend class MixerWorkerThread;
friend class FxMixerView;
Expand Down
Loading

0 comments on commit d9d085d

Please sign in to comment.