~ubuntu-branches/ubuntu/utopic/lmms/utopic

« back to all changes in this revision

Viewing changes to include/FxMixer.h

  • Committer: Package Import Robot
  • Author(s): Israel Dahl
  • Date: 2014-04-30 18:49:37 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20140430184937-hozuuxonlbshciya
Tags: 1.0.1-src-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * FxMixer.h - effect-mixer for LMMS
3
3
 *
4
 
 * Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
4
 * Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5
5
 *
6
6
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
7
7
 *
29
29
#include "Mixer.h"
30
30
#include "EffectChain.h"
31
31
#include "JournallingObject.h"
32
 
#include "ThreadableJob.h"
33
 
 
34
 
 
35
 
 
36
 
 
37
 
class FxChannel : public ThreadableJob
 
32
 
 
33
 
 
34
const int NumFxChannels = 64;
 
35
 
 
36
 
 
37
struct FxChannel
38
38
{
39
 
        public:
40
 
                FxChannel( int idx, Model * _parent );
41
 
                virtual ~FxChannel();
42
 
 
43
 
                EffectChain m_fxChain;
44
 
 
45
 
                // set to true if any effect in the channel is enabled and running
46
 
                bool m_stillRunning;
47
 
 
48
 
                float m_peakLeft;
49
 
                float m_peakRight;
50
 
                sampleFrame * m_buffer;
51
 
                BoolModel m_muteModel;
52
 
                FloatModel m_volumeModel;
53
 
                QString m_name;
54
 
                QMutex m_lock;
55
 
                int m_channelIndex; // what channel index are we
56
 
                bool m_queued; // are we queued up for rendering yet?
57
 
 
58
 
                // pointers to other channels that this one sends to
59
 
                QVector<fx_ch_t> m_sends;
60
 
                QVector<FloatModel *> m_sendAmount;
61
 
 
62
 
                // pointers to other channels that send to this one
63
 
                QVector<fx_ch_t> m_receives;
64
 
 
65
 
                virtual bool requiresProcessing() const { return true; }
66
 
 
67
 
        private:
68
 
                virtual void doProcessing( sampleFrame * _working_buffer );
69
 
};
70
 
 
71
 
 
72
 
 
73
 
class EXPORT FxMixer : public JournallingObject, public Model
 
39
        FxChannel( Model * _parent );
 
40
        ~FxChannel();
 
41
 
 
42
        EffectChain m_fxChain;
 
43
        bool m_used;
 
44
        bool m_stillRunning;
 
45
        float m_peakLeft;
 
46
        float m_peakRight;
 
47
        sampleFrame * m_buffer;
 
48
        BoolModel m_muteModel;
 
49
        FloatModel m_volumeModel;
 
50
        QString m_name;
 
51
        QMutex m_lock;
 
52
 
 
53
} ;
 
54
 
 
55
 
 
56
 
 
57
class FxMixer : public JournallingObject, public Model
74
58
{
75
59
public:
76
60
        FxMixer();
77
61
        virtual ~FxMixer();
78
62
 
79
63
        void mixToChannel( const sampleFrame * _buf, fx_ch_t _ch );
 
64
        void processChannel( fx_ch_t _ch, sampleFrame * _buf = NULL );
80
65
 
81
66
        void prepareMasterMix();
82
67
        void masterMix( sampleFrame * _buf );
83
68
 
 
69
 
 
70
        void clear();
 
71
 
84
72
        virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
85
73
        virtual void loadSettings( const QDomElement & _this );
86
74
 
91
79
 
92
80
        FxChannel * effectChannel( int _ch )
93
81
        {
94
 
                return m_fxChannels[_ch];
95
 
        }
96
 
 
97
 
        // make the output of channel fromChannel go to the input of channel toChannel
98
 
        // it is safe to call even if the send already exists
99
 
        void createChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel,
100
 
                                                   float amount = 1.0f);
101
 
 
102
 
        // delete the connection made by createChannelSend
103
 
        void deleteChannelSend(fx_ch_t fromChannel, fx_ch_t toChannel);
104
 
 
105
 
        // determine if adding a send from sendFrom to
106
 
        // sendTo would result in an infinite mixer loop.
107
 
        bool isInfiniteLoop(fx_ch_t fromChannel, fx_ch_t toChannel);
108
 
 
109
 
        // return the FloatModel of fromChannel sending its output to the input of
110
 
        // toChannel. NULL if there is no send.
111
 
        FloatModel * channelSendModel(fx_ch_t fromChannel, fx_ch_t toChannel);
112
 
 
113
 
        // add a new channel to the Fx Mixer.
114
 
        // returns the index of the channel that was just added
115
 
        int createChannel();
116
 
 
117
 
        // delete a channel from the FX mixer.
118
 
        void deleteChannel(int index);
119
 
 
120
 
        // delete all the mixer channels except master and remove all effects
121
 
        void clear();
122
 
 
123
 
        // re-arrange channels
124
 
        void moveChannelLeft(int index);
125
 
        void moveChannelRight(int index);
126
 
 
127
 
        // reset a channel's name, fx, sends, etc
128
 
        void clearChannel(fx_ch_t channelIndex);
129
 
 
130
 
        inline fx_ch_t numChannels() const
131
 
        {
132
 
                return m_fxChannels.size();
133
 
        }
 
82
                if( _ch >= 0 && _ch <= NumFxChannels )
 
83
                {
 
84
                        return m_fxChannels[_ch];
 
85
                }
 
86
                return NULL;
 
87
        }
 
88
 
134
89
 
135
90
private:
136
 
        // the fx channels in the mixer. index 0 is always master.
137
 
        QVector<FxChannel *> m_fxChannels;
138
 
 
139
 
        // make sure we have at least num channels
140
 
        void allocateChannelsTo(int num);
141
 
 
142
 
        void addChannelLeaf( int _ch, sampleFrame * _buf );
 
91
        FxChannel * m_fxChannels[NumFxChannels+1];      // +1 = master
 
92
 
143
93
 
144
94
        friend class MixerWorkerThread;
145
95
        friend class FxMixerView;