~ubuntu-branches/ubuntu/dapper/lmms/dapper

« back to all changes in this revision

Viewing changes to include/channel_track.h

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ragwitz
  • Date: 2005-12-22 16:22:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051222162250-key3p7x0212jy6dn
Tags: 0.1.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * channel_track.h - declaration of class channelTrack, a track-class which
3
3
 *                   contains all information about a channel and provides
4
 
 *                   a settings-window and an API for dealing with
5
 
 *                   sound-generator-plugins
 
4
 *                   a settings-window and an API for dealing with instruments
6
5
 *
7
 
 * Linux MultiMedia Studio
8
 
 * Copyright (c) 2004-2005 Tobias Doerffel <tobydox@users.sourceforge.net>
 
6
 * Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
7
 * 
 
8
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
9
9
 *
10
10
 * This program is free software; you can redistribute it and/or
11
11
 * modify it under the terms of the GNU General Public
46
46
 
47
47
#include "track.h"
48
48
#include "mixer.h"
49
 
#include "midi_device.h"
50
 
#include "templates.h"
 
49
#include "midi_event_processor.h"
 
50
#include "gui_templates.h"
 
51
#include "tab_widget.h"
51
52
 
52
53
 
53
54
class QLineEdit;
58
59
class lcdSpinBox;
59
60
class notePlayHandle;
60
61
class pianoWidget;
61
 
class soundGenerator;
 
62
class presetPreviewPlayHandle;
 
63
class instrument;
 
64
class midiPort;
 
65
class midiTabWidget;
62
66
class surroundArea;
63
 
class tabBar;
64
 
 
65
 
 
66
 
class channelTrack : public QWidget, public track, public midiDevice
 
67
class audioPort;
 
68
 
 
69
 
 
70
 
 
71
class channelTrack : public QWidget, public track, public midiEventProcessor
67
72
{
68
73
        Q_OBJECT
69
74
public:
70
75
        channelTrack( trackContainer * _tc );
71
76
        virtual ~channelTrack();
72
77
 
73
 
        // used by sound-generator
74
 
        void FASTCALL processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
 
78
        inline virtual trackTypes type( void ) const
 
79
        {
 
80
                return( m_trackType );
 
81
        }
 
82
 
 
83
 
 
84
        // used by instrument
 
85
        void FASTCALL processAudioBuffer( sampleFrame * _buf, Uint32 _frames,
75
86
                                                notePlayHandle * _n );
76
87
 
 
88
        virtual void FASTCALL processInEvent( const midiEvent & _me,
 
89
                                                const midiTime & _time );
 
90
        virtual void FASTCALL processOutEvent( const midiEvent & _me,
 
91
                                                const midiTime & _time );
 
92
 
77
93
        // returns the frequency of a given tone & octave.
78
94
        // This function also includes base_tone & base_octave in
79
95
        // its calculations
113
129
        }
114
130
        int FASTCALL masterKey( notePlayHandle * _n ) const;
115
131
 
 
132
        // play everything in given frame-range - creates note-play-handles
116
133
        virtual bool FASTCALL play( const midiTime & _start,
117
134
                                        Uint32 _start_frame, Uint32 _frames,
118
135
                                                        Uint32 _frame_base,
119
136
                                                        Sint16 _tco_num = -1 );
120
 
        inline virtual trackTypes trackType( void ) const
121
 
        {
122
 
                return( m_trackType );
123
 
        }
124
 
 
 
137
        // create new track-content-object = pattern
125
138
        virtual trackContentObject * FASTCALL createTCO( const midiTime &
126
139
                                                                        _pos );
127
140
 
128
141
 
 
142
        // called by track
129
143
        virtual void FASTCALL saveTrackSpecificSettings( QDomDocument & _doc,
130
144
                                                        QDomElement & _parent );
131
145
        virtual void FASTCALL loadTrackSpecificSettings( const QDomElement &
132
146
                                                                        _this );
133
 
        void FASTCALL loadPluginSettings( const QDomElement &
134
 
                                                        _plugin_settings );
135
 
 
136
 
        QWidget * widgetStack( void )
 
147
 
 
148
        // load instrument whose name matches given one
 
149
        instrument * FASTCALL loadInstrument( const QString & _plugin_name );
 
150
 
 
151
        // parent for all internal tab-widgets
 
152
        QWidget * tabWidgetParent( void )
137
153
        {
138
 
                return( m_widgetStack );
 
154
                return( m_tabWidget );
139
155
        }
140
156
 
141
157
 
144
160
        void surroundAreaPosChanged( const QPoint & _new_p );
145
161
        void textChanged( const QString & _new_name );
146
162
        void toggledChannelButton( bool _on );
147
 
        void noteDone( const note & _n );
148
163
 
149
164
 
150
165
protected:
151
166
        // capture close-events for toggling channel-button in track
152
 
        void closeEvent( QCloseEvent * _ce );
153
 
        void focusInEvent( QFocusEvent * _fe );
 
167
        virtual void closeEvent( QCloseEvent * _ce );
 
168
        virtual void focusInEvent( QFocusEvent * _fe );
 
169
        virtual void dragEnterEvent( QDragEnterEvent * _dee );
 
170
        virtual void dropEvent( QDropEvent * _de );
 
171
 
154
172
        inline virtual QString nodeName( void ) const
