~ubuntu-branches/ubuntu/hardy/lmms/hardy

« back to all changes in this revision

Viewing changes to src/core/note.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Tobias Doerffel
  • Date: 2007-09-17 15:00:24 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070917150024-mo0zk4ks81jawqii
Tags: 0.3.0-1ubuntu1
* Resynchronized with Debian (LP: #139759, LP: #90806, LP: #102639,
  LP: #113447, LP: #121172, LP: #124890)
* reverted changes from 0.2.1-1.1ubuntu1 as upstream merged/included them

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/*
4
4
 * note.cpp - implementation of class note
5
5
 *
6
 
 * Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
6
 * Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
7
7
 * 
8
8
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
9
9
 *
19
19
 *
20
20
 * You should have received a copy of the GNU General Public
21
21
 * License along with this program (see COPYING); if not, write to the
22
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23
 
 * Boston, MA 02111-1307, USA.
 
22
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
23
 * Boston, MA 02110-1301 USA.
24
24
 *
25
25
 */
26
26
 
39
39
 
40
40
#include <math.h>
41
41
 
42
 
#include "debug.h"
43
42
#include "note.h"
44
 
#include "knob.h"
 
43
#include "automatable_object_templates.h"
 
44
#include "detuning_helper.h"
45
45
#include "templates.h"
46
46
 
47
47
 
50
50
 
51
51
 
52
52
 
53
 
note::note( engine * _engine, const midiTime & _length, const midiTime & _pos,
 
53
note::note( const midiTime & _length, const midiTime & _pos,
54
54
                tones _tone, octaves _octave, volume _volume,
55
 
                                                        panning _panning ) :
56
 
        journallingObject( _engine ),
 
55
                                panning _panning, detuningHelper * _detuning ) :
57
56
        m_tone( C ),
58
57
        m_octave( DEFAULT_OCTAVE ),
59
58
        m_volume( DEFAULT_VOLUME ),
60
59
        m_panning( DEFAULT_PANNING ),
61
60
        m_length( _length ),
62
 
        m_pos( _pos ),
63
 
        m_detuning( NULL )
 
61
        m_pos( _pos )
64
62
{
65
63
        //saveJournallingState( FALSE );
66
64
        setJournalling( FALSE );
70
68
        setVolume( _volume );
71
69
        setPanning( _panning );
72
70
 
73
 
        if( _engine )
 
71
        if( _detuning )
 
72
        {
 
73
                m_detuning = sharedObject::ref( _detuning );
 
74
        }
 
75
        else
74
76
        {
75
77
                createDetuning();
76
78
        }
89
91
        m_length( _note.m_length ),
90
92
        m_pos( _note.m_pos )
91
93
{
92
 
        setDetuning( _note.m_detuning );
 
94
        m_detuning = sharedObject::ref( _note.m_detuning );
93
95
}
94
96
 
95
97
 
97
99
 
98
100
note::~note()
99
101
{
100
 
        if( m_detuning )
101
 
        {
102
 
                if( m_detuning->data().toInt() )
103
 
                {
104
 
                        m_detuning->setData( m_detuning->data().toInt() - 1 );
105
 
                }
106
 
                else
107
 
                {
108
 
                        delete m_detuning;
109
 
                }
110
 
        }
 
102
        sharedObject::unref( m_detuning );
111
103
}
112
104
 
113
105
 
226
218
        _this.setAttribute( "pan", m_panning );
227
219
        _this.setAttribute( "len", m_length );
228
220
        _this.setAttribute( "pos", m_pos );
229
 
        if( m_length > 0 && m_detuning )
 
221
        if( m_length > 0 )
230
222
        {
231
223
                m_detuning->saveSettings( _doc, _this, "detuning" );
232
224
        }
297
289
 
298
290
 
299
291
 
300
 
void note::setDetuning( knob * _detuning )
301
 
{
302
 
        m_detuning = _detuning;
303
 
        if( m_detuning )
304
 
        {
305
 
                m_detuning->setData( m_detuning->data().toInt() + 1 );
306
 
        }
307
 
}
308
 
 
309
 
 
310
 
 
311
 
 
312
292
void note::createDetuning( void )
313
293
{
314
 
        m_detuning = new knob( knobDark_28, NULL,
315
 
                                                QObject::tr( "Note detuning" ),
316
 
                                                eng(), NULL );
317
 
        m_detuning->initAutomationPattern( eng() );
318
 
        m_detuning->setData( 0 );
 
294
        m_detuning = new detuningHelper;
 
295
        m_detuning->initAutomationPattern();
319
296
        m_detuning->setRange( -MAX_DETUNING, MAX_DETUNING, 0.1f );
320
297
}
321
298
 
322
299
 
323
300
 
324
301
 
325
 
void note::detachCurrentDetuning( void )
 
302
bool note::hasDetuningInfo( void )
326
303
{
327
 
        if( m_detuning->data().toInt() )
328
 
        {
329
 
                m_detuning->setData( m_detuning->data().toInt() - 1 );
330
 
 
331
 
                QDomDocument doc;
332
 
                QDomElement parent = doc.createElement( "clone" );
333
 
                m_detuning->saveSettings( doc, parent );
334
 
                createDetuning();
335
 
                m_detuning->loadSettings( parent );
336
 
        }
 
304
        automationPattern::timeMap map =
 
305
                        m_detuning->getAutomationPattern()->getTimeMap();
 
306
        return( map.size() > 1 || map[0] != 0 );
337
307
}
338
308
 
339
309