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

« back to all changes in this revision

Viewing changes to include/instrument.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
/*
 
2
 * instrument.h - declaration of class instrument, which provides a
 
3
 *                standard interface for all instrument plugins
 
4
 *
 
5
 * Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
6
 * 
 
7
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public
 
11
 * License as published by the Free Software Foundation; either
 
12
 * version 2 of the License, or (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
 * General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public
 
20
 * License along with this program (see COPYING); if not, write to the
 
21
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
22
 * Boston, MA 02111-1307, USA.
 
23
 *
 
24
 */
 
25
 
 
26
 
 
27
#ifndef _INSTRUMENT_H
 
28
#define _INSTRUMENT_H
 
29
 
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#include <config.h>
 
33
#endif
 
34
 
 
35
 
 
36
#include "qt3support.h"
 
37
 
 
38
#ifdef QT4
 
39
 
 
40
#include <QWidget>
 
41
#include <QVector>
 
42
 
 
43
#else
 
44
 
 
45
#include <qwidget.h>
 
46
#include <qvaluevector.h>
 
47
 
 
48
#endif
 
49
 
 
50
 
 
51
#include "plugin.h"
 
52
#include "mixer.h"
 
53
 
 
54
 
 
55
// forward-declarations
 
56
class channelTrack;
 
57
class notePlayHandle;
 
58
 
 
59
 
 
60
class instrument : public QWidget, public plugin
 
61
{
 
62
public:
 
63
        instrument( channelTrack * _channel_track, const QString & _name );
 
64
        virtual ~instrument();
 
65
 
 
66
        // if the plugin doesn't play each note, it can create an instrument-
 
67
        // play-handle and re-implement this method, so that it mixes it's
 
68
        // output buffer only once per mixer-period
 
69
        virtual void play( void );
 
70
 
 
71
        // must be overloaded by actual plugin
 
72
        virtual void FASTCALL playNote( notePlayHandle * note_to_play );
 
73
 
 
74
        // needed for deleting plugin-specific-data of a note - plugin has to
 
75
        // cast void-ptr so that the plugin-data is deleted properly
 
76
        // (call of dtor if it's a class etc.)
 
77
        virtual void FASTCALL deleteNotePluginData( notePlayHandle *
 
78
                                                        _note_to_play );
 
79
 
 
80
        // Get number of sample-frames that should be used when playing beat
 
81
        // (note with unspecified length)
 
82
        // Per default this function returns 0. In this case, channel is using
 
83
        // the length of the longest envelope (if one active).
 
84
        virtual Uint32 FASTCALL beatLen( notePlayHandle * _n ) const;
 
85
 
 
86
 
 
87
        // instrument-play-handles use this for checking whether they can mark
 
88
        // themselves as done, so that mixer trashes them
 
89
        inline virtual bool valid( void ) const
 
90
        {
 
91
                return( m_valid );
 
92
        }
 
93
 
 
94
 
 
95
        // instantiate instrument-plugin with given name or return NULL
 
96
        // on failure
 
97
        static instrument * FASTCALL instantiate( const QString & _plugin_name,
 
98
                                                channelTrack * _channel_track );
 
99
 
 
100
protected:
 
101
        inline channelTrack * getChannelTrack( void ) const
 
102
        {
 
103
                return( m_channelTrack );
 
104
        }
 
105
 
 
106
        // instruments can use this for invalidating themselves, which is for
 
107
        // example neccessary when being destroyed and having instrument-play-
 
108
        // handles running
 
109
        inline void invalidate( void )
 
110
        {
 
111
                m_valid = FALSE;
 
112
                mixer::inst()->checkValidityOfPlayHandles();
 
113
        }
 
114
 
 
115
 
 
116
private:
 
117
        channelTrack * m_channelTrack;
 
118
        bool m_valid;
 
119
 
 
120
} ;
 
121
 
 
122
 
 
123
#endif