155
173
        {
156
174
                return( "channeltrack" );
158
176
        // invalidates all note-play-handles linked to this channel
159
177
        void invalidateAllMyNPH( void );
160
178
 
 
179
        void noteOffAll( void );
 
180
 
161
181
 
162
182
protected slots:
163
183
        void saveSettingsBtnClicked( void );
166
186
private:
167
187
        trackTypes m_trackType;
168
188
 
 
189
        midiPort * m_midiPort;
 
190
 
 
191
        audioPort * m_audioPort;
 
192
 
 
193
 
 
194
        notePlayHandle * m_notes[NOTES_PER_OCTAVE * OCTAVES];
 
195
 
 
196
 
169
197
        tones m_baseTone;
170
198
        octaves m_baseOctave;
171
199
 
172
200
        QString m_name;
173
201
 
174
 
        QWidget * m_generalSettingsWidget;
 
202
 
 
203
        // widgets on the top of a channel-track-window
 
204
        tabWidget * m_generalSettingsWidget;
175
205
        QLineEdit * m_channelNameLE;
176
 
        tabBar * m_tabBar;
177
 
        QWidget * m_widgetStack;
178
 
        
179
 
        // widgets in widget-stack
180
 
        soundGenerator * m_soundGenPluginWidget;
181
 
        envelopeTabWidget * m_envWidget;
182
 
        arpAndChordsTabWidget * m_arpWidget;
183
 
 
184
 
        // buttons for selecting widgets in widget-stack
185
 
        QPushButton * m_soundGenPluginBtn;
186
 
        QPushButton * m_envBtn;
187
 
        QPushButton * m_arpBtn;
188
 
 
189
 
        // knobs etc. in general-settings-widget
190
206
        knob * m_volumeKnob;
191
207
        surroundArea * m_surroundArea;
192
208
        lcdSpinBox * m_effectChannelNumber;
193
209
        QPushButton * m_saveSettingsBtn;
194
210
 
 
211
        
 
212
        // tab-widget with all children
 
213
        tabWidget * m_tabWidget;
 
214
        instrument * m_instrument;
 
215
        envelopeTabWidget * m_envWidget;
 
216
        arpAndChordsTabWidget * m_arpWidget;
 
217
        midiTabWidget * m_midiWidget;
 
218
 
 
219
 
 
220
        // test-piano at the bottom of every channel-settings-window
 
221
        pianoWidget * m_pianoWidget;
 
222
 
 
223
 
195
224
        // widgets in track-settings-widget
196
 
 
197
225
        knob * m_tswVolumeKnob;
198
226
        surroundArea * m_tswSurroundArea;
199
227
        channelButton * m_tswChannelButton;
200
228
 
201
 
        // test-piano at the bottom of every channel-settings-window
202
 
        pianoWidget * m_pianoWidget;
203
 
 
204
 
 
 
229
 
 
230
        friend class channelButton;
205
231
        friend class notePlayHandle;
 
232
        friend class presetPreviewPlayHandle;
206
233
 
207
234
 
208
235
signals:
209
 
        void noteFromMidiDeviceDone( const note & _n );
 
236
        void noteDone( const note & _n );
210
237
 
211
238
} ;
212
239
 
216
243
class channelButton : public QPushButton
217
244
{
218
245
public:
219
 
        channelButton( channelTrack * _channel_track ) :
220
 
                QPushButton( _channel_track->getTrackSettingsWidget() ),
221
 
                m_channelTrack( _channel_track )
222
 
        {
223
 
        }
224
 
 
225
 
        virtual ~channelButton()
226
 
        {
227
 
        }
 
246
        channelButton( channelTrack * _channel_track );
 
247
        virtual ~channelButton();
228
248
 
229
249
 
230
250
protected:
231
 
        virtual void drawButtonLabel( QPainter * _p )
232
 
        {
233
 
                QString pn = m_channelTrack->pluginName() + ":";
234
 
                int extra = 
235
 
#ifdef QT4
236
 
                        isChecked
237
 
#else
238
 
                        isOn
239
 
#endif
240
 
                                () ? -1 : -3;
241
 
                _p->setFont( pointSize<7>( _p->font() ) );
242
 
#ifdef QT4
243
 
                _p->setPen( QApplication::palette().buttonText().color() );
244
 
#else
245
 
                _p->setPen( QApplication::palette().color( QPalette::Normal,
246
 
                                                QColorGroup::ButtonText ) );
247
 
#endif
248
 
                _p->drawText( ( width() -
249
 
                                QFontMetrics( _p->font() ).width( pn ) ) / 2 +
250
 
                                        extra, height() / 2 + extra, pn );
251
 
                _p->setPen( QColor( 0, 0, 0 ) );
252
 
                _p->drawText( ( width() -
253
 
                                QFontMetrics( _p->font() ).width( text() ) ) /
254
 
                                2 + extra, height() / 2 +
255
 
                                QFontMetrics( _p->font() ).height() + extra,
256
 
                                                                text() );
257
 
        }
 
251
        // since we want to draw a special label (instrument- and channel-name)
 
252
        // on our button, we have to re-implement this for doing so
 
253
        virtual void drawButtonLabel( QPainter * _p );
 
254
 
 
255
        // allow drops on this button - we just forward them to channel-track
 
256
        virtual void dragEnterEvent( QDragEnterEvent * _dee );
 
257
        virtual void dropEvent( QDropEvent * _de );
 
258
 
258
259
 
259
260
private:
260
261
        channelTrack * m_channelTrack;