Reworked MIDI event handling in InstrumentTrack and renamed MIDI classes

The MIDI event handling in InstrumentTrack was complex and buggy. It has
been simplified now such that processInEvent() tries to handle note on,
note off and key pressure events. The actions taken should result in
equivalent calls to processOutEvent() by NotePlayHandle instances. The
processOutEvent() function sends according MIDI events to the attached
instruments. All unhandled MIDI events are directly forwarded to the
instrument in processInEvent().

It's possible that some corner-cases are not handled yet with the new code
and we have regressions now.

Furthermore renamed midiTime/midiEvent to MidiTime/MidiEvent to match
coding style.

Closes #72.
This commit is contained in:
Tobias Doerffel
2014-01-25 23:52:25 +01:00
parent 790266f0c1
commit 3a827f061f
70 changed files with 901 additions and 891 deletions

View File

@@ -31,7 +31,7 @@
#include "lmms_basics.h"
#include "JournallingObject.h"
#include "midi_time.h"
#include "MidiTime.h"
#include "AutomationPattern.h"
#include "ComboBoxModel.h"
@@ -127,7 +127,7 @@ protected slots:
void pasteValues();
void deleteSelectedValues();
void updatePosition( const midiTime & _t );
void updatePosition( const MidiTime & _t );
void zoomingXChanged();
void zoomingYChanged();
@@ -218,7 +218,7 @@ private:
QScrollBar * m_leftRightScroll;
QScrollBar * m_topBottomScroll;
midiTime m_currentPosition;
MidiTime m_currentPosition;
actions m_action;
@@ -258,7 +258,7 @@ private:
signals:
void currentPatternChanged();
void positionChanged( const midiTime & );
void positionChanged( const MidiTime & );
} ;

View File

@@ -33,7 +33,7 @@
class AutomationTrack;
class midiTime;
class MidiTime;
@@ -72,12 +72,12 @@ public:
}
void setTension( QString _new_tension );
virtual midiTime length() const;
virtual MidiTime length() const;
midiTime putValue( const midiTime & _time, const float _value,
MidiTime putValue( const MidiTime & _time, const float _value,
const bool _quant_pos = true );
void removeValue( const midiTime & _time );
void removeValue( const MidiTime & _time );
inline const timeMap & getTimeMap() const
{
@@ -104,8 +104,8 @@ public:
return m_timeMap.isEmpty() == false;
}
float valueAt( const midiTime & _time ) const;
float *valuesAfter( const midiTime & _time ) const;
float valueAt( const MidiTime & _time ) const;
float *valuesAfter( const MidiTime & _time ) const;
const QString name() const;
@@ -123,7 +123,7 @@ public:
return classNodeName();
}
void processMidiTime( const midiTime & _time );
void processMidiTime( const MidiTime & _time );
virtual trackContentObjectView * createView( trackView * _tv );

View File

@@ -36,7 +36,7 @@ public:
AutomationTrack( TrackContainer* tc, bool _hidden = false );
virtual ~AutomationTrack();
virtual bool play( const midiTime & _start, const fpp_t _frames,
virtual bool play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 );
virtual QString nodeName() const
@@ -45,7 +45,7 @@ public:
}
virtual trackView * createView( TrackContainerView* );
virtual trackContentObject * createTCO( const midiTime & _pos );
virtual trackContentObject * createTCO( const MidiTime & _pos );
virtual void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent );

View File

@@ -35,8 +35,8 @@
// forward-declarations
class InstrumentTrack;
class InstrumentView;
class midiEvent;
class midiTime;
class MidiEvent;
class MidiTime;
class notePlayHandle;
class track;
@@ -99,7 +99,7 @@ public:
// sub-classes can re-implement this for receiving all incoming
// MIDI-events
inline virtual bool handleMidiEvent( const midiEvent &, const midiTime & )
inline virtual bool handleMidiEvent( const MidiEvent&, const MidiTime& = MidiTime() )
{
return false;
}

View File

@@ -69,12 +69,10 @@ public:
void processAudioBuffer( sampleFrame * _buf, const fpp_t _frames,
notePlayHandle * _n );
midiEvent applyMasterKey( const midiEvent & _me );
MidiEvent applyMasterKey( const MidiEvent& event );
virtual void processInEvent( const midiEvent & _me,
const midiTime & _time );
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time );
virtual void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime() );
virtual void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime() );
// silence all running notes played by this track
void silenceAllNotes();
@@ -117,13 +115,13 @@ public:
}
// play everything in given frame-range - creates note-play-handles
virtual bool play( const midiTime & _start, const fpp_t _frames,
virtual bool play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 );
// create new view for me
virtual trackView * createView( TrackContainerView* tcv );
// create new track-content-object = pattern
virtual trackContentObject * createTCO( const midiTime & _pos );
virtual trackContentObject * createTCO( const MidiTime & _pos );
// called by track

View File

@@ -1,7 +1,7 @@
/*
* midi.h - constants, structs etc. concerning MIDI
* Midi.h - constants, structs etc. concerning MIDI
*
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -26,8 +26,6 @@
#define _MIDI_H
#include "lmms_basics.h"
#include "panning_constants.h"
#include <cstdlib>
enum MidiEventTypes
@@ -60,7 +58,7 @@ enum MidiEventTypes
MidiMetaEvent = 0xFF
} ;
enum MidiMetaEvents
enum MidiMetaEventTypes
{
MidiMetaInvalid = 0x00,
MidiCopyright = 0x02,
@@ -79,6 +77,7 @@ enum MidiMetaEvents
MidiMetaCustom = 0x80,
MidiNotePanning
} ;
typedef MidiMetaEventTypes MidiMetaEventType;
enum MidiStandardControllers
@@ -120,139 +119,4 @@ const int MidiMaxNote = 127;
const int MidiMaxPanning = 127;
const int MidiMinPanning = -128;
struct midiEvent
{
midiEvent( MidiEventTypes _type = MidiActiveSensing,
int8_t _channel = 0,
int16_t _param1 = 0,
int16_t _param2 = 0,
const void * _sourcePort = NULL ) :
m_type( _type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( _channel ),
m_sysExData( NULL ),
m_sourcePort( _sourcePort ),
m_fromMidiPort( false )
{
m_data.m_param[0] = _param1;
m_data.m_param[1] = _param2;
}
midiEvent( MidiEventTypes _type, const char * _sysex_data,
int _data_len ) :
m_type( _type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( 0 ),
m_sysExData( _sysex_data ),
m_sourcePort( NULL ),
m_fromMidiPort( false )
{
m_data.m_sysExDataLen = _data_len;
}
midiEvent( const midiEvent & _copy ) :
m_type( _copy.m_type ),
m_metaEvent( _copy.m_metaEvent ),
m_channel( _copy.m_channel ),
m_data( _copy.m_data ),
m_sysExData( _copy.m_sysExData ),
m_sourcePort( _copy.m_sourcePort ),
m_fromMidiPort( _copy.m_fromMidiPort )
{
}
inline MidiEventTypes type() const
{
return m_type;
}
inline int channel() const
{
return m_channel;
}
inline int16_t key() const
{
return m_data.m_param[0];
}
inline int16_t & key()
{
return m_data.m_param[0];
}
inline uint8_t controllerNumber() const
{
return m_data.m_param[0];
}
inline uint8_t controllerValue() const
{
return m_data.m_param[1];
}
inline int16_t velocity() const
{
return m_data.m_param[1];
}
inline int16_t & velocity()
{
return m_data.m_param[1];
}
inline int16_t midiPanning() const
{
return m_data.m_param[1];
}
inline volume_t getVolume() const
{
return (volume_t)( velocity() * 100 / MidiMaxVelocity );
}
inline const void * sourcePort() const
{
return m_sourcePort;
}
inline panning_t getPanning() const
{
return (panning_t) ( PanningLeft +
( (float)( midiPanning() - MidiMinPanning ) ) /
( (float)( MidiMaxPanning - MidiMinPanning ) ) *
( (float)( PanningRight - PanningLeft ) ) );
}
void setFromMidiPort( bool enabled )
{
m_fromMidiPort = enabled;
}
bool isFromMidiPort() const
{
return m_fromMidiPort;
}
MidiEventTypes m_type; // MIDI event type
MidiMetaEvents m_metaEvent; // Meta event (mostly unused)
int8_t m_channel; // MIDI channel
union
{
int16_t m_param[2]; // first/second parameter (key/velocity)
uint8_t m_bytes[4]; // raw bytes
int32_t m_sysExDataLen; // len of m_sysExData
} m_data;
const char * m_sysExData;
const void * m_sourcePort;
private:
bool m_fromMidiPort;
} ;
#endif

View File

@@ -62,8 +62,8 @@ public:
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time,
virtual void processOutEvent( const MidiEvent & _me,
const MidiTime & _time,
const MidiPort * _port );
virtual void applyPortMode( MidiPort * _port );
@@ -84,7 +84,7 @@ public:
}
// return name of port which specified MIDI event came from
virtual QString sourcePortName( const midiEvent & ) const;
virtual QString sourcePortName( const MidiEvent & ) const;
// (un)subscribe given MidiPort to/from destination-port
virtual void subscribeReadablePort( MidiPort * _port,

View File

@@ -29,7 +29,7 @@
#include <QtCore/QVector>
#include "midi.h"
#include "MidiEvent.h"
#include "MidiEventProcessor.h"
#include "tab_widget.h"
@@ -45,8 +45,8 @@ public:
virtual ~MidiClient();
// to be implemented by sub-classes
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time,
virtual void processOutEvent( const MidiEvent & _me,
const MidiTime & _time,
const MidiPort * _port ) = 0;
// inheriting classes can re-implement this for being able to update
@@ -78,13 +78,13 @@ public:
}
// return name of port which specified MIDI event came from
virtual QString sourcePortName( const midiEvent & ) const
virtual QString sourcePortName( const MidiEvent & ) const
{
return QString();
}
// (un)subscribe given MidiPort to/from destination-port
// (un)subscribe given MidiPort to/from destination-port
virtual void subscribeReadablePort( MidiPort * _port,
const QString & _dest,
bool _subscribe = true );
@@ -167,7 +167,7 @@ protected:
private:
// this does MIDI-event-process
void processParsedEvent();
virtual void processOutEvent( const midiEvent& event, const midiTime& time, const MidiPort* port );
virtual void processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port );
// small helper function returning length of a certain event - this
// is necessary for parsing raw-MIDI-data
@@ -188,7 +188,7 @@ private:
// event type include?
uint32_t m_buffer[RAW_MIDI_PARSE_BUF_SIZE];
// buffer for incoming data
midiEvent m_midiEvent; // midi-event
MidiEvent m_midiEvent; // midi-event
} m_midiParseData;
} ;

View File

@@ -43,11 +43,11 @@ public:
MidiController( Model * _parent );
virtual ~MidiController();
virtual void processInEvent( const midiEvent & _me,
const midiTime & _time );
virtual void processInEvent( const MidiEvent & _me,
const MidiTime & _time );
virtual void processOutEvent( const midiEvent& _me,
const midiTime & _time)
virtual void processOutEvent( const MidiEvent& _me,
const MidiTime & _time)
{
// No output yet
}

209
include/MidiEvent.h Normal file
View File

@@ -0,0 +1,209 @@
/*
* MidiEvent.h - MidiEvent class
*
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _MIDI_EVENT_H
#define _MIDI_EVENT_H
#include <cstdlib>
#include "Midi.h"
#include "panning_constants.h"
class MidiEvent
{
public:
MidiEvent( MidiEventTypes type = MidiActiveSensing,
int8_t channel = 0,
int16_t param1 = 0,
int16_t param2 = 0,
const void* sourcePort = NULL ) :
m_type( type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( channel ),
m_sysExData( NULL ),
m_sourcePort( sourcePort )
{
m_data.m_param[0] = param1;
m_data.m_param[1] = param2;
}
MidiEvent( MidiEventTypes type, const char* sysExData, int dataLen ) :
m_type( type ),
m_metaEvent( MidiMetaInvalid ),
m_channel( 0 ),
m_sysExData( sysExData ),
m_sourcePort( NULL )
{
m_data.m_sysExDataLen = dataLen;
}
MidiEvent( const MidiEvent& other ) :
m_type( other.m_type ),
m_metaEvent( other.m_metaEvent ),
m_channel( other.m_channel ),
m_data( other.m_data ),
m_sysExData( other.m_sysExData ),
m_sourcePort( other.m_sourcePort )
{
}
MidiEventTypes type() const
{
return m_type;
}
void setType( MidiEventTypes type )
{
m_type = type;
}
void setMetaEvent( MidiMetaEventType metaEvent )
{
m_metaEvent = metaEvent;
}
MidiMetaEventType metaEvent() const
{
return m_metaEvent;
}
int8_t channel() const
{
return m_channel;
}
void setChannel( int8_t channel )
{
m_channel = channel;
}
int16_t param( int i ) const
{
return m_data.m_param[i];
}
void setParam( int i, uint16_t value )
{
m_data.m_param[i] = value;
}
int16_t key() const
{
return param( 0 );
}
void setKey( int16_t key )
{
m_data.m_param[0] = key;
}
uint8_t velocity() const
{
return m_data.m_param[1] & 0x7F;
}
void setVelocity( int16_t velocity )
{
m_data.m_param[1] = velocity;
}
panning_t panning() const
{
return (panning_t) ( PanningLeft +
( (float)( midiPanning() - MidiMinPanning ) ) /
( (float)( MidiMaxPanning - MidiMinPanning ) ) *
( (float)( PanningRight - PanningLeft ) ) );
}
int16_t midiPanning() const
{
return m_data.m_param[1];
}
volume_t volume() const
{
return (volume_t)( velocity() * 100 / MidiMaxVelocity );
}
const void* sourcePort() const
{
return m_sourcePort;
}
uint8_t controllerNumber() const
{
return param( 0 ) & 0x7F;
}
void setControllerNumber( uint8_t num )
{
setParam( 0, num );
}
uint8_t controllerValue() const
{
return param( 1 );
}
void setControllerValue( uint8_t value )
{
setParam( 1, value );
}
uint8_t program() const
{
return param( 0 );
}
uint8_t channelPressure() const
{
return param( 0 );
}
int16_t pitchBend() const
{
return param( 0 );
}
void setPitchBend( uint16_t pitchBend )
{
setParam( 0, pitchBend );
}
private:
MidiEventTypes m_type; // MIDI event type
MidiMetaEventType m_metaEvent; // Meta event (mostly unused)
int8_t m_channel; // MIDI channel
union
{
int16_t m_param[2]; // first/second parameter (key/velocity)
uint8_t m_bytes[4]; // raw bytes
int32_t m_sysExDataLen; // len of m_sysExData
} m_data;
const char* m_sysExData;
const void* m_sourcePort;
} ;
#endif

View File

@@ -25,27 +25,25 @@
#ifndef _MIDI_EVENT_PROCESSOR_H
#define _MIDI_EVENT_PROCESSOR_H
class midiEvent;
class midiTime;
#include "MidiEvent.h"
#include "MidiTime.h"
// all classes being able to process MIDI-events should inherit from this
class MidiEventProcessor
{
public:
inline MidiEventProcessor()
MidiEventProcessor()
{
}
virtual inline ~MidiEventProcessor()
virtual ~MidiEventProcessor()
{
}
// to be implemented by inheriting classes
virtual void processInEvent( const midiEvent & _me,
const midiTime & _time ) = 0;
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time ) = 0;
virtual void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime() ) = 0;
virtual void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime() ) = 0;
} ;

View File

@@ -1,8 +1,8 @@
/*
* MidiPort.h - abstraction of MIDI ports which are part of LMMS's MIDI-
* MidiPort.h - abstraction of MIDI ports which are part of LMMS' MIDI
* sequencing system
*
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -28,16 +28,17 @@
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QPair>
#include <QtCore/QMap>
#include "midi.h"
#include "Midi.h"
#include "MidiTime.h"
#include "AutomatableModel.h"
class MidiClient;
class MidiEvent;
class MidiEventProcessor;
class MidiPortMenu;
class midiTime;
// class for abstraction of MIDI-port
@@ -104,8 +105,8 @@ public:
return outputChannel() - 1;
}
void processInEvent( const midiEvent & _me, const midiTime & _time );
void processOutEvent( const midiEvent & _me, const midiTime & _time );
void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime() );
void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime() );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );

View File

@@ -1,8 +1,8 @@
/*
* midi_time.h - declaration of class midiTime which provides data-type for
* position- and length-variables
* MidiTime.h - declaration of class MidiTime which provides data type for
* position- and length-variables
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -35,25 +35,25 @@ const int DefaultStepsPerTact = 16;
const int DefaultBeatsPerTact = DefaultTicksPerTact / DefaultStepsPerTact;
class EXPORT midiTime
class EXPORT MidiTime
{
public:
inline midiTime( const tact_t _tact, const tick_t _ticks ) :
m_ticks( _tact * s_ticksPerTact + _ticks )
MidiTime( const tact_t tact, const tick_t ticks ) :
m_ticks( tact * s_ticksPerTact + ticks )
{
}
inline midiTime( const tick_t _ticks = 0 ) :
m_ticks( _ticks )
MidiTime( const tick_t ticks = 0 ) :
m_ticks( ticks )
{
}
inline midiTime( const midiTime & _t ) :
m_ticks( _t.m_ticks )
MidiTime( const MidiTime& time ) :
m_ticks( time.m_ticks )
{
}
inline midiTime toNearestTact() const
MidiTime toNearestTact() const
{
if( m_ticks % s_ticksPerTact >= s_ticksPerTact/2 )
{
@@ -62,30 +62,30 @@ public:
return getTact() * s_ticksPerTact;
}
inline midiTime & operator=( const midiTime & _t )
MidiTime& operator=( const MidiTime& time )
{
m_ticks = _t.m_ticks;
m_ticks = time.m_ticks;
return *this;
}
inline midiTime & operator+=( const midiTime & _t )
MidiTime& operator+=( const MidiTime& time )
{
m_ticks += _t.m_ticks;
m_ticks += time.m_ticks;
return *this;
}
inline midiTime & operator-=( const midiTime & _t )
MidiTime& operator-=( const MidiTime& time )
{
m_ticks -= _t.m_ticks;
m_ticks -= time.m_ticks;
return *this;
}
inline tact_t getTact() const
tact_t getTact() const
{
return m_ticks / s_ticksPerTact;
}
inline tact_t nextFullTact() const
tact_t nextFullTact() const
{
if( m_ticks % s_ticksPerTact == 0 )
{
@@ -94,37 +94,34 @@ public:
return m_ticks / s_ticksPerTact + 1;
}
inline void setTicks( tick_t _t )
void setTicks( tick_t ticks )
{
m_ticks = _t;
m_ticks = ticks;
}
inline tick_t getTicks() const
tick_t getTicks() const
{
return m_ticks;
}
inline operator int() const
operator int() const
{
return m_ticks;
}
// calculate number of frame that are needed this time
inline f_cnt_t frames( const float _frames_per_tick ) const
f_cnt_t frames( const float framesPerTick ) const
{
if( m_ticks >= 0 )
{
return static_cast<f_cnt_t>( m_ticks *
_frames_per_tick );
return static_cast<f_cnt_t>( m_ticks * framesPerTick );
}
return 0;
}
static inline midiTime fromFrames( const f_cnt_t _frames,
const float _frames_per_tick )
static MidiTime fromFrames( const f_cnt_t frames, const float framesPerTick )
{
return midiTime( static_cast<int>( _frames /
_frames_per_tick ) );
return MidiTime( static_cast<int>( frames / framesPerTick ) );
}
@@ -143,6 +140,7 @@ public:
s_ticksPerTact = _tpt;
}
private:
tick_t m_ticks;

View File

@@ -56,8 +56,8 @@ public:
virtual void processOutEvent( const midiEvent & _me,
const midiTime & _time,
virtual void processOutEvent( const MidiEvent & _me,
const MidiTime & _time,
const MidiPort * _port );
virtual void applyPortMode( MidiPort * _port );
@@ -78,7 +78,7 @@ public:
#endif
// return name of port which specified MIDI event came from
virtual QString sourcePortName( const midiEvent & ) const;
virtual QString sourcePortName( const MidiEvent & ) const;
// (un)subscribe given MidiPort to/from destination-port
virtual void subscribeReadablePort( MidiPort * _port,

View File

@@ -1,7 +1,7 @@
/*
* RemotePlugin.h - base class providing RPC like mechanisms
*
* Copyright (c) 2008-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -26,7 +26,7 @@
#define _REMOTE_PLUGIN_H
#include "export.h"
#include "midi.h"
#include "MidiEvent.h"
#include "VST_sync_shm.h"
#include <vector>
@@ -724,7 +724,7 @@ public:
bool process( const sampleFrame * _in_buf, sampleFrame * _out_buf );
void processMidiEvent( const midiEvent &, const f_cnt_t _offset );
void processMidiEvent( const MidiEvent&, const f_cnt_t _offset );
void updateSampleRate( sample_rate_t _sr )
{
@@ -820,8 +820,7 @@ public:
virtual void process( const sampleFrame * _in_buf,
sampleFrame * _out_buf ) = 0;
virtual void processMidiEvent( const midiEvent &,
const f_cnt_t /* _offset */ )
virtual void processMidiEvent( const MidiEvent&, const f_cnt_t /* _offset */ )
{
}
@@ -1120,7 +1119,7 @@ bool RemotePluginClient::processMessage( const message & _m )
case IdMidiEvent:
processMidiEvent(
midiEvent( static_cast<MidiEventTypes>(
MidiEvent( static_cast<MidiEventTypes>(
_m.getInt( 0 ) ),
_m.getInt( 1 ),
_m.getInt( 2 ),

View File

@@ -61,7 +61,7 @@ private:
typedef QList<QPair<sampleFrame *, f_cnt_t> > bufferList;
bufferList m_buffers;
f_cnt_t m_framesRecorded;
midiTime m_minLength;
MidiTime m_minLength;
track * m_track;
bbTrack * m_bbTrack;

View File

@@ -43,7 +43,7 @@ public:
SampleTCO( track * _track );
virtual ~SampleTCO();
virtual void changeLength( const midiTime & _length );
virtual void changeLength( const MidiTime & _length );
const QString & sampleFile() const;
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
@@ -58,7 +58,7 @@ public:
return m_sampleBuffer;
}
midiTime sampleLength() const;
MidiTime sampleLength() const;
virtual trackContentObjectView * createView( trackView * _tv );
@@ -121,10 +121,10 @@ public:
SampleTrack( TrackContainer* tc );
virtual ~SampleTrack();
virtual bool play( const midiTime & _start, const fpp_t _frames,
virtual bool play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 );
virtual trackView * createView( TrackContainerView* tcv );
virtual trackContentObject * createTCO( const midiTime & _pos );
virtual trackContentObject * createTCO( const MidiTime & _pos );
virtual void saveTrackSpecificSettings( QDomDocument & _doc,

View File

@@ -56,7 +56,7 @@ public:
return( m_scrollArea );
}
inline const midiTime & currentPosition() const
inline const MidiTime & currentPosition() const
{
return( m_currentPosition );
}
@@ -142,7 +142,7 @@ protected:
virtual void undoStep( JournalEntry & _je );
virtual void redoStep( JournalEntry & _je );
midiTime m_currentPosition;
MidiTime m_currentPosition;
private:
@@ -180,7 +180,7 @@ private:
signals:
void positionChanged( const midiTime & _pos );
void positionChanged( const MidiTime & _pos );
} ;

View File

@@ -109,10 +109,10 @@ public:
bbTrack( TrackContainer* tc );
virtual ~bbTrack();
virtual bool play( const midiTime & _start, const fpp_t _frames,
virtual bool play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 );
virtual trackView * createView( TrackContainerView* tcv );
virtual trackContentObject * createTCO( const midiTime & _pos );
virtual trackContentObject * createTCO( const MidiTime & _pos );
virtual void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent );

View File

@@ -38,7 +38,7 @@ public:
bbTrackContainer();
virtual ~bbTrackContainer();
virtual bool play( midiTime _start, const fpp_t _frames,
virtual bool play( MidiTime _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 );
virtual void updateAfterTrackAdd();

View File

@@ -30,7 +30,7 @@
#include "volume.h"
#include "panning.h"
#include "midi_time.h"
#include "MidiTime.h"
#include "SerializingObject.h"
class DetuningHelper;
@@ -81,8 +81,8 @@ const float MaxDetuning = 4 * 12.0f;
class EXPORT note : public SerializingObject
{
public:
note( const midiTime & _length = midiTime( 0 ),
const midiTime & _pos = midiTime( 0 ),
note( const MidiTime & _length = MidiTime( 0 ),
const MidiTime & _pos = MidiTime( 0 ),
int key = DefaultKey,
volume_t _volume = DefaultVolume,
panning_t _panning = DefaultPanning,
@@ -93,8 +93,8 @@ public:
// used by GUI
inline void setSelected( const bool _selected ){ m_selected = _selected; }
inline void setOldKey( const int _oldKey ){ m_oldKey = _oldKey; }
inline void setOldPos( const midiTime & _oldPos ){ m_oldPos = _oldPos; }
inline void setOldLength( const midiTime & _oldLength )
inline void setOldPos( const MidiTime & _oldPos ){ m_oldPos = _oldPos; }
inline void setOldLength( const MidiTime & _oldLength )
{
m_oldLength = _oldLength;
}
@@ -104,11 +104,11 @@ public:
}
void setLength( const midiTime & _length );
void setPos( const midiTime & _pos );
void setLength( const MidiTime & _length );
void setPos( const MidiTime & _pos );
void setKey( const int _key );
virtual void setVolume( const volume_t _volume = DefaultVolume );
void setPanning( const panning_t _panning = DefaultPanning );
virtual void setVolume( const volume_t volume = DefaultVolume );
virtual void setPanning( const panning_t panning = DefaultPanning );
void quantizeLength( const int _q_grid );
void quantizePos( const int _q_grid );
@@ -129,12 +129,12 @@ public:
return m_oldKey;
}
inline midiTime oldPos() const
inline MidiTime oldPos() const
{
return m_oldPos;
}
inline midiTime oldLength() const
inline MidiTime oldLength() const
{
return m_oldLength;
}
@@ -144,23 +144,23 @@ public:
return m_isPlaying;
}
inline midiTime endPos() const
inline MidiTime endPos() const
{
const int l = length();
return pos() + l;
}
inline const midiTime & length() const
inline const MidiTime & length() const
{
return m_length;
}
inline const midiTime & pos() const
inline const MidiTime & pos() const
{
return m_pos;
}
inline midiTime pos( midiTime _base_pos ) const
inline MidiTime pos( MidiTime _base_pos ) const
{
const int bp = _base_pos;
return m_pos - bp;
@@ -191,7 +191,7 @@ public:
return classNodeName();
}
static midiTime quantized( const midiTime & _m, const int _q_grid );
static MidiTime quantized( const MidiTime & _m, const int _q_grid );
DetuningHelper * detuning() const
{
@@ -226,15 +226,15 @@ private:
// for piano roll editing
bool m_selected;
int m_oldKey;
midiTime m_oldPos;
midiTime m_oldLength;
MidiTime m_oldPos;
MidiTime m_oldLength;
bool m_isPlaying;
int m_key;
volume_t m_volume;
panning_t m_panning;
midiTime m_length;
midiTime m_pos;
MidiTime m_length;
MidiTime m_pos;
DetuningHelper * m_detuning;
void createDetuning();

View File

@@ -2,7 +2,7 @@
* note_play_handle.h - declaration of class notePlayHandle which is needed
* by LMMS-Play-Engine
*
* Copyright (c) 2004-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -52,13 +52,19 @@ public:
const f_cnt_t _offset,
const f_cnt_t _frames, const note & _n,
notePlayHandle * _parent = NULL,
const bool _part_of_arp = false );
const bool _part_of_arp = false,
int midiChannel = -1 );
virtual ~notePlayHandle();
virtual void setVolume( const volume_t _volume = DefaultVolume );
virtual void setVolume( const volume_t volume = DefaultVolume );
virtual void setPanning( const panning_t panning = DefaultPanning );
int midiVelocity() const;
int midiKey() const;
int midiChannel() const
{
return m_midiChannel;
}
const float & frequency() const
{
@@ -189,15 +195,15 @@ public:
m_bbTrack = _bb_track;
}
void processMidiTime( const midiTime & _time );
void processMidiTime( const MidiTime & _time );
void resize( const bpm_t _new_tempo );
void setSongGlobalParentOffset( const midiTime &offset )
void setSongGlobalParentOffset( const MidiTime &offset )
{
m_songGlobalParentOffset = offset;
}
const midiTime &songGlobalParentOffset() const
const MidiTime &songGlobalParentOffset() const
{
return m_songGlobalParentOffset;
}
@@ -266,13 +272,15 @@ private:
bpm_t m_origTempo; // original tempo
f_cnt_t m_origFrames; // original m_frames
int m_origBaseNote;
const int m_origBaseNote;
float m_frequency;
float m_unpitchedFrequency;
BaseDetuning * m_baseDetuning;
midiTime m_songGlobalParentOffset;
MidiTime m_songGlobalParentOffset;
const int m_midiChannel;
} ;

View File

@@ -2,7 +2,7 @@
* panning.h - declaration of some types, concerning the
* panning of a note
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -30,7 +30,7 @@
#include "volume.h"
#include "templates.h"
#include "panning_constants.h"
#include "midi.h"
#include "Midi.h"
inline stereoVolumeVector panningToVolumeVector( panning_t _p,
float _scale = 1.0f )

View File

@@ -64,8 +64,8 @@ public:
void init();
virtual midiTime length() const;
midiTime beatPatternLength() const;
virtual MidiTime length() const;
MidiTime beatPatternLength() const;
// note management
note * addNote( const note & _new_note, const bool _quant_pos = true );

View File

@@ -135,8 +135,8 @@ protected slots:
void pasteNotes();
void deleteSelectedNotes();
void updatePosition( const midiTime & _t );
void updatePositionAccompany( const midiTime & _t );
void updatePosition( const MidiTime & _t );
void updatePositionAccompany( const MidiTime & _t );
void zoomingChanged();
void quantizeChanged();
@@ -203,9 +203,9 @@ private:
pianoRoll( const pianoRoll & );
virtual ~pianoRoll();
void autoScroll( const midiTime & _t );
void autoScroll( const MidiTime & _t );
midiTime newNoteLen() const;
MidiTime newNoteLen() const;
void shiftPos(int amount);
void shiftSemiTone(int amount);
@@ -276,7 +276,7 @@ private:
QScrollBar * m_leftRightScroll;
QScrollBar * m_topBottomScroll;
midiTime m_currentPosition;
MidiTime m_currentPosition;
bool m_recording;
QList<note> m_recordingNotes;
@@ -315,7 +315,7 @@ private:
// remember these values to use them
// for the next note that is set
midiTime m_lenOfNewNotes;
MidiTime m_lenOfNewNotes;
volume_t m_lastNoteVolume;
panning_t m_lastNotePanning;
@@ -345,7 +345,7 @@ private:
signals:
void positionChanged( const midiTime & );
void positionChanged( const MidiTime & );
} ;

View File

@@ -65,11 +65,11 @@ public:
} ;
class playPos : public midiTime
class playPos : public MidiTime
{
public:
playPos( const int _abs = 0 ) :
midiTime( _abs ),
MidiTime( _abs ),
m_timeLine( NULL ),
m_timeLineUpdate( true ),
m_currentFrame( 0.0f )

View File

@@ -84,7 +84,7 @@ private slots:
void masterPitchReleased();
void updateScrollBar( int );
void updatePosition( const midiTime & _t );
void updatePosition( const MidiTime & _t );
void zoomingChanged();

View File

@@ -61,7 +61,7 @@ public:
timeLine( int _xoff, int _yoff, float _ppt, song::playPos & _pos,
const midiTime & _begin, QWidget * _parent );
const MidiTime & _begin, QWidget * _parent );
virtual ~timeLine();
inline song::playPos & pos()
@@ -84,23 +84,23 @@ public:
return m_loopPoints == LoopPointsEnabled;
}
inline const midiTime & loopBegin() const
inline const MidiTime & loopBegin() const
{
return ( m_loopPos[0] < m_loopPos[1] ) ?
m_loopPos[0] : m_loopPos[1];
}
inline const midiTime & loopEnd() const
inline const MidiTime & loopEnd() const
{
return ( m_loopPos[0] > m_loopPos[1] ) ?
m_loopPos[0] : m_loopPos[1];
}
inline void savePos( const midiTime & _pos )
inline void savePos( const MidiTime & _pos )
{
m_savedPos = _pos;
}
inline const midiTime & savedPos() const
inline const MidiTime & savedPos() const
{
return m_savedPos;
}
@@ -121,18 +121,18 @@ public:
return "timeline";
}
inline int markerX( const midiTime & _t ) const
inline int markerX( const MidiTime & _t ) const
{
return m_xOffset + static_cast<int>( ( _t - m_begin ) *
m_ppt / midiTime::ticksPerTact() );
m_ppt / MidiTime::ticksPerTact() );
}
public slots:
void updatePosition( const midiTime & );
void updatePosition( const MidiTime & );
void updatePosition()
{
updatePosition( midiTime() );
updatePosition( MidiTime() );
}
void toggleAutoScroll( int _n );
void toggleLoopPoints( int _n );
@@ -162,10 +162,10 @@ private:
int m_posMarkerX;
float m_ppt;
song::playPos & m_pos;
const midiTime & m_begin;
midiTime m_loopPos[2];
const MidiTime & m_begin;
MidiTime m_loopPos[2];
midiTime m_savedPos;
MidiTime m_savedPos;
textFloat * m_hint;
@@ -183,7 +183,7 @@ private:
signals:
void positionChanged( const midiTime & _t );
void positionChanged( const MidiTime & _t );
void loopPointStateLoaded( int _n );
} ;

View File

@@ -31,7 +31,7 @@
#include <QtGui/QWidget>
#include "lmms_basics.h"
#include "midi_time.h"
#include "MidiTime.h"
#include "rubberband.h"
#include "JournallingObject.h"
#include "AutomatableModel.h"
@@ -101,24 +101,24 @@ public:
}
inline const midiTime & startPosition() const
inline const MidiTime & startPosition() const
{
return m_startPosition;
}
inline midiTime endPosition() const
inline MidiTime endPosition() const
{
const int sp = m_startPosition;
return sp + m_length;
}
inline const midiTime & length() const
inline const MidiTime & length() const
{
return m_length;
}
virtual void movePosition( const midiTime & _pos );
virtual void changeLength( const midiTime & _length );
virtual void movePosition( const MidiTime & _pos );
virtual void changeLength( const MidiTime & _length );
virtual trackContentObjectView * createView( trackView * _tv ) = 0;
@@ -151,8 +151,8 @@ private:
track * m_track;
QString m_name;
midiTime m_startPosition;
midiTime m_length;
MidiTime m_startPosition;
MidiTime m_length;
BoolModel m_mutedModel;
BoolModel m_soloModel;
@@ -230,7 +230,7 @@ private:
textFloat * m_hint;
midiTime m_oldTime;// used for undo/redo while mouse-button is pressed
MidiTime m_oldTime;// used for undo/redo while mouse-button is pressed
} ;
@@ -258,11 +258,11 @@ public:
}
}
midiTime endPosition( const midiTime & _pos_start );
MidiTime endPosition( const MidiTime & _pos_start );
public slots:
void update();
void changePosition( const midiTime & _new_pos = midiTime( -1 ) );
void changePosition( const MidiTime & _new_pos = MidiTime( -1 ) );
protected:
@@ -289,7 +289,7 @@ private:
} ;
track * getTrack();
midiTime getPosition( int _mouse_x );
MidiTime getPosition( int _mouse_x );
trackView * m_trackView;
@@ -382,12 +382,12 @@ public:
return m_type;
}
virtual bool play( const midiTime & _start, const fpp_t _frames,
virtual bool play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num = -1 ) = 0;
virtual trackView * createView( TrackContainerView * _view ) = 0;
virtual trackContentObject * createTCO( const midiTime & _pos ) = 0;
virtual trackContentObject * createTCO( const MidiTime & _pos ) = 0;
virtual void saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent ) = 0;
@@ -415,13 +415,13 @@ public:
{
return( m_trackContentObjects );
}
void getTCOsInRange( tcoVector & _tco_v, const midiTime & _start,
const midiTime & _end );
void getTCOsInRange( tcoVector & _tco_v, const MidiTime & _start,
const MidiTime & _end );
void swapPositionOfTCOs( int _tco_num1, int _tco_num2 );
void insertTact( const midiTime & _pos );
void removeTact( const midiTime & _pos );
void insertTact( const MidiTime & _pos );
void removeTact( const MidiTime & _pos );
tact_t length() const;

View File

@@ -2,7 +2,7 @@
* volume.h - declaration of some constants and types, concerning the volume
* of a note
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -29,7 +29,7 @@
#include "lmmsconfig.h"
#include "lmms_basics.h"
#include "midi.h"
#include "Midi.h"
const volume_t MinVolume = 0;
const volume_t MaxVolume = 200;

View File

@@ -1744,8 +1744,7 @@ p->putValue( jt->pos, value, false );
{
continue;
}
trackContentObject * tco =
bb_tracks[it->pattern]->createTCO( midiTime() );
trackContentObject * tco = bb_tracks[it->pattern]->createTCO( MidiTime() );
tco->movePosition( it->position );
if( it->length != DefaultTicksPerTact )
{

View File

@@ -38,6 +38,7 @@
#include "pattern.h"
#include "Instrument.h"
#include "MainWindow.h"
#include "MidiTime.h"
#include "debug.h"
#include "embed.h"
#include "song.h"
@@ -152,7 +153,7 @@ public:
AutomationTrack * at;
AutomationPattern * ap;
midiTime lastPos;
MidiTime lastPos;
smfMidiCC & create( TrackContainer* tc )
{
@@ -172,11 +173,11 @@ public:
}
smfMidiCC & putValue( midiTime time, AutomatableModel * objModel, float value )
smfMidiCC & putValue( MidiTime time, AutomatableModel * objModel, float value )
{
if( !ap || time > lastPos + DefaultTicksPerTact )
{
midiTime pPos = midiTime( time.getTact(), 0 );
MidiTime pPos = MidiTime( time.getTact(), 0 );
ap = dynamic_cast<AutomationPattern*>(
at->createTCO(0) );
ap->movePosition( pPos );
@@ -186,7 +187,7 @@ public:
lastPos = time;
time = time - ap->startPosition();
ap->putValue( time, value, false );
ap->changeLength( midiTime( time.getTact() + 1, 0 ) );
ap->changeLength( MidiTime( time.getTact() + 1, 0 ) );
return *this;
}
@@ -212,7 +213,7 @@ public:
Instrument * it_inst;
bool isSF2;
bool hasNotes;
midiTime lastEnd;
MidiTime lastEnd;
smfMidiChannel * create( TrackContainer* tc )
{
@@ -247,7 +248,7 @@ public:
{
if( !p || n.pos() > lastEnd + DefaultTicksPerTact )
{
midiTime pPos = midiTime(n.pos().getTact(), 0 );
MidiTime pPos = MidiTime( n.pos().getTact(), 0 );
p = dynamic_cast<pattern *>( it->createTCO( 0 ) );
p->movePosition( pPos );
}

View File

@@ -29,7 +29,7 @@
#include <QtCore/QPair>
#include <QtCore/QVector>
#include "midi.h"
#include "MidiEvent.h"
#include "ImportFilter.h"
@@ -117,8 +117,8 @@ private:
}
typedef QVector<QPair<int, midiEvent> > eventVector;
eventVector m_events;
typedef QVector<QPair<int, MidiEvent> > EventVector;
EventVector m_events;
int m_timingDivision;
} ;

View File

@@ -286,17 +286,16 @@ int opl2instrument::pushVoice(int v) {
return i;
}
bool opl2instrument::handleMidiEvent( const midiEvent & _me,
const midiTime & _time )
bool opl2instrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time )
{
emulatorMutex.lock();
int key, vel, voice, tmp_pb;
switch(_me.m_type) {
switch(event.type()) {
case MidiNoteOn:
// to get us in line with MIDI(?)
key = _me.key() +12;
vel = _me.velocity();
key = event.key() +12;
vel = event.velocity();
voice = popVoice();
if( voice != OPL2_NO_VOICE ) {
@@ -311,7 +310,7 @@ bool opl2instrument::handleMidiEvent( const midiEvent & _me,
}
break;
case MidiNoteOff:
key = _me.key() +12;
key = event.key() +12;
for(voice=0; voice<9; ++voice) {
if( voiceNote[voice] == key ) {
theEmulator->write(0xA0+voice, fnums[key] & 0xff);
@@ -323,8 +322,8 @@ bool opl2instrument::handleMidiEvent( const midiEvent & _me,
velocities[key] = 0;
break;
case MidiKeyPressure:
key = _me.key() +12;
vel = _me.velocity();
key = event.key() +12;
vel = event.velocity();
if( velocities[key] != 0) {
velocities[key] = vel;
}
@@ -337,12 +336,12 @@ bool opl2instrument::handleMidiEvent( const midiEvent & _me,
case MidiPitchBend:
// Update fnumber table
// Pitchbend should be in the range 0...16383 but the new range knob gets it wrong.
// tmp_pb = (2*BEND_CENTS)*((float)_me.m_data.m_param[0]/16383)-BEND_CENTS;
// tmp_pb = (2*BEND_CENTS)*((float)event.m_data.m_param[0]/16383)-BEND_CENTS;
// Something like 100 cents = 8192, but offset by 8192 so the +/-100 cents range goes from 0...16383?
tmp_pb = ( _me.m_data.m_param[0]-8192 ) * BEND_CENTS / 8192;
tmp_pb = ( event.pitchBend()-8192 ) * BEND_CENTS / 8192;
printf("Pitch bend: %d -> %d cents\n",_me.m_data.m_param[0],tmp_pb);
printf("Pitch bend: %d -> %d cents\n",event.pitchBend(),tmp_pb);
if( tmp_pb != pitchbend ) {
pitchbend = tmp_pb;
tuneEqual(69, 440.0);
@@ -356,7 +355,7 @@ bool opl2instrument::handleMidiEvent( const midiEvent & _me,
}
break;
default:
printf("Midi event type %d\n",_me.m_type);
printf("Midi event type %d\n",event.type());
}
emulatorMutex.unlock();
return true;

View File

@@ -50,8 +50,7 @@ public:
inline virtual bool isMidiBased() const { return true; }
virtual bool handleMidiEvent( const midiEvent & _me,
const midiTime & _time );
virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time );
virtual void play( sampleFrame * _working_buffer );
void saveSettings( QDomDocument & _doc, QDomElement & _this );

View File

@@ -310,13 +310,12 @@ void vestigeInstrument::play( sampleFrame * _buf )
bool vestigeInstrument::handleMidiEvent( const midiEvent & _me,
const midiTime & _time )
bool vestigeInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time )
{
m_pluginMutex.lock();
if( m_plugin != NULL )
{
m_plugin->processMidiEvent( _me, _time );
m_plugin->processMidiEvent( event, time );
}
m_pluginMutex.unlock();
@@ -779,8 +778,7 @@ void VestigeInstrumentView::noteOffAll( void )
{
for( int key = 0; key <= MidiMaxNote; ++key )
{
m_vi->m_plugin->processMidiEvent(
midiEvent( MidiNoteOff, 0, key, 0 ), 0 );
m_vi->m_plugin->processMidiEvent( MidiEvent( MidiNoteOff, 0, key, 0 ), 0 );
}
}
m_vi->m_pluginMutex.unlock();

View File

@@ -1,7 +1,7 @@
/*
* vestige.h - instrument VeSTige for hosting VST-plugins
*
* Copyright (c) 2005-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -34,7 +34,6 @@
#include "Instrument.h"
#include "InstrumentView.h"
#include "midi.h"
#include "note.h"
#include "knob.h"
@@ -69,8 +68,7 @@ public:
return true;
}
virtual bool handleMidiEvent( const midiEvent & _me,
const midiTime & _time );
virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time );
virtual PluginView * instantiateView( QWidget * _parent );

View File

@@ -1,7 +1,7 @@
/*
* LocalZynAddSubFx.cpp - local implementation of ZynAddSubFx plugin
*
* Copyright (c) 2009-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2009-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -190,47 +190,43 @@ void LocalZynAddSubFx::setLmmsWorkingDir( const std::string & _dir )
void LocalZynAddSubFx::processMidiEvent( const midiEvent & _e )
void LocalZynAddSubFx::processMidiEvent( const MidiEvent& event )
{
// all functions are called while m_master->mutex is held
static NULLMidiIn midiIn;
switch( _e.m_type )
switch( event.type() )
{
case MidiNoteOn:
if( _e.velocity() > 0 )
if( event.velocity() > 0 )
{
if( _e.key() <= 0 || _e.key() >= 128 )
if( event.key() <= 0 || event.key() >= 128 )
{
break;
}
if( m_runningNotes[_e.key()] > 0 )
if( m_runningNotes[event.key()] > 0 )
{
m_master->NoteOff( _e.channel(), _e.key() );
m_master->NoteOff( event.channel(), event.key() );
}
++m_runningNotes[_e.key()];
m_master->NoteOn( _e.channel(), _e.key(), _e.velocity() );
++m_runningNotes[event.key()];
m_master->NoteOn( event.channel(), event.key(), event.velocity() );
break;
}
case MidiNoteOff:
if( _e.key() <= 0 || _e.key() >= 128 )
if( event.key() <= 0 || event.key() >= 128 )
{
break;
}
if( --m_runningNotes[_e.key()] <= 0 )
if( --m_runningNotes[event.key()] <= 0 )
{
m_master->NoteOff( _e.channel(), _e.key() );
m_master->NoteOff( event.channel(), event.key() );
}
break;
case MidiPitchBend:
m_master->SetController( _e.channel(), C_pitchwheel,
_e.m_data.m_param[0] +
_e.m_data.m_param[1]*128-8192 );
m_master->SetController( event.channel(), C_pitchwheel, event.pitchBend()-8192 );
break;
case MidiControlChange:
m_master->SetController( _e.channel(),
midiIn.getcontroller( _e.m_data.m_param[0] ),
_e.m_data.m_param[1] );
m_master->SetController( event.channel(), midiIn.getcontroller( event.controllerNumber() ), event.controllerValue() );
break;
default:
break;

View File

@@ -1,7 +1,7 @@
/*
* LocalZynAddSubFx.h - local implementation of ZynAddSubFx plugin
*
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2009-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -25,6 +25,7 @@
#ifndef _LOCAL_ZYNADDSUBFX_H
#define _LOCAL_ZYNADDSUBFX_H
#include "MidiEvent.h"
#include "note.h"
class Master;
@@ -48,7 +49,7 @@ public:
void setPresetDir( const std::string & _dir );
void setLmmsWorkingDir( const std::string & _dir );
void processMidiEvent( const midiEvent & _e );
void processMidiEvent( const MidiEvent& event );
void processAudio( sampleFrame * _out );

View File

@@ -1,7 +1,7 @@
/*
* RemoteZynAddSubFx.cpp - ZynAddSubFx-embedding plugin
*
* Copyright (c) 2008-2012 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -126,10 +126,9 @@ public:
}
// all functions are called while m_master->mutex is held
virtual void processMidiEvent( const midiEvent & _e,
const f_cnt_t /* _offset */ )
virtual void processMidiEvent( const MidiEvent& event, const f_cnt_t /* _offset */ )
{
LocalZynAddSubFx::processMidiEvent( _e );
LocalZynAddSubFx::processMidiEvent( event );
}

View File

@@ -340,14 +340,13 @@ void ZynAddSubFxInstrument::play( sampleFrame * _buf )
bool ZynAddSubFxInstrument::handleMidiEvent( const midiEvent & _me,
const midiTime & _time )
bool ZynAddSubFxInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time )
{
// do not forward external MIDI Control Change events if the according
// LED is not checked
if( _me.type() == MidiControlChange &&
_me.sourcePort() != this &&
m_forwardMidiCcModel.value() == false )
if( event.type() == MidiControlChange &&
event.sourcePort() != this &&
m_forwardMidiCcModel.value() == false )
{
return true;
}
@@ -355,11 +354,11 @@ bool ZynAddSubFxInstrument::handleMidiEvent( const midiEvent & _me,
m_pluginMutex.lock();
if( m_remotePlugin )
{
m_remotePlugin->processMidiEvent( _me, 0 );
m_remotePlugin->processMidiEvent( event, 0 );
}
else
{
m_plugin->processMidiEvent( _me );
m_plugin->processMidiEvent( event );
}
m_pluginMutex.unlock();
@@ -446,8 +445,7 @@ void ZynAddSubFxInstrument::initPlugin()
void ZynAddSubFxInstrument::sendControlChange( MidiControllers midiCtl, float value )
{
handleMidiEvent( midiEvent( MidiControlChange, instrumentTrack()->midiPort()->realOutputChannel(), midiCtl, (int) value, this ),
midiTime() );
handleMidiEvent( MidiEvent( MidiControlChange, instrumentTrack()->midiPort()->realOutputChannel(), midiCtl, (int) value, this ) );
}

View File

@@ -70,8 +70,7 @@ public:
virtual void play( sampleFrame * _working_buffer );
virtual bool handleMidiEvent( const midiEvent & _me,
const midiTime & _time );
virtual bool handleMidiEvent( const MidiEvent& event, const MidiTime& time = MidiTime() );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );

View File

@@ -45,7 +45,7 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) :
m_tension( "1.0" ),
m_progressionType( DiscreteProgression )
{
changeLength( midiTime( 1, 0 ) );
changeLength( MidiTime( 1, 0 ) );
}
@@ -166,7 +166,7 @@ const AutomatableModel * AutomationPattern::firstObject() const
//TODO: Improve this
midiTime AutomationPattern::length() const
MidiTime AutomationPattern::length() const
{
tick_t max_length = 0;
@@ -175,19 +175,19 @@ midiTime AutomationPattern::length() const
{
max_length = qMax<tick_t>( max_length, it.key() );
}
return midiTime( qMax( midiTime( max_length ).getTact() + 1, 1 ), 0 );
return MidiTime( qMax( MidiTime( max_length ).getTact() + 1, 1 ), 0 );
}
midiTime AutomationPattern::putValue( const midiTime & _time,
MidiTime AutomationPattern::putValue( const MidiTime & _time,
const float _value,
const bool _quant_pos )
{
cleanObjects();
midiTime newTime = _quant_pos && engine::automationEditor() ?
MidiTime newTime = _quant_pos && engine::automationEditor() ?
note::quantized( _time,
engine::automationEditor()->quantization() ) :
_time;
@@ -215,7 +215,7 @@ midiTime AutomationPattern::putValue( const midiTime & _time,
void AutomationPattern::removeValue( const midiTime & _time )
void AutomationPattern::removeValue( const MidiTime & _time )
{
cleanObjects();
@@ -240,7 +240,7 @@ void AutomationPattern::removeValue( const midiTime & _time )
float AutomationPattern::valueAt( const midiTime & _time ) const
float AutomationPattern::valueAt( const MidiTime & _time ) const
{
if( m_timeMap.isEmpty() )
{
@@ -306,7 +306,7 @@ float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const
float *AutomationPattern::valuesAfter( const midiTime & _time ) const
float *AutomationPattern::valuesAfter( const MidiTime & _time ) const
{
timeMap::ConstIterator v = m_timeMap.lowerBound( _time );
if( v == m_timeMap.end() || (v+1) == m_timeMap.end() )
@@ -417,7 +417,7 @@ const QString AutomationPattern::name() const
void AutomationPattern::processMidiTime( const midiTime & _time )
void AutomationPattern::processMidiTime( const MidiTime & _time )
{
if( _time >= 0 && hasAutomation() )
{

View File

@@ -477,7 +477,7 @@ void InstrumentFunctionArpeggio::processNote( notePlayHandle * _n )
}
// create new arp-note
note new_note( midiTime( 0 ), midiTime( 0 ),
note new_note( MidiTime( 0 ), MidiTime( 0 ),
sub_note_key,
(volume_t)
qRound( _n->getVolume() * vol_level ),

View File

@@ -38,6 +38,7 @@
#include "Piano.h"
#include "InstrumentTrack.h"
#include "MidiEvent.h"
#include "MidiEventProcessor.h"
@@ -96,7 +97,7 @@ void Piano::handleKeyPress( int key, int midiVelocity )
{
if( isValidKey( key ) )
{
m_midiEvProc->processInEvent( midiEvent( MidiNoteOn, 0, key, midiVelocity ), midiTime() );
m_midiEvProc->processInEvent( MidiEvent( MidiNoteOn, 0, key, midiVelocity ) );
m_pressedKeys[key] = true;
}
}
@@ -113,7 +114,7 @@ void Piano::handleKeyRelease( int key )
{
if( isValidKey( key ) )
{
m_midiEvProc->processInEvent( midiEvent( MidiNoteOff, 0, key, 0 ), midiTime() );
m_midiEvProc->processInEvent( MidiEvent( MidiNoteOff, 0, key, 0 ) );
m_pressedKeys[key] = false;
}
}

View File

@@ -1,7 +1,7 @@
/*
* RemotePlugin.cpp - base class providing RPC like mechanisms
*
* Copyright (c) 2008-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -281,14 +281,14 @@ bool RemotePlugin::process( const sampleFrame * _in_buf,
void RemotePlugin::processMidiEvent( const midiEvent & _e,
void RemotePlugin::processMidiEvent( const MidiEvent & _e,
const f_cnt_t _offset )
{
message m( IdMidiEvent );
m.addInt( _e.m_type );
m.addInt( _e.m_channel );
m.addInt( _e.m_data.m_param[0] );
m.addInt( _e.m_data.m_param[1] );
m.addInt( _e.type() );
m.addInt( _e.channel() );
m.addInt( _e.param( 0 ) );
m.addInt( _e.param( 1 ) );
m.addInt( _offset );
lock();
sendMessage( m );

View File

@@ -73,7 +73,7 @@ void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ )
writeBuffer( recbuf, frames );
m_framesRecorded += frames;
midiTime len = (tick_t)( m_framesRecorded / engine::framesPerTick() );
MidiTime len = (tick_t)( m_framesRecorded / engine::framesPerTick() );
if( len > m_minLength )
{
// m_tco->changeLength( len );

View File

@@ -54,7 +54,7 @@ bbTrackContainer::~bbTrackContainer()
bool bbTrackContainer::play( midiTime _start, fpp_t _frames,
bool bbTrackContainer::play( MidiTime _start, fpp_t _frames,
f_cnt_t _offset, int _tco_num )
{
bool played_a_note = false;
@@ -63,7 +63,7 @@ bool bbTrackContainer::play( midiTime _start, fpp_t _frames,
return false;
}
_start = _start % ( lengthOfBB( _tco_num ) * midiTime::ticksPerTact() );
_start = _start % ( lengthOfBB( _tco_num ) * MidiTime::ticksPerTact() );
TrackList tl = tracks();
for( TrackList::iterator it = tl.begin(); it != tl.end(); ++it )
@@ -99,7 +99,7 @@ void bbTrackContainer::updateAfterTrackAdd()
tact_t bbTrackContainer::lengthOfBB( int _bb )
{
midiTime max_length = midiTime::ticksPerTact();
MidiTime max_length = MidiTime::ticksPerTact();
const TrackList & tl = tracks();
for( TrackList::const_iterator it = tl.begin(); it != tl.end(); ++it )
@@ -172,7 +172,7 @@ void bbTrackContainer::fixIncorrectPositions()
{
for( int i = 0; i < numOfBBs(); ++i )
{
( *it )->getTCO( i )->movePosition( midiTime( i, 0 ) );
( *it )->getTCO( i )->movePosition( MidiTime( i, 0 ) );
}
}
}
@@ -252,10 +252,10 @@ void bbTrackContainer::createTCOsForBB( int _bb )
{
while( tl[i]->numOfTCOs() < _bb + 1 )
{
midiTime position = midiTime( tl[i]->numOfTCOs(), 0 );
MidiTime position = MidiTime( tl[i]->numOfTCOs(), 0 );
trackContentObject * tco = tl[i]->createTCO( position );
tco->movePosition( position );
tco->changeLength( midiTime( 1, 0 ) );
tco->changeLength( MidiTime( 1, 0 ) );
}
}
}

View File

@@ -31,6 +31,7 @@
#include "gui_templates.h"
#include "song.h"
#include "MidiPort.h"
#include "MidiTime.h"
#include "note.h"
@@ -160,73 +161,70 @@ QString MidiAlsaSeq::probeDevice()
void MidiAlsaSeq::processOutEvent( const midiEvent & _me,
const midiTime & _time,
const MidiPort * _port )
void MidiAlsaSeq::processOutEvent( const MidiEvent& event, const MidiTime& time, const MidiPort* port )
{
// HACK!!! - need a better solution which isn't that easy since we
// cannot store const-ptrs in our map because we need to call non-const
// methods of MIDI-port - it's a mess...
MidiPort * p = const_cast<MidiPort *>( _port );
MidiPort* p = const_cast<MidiPort *>( port );
snd_seq_event_t ev;
snd_seq_ev_clear( &ev );
snd_seq_ev_set_source( &ev, ( m_portIDs[p][1] != -1 ) ?
m_portIDs[p][1] : m_portIDs[p][0] );
snd_seq_ev_set_subs( &ev );
snd_seq_ev_schedule_tick( &ev, m_queueID, 1, static_cast<int>( _time ) );
snd_seq_ev_schedule_tick( &ev, m_queueID, 1, static_cast<int>( time ) );
ev.queue = m_queueID;
switch( _me.m_type )
switch( event.type() )
{
case MidiNoteOn:
snd_seq_ev_set_noteon( &ev,
_me.channel(),
_me.key() + KeysPerOctave,
_me.velocity() );
event.channel(),
event.key() + KeysPerOctave,
event.velocity() );
break;
case MidiNoteOff:
snd_seq_ev_set_noteoff( &ev,
_me.channel(),
_me.key() + KeysPerOctave,
_me.velocity() );
event.channel(),
event.key() + KeysPerOctave,
event.velocity() );
break;
case MidiKeyPressure:
snd_seq_ev_set_keypress( &ev,
_me.channel(),
_me.key() + KeysPerOctave,
_me.velocity() );
event.channel(),
event.key() + KeysPerOctave,
event.velocity() );
break;
case MidiControlChange:
snd_seq_ev_set_controller( &ev,
_me.channel(),
_me.m_data.m_param[0],
_me.m_data.m_param[1] );
event.channel(),
event.controllerNumber(),
event.controllerValue() );
break;
case MidiProgramChange:
snd_seq_ev_set_pgmchange( &ev,
_me.channel(),
_me.m_data.m_param[0] );
event.channel(),
event.program() );
break;
case MidiChannelPressure:
snd_seq_ev_set_chanpress( &ev,
_me.channel(),
_me.m_data.m_param[0] );
event.channel(),
event.channelPressure() );
break;
case MidiPitchBend:
snd_seq_ev_set_pitchbend( &ev,
_me.channel(),
_me.m_data.m_param[0] - 8192 );
event.channel(),
event.param( 0 ) - 8192 );
break;
default:
fprintf( stderr, "ALSA-sequencer: unhandled output "
"event %d\n", (int) _me.m_type );
qWarning( "MidiAlsaSeq: unhandled output event %d\n", (int) event.type() );
return;
}
@@ -353,7 +351,7 @@ void MidiAlsaSeq::removePort( MidiPort * _port )
QString MidiAlsaSeq::sourcePortName( const midiEvent & _event ) const
QString MidiAlsaSeq::sourcePortName( const MidiEvent & _event ) const
{
if( _event.sourcePort() )
{
@@ -535,70 +533,70 @@ void MidiAlsaSeq::run()
switch( ev->type )
{
case SND_SEQ_EVENT_NOTEON:
dest->processInEvent( midiEvent( MidiNoteOn,
dest->processInEvent( MidiEvent( MidiNoteOn,
ev->data.note.channel,
ev->data.note.note -
KeysPerOctave,
ev->data.note.velocity,
source
),
midiTime( ev->time.tick ) );
MidiTime( ev->time.tick ) );
break;
case SND_SEQ_EVENT_NOTEOFF:
dest->processInEvent( midiEvent( MidiNoteOff,
dest->processInEvent( MidiEvent( MidiNoteOff,
ev->data.note.channel,
ev->data.note.note -
KeysPerOctave,
ev->data.note.velocity,
source
),
midiTime( ev->time.tick) );
MidiTime( ev->time.tick) );
break;
case SND_SEQ_EVENT_KEYPRESS:
dest->processInEvent( midiEvent(
dest->processInEvent( MidiEvent(
MidiKeyPressure,
ev->data.note.channel,
ev->data.note.note -
KeysPerOctave,
ev->data.note.velocity,
source
), midiTime() );
), MidiTime() );
break;
case SND_SEQ_EVENT_CONTROLLER:
dest->processInEvent( midiEvent(
dest->processInEvent( MidiEvent(
MidiControlChange,
ev->data.control.channel,
ev->data.control.param,
ev->data.control.value, source ),
midiTime() );
MidiTime() );
break;
case SND_SEQ_EVENT_PGMCHANGE:
dest->processInEvent( midiEvent(
dest->processInEvent( MidiEvent(
MidiProgramChange,
ev->data.control.channel,
ev->data.control.param,
ev->data.control.value, source ),
midiTime() );
MidiTime() );
break;
case SND_SEQ_EVENT_CHANPRESS:
dest->processInEvent( midiEvent(
dest->processInEvent( MidiEvent(
MidiChannelPressure,
ev->data.control.channel,
ev->data.control.param,
ev->data.control.value, source ),
midiTime() );
MidiTime() );
break;
case SND_SEQ_EVENT_PITCHBEND:
dest->processInEvent( midiEvent( MidiPitchBend,
dest->processInEvent( MidiEvent( MidiPitchBend,
ev->data.control.channel,
ev->data.control.value + 8192, 0, source ),
midiTime() );
MidiTime() );
break;
case SND_SEQ_EVENT_SENSING:

View File

@@ -25,7 +25,6 @@
#include "MidiClient.h"
#include "MidiPort.h"
#include "templates.h"
#include "note.h"
@@ -44,32 +43,32 @@ MidiClient::~MidiClient()
void MidiClient::applyPortMode( MidiPort * )
void MidiClient::applyPortMode( MidiPort* )
{
}
void MidiClient::applyPortName( MidiPort * )
void MidiClient::applyPortName( MidiPort* )
{
}
void MidiClient::addPort( MidiPort * _port )
void MidiClient::addPort( MidiPort* port )
{
m_midiPorts.push_back( _port );
m_midiPorts.push_back( port );
}
void MidiClient::removePort( MidiPort * _port )
void MidiClient::removePort( MidiPort* port )
{
QVector<MidiPort *>::Iterator it =
qFind( m_midiPorts.begin(), m_midiPorts.end(), _port );
qFind( m_midiPorts.begin(), m_midiPorts.end(), port );
if( it != m_midiPorts.end() )
{
m_midiPorts.erase( it );
@@ -79,14 +78,14 @@ void MidiClient::removePort( MidiPort * _port )
void MidiClient::subscribeReadablePort( MidiPort *, const QString & , bool )
void MidiClient::subscribeReadablePort( MidiPort*, const QString& , bool )
{
}
void MidiClient::subscribeWritablePort( MidiPort * , const QString & , bool )
void MidiClient::subscribeWritablePort( MidiPort* , const QString& , bool )
{
}
@@ -124,7 +123,7 @@ void MidiClientRaw::parseData( const unsigned char c )
{
if( c == MidiSystemReset )
{
m_midiParseData.m_midiEvent.m_type = MidiSystemReset;
m_midiParseData.m_midiEvent.setType( MidiSystemReset );
m_midiParseData.m_status = 0;
processParsedEvent();
}
@@ -206,34 +205,30 @@ void MidiClientRaw::parseData( const unsigned char c )
* We simply keep the status as it is, just reset the parameter counter.
* If another status byte comes in, it will overwrite the status.
*/
m_midiParseData.m_midiEvent.m_type = static_cast<MidiEventTypes>( m_midiParseData.m_status );
m_midiParseData.m_midiEvent.m_channel = m_midiParseData.m_channel;
m_midiParseData.m_midiEvent.setType( static_cast<MidiEventTypes>( m_midiParseData.m_status ) );
m_midiParseData.m_midiEvent.setChannel( m_midiParseData.m_channel );
m_midiParseData.m_bytes = 0; /* Related to running status! */
switch( m_midiParseData.m_midiEvent.m_type )
switch( m_midiParseData.m_midiEvent.type() )
{
case MidiNoteOff:
case MidiNoteOn:
case MidiKeyPressure:
case MidiProgramChange:
case MidiChannelPressure:
m_midiParseData.m_midiEvent.m_data.m_param[0] =
m_midiParseData.m_buffer[0] - KeysPerOctave;
m_midiParseData.m_midiEvent.m_data.m_param[1] =
m_midiParseData.m_buffer[1];
m_midiParseData.m_midiEvent.setKey( m_midiParseData.m_buffer[0] - KeysPerOctave );
m_midiParseData.m_midiEvent.setVelocity( m_midiParseData.m_buffer[1] );
break;
case MidiControlChange:
m_midiParseData.m_midiEvent.m_data.m_param[0] = m_midiParseData.m_buffer[0];
m_midiParseData.m_midiEvent.m_data.m_param[1] = m_midiParseData.m_buffer[1];
m_midiParseData.m_midiEvent.setControllerNumber( m_midiParseData.m_buffer[0] );
m_midiParseData.m_midiEvent.setControllerValue( m_midiParseData.m_buffer[1] );
break;
case MidiPitchBend:
// Pitch-bend is transmitted with 14-bit precision.
// Note: '|' does here the same as '+' (no common bits),
// but might be faster
m_midiParseData.m_midiEvent.m_data.m_param[0] =
( ( m_midiParseData.m_buffer[1] * 128 ) |
m_midiParseData.m_buffer[0] );
m_midiParseData.m_midiEvent.setPitchBend( ( m_midiParseData.m_buffer[1] * 128 ) | m_midiParseData.m_buffer[0] );
break;
default:
@@ -251,33 +246,29 @@ void MidiClientRaw::processParsedEvent()
{
for( int i = 0; i < m_midiPorts.size(); ++i )
{
m_midiPorts[i]->processInEvent( m_midiParseData.m_midiEvent,
midiTime() );
m_midiPorts[i]->processInEvent( m_midiParseData.m_midiEvent );
}
}
void MidiClientRaw::processOutEvent( const midiEvent & _me,
const midiTime & ,
const MidiPort * _port )
void MidiClientRaw::processOutEvent( const MidiEvent& event, const MidiTime & , const MidiPort* port )
{
// TODO: also evaluate _time and queue event if necessary
switch( _me.m_type )
switch( event.type() )
{
case MidiNoteOn:
case MidiNoteOff:
case MidiKeyPressure:
sendByte( _me.m_type | _me.channel() );
sendByte( _me.m_data.m_param[0] + KeysPerOctave );
sendByte( tLimit( (int) _me.m_data.m_param[1],
0, 127 ) );
sendByte( event.type() | event.channel() );
sendByte( event.key() + KeysPerOctave );
sendByte( event.velocity() );
break;
default:
qWarning( "MidiClientRaw: unhandled MIDI-event %d\n",
(int) _me.m_type );
(int) event.type() );
break;
}
}

View File

@@ -73,20 +73,19 @@ void MidiController::updateName()
void MidiController::processInEvent( const midiEvent & _me,
const midiTime & _time )
void MidiController::processInEvent( const MidiEvent& event, const MidiTime& time )
{
unsigned char controllerNum;
switch( _me.m_type )
switch( event.type() )
{
case MidiControlChange:
controllerNum = _me.m_data.m_bytes[0] & 0x7F;
controllerNum = event.controllerNumber();
if( m_midiPort.inputController() == controllerNum + 1 &&
( m_midiPort.inputChannel() == _me.m_channel + 1 ||
( m_midiPort.inputChannel() == event.channel() + 1 ||
m_midiPort.inputChannel() == 0 ) )
{
unsigned char val = _me.m_data.m_bytes[2] & 0x7F;
unsigned char val = event.controllerValue();
m_lastValue = (float)( val ) / 127.0f;
emit valueChanged();
}

View File

@@ -2,7 +2,7 @@
* MidiPort.cpp - abstraction of MIDI-ports which are part of LMMS's MIDI-
* sequencing system
*
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -123,64 +123,58 @@ void MidiPort::setMode( Modes _mode )
void MidiPort::processInEvent( const midiEvent & _me, const midiTime & _time )
void MidiPort::processInEvent( const MidiEvent& event, const MidiTime& time )
{
// mask event
if( inputEnabled() &&
( inputChannel()-1 == _me.m_channel || inputChannel() == 0 ) )
( inputChannel() == 0 || inputChannel()-1 == event.channel() ) )
{
midiEvent ev = _me;
if( _me.m_type == MidiNoteOn ||
_me.m_type == MidiNoteOff ||
_me.m_type == MidiKeyPressure )
MidiEvent inEvent = event;
if( event.type() == MidiNoteOn ||
event.type() == MidiNoteOff ||
event.type() == MidiKeyPressure )
{
ev.key() = ev.key() + KeysPerOctave;
if( ev.key() < 0 || ev.key() >= NumKeys )
inEvent.setKey( inEvent.key() + KeysPerOctave );
if( inEvent.key() < 0 || inEvent.key() >= NumKeys )
{
return;
}
}
if( fixedInputVelocity() >= 0 && _me.velocity() > 0 )
if( fixedInputVelocity() >= 0 && inEvent.velocity() > 0 )
{
ev.velocity() = fixedInputVelocity();
inEvent.setVelocity( fixedInputVelocity() );
}
ev.setFromMidiPort( true );
m_midiEventProcessor->processInEvent( ev, _time );
m_midiEventProcessor->processInEvent( inEvent, time );
}
}
void MidiPort::processOutEvent( const midiEvent & _me, const midiTime & _time )
void MidiPort::processOutEvent( const MidiEvent& event, const MidiTime& time )
{
// mask event
if( outputEnabled() && realOutputChannel() == _me.m_channel )
if( outputEnabled() && realOutputChannel() == event.channel() )
{
midiEvent ev = _me;
// we use/display MIDI channels 1...16 but we need 0...15 for
// the outside world
// We are already in "real" MIDI channel space here
/* if( ev.m_channel > 0 )
{
--ev.m_channel;
} */
if( ( _me.m_type == MidiNoteOn || _me.m_type == MidiNoteOff ) &&
MidiEvent outEvent = event;
if( ( event.type() == MidiNoteOn || event.type() == MidiNoteOff ) &&
fixedOutputNote() >= 0 )
{
// Convert MIDI note number (from spinbox) -> LMMS note number
// that will be converted back when outputted.
ev.key() = fixedOutputNote() - KeysPerOctave;
outEvent.setKey( fixedOutputNote() - KeysPerOctave );
}
if( fixedOutputVelocity() >= 0 && _me.velocity() > 0 &&
( _me.m_type == MidiNoteOn ||
_me.m_type == MidiKeyPressure ) )
if( fixedOutputVelocity() >= 0 && event.velocity() > 0 &&
( event.type() == MidiNoteOn || event.type() == MidiKeyPressure ) )
{
ev.velocity() = fixedOutputVelocity();
outEvent.setVelocity( fixedOutputVelocity() );
}
m_midiClient->processOutEvent( ev, _time, this );
m_midiClient->processOutEvent( outEvent, time, this );
}
}
@@ -420,9 +414,9 @@ void MidiPort::updateWritablePorts( void )
void MidiPort::updateOutputProgram( void )
{
processOutEvent( midiEvent( MidiProgramChange,
processOutEvent( MidiEvent( MidiProgramChange,
realOutputChannel(),
outputProgram()-1 ), midiTime( 0 ) );
outputProgram()-1 ), MidiTime( 0 ) );
}

View File

@@ -57,8 +57,8 @@ MidiWinMM::~MidiWinMM()
void MidiWinMM::processOutEvent( const midiEvent & _me,
const midiTime & _time,
void MidiWinMM::processOutEvent( const MidiEvent & _me,
const MidiTime & _time,
const MidiPort * _port )
{
const DWORD shortMsg = ( _me.m_type + _me.channel() ) +
@@ -137,7 +137,7 @@ void MidiWinMM::removePort( MidiPort * _port )
QString MidiWinMM::sourcePortName( const midiEvent & _event ) const
QString MidiWinMM::sourcePortName( const MidiEvent & _event ) const
{
if( _event.sourcePort() )
{
@@ -232,22 +232,22 @@ void MidiWinMM::handleInputEvent( HMIDIIN _hm, DWORD _ev )
case MidiNoteOff:
case MidiKeyPressure:
( *it )->processInEvent(
midiEvent( cmdtype, chan, par1 - KeysPerOctave,
par2 & 0xff, &_hm ), midiTime() );
MidiEvent( cmdtype, chan, par1 - KeysPerOctave,
par2 & 0xff, &_hm ), MidiTime() );
break;
case MidiControlChange:
case MidiProgramChange:
case MidiChannelPressure:
( *it )->processInEvent(
midiEvent( cmdtype, chan, par1, par2 & 0xff, &_hm ),
midiTime() );
MidiEvent( cmdtype, chan, par1, par2 & 0xff, &_hm ),
MidiTime() );
break;
case MidiPitchBend:
( *it )->processInEvent(
midiEvent( cmdtype, chan, par1 + par2*128, 0, &_hm ),
midiTime() );
MidiEvent( cmdtype, chan, par1 + par2*128, 0, &_hm ),
MidiTime() );
break;
default:

View File

@@ -35,7 +35,7 @@
note::note( const midiTime & _length, const midiTime & _pos,
note::note( const MidiTime & _length, const MidiTime & _pos,
int _key, volume_t _volume, panning_t _panning,
DetuningHelper * _detuning ) :
m_selected( false ),
@@ -96,7 +96,7 @@ note::~note()
void note::setLength( const midiTime & _length )
void note::setLength( const MidiTime & _length )
{
// addJournalEntry( journalEntry( ChangeLength, m_length - _length ) );
m_length = _length;
@@ -105,7 +105,7 @@ void note::setLength( const midiTime & _length )
void note::setPos( const midiTime & _pos )
void note::setPos( const MidiTime & _pos )
{
// addJournalEntry( journalEntry( ChangePosition, m_pos - _pos ) );
m_pos = _pos;
@@ -144,7 +144,7 @@ void note::setPanning( const panning_t _panning )
midiTime note::quantized( const midiTime & _m, const int _q_grid )
MidiTime note::quantized( const MidiTime & _m, const int _q_grid )
{
float p = ( (float) _m / _q_grid );
if( p - floorf( p ) < 0.5f )

View File

@@ -29,6 +29,7 @@
#include "DetuningHelper.h"
#include "InstrumentSoundShaping.h"
#include "InstrumentTrack.h"
#include "MidiEvent.h"
#include "MidiPort.h"
#include "song.h"
@@ -48,7 +49,8 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
const f_cnt_t _frames,
const note & _n,
notePlayHandle *parent,
const bool _part_of_arp ) :
const bool _part_of_arp,
int MidiEventChannel ) :
playHandle( NotePlayHandle, _offset ),
note( _n.length(), _n.pos(), _n.key(),
_n.getVolume(), _n.getPanning(), _n.detuning() ),
@@ -73,7 +75,8 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
m_frequency( 0 ),
m_unpitchedFrequency( 0 ),
m_baseDetuning( NULL ),
m_songGlobalParentOffset( 0 )
m_songGlobalParentOffset( 0 ),
m_midiChannel( MidiEventChannel >= 0 ? MidiEventChannel : instrumentTrack()->midiPort()->realOutputChannel() )
{
if( isTopNote() )
{
@@ -103,12 +106,10 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
if( !isTopNote() || !instrumentTrack()->isArpeggioEnabled() )
{
// send MIDI-note-on-event
m_instrumentTrack->processOutEvent( midiEvent( MidiNoteOn,
m_instrumentTrack->midiPort()->realOutputChannel(),
midiKey(), midiVelocity() ),
midiTime::fromFrames( offset(),
engine::framesPerTick() ) );
// send MidiNoteOn event
m_instrumentTrack->processOutEvent(
MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity() ),
MidiTime::fromFrames( offset(), engine::framesPerTick() ) );
}
}
@@ -151,10 +152,21 @@ notePlayHandle::~notePlayHandle()
void notePlayHandle::setVolume( const volume_t _volume )
{
note::setVolume( _volume );
m_instrumentTrack->processOutEvent( midiEvent( MidiKeyPressure,
m_instrumentTrack->midiPort()->realOutputChannel(),
midiKey(), midiVelocity() ), 0 );
m_instrumentTrack->processOutEvent( MidiEvent( MidiKeyPressure, midiChannel(), midiKey(), midiVelocity() ) );
}
void notePlayHandle::setPanning( const panning_t panning )
{
note::setPanning( panning );
MidiEvent event( MidiMetaEvent, midiChannel(), midiKey(), panningToMidi( panning ) );
event.setMetaEvent( MidiNotePanning );
m_instrumentTrack->processOutEvent( event );
}
@@ -341,12 +353,10 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
if( !isTopNote() || !instrumentTrack()->isArpeggioEnabled() )
{
// send MIDI-note-off-event
m_instrumentTrack->processOutEvent( midiEvent( MidiNoteOff,
m_instrumentTrack->midiPort()->realOutputChannel(),
midiKey(), 0 ),
midiTime::fromFrames( m_framesBeforeRelease,
engine::framesPerTick() ) );
// send MidiNoteOff event
m_instrumentTrack->processOutEvent(
MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ),
MidiTime::fromFrames( m_framesBeforeRelease, engine::framesPerTick() ) );
}
m_released = true;
@@ -501,7 +511,7 @@ void notePlayHandle::updateFrequency()
void notePlayHandle::processMidiTime( const midiTime& time )
void notePlayHandle::processMidiTime( const MidiTime& time )
{
if( detuning() && time >= songGlobalParentOffset()+pos() )
{

View File

@@ -76,7 +76,7 @@
#include <sys/shm.h>
#endif
tick_t midiTime::s_ticksPerTact = DefaultTicksPerTact;
tick_t MidiTime::s_ticksPerTact = DefaultTicksPerTact;
@@ -256,7 +256,7 @@ void song::setTempo()
void song::setTimeSignature()
{
midiTime::setTicksPerTact( ticksPerTact() );
MidiTime::setTicksPerTact( ticksPerTact() );
emit timeSignatureChanged( m_oldTicksPerTact, ticksPerTact() );
emit dataChanged();
m_oldTicksPerTact = ticksPerTact();
@@ -494,7 +494,7 @@ void song::processNextBuffer()
#endif
// did we play a whole tact?
if( ticks >= midiTime::ticksPerTact() )
if( ticks >= MidiTime::ticksPerTact() )
{
// per default we just continue playing even if
// there's no more stuff to play
@@ -525,7 +525,7 @@ void song::processNextBuffer()
// then start from beginning and keep
// offset
ticks = ticks % ( max_tact *
midiTime::ticksPerTact() );
MidiTime::ticksPerTact() );
#ifdef VST_SNC_LATENCY
m_SncVSTplug->ppqPos = ( ( ticks + 0 )
/ (float)48 )

View File

@@ -47,7 +47,7 @@ QPixmap * timeLine::s_loopPointPixmap = NULL;
timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
song::playPos & _pos, const midiTime & _begin,
song::playPos & _pos, const MidiTime & _begin,
QWidget * _parent ) :
QWidget( _parent ),
m_autoScroll( AutoScrollEnabled ),
@@ -175,7 +175,7 @@ void timeLine::loadSettings( const QDomElement & _this )
void timeLine::updatePosition( const midiTime & )
void timeLine::updatePosition( const MidiTime & )
{
const int new_x = markerX( m_pos );
@@ -238,7 +238,7 @@ void timeLine::paintEvent( QPaintEvent * )
tact_t tact_num = m_begin.getTact();
int x = m_xOffset + s_posMarkerPixmap->width() / 2 -
( ( static_cast<int>( m_begin * m_ppt ) / midiTime::ticksPerTact() ) % static_cast<int>( m_ppt ) );
( ( static_cast<int>( m_begin * m_ppt ) / MidiTime::ticksPerTact() ) % static_cast<int>( m_ppt ) );
p.setPen( QColor( 192, 192, 192 ) );
for( int i = 0; x + i * m_ppt < width(); ++i )
@@ -248,7 +248,7 @@ void timeLine::paintEvent( QPaintEvent * )
++tact_num;
if( ( tact_num - 1 ) %
qMax( 1, qRound( 1.0f / 3.0f *
midiTime::ticksPerTact() / m_ppt ) ) == 0 )
MidiTime::ticksPerTact() / m_ppt ) ) == 0 )
{
const QString s = QString::number( tact_num );
p.drawText( cx + qRound( ( m_ppt - p.fontMetrics().
@@ -285,7 +285,7 @@ void timeLine::mousePressEvent( QMouseEvent* event )
}
else if( event->button() == Qt::RightButton )
{
const midiTime t = m_begin + static_cast<int>( event->x() * midiTime::ticksPerTact() / m_ppt );
const MidiTime t = m_begin + static_cast<int>( event->x() * MidiTime::ticksPerTact() / m_ppt );
if( m_loopPos[0] > m_loopPos[1] )
{
qSwap( m_loopPos[0], m_loopPos[1] );
@@ -324,7 +324,7 @@ void timeLine::mousePressEvent( QMouseEvent* event )
void timeLine::mouseMoveEvent( QMouseEvent* event )
{
const midiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * midiTime::ticksPerTact() / m_ppt );
const MidiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerTact() / m_ppt );
switch( m_action )
{
@@ -356,9 +356,9 @@ void timeLine::mouseMoveEvent( QMouseEvent* event )
// Note, swap 1 and 0 below and the behavior "skips" the other
// marking instead of pushing it.
if( m_action == MoveLoopBegin )
m_loopPos[0] -= midiTime::ticksPerTact();
m_loopPos[0] -= MidiTime::ticksPerTact();
else
m_loopPos[1] += midiTime::ticksPerTact();
m_loopPos[1] += MidiTime::ticksPerTact();
}
update();
break;

View File

@@ -145,7 +145,7 @@ trackContentObject::~trackContentObject()
*
* \param _pos The new position of the track content object.
*/
void trackContentObject::movePosition( const midiTime & _pos )
void trackContentObject::movePosition( const MidiTime & _pos )
{
if( m_startPosition != _pos )
{
@@ -166,7 +166,7 @@ void trackContentObject::movePosition( const midiTime & _pos )
*
* \param _length The new length of the track content object.
*/
void trackContentObject::changeLength( const midiTime & _length )
void trackContentObject::changeLength( const MidiTime & _length )
{
if( m_length != _length )
{
@@ -243,7 +243,7 @@ void trackContentObject::paste()
{
if( Clipboard::getContent( nodeName() ) != NULL )
{
const midiTime pos = startPosition();
const MidiTime pos = startPosition();
restoreState( *( Clipboard::getContent( nodeName() ) ) );
movePosition( pos );
}
@@ -422,7 +422,7 @@ void trackContentObjectView::updateLength()
{
setFixedWidth(
static_cast<int>( m_tco->length() * pixelsPerTact() /
midiTime::ticksPerTact() ) +
MidiTime::ticksPerTact() ) +
TCO_BORDER_WIDTH * 2-1 );
}
m_trackView->trackContainerView()->update();
@@ -485,7 +485,7 @@ void trackContentObjectView::dropEvent( QDropEvent * _de )
multimediaProject mmp( value.toUtf8() );
// at least save position before getting to moved to somewhere
// the user doesn't expect...
midiTime pos = m_tco->startPosition();
MidiTime pos = m_tco->startPosition();
m_tco->restoreState( mmp.content().firstChild().toElement() );
m_tco->movePosition( pos );
AutomationPattern::resolveAllIDs();
@@ -654,9 +654,9 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me )
if( m_action == Move )
{
const int x = mapToParent( _me->pos() ).x() - m_initialMouseX;
midiTime t = qMax( 0, (int)
MidiTime t = qMax( 0, (int)
m_trackView->trackContainerView()->currentPosition()+
static_cast<int>( x * midiTime::ticksPerTact() /
static_cast<int>( x * MidiTime::ticksPerTact() /
ppt ) );
if( ! ( _me->modifiers() & Qt::ControlModifier )
&& _me->button() == Qt::NoButton )
@@ -668,7 +668,7 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me )
s_textFloat->setText( QString( "%1:%2" ).
arg( m_tco->startPosition().getTact() + 1 ).
arg( m_tco->startPosition().getTicks() %
midiTime::ticksPerTact() ) );
MidiTime::ticksPerTact() ) );
s_textFloat->moveGlobal( this, QPoint( width() + 2,
height() + 2 ) );
}
@@ -678,7 +678,7 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me )
QVector<selectableObject *> so =
m_trackView->trackContainerView()->selectedObjects();
QVector<trackContentObject *> tcos;
midiTime smallest_pos, t;
MidiTime smallest_pos, t;
// find out smallest position of all selected objects for not
// moving an object before zero
for( QVector<selectableObject *>::iterator it = so.begin();
@@ -695,13 +695,13 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me )
smallest_pos = qMin<int>( smallest_pos,
(int)tco->startPosition() +
static_cast<int>( dx *
midiTime::ticksPerTact() / ppt ) );
MidiTime::ticksPerTact() / ppt ) );
}
for( QVector<trackContentObject *>::iterator it = tcos.begin();
it != tcos.end(); ++it )
{
t = ( *it )->startPosition() +
static_cast<int>( dx *midiTime::ticksPerTact() /
static_cast<int>( dx *MidiTime::ticksPerTact() /
ppt )-smallest_pos;
if( ! ( _me->modifiers() & Qt::AltModifier )
&& _me->button() == Qt::NoButton )
@@ -713,22 +713,22 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me )
}
else if( m_action == Resize )
{
midiTime t = qMax( midiTime::ticksPerTact() / 16, static_cast<int>( _me->x() * midiTime::ticksPerTact() / ppt ) );
MidiTime t = qMax( MidiTime::ticksPerTact() / 16, static_cast<int>( _me->x() * MidiTime::ticksPerTact() / ppt ) );
if( ! ( _me->modifiers() & Qt::ControlModifier ) && _me->button() == Qt::NoButton )
{
t = qMax<int>( midiTime::ticksPerTact(), t.toNearestTact() );
t = qMax<int>( MidiTime::ticksPerTact(), t.toNearestTact() );
}
m_tco->changeLength( t );
s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ).
arg( m_tco->length().getTact() ).
arg( m_tco->length().getTicks() %
midiTime::ticksPerTact() ).
MidiTime::ticksPerTact() ).
arg( m_tco->startPosition().getTact() + 1 ).
arg( m_tco->startPosition().getTicks() %
midiTime::ticksPerTact() ).
MidiTime::ticksPerTact() ).
arg( m_tco->endPosition().getTact() + 1 ).
arg( m_tco->endPosition().getTicks() %
midiTime::ticksPerTact() ) );
MidiTime::ticksPerTact() ) );
s_textFloat->moveGlobal( this, QPoint( width() + 2,
height() + 2) );
}
@@ -864,8 +864,8 @@ trackContentWidget::trackContentWidget( trackView * _parent ) :
setAcceptDrops( true );
connect( _parent->trackContainerView(),
SIGNAL( positionChanged( const midiTime & ) ),
this, SLOT( changePosition( const midiTime & ) ) );
SIGNAL( positionChanged( const MidiTime & ) ),
this, SLOT( changePosition( const MidiTime & ) ) );
updateBackground();
}
@@ -1014,7 +1014,7 @@ void trackContentWidget::update()
*
* \param _new_pos The MIDI time to move to.
*/
void trackContentWidget::changePosition( const midiTime & _new_pos )
void trackContentWidget::changePosition( const MidiTime & _new_pos )
{
if( m_trackView->trackContainerView() == engine::getBBEditor() )
{
@@ -1051,7 +1051,7 @@ void trackContentWidget::changePosition( const midiTime & _new_pos )
return;
}
midiTime pos = _new_pos;
MidiTime pos = _new_pos;
if( pos < 0 )
{
pos = m_trackView->trackContainerView()->currentPosition();
@@ -1077,7 +1077,7 @@ void trackContentWidget::changePosition( const midiTime & _new_pos )
( ts <= begin && te >= end ) )
{
tcov->move( static_cast<int>( ( ts - begin ) * ppt /
midiTime::ticksPerTact() ),
MidiTime::ticksPerTact() ),
tcov->y() );
if( !tcov->isVisible() )
{
@@ -1122,7 +1122,7 @@ void trackContentWidget::dropEvent( QDropEvent * _de )
if( type == ( "tco_" + QString::number( getTrack()->type() ) ) &&
m_trackView->trackContainerView()->fixedTCOs() == false )
{
const midiTime pos = getPosition( _de->pos().x()
const MidiTime pos = getPosition( _de->pos().x()
).toNearestTact();
trackContentObject * tco = getTrack()->createTCO( pos );
@@ -1162,8 +1162,8 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me )
else if( _me->button() == Qt::LeftButton &&
!m_trackView->trackContainerView()->fixedTCOs() )
{
const midiTime pos = getPosition( _me->x() ).getTact() *
midiTime::ticksPerTact();
const MidiTime pos = getPosition( _me->x() ).getTact() *
MidiTime::ticksPerTact();
trackContentObject * tco = getTrack()->createTCO( pos );
tco->saveJournallingState( false );
@@ -1237,7 +1237,7 @@ void trackContentWidget::undoStep( JournalEntry & _je )
case RemoveTrackContentObject:
{
trackContentObject * tco = getTrack()->createTCO( midiTime( 0 ) );
trackContentObject * tco = getTrack()->createTCO( MidiTime( 0 ) );
multimediaProject mmp(
_je.data().toMap()["state"].
toString().toUtf8() );
@@ -1292,11 +1292,11 @@ track * trackContentWidget::getTrack()
*
* \param _mouse_x the mouse's current X position in pixels.
*/
midiTime trackContentWidget::getPosition( int _mouse_x )
MidiTime trackContentWidget::getPosition( int _mouse_x )
{
return midiTime( m_trackView->trackContainerView()->
return MidiTime( m_trackView->trackContainerView()->
currentPosition() + _mouse_x *
midiTime::ticksPerTact() /
MidiTime::ticksPerTact() /
static_cast<int>( m_trackView->
trackContainerView()->pixelsPerTact() ) );
}
@@ -1307,11 +1307,11 @@ midiTime trackContentWidget::getPosition( int _mouse_x )
*
* \param _pos_start the starting position of the Widget (from getPosition())
*/
midiTime trackContentWidget::endPosition( const midiTime & _pos_start )
MidiTime trackContentWidget::endPosition( const MidiTime & _pos_start )
{
const float ppt = m_trackView->trackContainerView()->pixelsPerTact();
const int w = width();
return _pos_start + static_cast<int>( w * midiTime::ticksPerTact() / ppt );
return _pos_start + static_cast<int>( w * MidiTime::ticksPerTact() / ppt );
}
@@ -1762,7 +1762,7 @@ void track::loadSettings( const QDomElement & _this )
!node.toElement().attribute( "metadata" ).toInt() )
{
trackContentObject * tco = createTCO(
midiTime( 0 ) );
MidiTime( 0 ) );
tco->restoreState( node.toElement() );
saveJournallingState( false );
restoreJournallingState();
@@ -1852,7 +1852,7 @@ trackContentObject * track::getTCO( int _tco_num )
}
printf( "called track::getTCO( %d ), "
"but TCO %d doesn't exist\n", _tco_num, _tco_num );
return createTCO( _tco_num * midiTime::ticksPerTact() );
return createTCO( _tco_num * MidiTime::ticksPerTact() );
}
@@ -1898,8 +1898,8 @@ int track::getTCONum( trackContentObject * _tco )
* \param _start The MIDI start time of the range.
* \param _end The MIDI endi time of the range.
*/
void track::getTCOsInRange( tcoVector & _tco_v, const midiTime & _start,
const midiTime & _end )
void track::getTCOsInRange( tcoVector & _tco_v, const MidiTime & _start,
const MidiTime & _end )
{
for( tcoVector::iterator it_o = m_trackContentObjects.begin();
it_o != m_trackContentObjects.end(); ++it_o )
@@ -1948,7 +1948,7 @@ void track::swapPositionOfTCOs( int _tco_num1, int _tco_num2 )
qSwap( m_trackContentObjects[_tco_num1],
m_trackContentObjects[_tco_num2] );
const midiTime pos = m_trackContentObjects[_tco_num1]->startPosition();
const MidiTime pos = m_trackContentObjects[_tco_num1]->startPosition();
m_trackContentObjects[_tco_num1]->movePosition(
m_trackContentObjects[_tco_num2]->startPosition() );
@@ -1965,7 +1965,7 @@ void track::swapPositionOfTCOs( int _tco_num1, int _tco_num2 )
* in ascending order by TCO time, once we hit a TCO that was earlier
* than the insert time, we could fall out of the loop early.
*/
void track::insertTact( const midiTime & _pos )
void track::insertTact( const MidiTime & _pos )
{
// we'll increase the position of every TCO, positioned behind _pos, by
// one tact
@@ -1975,7 +1975,7 @@ void track::insertTact( const midiTime & _pos )
if( ( *it )->startPosition() >= _pos )
{
( *it )->movePosition( (*it)->startPosition() +
midiTime::ticksPerTact() );
MidiTime::ticksPerTact() );
}
}
}
@@ -1987,7 +1987,7 @@ void track::insertTact( const midiTime & _pos )
*
* \param _pos The time at which we want to remove the bar.
*/
void track::removeTact( const midiTime & _pos )
void track::removeTact( const MidiTime & _pos )
{
// we'll decrease the position of every TCO, positioned behind _pos, by
// one tact
@@ -1997,7 +1997,7 @@ void track::removeTact( const midiTime & _pos )
if( ( *it )->startPosition() >= _pos )
{
( *it )->movePosition( qMax( ( *it )->startPosition() -
midiTime::ticksPerTact(), 0 ) );
MidiTime::ticksPerTact(), 0 ) );
}
}
}
@@ -2025,7 +2025,7 @@ tact_t track::length() const
}
}
return last / midiTime::ticksPerTact();
return last / MidiTime::ticksPerTact();
}

View File

@@ -57,7 +57,6 @@
#include "gui_templates.h"
#include "timeline.h"
#include "tooltip.h"
#include "midi.h"
#include "tool_button.h"
#include "text_float.h"
#include "combobox.h"
@@ -131,10 +130,10 @@ AutomationEditor::AutomationEditor() :
engine::getSong()->getPlayPos(
song::Mode_PlayAutomationPattern ),
m_currentPosition, this );
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
m_timeLine, SLOT( updatePosition( const midiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const midiTime & ) ),
this, SLOT( updatePosition( const midiTime & ) ) );
connect( this, SIGNAL( positionChanged( const MidiTime & ) ),
m_timeLine, SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ),
this, SLOT( updatePosition( const MidiTime & ) ) );
m_toolBar = new QWidget( this );
@@ -789,8 +788,8 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 )
x += xstep;
i += 1;
m_pattern->removeValue( midiTime( x ) );
m_pattern->putValue( midiTime( x ), y );
m_pattern->removeValue( MidiTime( x ) );
m_pattern->putValue( MidiTime( x ), y );
}
}
@@ -843,7 +842,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me )
// loop through whole time-map...
while( it != time_map.end() )
{
midiTime len = 4;
MidiTime len = 4;
// and check whether the user clicked on an
// existing value
@@ -878,9 +877,9 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me )
if( it == time_map.end() )
{
// then set new value
midiTime value_pos( pos_ticks );
MidiTime value_pos( pos_ticks );
midiTime new_time =
MidiTime new_time =
m_pattern->putValue( value_pos,
level );
@@ -1020,8 +1019,8 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me )
// moved properly according to new starting-
// time in the time map of pattern
m_pattern->removeValue(
midiTime( pos_ticks ) );
m_pattern->putValue( midiTime( pos_ticks ),
MidiTime( pos_ticks ) );
m_pattern->putValue( MidiTime( pos_ticks ),
level );
}
@@ -1033,7 +1032,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me )
( _me->buttons() & Qt::LeftButton &&
m_editMode == ERASE ) )
{
m_pattern->removeValue( midiTime( pos_ticks ) );
m_pattern->removeValue( MidiTime( pos_ticks ) );
}
else if( _me->buttons() & Qt::NoButton && m_editMode == DRAW )
{
@@ -1216,7 +1215,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me )
for( timeMap::iterator it = m_selValuesForMove.begin();
it != m_selValuesForMove.end(); ++it )
{
midiTime new_value_pos;
MidiTime new_value_pos;
if( it.key() )
{
int value_tact =
@@ -1236,7 +1235,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me )
DefaultTicksPerTact;
}
m_pattern->removeValue( it.key() );
new_value_pos = midiTime( value_tact,
new_value_pos = MidiTime( value_tact,
value_ticks );
}
new_selValuesForMove[
@@ -2242,7 +2241,7 @@ void AutomationEditor::deleteSelectedValues()
void AutomationEditor::updatePosition( const midiTime & _t )
void AutomationEditor::updatePosition( const MidiTime & _t )
{
if( ( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() ==
@@ -2257,7 +2256,7 @@ void AutomationEditor::updatePosition( const midiTime & _t )
}
else if( _t < m_currentPosition )
{
midiTime t = qMax( _t - w * DefaultTicksPerTact *
MidiTime t = qMax( _t - w * DefaultTicksPerTact *
DefaultTicksPerTact / m_ppt, 0 );
m_leftRightScroll->setValue( t.getTact() *
DefaultTicksPerTact );

View File

@@ -250,7 +250,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
if( it+1 == m_pat->getTimeMap().end() )
{
const float x1 = x_base + it.key() * ppt /
midiTime::ticksPerTact();
MidiTime::ticksPerTact();
const float x2 = (float)( width() - TCO_BORDER_WIDTH );
p.fillRect( QRectF( x1, 0.0f, x2-x1, it.value() ),
lin2grad );
@@ -262,9 +262,9 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
{
float value = values[i - it.key()];
const float x1 = x_base + i * ppt /
midiTime::ticksPerTact();
MidiTime::ticksPerTact();
const float x2 = x_base + (i+1) * ppt /
midiTime::ticksPerTact();
MidiTime::ticksPerTact();
p.fillRect( QRectF( x1, 0.0f, x2-x1, value ),
lin2grad );

View File

@@ -63,13 +63,13 @@ public:
}
virtual void processInEvent( const midiEvent& event, const midiTime& time )
virtual void processInEvent( const MidiEvent& event, const MidiTime& time )
{
if( event.m_type == MidiControlChange &&
( m_midiPort.inputChannel() == event.m_channel + 1 || m_midiPort.inputChannel() == 0 ) )
if( event.type() == MidiControlChange &&
( m_midiPort.inputChannel() == 0 || m_midiPort.inputChannel() == event.channel() + 1 ) )
{
m_detectedMidiChannel = event.m_channel + 1;
m_detectedMidiController = ( event.m_data.m_bytes[0] & 0x7F ) + 1;
m_detectedMidiChannel = event.channel() + 1;
m_detectedMidiController = event.controllerNumber() + 1;
m_detectedMidiPort = engine::mixer()->midiClient()->sourcePortName( event );
emit valueChanged();

View File

@@ -53,7 +53,7 @@
#include "knob.h"
#include "string_pair_drag.h"
#include "MainWindow.h"
#include "midi.h"
#include "MidiEvent.h"
#include "templates.h"
#include "update_event.h"
@@ -465,7 +465,7 @@ void PianoView::mousePressEvent( QMouseEvent * _me )
velocity = MidiMaxVelocity;
}
// set note on
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOn, 0, key_num, velocity ), midiTime() );
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOn, 0, key_num, velocity ), MidiTime() );
m_piano->setKeyState( key_num, true );
m_lastKey = key_num;
@@ -510,7 +510,7 @@ void PianoView::mouseReleaseEvent( QMouseEvent * )
{
if( m_piano != NULL )
{
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOff, 0, m_lastKey, 0 ), midiTime() );
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, 0, m_lastKey, 0 ), MidiTime() );
m_piano->setKeyState( m_lastKey, false );
}
@@ -571,7 +571,7 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me )
{
if( m_lastKey != -1 )
{
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOff, 0, m_lastKey, 0 ), midiTime() );
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, 0, m_lastKey, 0 ), MidiTime() );
m_piano->setKeyState( m_lastKey, false );
m_lastKey = -1;
}
@@ -579,7 +579,7 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me )
{
if( _me->pos().y() > PIANO_BASE )
{
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOn, 0, key_num, velocity ), midiTime() );
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOn, 0, key_num, velocity ), MidiTime() );
m_piano->setKeyState( key_num, true );
m_lastKey = key_num;
}
@@ -593,7 +593,7 @@ void PianoView::mouseMoveEvent( QMouseEvent * _me )
}
else if( m_piano->isKeyPressed( key_num ) )
{
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiKeyPressure, 0, key_num, velocity ), midiTime() );
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiKeyPressure, 0, key_num, velocity ), MidiTime() );
}
}
@@ -690,7 +690,7 @@ void PianoView::focusOutEvent( QFocusEvent * )
// hang otherwise
for( int i = 0; i < NumKeys; ++i )
{
m_piano->midiEventProcessor()->processInEvent( midiEvent( MidiNoteOff, 0, i, 0 ), midiTime() );
m_piano->midiEventProcessor()->processInEvent( MidiEvent( MidiNoteOff, 0, i, 0 ), MidiTime() );
m_piano->setKeyState( i, false );
}
update();

View File

@@ -127,9 +127,9 @@ trackView * TrackContainerView::addTrackView( trackView * _tv )
m_trackViews.push_back( _tv );
m_scrollLayout->addWidget( _tv );
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
connect( this, SIGNAL( positionChanged( const MidiTime & ) ),
_tv->getTrackContentWidget(),
SLOT( changePosition( const midiTime & ) ) );
SLOT( changePosition( const MidiTime & ) ) );
realignTracks();
return( _tv );
}

View File

@@ -56,7 +56,7 @@
#include "gui_templates.h"
#include "InstrumentTrack.h"
#include "MainWindow.h"
#include "midi.h"
#include "MidiEvent.h"
#include "mmp.h"
#include "pattern.h"
#include "Piano.h"
@@ -162,7 +162,7 @@ pianoRoll::pianoRoll() :
m_oldNotesEditHeight( 100 ),
m_notesEditHeight( 100 ),
m_ppt( DEFAULT_PR_PPT ),
m_lenOfNewNotes( midiTime( 0, DefaultTicksPerTact/4 ) ),
m_lenOfNewNotes( MidiTime( 0, DefaultTicksPerTact/4 ) ),
m_lastNoteVolume( DefaultVolume ),
m_lastNotePanning( DefaultPanning ),
m_startKey( INITIAL_START_KEY ),
@@ -283,21 +283,21 @@ pianoRoll::pianoRoll() :
engine::getSong()->getPlayPos(
song::Mode_PlayPattern ),
m_currentPosition, this );
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
m_timeLine, SLOT( updatePosition( const midiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const midiTime & ) ),
this, SLOT( updatePosition( const midiTime & ) ) );
connect( this, SIGNAL( positionChanged( const MidiTime & ) ),
m_timeLine, SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ),
this, SLOT( updatePosition( const MidiTime & ) ) );
// update timeline when in record-accompany mode
connect( engine::getSong()->getPlayPos( song::Mode_PlaySong ).m_timeLine,
SIGNAL( positionChanged( const midiTime & ) ),
SIGNAL( positionChanged( const MidiTime & ) ),
this,
SLOT( updatePositionAccompany( const midiTime & ) ) );
SLOT( updatePositionAccompany( const MidiTime & ) ) );
// TODO
/* connect( engine::getSong()->getPlayPos( song::Mode_PlayBB ).m_timeLine,
SIGNAL( positionChanged( const midiTime & ) ),
SIGNAL( positionChanged( const MidiTime & ) ),
this,
SLOT( updatePositionAccompany( const midiTime & ) ) );*/
SLOT( updatePositionAccompany( const MidiTime & ) ) );*/
m_toolBar = new QWidget( this );
@@ -927,7 +927,7 @@ inline void pianoRoll::drawDetuningInfo( QPainter & _p, note * _n, int _x,
{
break;
}
int pos_x = _x + pos_ticks * m_ppt / midiTime::ticksPerTact();
int pos_x = _x + pos_ticks * m_ppt / MidiTime::ticksPerTact();
const float level = it.value();
@@ -1522,7 +1522,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
x -= WHITE_KEY_WIDTH;
// get tick in which the user clicked
int pos_ticks = x * midiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
m_currentPosition;
@@ -1535,7 +1535,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
// loop through whole note-vector...
for( int i = 0; i < notes.size(); ++i )
{
midiTime len = ( *it )->length();
MidiTime len = ( *it )->length();
if( len < 0 )
{
len = 4;
@@ -1552,7 +1552,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
( edit_note == true &&
pos_ticks <= ( *it )->pos() +
NE_LINE_WIDTH *
midiTime::ticksPerTact() /
MidiTime::ticksPerTact() /
m_ppt )
)
)
@@ -1593,8 +1593,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
// +32 to quanitize the note correctly when placing notes with
// the mouse. We do this here instead of in note.quantized
// because live notes should still be quantized at the half.
midiTime note_pos( pos_ticks - ( quantization() / 2 ) );
midiTime note_len( newNoteLen() );
MidiTime note_pos( pos_ticks - ( quantization() / 2 ) );
MidiTime note_len( newNoteLen() );
note new_note( note_len, note_pos, key_num );
new_note.setSelected( true );
@@ -1701,8 +1701,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
// clicked at the "tail" of the note?
if( pos_ticks*m_ppt/midiTime::ticksPerTact() >
( m_currentNote->pos() + m_currentNote->length() )*m_ppt/ midiTime::ticksPerTact() - RESIZE_AREA_WIDTH &&
if( pos_ticks*m_ppt/MidiTime::ticksPerTact() >
( m_currentNote->pos() + m_currentNote->length() )*m_ppt/ MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH &&
m_currentNote->length() > 0 )
{
// then resize the note
@@ -1865,16 +1865,16 @@ void pianoRoll::testPlayNote( note * n )
{
m_lastKey = n->key();
if( ! n->isPlaying() && ! m_recording &&
! engine::getSong()->isPlaying() )
if( ! n->isPlaying() && ! m_recording && ! engine::getSong()->isPlaying() )
{
n->setIsPlaying( true );
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( n->key(), volumeToMidi( n->getVolume() ) );
midiEvent evt( MidiMetaEvent, 0, n->key(), panningToMidi( n->getPanning() ) );
evt.m_metaEvent = MidiNotePanning;
m_pattern->instrumentTrack()->processInEvent( evt, midiTime() );
MidiEvent event( MidiMetaEvent, 0, n->key(), panningToMidi( n->getPanning() ) );
event.setMetaEvent( MidiNotePanning );
m_pattern->instrumentTrack()->processInEvent( event, 0 );
}
}
@@ -1919,10 +1919,6 @@ void pianoRoll::testPlayKey( int key, int velocity, int pan )
// play new key
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key, velocity );
// set panning of newly played key
midiEvent evt( MidiMetaEvent, 0, key, pan );
evt.m_metaEvent = MidiNotePanning;
}
@@ -2183,9 +2179,9 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// convert to ticks so that we can check which notes
// are in the range
int ticks_start = (x-pixel_range/2) *
midiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
int ticks_end = (x+pixel_range/2) *
midiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
// get note-vector of current pattern
const NoteVector & notes = m_pattern->notes();
@@ -2234,14 +2230,14 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
{
n->setVolume( vol );
m_pattern->instrumentTrack()->processInEvent(
midiEvent( MidiKeyPressure, 0, n->key(), volumeToMidi( vol ) ), midiTime() );
MidiEvent( MidiKeyPressure, 0, n->key(), volumeToMidi( vol ) ), MidiTime() );
}
else if( m_noteEditMode == NoteEditPanning )
{
n->setPanning( pan );
midiEvent evt( MidiMetaEvent, 0, n->key(), panningToMidi( pan ) );
evt.m_metaEvent = MidiNotePanning;
m_pattern->instrumentTrack()->processInEvent( evt, midiTime() );
MidiEvent evt( MidiMetaEvent, 0, n->key(), panningToMidi( pan ) );
evt.setMetaEvent( MidiNotePanning );
m_pattern->instrumentTrack()->processInEvent( evt, MidiTime() );
}
}
else
@@ -2264,7 +2260,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// set move- or resize-cursor
// get tick in which the cursor is posated
int pos_ticks = ( x * midiTime::ticksPerTact() ) /
int pos_ticks = ( x * MidiTime::ticksPerTact() ) /
m_ppt + m_currentPosition;
// get note-vector of current pattern
@@ -2296,10 +2292,10 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// cursor at the "tail" of the note?
if( ( *it )->length() > 0 &&
pos_ticks*m_ppt /
midiTime::ticksPerTact() >
MidiTime::ticksPerTact() >
( ( *it )->pos() +
( *it )->length() )*m_ppt/
midiTime::ticksPerTact()-
MidiTime::ticksPerTact()-
RESIZE_AREA_WIDTH )
{
if( QApplication::overrideCursor() )
@@ -2363,7 +2359,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// change size of selection
// get tick in which the cursor is posated
int pos_ticks = x * midiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
m_currentPosition;
m_selectedTick = pos_ticks - m_selectStartTick;
@@ -2383,7 +2379,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// holding down right-click to delete notes
// get tick in which the user clicked
int pos_ticks = x * midiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
m_currentPosition;
@@ -2396,7 +2392,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
// loop through whole note-vector...
while( it != notes.end() )
{
midiTime len = ( *it )->length();
MidiTime len = ( *it )->length();
if( len < 0 )
{
len = 4;
@@ -2413,7 +2409,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
( edit_note == true &&
pos_ticks <= ( *it )->pos() +
NE_LINE_WIDTH *
midiTime::ticksPerTact() /
MidiTime::ticksPerTact() /
m_ppt )
)
)
@@ -2474,7 +2470,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
}
// get tick in which the cursor is posated
int pos_ticks = x * midiTime::ticksPerTact()/ m_ppt +
int pos_ticks = x * MidiTime::ticksPerTact()/ m_ppt +
m_currentPosition;
m_selectedTick = pos_ticks -
@@ -2535,7 +2531,7 @@ void pianoRoll::dragNotes( int x, int y, bool alt, bool shift )
// convert pixels to ticks and keys
int off_x = x - m_moveStartX;
int off_ticks = off_x * midiTime::ticksPerTact() / m_ppt;
int off_ticks = off_x * MidiTime::ticksPerTact() / m_ppt;
int off_key = getKey( y ) - getKey( m_moveStartY );
// handle scroll changes while dragging
@@ -2587,7 +2583,7 @@ void pianoRoll::dragNotes( int x, int y, bool alt, bool shift )
{
shifted_pos -= off_ticks;
}
( *it )->setPos( midiTime( shifted_pos ) );
( *it )->setPos( MidiTime( shifted_pos ) );
}
if( ( *it )->selected() )
@@ -2614,7 +2610,7 @@ void pianoRoll::dragNotes( int x, int y, bool alt, bool shift )
key_num = NumKeys;
}
( *it )->setPos( midiTime( pos_ticks ) );
( *it )->setPos( MidiTime( pos_ticks ) );
( *it )->setKey( key_num );
}
else if( m_action == ActionResizeNote )
@@ -2636,7 +2632,7 @@ void pianoRoll::dragNotes( int x, int y, bool alt, bool shift )
shift_ref_pos = pos;
}
}
( *it )->setLength( midiTime( ticks_new ) );
( *it )->setLength( MidiTime( ticks_new ) );
m_lenOfNewNotes = ( *it )->length();
}
@@ -2941,7 +2937,7 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
// triplet mode occurs if the note duration isn't a multiple of 3
bool triplets = ( quantization() % 3 != 0 );
int spt = midiTime::stepsPerTact();
int spt = MidiTime::stepsPerTact();
float pp16th = (float)m_ppt / spt;
int bpt = DefaultBeatsPerTact;
if ( triplets ) {
@@ -2953,7 +2949,7 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
int tact_16th = m_currentPosition / bpt;
const int offset = ( m_currentPosition % bpt ) *
m_ppt / midiTime::ticksPerTact();
m_ppt / MidiTime::ticksPerTact();
bool show32nds = ( m_zoomingModel.value() > 3 );
@@ -3047,9 +3043,9 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
int pos_ticks = ( *it )->pos();
int note_width = len_ticks * m_ppt /
midiTime::ticksPerTact();
MidiTime::ticksPerTact();
const int x = ( pos_ticks - m_currentPosition ) *
m_ppt / midiTime::ticksPerTact();
m_ppt / MidiTime::ticksPerTact();
// skip this note if not in visible area at all
if( !( x + note_width >= 0 &&
x <= width() - WHITE_KEY_WIDTH ) )
@@ -3141,9 +3137,9 @@ void pianoRoll::paintEvent( QPaintEvent * _pe )
// now draw selection-frame
int x = ( ( sel_pos_start - m_currentPosition ) * m_ppt ) /
midiTime::ticksPerTact();
MidiTime::ticksPerTact();
int w = ( ( ( sel_pos_end - m_currentPosition ) * m_ppt ) /
midiTime::ticksPerTact() ) - x;
MidiTime::ticksPerTact() ) - x;
int y = (int) y_base - sel_key_start * KEY_LINE_HEIGHT;
int h = (int) y_base - sel_key_end * KEY_LINE_HEIGHT - y;
p.setPen( QColor( 0, 64, 192 ) );
@@ -3407,7 +3403,7 @@ void pianoRoll::startRecordNote( const note & _n )
engine::getSong()->playMode() ==
song::Mode_PlayPattern ) )
{
midiTime sub;
MidiTime sub;
if( engine::getSong()->playMode() == song::Mode_PlaySong )
{
sub = m_pattern->startPosition();
@@ -3596,7 +3592,7 @@ void pianoRoll::copy_to_clipboard( const NoteVector & _notes ) const
QDomElement note_list = mmp.createElement( "note-list" );
mmp.content().appendChild( note_list );
midiTime start_pos( _notes.front()->pos().getTact(), 0 );
MidiTime start_pos( _notes.front()->pos().getTact(), 0 );
for( NoteVector::ConstIterator it = _notes.begin(); it != _notes.end();
++it )
{
@@ -3752,20 +3748,20 @@ void pianoRoll::deleteSelectedNotes()
void pianoRoll::autoScroll( const midiTime & _t )
void pianoRoll::autoScroll( const MidiTime & _t )
{
const int w = width() - WHITE_KEY_WIDTH;
if( _t > m_currentPosition + w * midiTime::ticksPerTact() / m_ppt )
if( _t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt )
{
m_leftRightScroll->setValue( _t.getTact() *
midiTime::ticksPerTact() );
MidiTime::ticksPerTact() );
}
else if( _t < m_currentPosition )
{
midiTime t = qMax( _t - w * midiTime::ticksPerTact() *
midiTime::ticksPerTact() / m_ppt, 0 );
MidiTime t = qMax( _t - w * MidiTime::ticksPerTact() *
MidiTime::ticksPerTact() / m_ppt, 0 );
m_leftRightScroll->setValue( t.getTact() *
midiTime::ticksPerTact() );
MidiTime::ticksPerTact() );
}
m_scrollBack = false;
}
@@ -3773,7 +3769,7 @@ void pianoRoll::autoScroll( const midiTime & _t )
void pianoRoll::updatePosition( const midiTime & _t )
void pianoRoll::updatePosition( const MidiTime & _t )
{
if( ( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() ==
@@ -3788,14 +3784,14 @@ void pianoRoll::updatePosition( const midiTime & _t )
void pianoRoll::updatePositionAccompany( const midiTime & _t )
void pianoRoll::updatePositionAccompany( const MidiTime & _t )
{
song * s = engine::getSong();
if( m_recording && validPattern() &&
s->playMode() != song::Mode_PlayPattern )
{
midiTime pos = _t;
MidiTime pos = _t;
if( s->playMode() != song::Mode_PlayBB )
{
pos -= m_pattern->startPosition();
@@ -3868,7 +3864,7 @@ void pianoRoll::updateSemiToneMarkerMenu()
midiTime pianoRoll::newNoteLen() const
MidiTime pianoRoll::newNoteLen() const
{
if( m_noteLenModel.value() == 0 )
{
@@ -3906,7 +3902,7 @@ note * pianoRoll::noteUnderMouse()
int key_num = getKey( pos.y() );
int pos_ticks = ( pos.x() - WHITE_KEY_WIDTH ) *
midiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
// will be our iterator in the following loop
NoteVector::ConstIterator it = notes.begin()+notes.size()-1;

View File

@@ -99,11 +99,11 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) :
pixelsPerTact(),
m_s->m_playPos[song::Mode_PlaySong],
m_currentPosition, this );
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
connect( this, SIGNAL( positionChanged( const MidiTime & ) ),
m_s->m_playPos[song::Mode_PlaySong].m_timeLine,
SLOT( updatePosition( const midiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const midiTime & ) ),
this, SLOT( updatePosition( const midiTime & ) ) );
SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ),
this, SLOT( updatePosition( const MidiTime & ) ) );
m_positionLine = new positionLine( this );
@@ -419,7 +419,7 @@ void songEditor::setHighQuality( bool _hq )
void songEditor::scrolled( int _new_pos )
{
update();
emit positionChanged( m_currentPosition = midiTime( _new_pos, 0 ) );
emit positionChanged( m_currentPosition = MidiTime( _new_pos, 0 ) );
}
@@ -503,7 +503,7 @@ void songEditor::keyPressEvent( QKeyEvent * _ke )
}
else if( _ke->key() == Qt::Key_Left )
{
tick_t t = m_s->currentTick() - midiTime::ticksPerTact();
tick_t t = m_s->currentTick() - MidiTime::ticksPerTact();
if( t >= 0 )
{
m_s->setPlayPos( t, song::Mode_PlaySong );
@@ -511,7 +511,7 @@ void songEditor::keyPressEvent( QKeyEvent * _ke )
}
else if( _ke->key() == Qt::Key_Right )
{
tick_t t = m_s->currentTick() + midiTime::ticksPerTact();
tick_t t = m_s->currentTick() + MidiTime::ticksPerTact();
if( t < MaxSongLength )
{
m_s->setPlayPos( t, song::Mode_PlaySong );
@@ -706,7 +706,7 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth
}
void songEditor::updatePosition( const midiTime & _t )
void songEditor::updatePosition( const MidiTime & _t )
{
int widgetWidth, trackOpWidth;
if( configManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() )
@@ -727,15 +727,15 @@ void songEditor::updatePosition( const midiTime & _t )
const int w = width() - widgetWidth
- trackOpWidth
- 32; // rough estimation for width of right scrollbar
if( _t > m_currentPosition + w * midiTime::ticksPerTact() /
if( _t > m_currentPosition + w * MidiTime::ticksPerTact() /
pixelsPerTact() )
{
animateScroll( m_leftRightScroll, _t.getTact(), m_smoothScroll );
}
else if( _t < m_currentPosition )
{
midiTime t = qMax(
(int)( _t - w * midiTime::ticksPerTact() /
MidiTime t = qMax(
(int)( _t - w * MidiTime::ticksPerTact() /
pixelsPerTact() ),
0 );
animateScroll( m_leftRightScroll, t.getTact(), m_smoothScroll );

View File

@@ -50,7 +50,7 @@ AutomationTrack::~AutomationTrack()
bool AutomationTrack::play( const midiTime & _start, const fpp_t _frames,
bool AutomationTrack::play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _frame_base, int _tco_num )
{
if( isMuted() )
@@ -77,7 +77,7 @@ bool AutomationTrack::play( const midiTime & _start, const fpp_t _frames,
{
continue;
}
midiTime cur_start = _start;
MidiTime cur_start = _start;
if( _tco_num < 0 )
{
cur_start -= p->startPosition();
@@ -98,7 +98,7 @@ trackView * AutomationTrack::createView( TrackContainerView* tcv )
trackContentObject * AutomationTrack::createTCO( const midiTime & )
trackContentObject * AutomationTrack::createTCO( const MidiTime & )
{
return new AutomationPattern( this );
}
@@ -168,11 +168,11 @@ void AutomationTrackView::dropEvent( QDropEvent * _de )
journallingObject( val.toInt() ) );
if( mod != NULL )
{
midiTime pos = midiTime( trackContainerView()->
MidiTime pos = MidiTime( trackContainerView()->
currentPosition() +
( _de->pos().x() -
getTrackContentWidget()->x() ) *
midiTime::ticksPerTact() /
MidiTime::ticksPerTact() /
static_cast<int>( trackContainerView()->pixelsPerTact() ) )
.toNearestTact();

View File

@@ -202,15 +202,15 @@ void InstrumentTrack::processAudioBuffer( sampleFrame * _buf,
midiEvent InstrumentTrack::applyMasterKey( const midiEvent & _me )
MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event )
{
midiEvent copy( _me );
switch( _me.m_type )
MidiEvent copy( event );
switch( event.type() )
{
case MidiNoteOn:
case MidiNoteOff:
case MidiKeyPressure:
copy.key() = masterKey( _me.key() );
copy.setKey( masterKey( event.key() ) );
break;
default:
break;
@@ -221,109 +221,92 @@ midiEvent InstrumentTrack::applyMasterKey( const midiEvent & _me )
void InstrumentTrack::processInEvent( const midiEvent & _me,
const midiTime & _time )
void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time )
{
engine::mixer()->lock();
// in the special case this event comes from a MIDI port, the instrument
// is MIDI based (VST plugin, Sf2Player etc.) and the user did not set
// a dedicated MIDI output channel, directly pass the MIDI event to the
// instrument plugin
if( _me.isFromMidiPort() && m_instrument->isMidiBased()/* &&
midiPort()->realOutputChannel() < 0 */ )
{
m_instrument->handleMidiEvent( _me, _time );
engine::mixer()->unlock();
return;
}
bool eventHandled = false;
switch( _me.m_type )
switch( event.type() )
{
// we don't send MidiNoteOn, MidiNoteOff and MidiKeyPressure
// events to instrument as notePlayHandle will send them on its
// own
case MidiNoteOn:
if( _me.velocity() > 0 )
case MidiNoteOn:
if( event.velocity() > 0 )
{
if( m_notes[_me.key()] == NULL )
if( m_notes[event.key()] == NULL )
{
if( !configManager::inst()->value( "ui",
"manualchannelpiano" ).toInt() )
if( !configManager::inst()->value( "ui", "manualchannelpiano" ).toInt() )
{
m_piano.setKeyState(
_me.key(), true );
m_piano.setKeyState( event.key(), true );
}
// create temporary note
note n;
n.setKey( _me.key() );
n.setVolume( _me.getVolume() );
n.setKey( event.key() );
n.setVolume( event.volume() );
// create (timed) note-play-handle
notePlayHandle * nph = new
notePlayHandle( this,
_time.frames(
engine::framesPerTick() ),
typeInfo<f_cnt_t>::max() / 2,
n );
if( engine::mixer()->addPlayHandle(
nph ) )
notePlayHandle* nph = new notePlayHandle( this, time.frames( engine::framesPerTick() ), typeInfo<f_cnt_t>::max() / 2,
n, NULL, false, event.channel() );
if( engine::mixer()->addPlayHandle( nph ) )
{
m_notes[_me.key()] = nph;
m_notes[event.key()] = nph;
}
emit noteOn( n );
eventHandled = true;
}
break;
}
case MidiNoteOff:
{
notePlayHandle * n = m_notes[_me.key()];
if( n != NULL )
notePlayHandle* nph = m_notes[event.key()];
if( nph != NULL )
{
// create dummy-note which has the same length
// as the played note for sending it later
// to all slots connected to signal noteOff()
// this is for example needed by piano-roll for
// recording notes into a pattern
note done_note(
midiTime( static_cast<f_cnt_t>(
n->totalFramesPlayed() /
engine::framesPerTick() ) ),
0,
n->key(),
n->getVolume(),
n->getPanning() );
note n( MidiTime( static_cast<f_cnt_t>( nph->totalFramesPlayed() / engine::framesPerTick() ) ),
0, nph->key(), nph->getVolume(), nph->getPanning() );
n->noteOff();
m_notes[_me.key()] = NULL;
emit noteOff( n );
emit noteOff( done_note );
// now do actual note off and remove internal reference to NotePlayHandle (which itself will
// be deleted later automatically)
nph->noteOff();
m_notes[event.key()] = NULL;
eventHandled = true;
}
break;
}
case MidiKeyPressure:
if( m_notes[_me.key()] != NULL )
if( m_notes[event.key()] != NULL )
{
m_notes[_me.key()]->setVolume( _me.getVolume() );
eventHandled = true;
// setVolume() calls processOutEvent() with MidiKeyPressure so the
// attached instrument will receive the event as well
m_notes[event.key()]->setVolume( event.volume() );
}
break;
case MidiPitchBend:
// updatePitch() is connected to
// m_pitchModel::dataChanged() which will send out
// updatePitch() is connected to m_pitchModel::dataChanged() which will send out
// MidiPitchBend events
m_pitchModel.setValue( m_pitchModel.minValue() +
_me.m_data.m_param[0] *
m_pitchModel.range() / 16384 );
m_pitchModel.setValue( m_pitchModel.minValue() + event.pitchBend() * m_pitchModel.range() / 16384 );
break;
case MidiControlChange:
if( _me.controllerNumber() == MidiControllerSustain )
if( event.controllerNumber() == MidiControllerSustain )
{
if( _me.controllerValue() > MidiMaxControllerValue/2 )
if( event.controllerValue() > MidiMaxControllerValue/2 )
{
m_sustainPedalPressed = true;
}
@@ -332,120 +315,99 @@ void InstrumentTrack::processInEvent( const midiEvent & _me,
m_sustainPedalPressed = false;
}
}
if( _me.controllerNumber() == MidiControllerAllSoundOff ||
_me.controllerNumber() == MidiControllerAllNotesOff ||
_me.controllerNumber() == MidiControllerOmniOn ||
_me.controllerNumber() == MidiControllerOmniOff ||
_me.controllerNumber() == MidiControllerMonoOn ||
_me.controllerNumber() == MidiControllerPolyOn )
if( event.controllerNumber() == MidiControllerAllSoundOff ||
event.controllerNumber() == MidiControllerAllNotesOff ||
event.controllerNumber() == MidiControllerOmniOn ||
event.controllerNumber() == MidiControllerOmniOff ||
event.controllerNumber() == MidiControllerMonoOn ||
event.controllerNumber() == MidiControllerPolyOn )
{
silenceAllNotes();
}
m_instrument->handleMidiEvent( _me, _time );
break;
case MidiProgramChange:
m_instrument->handleMidiEvent( _me, _time );
break;
case MidiMetaEvent:
// handle special cases such as note panning
switch( _me.m_metaEvent )
switch( event.metaEvent() )
{
case MidiNotePanning:
if( m_notes[_me.key()] != NULL )
if( m_notes[event.key()] != NULL )
{
m_notes[_me.key()]->setPanning( _me.getPanning() );
eventHandled = true;
m_notes[event.key()]->setPanning( event.panning() );
}
break;
default:
printf( "instrument-track: unhandled "
"MIDI meta event: %i\n",
_me.m_metaEvent );
qWarning( "InstrumentTrack: unhandled MIDI meta event: %i", event.metaEvent() );
break;
}
break;
default:
if( !m_instrument->handleMidiEvent( _me, _time ) )
{
printf( "instrument-track: unhandled "
"MIDI event %d\n", _me.m_type );
}
break;
}
if( eventHandled == false && instrument()->handleMidiEvent( event, time ) == false )
{
qWarning( "InstrumentTrack: unhandled MIDI event %d", event.type() );
}
engine::mixer()->unlock();
}
void InstrumentTrack::processOutEvent( const midiEvent & _me,
const midiTime & _time )
void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& time )
{
int k;
switch( _me.m_type )
switch( event.type() )
{
case MidiNoteOn:
if( !configManager::inst()->value( "ui",
"manualchannelpiano" ).toInt() )
if( !configManager::inst()->value( "ui", "manualchannelpiano" ).toInt() )
{
m_piano.setKeyState( _me.key(), true );
m_piano.setKeyState( event.key(), true );
}
if( !configManager::inst()->value( "ui",
"disablechannelactivityindicators" ).toInt() )
if( !configManager::inst()->value( "ui", "disablechannelactivityindicators" ).toInt() )
{
if( m_notes[_me.key()] == NULL )
if( m_notes[event.key()] == NULL )
{
emit newNote();
}
}
k = masterKey( _me.key() );
k = masterKey( event.key() );
if( k >= 0 && k < NumKeys )
{
if( m_runningMidiNotes[k] > 0 )
{
m_instrument->handleMidiEvent(
midiEvent( MidiNoteOff, midiPort()->realOutputChannel(), k, 0 ),
_time );
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), k, 0 ), time );
}
++m_runningMidiNotes[k];
m_instrument->handleMidiEvent(
midiEvent( MidiNoteOn, midiPort()->realOutputChannel(), k,
_me.velocity() ), _time );
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOn, midiPort()->realOutputChannel(), k, event.velocity() ), time );
}
break;
case MidiNoteOff:
if( !configManager::inst()->value( "ui",
"manualchannelpiano" ).toInt() )
if( !configManager::inst()->value( "ui", "manualchannelpiano" ).toInt() )
{
m_piano.setKeyState( _me.key(), false );
m_piano.setKeyState( event.key(), false );
}
k = masterKey( _me.key() );
if( k >= 0 && k < NumKeys &&
--m_runningMidiNotes[k] <= 0 )
k = masterKey( event.key() );
if( k >= 0 && k < NumKeys && --m_runningMidiNotes[k] <= 0 )
{
m_runningMidiNotes[k] = qMax( 0, m_runningMidiNotes[k] );
m_instrument->handleMidiEvent(
midiEvent( MidiNoteOff, midiPort()->realOutputChannel(), k, 0 ),
_time );
m_instrument->handleMidiEvent( MidiEvent( MidiNoteOff, midiPort()->realOutputChannel(), k, 0 ), time );
}
break;
default:
if( m_instrument != NULL )
{
m_instrument->handleMidiEvent(
applyMasterKey( _me ),
_time );
}
m_instrument->handleMidiEvent( applyMasterKey( event ), time );
break;
}
// if appropriate, midi-port does futher routing
m_midiPort.processOutEvent( _me, _time );
m_midiPort.processOutEvent( event, time );
}
@@ -525,7 +487,7 @@ void InstrumentTrack::deleteNotePluginData( notePlayHandle * _n )
// Notes deleted when keys still pressed
if( m_notes[_n->key()] == _n )
{
note done_note( midiTime( static_cast<f_cnt_t>(
note done_note( MidiTime( static_cast<f_cnt_t>(
_n->totalFramesPlayed() /
engine::framesPerTick() ) ),
0, _n->key(),
@@ -581,9 +543,7 @@ void InstrumentTrack::updateBaseNote()
void InstrumentTrack::updatePitch()
{
updateBaseNote();
processOutEvent( midiEvent( MidiPitchBend,
midiPort()->realOutputChannel(),
midiPitch() ), 0 );
processOutEvent( MidiEvent( MidiPitchBend, midiPort()->realOutputChannel(), midiPitch() ), 0 );
}
@@ -616,7 +576,7 @@ void InstrumentTrack::removeMidiPortNode( multimediaProject & _mmp )
bool InstrumentTrack::play( const midiTime & _start, const fpp_t _frames,
bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _offset, int _tco_num )
{
const float frames_per_tick = engine::framesPerTick();
@@ -657,7 +617,7 @@ bool InstrumentTrack::play( const midiTime & _start, const fpp_t _frames,
{
continue;
}
midiTime cur_start = _start;
MidiTime cur_start = _start;
if( _tco_num < 0 )
{
cur_start -= p->startPosition();
@@ -747,7 +707,7 @@ bool InstrumentTrack::play( const midiTime & _start, const fpp_t _frames,
trackContentObject * InstrumentTrack::createTCO( const midiTime & )
trackContentObject * InstrumentTrack::createTCO( const MidiTime & )
{
return new pattern( this );
}
@@ -1182,8 +1142,8 @@ void InstrumentTrackView::toggleInstrumentWindow( bool _on )
void InstrumentTrackView::activityIndicatorPressed()
{
model()->processInEvent(
midiEvent( MidiNoteOn, 0, DefaultKey, MidiMaxVelocity ),
midiTime() );
MidiEvent( MidiNoteOn, 0, DefaultKey, MidiMaxVelocity ),
MidiTime() );
}
@@ -1191,8 +1151,8 @@ void InstrumentTrackView::activityIndicatorPressed()
void InstrumentTrackView::activityIndicatorReleased()
{
model()->processInEvent( midiEvent( MidiNoteOff, 0, DefaultKey, 0 ),
midiTime() );
model()->processInEvent( MidiEvent( MidiNoteOff, 0, DefaultKey, 0 ),
MidiTime() );
}

View File

@@ -74,7 +74,7 @@ SampleTCO::~SampleTCO()
void SampleTCO::changeLength( const midiTime & _length )
void SampleTCO::changeLength( const MidiTime & _length )
{
trackContentObject::changeLength( qMax( static_cast<int>( _length ), DefaultTicksPerTact ) );
}
@@ -128,7 +128,7 @@ void SampleTCO::updateLength( bpm_t )
midiTime SampleTCO::sampleLength() const
MidiTime SampleTCO::sampleLength() const
{
return (int)( m_sampleBuffer->frames() / engine::framesPerTick() );
}
@@ -406,7 +406,7 @@ SampleTrack::~SampleTrack()
bool SampleTrack::play( const midiTime & _start, const fpp_t _frames,
bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _offset, int /*_tco_num*/ )
{
m_audioPort.effects()->startRunning();
@@ -461,7 +461,7 @@ trackView * SampleTrack::createView( TrackContainerView* tcv )
trackContentObject * SampleTrack::createTCO( const midiTime & )
trackContentObject * SampleTrack::createTCO( const MidiTime & )
{
return new SampleTCO( this );
}

View File

@@ -55,7 +55,7 @@ bbTCO::bbTCO( track * _track, unsigned int _color ) :
if( t > 0 )
{
saveJournallingState( false );
changeLength( midiTime( t, 0 ) );
changeLength( MidiTime( t, 0 ) );
restoreJournallingState();
}
}
@@ -192,7 +192,7 @@ void bbTCOView::paintEvent( QPaintEvent * )
tact_t t = engine::getBBTrackContainer()->lengthOfBB(
bbTrack::numOfBBTrack( m_bbTCO->getTrack() ) );
if( m_bbTCO->length() > midiTime::ticksPerTact() && t > 0 )
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
{
for( int x = static_cast<int>( t * pixelsPerTact() );
x < width()-2;
@@ -341,7 +341,7 @@ bbTrack::~bbTrack()
// play _frames frames of given TCO within starting with _start
bool bbTrack::play( const midiTime & _start, const fpp_t _frames,
bool bbTrack::play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _offset, int _tco_num )
{
if( isMuted() )
@@ -362,8 +362,8 @@ bool bbTrack::play( const midiTime & _start, const fpp_t _frames,
return false;
}
midiTime lastPosition;
midiTime lastLen;
MidiTime lastPosition;
MidiTime lastLen;
for( tcoVector::iterator it = tcos.begin(); it != tcos.end(); ++it )
{
if( !( *it )->isMuted() &&
@@ -392,7 +392,7 @@ trackView * bbTrack::createView( TrackContainerView* tcv )
trackContentObject * bbTrack::createTCO( const midiTime & _pos )
trackContentObject * bbTrack::createTCO( const MidiTime & _pos )
{
// if we're creating a new bbTCO, we colorize it according to the
// previous bbTCO, so we have to get all TCOs from 0 to _pos and

View File

@@ -63,7 +63,7 @@ pattern::pattern( InstrumentTrack * _instrument_track ) :
trackContentObject( _instrument_track ),
m_instrumentTrack( _instrument_track ),
m_patternType( BeatPattern ),
m_steps( midiTime::stepsPerTact() ),
m_steps( MidiTime::stepsPerTact() ),
m_frozenPattern( NULL ),
m_freezing( false ),
m_freezeAborted( false )
@@ -127,14 +127,14 @@ void pattern::init()
midiTime pattern::length() const
MidiTime pattern::length() const
{
if( m_patternType == BeatPattern )
{
return beatPatternLength();
}
tick_t max_length = midiTime::ticksPerTact();
tick_t max_length = MidiTime::ticksPerTact();
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
@@ -145,16 +145,16 @@ midiTime pattern::length() const
( *it )->endPos() );
}
}
return midiTime( max_length ).nextFullTact() *
midiTime::ticksPerTact();
return MidiTime( max_length ).nextFullTact() *
MidiTime::ticksPerTact();
}
midiTime pattern::beatPatternLength() const
MidiTime pattern::beatPatternLength() const
{
tick_t max_length = midiTime::ticksPerTact();
tick_t max_length = MidiTime::ticksPerTact();
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
@@ -163,18 +163,18 @@ midiTime pattern::beatPatternLength() const
{
max_length = qMax<tick_t>( max_length,
( *it )->pos() +
midiTime::ticksPerTact() /
midiTime::stepsPerTact() );
MidiTime::ticksPerTact() /
MidiTime::stepsPerTact() );
}
}
if( m_steps != midiTime::stepsPerTact() )
if( m_steps != MidiTime::stepsPerTact() )
{
max_length = m_steps * midiTime::ticksPerTact() /
midiTime::stepsPerTact() ;
max_length = m_steps * MidiTime::ticksPerTact() /
MidiTime::stepsPerTact() ;
}
return midiTime( max_length ).nextFullTact() * midiTime::ticksPerTact();
return MidiTime( max_length ).nextFullTact() * MidiTime::ticksPerTact();
}
@@ -385,7 +385,7 @@ void pattern::loadSettings( const QDomElement & _this )
{
movePosition( _this.attribute( "pos" ).toInt() );
}
changeLength( midiTime( _this.attribute( "len" ).toInt() ) );
changeLength( MidiTime( _this.attribute( "len" ).toInt() ) );
if( _this.attribute( "muted" ).toInt() != isMuted() )
{
toggleMute();
@@ -409,7 +409,7 @@ void pattern::loadSettings( const QDomElement & _this )
m_steps = _this.attribute( "steps" ).toInt();
if( m_steps == 0 )
{
m_steps = midiTime::stepsPerTact();
m_steps = MidiTime::stepsPerTact();
}
ensureBeatNotes();
@@ -487,7 +487,7 @@ void pattern::abortFreeze()
void pattern::addSteps()
{
m_steps += midiTime::stepsPerTact();
m_steps += MidiTime::stepsPerTact();
ensureBeatNotes();
emit dataChanged();
}
@@ -497,7 +497,7 @@ void pattern::addSteps()
void pattern::removeSteps()
{
int _n = midiTime::stepsPerTact();
int _n = MidiTime::stepsPerTact();
if( _n < m_steps )
{
for( int i = m_steps - _n; i < m_steps; ++i )
@@ -506,8 +506,8 @@ void pattern::removeSteps()
it != m_notes.end(); ++it )
{
if( ( *it )->pos() ==
i * midiTime::ticksPerTact() /
midiTime::stepsPerTact() &&
i * MidiTime::ticksPerTact() /
MidiTime::stepsPerTact() &&
( *it )->length() <= 0 )
{
removeNote( *it );
@@ -542,8 +542,8 @@ void pattern::ensureBeatNotes()
it != m_notes.end(); ++it )
{
if( ( *it )->pos() ==
i * midiTime::ticksPerTact() /
midiTime::stepsPerTact() &&
i * MidiTime::ticksPerTact() /
MidiTime::stepsPerTact() &&
( *it )->length() <= 0 )
{
found = true;
@@ -552,9 +552,9 @@ void pattern::ensureBeatNotes()
}
if( found == false )
{
addNote( note( midiTime( 0 ), midiTime( i *
midiTime::ticksPerTact() /
midiTime::stepsPerTact() ) ), false );
addNote( note( MidiTime( 0 ), MidiTime( i *
MidiTime::ticksPerTact() /
MidiTime::stepsPerTact() ) ), false );
}
}
}
@@ -591,17 +591,17 @@ bool pattern::empty()
void pattern::changeTimeSignature()
{
midiTime last_pos = midiTime::ticksPerTact();
MidiTime last_pos = MidiTime::ticksPerTact();
for( NoteVector::ConstIterator cit = m_notes.begin();
cit != m_notes.end(); ++cit )
{
if( ( *cit )->length() < 0 && ( *cit )->pos() > last_pos )
{
last_pos = ( *cit )->pos()+midiTime::ticksPerTact() /
midiTime::stepsPerTact();
last_pos = ( *cit )->pos()+MidiTime::ticksPerTact() /
MidiTime::stepsPerTact();
}
}
last_pos = last_pos.nextFullTact() * midiTime::ticksPerTact();
last_pos = last_pos.nextFullTact() * MidiTime::ticksPerTact();
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); )
{
if( ( *it )->length() == 0 && ( *it )->pos() >= last_pos )
@@ -616,8 +616,8 @@ void pattern::changeTimeSignature()
}
}
m_steps = qMax<tick_t>(
qMax<tick_t>( m_steps, midiTime::stepsPerTact() ),
last_pos.getTact() * midiTime::stepsPerTact() );
qMax<tick_t>( m_steps, MidiTime::stepsPerTact() ),
last_pos.getTact() * MidiTime::stepsPerTact() );
ensureBeatNotes();
}
@@ -970,7 +970,7 @@ void patternView::mouseDoubleClickEvent( QMouseEvent * _me )
if( m_pat->type() == pattern::MelodyPattern ||
!( m_pat->type() == pattern::BeatPattern &&
( pixelsPerTact() >= 192 ||
m_pat->m_steps != midiTime::stepsPerTact() ) &&
m_pat->m_steps != MidiTime::stepsPerTact() ) &&
_me->y() > height() - s_stepBtnOff->height() ) )
{
openInPianoRoll();
@@ -985,7 +985,7 @@ void patternView::mousePressEvent( QMouseEvent * _me )
if( _me->button() == Qt::LeftButton &&
m_pat->m_patternType == pattern::BeatPattern &&
( fixedTCOs() || pixelsPerTact() >= 96 ||
m_pat->m_steps != midiTime::stepsPerTact() ) &&
m_pat->m_steps != MidiTime::stepsPerTact() ) &&
_me->y() > height() - s_stepBtnOff->height() )
{
int step = ( _me->x() - TCO_BORDER_WIDTH ) *
@@ -1033,7 +1033,7 @@ void patternView::wheelEvent( QWheelEvent * _we )
{
if( m_pat->m_patternType == pattern::BeatPattern &&
( fixedTCOs() || pixelsPerTact() >= 96 ||
m_pat->m_steps != midiTime::stepsPerTact() ) &&
m_pat->m_steps != MidiTime::stepsPerTact() ) &&
_we->y() > height() - s_stepBtnOff->height() )
{
int step = ( _we->x() - TCO_BORDER_WIDTH ) *
@@ -1192,9 +1192,9 @@ void patternView::paintEvent( QPaintEvent * )
{
const int x1 = 2 * x_base +
static_cast<int>( ( *it )->pos() * ppt /
midiTime::ticksPerTact() );
MidiTime::ticksPerTact() );
const int x2 =
static_cast<int>( ( ( *it )->pos() + ( *it )->length() ) * ppt / midiTime::ticksPerTact() );
static_cast<int>( ( ( *it )->pos() + ( *it )->length() ) * ppt / MidiTime::ticksPerTact() );
p.drawLine( x1, y_base + y_pos,
x2, y_base + y_pos );
@@ -1205,7 +1205,7 @@ void patternView::paintEvent( QPaintEvent * )
}
else if( m_pat->m_patternType == pattern::BeatPattern &&
( fixedTCOs() || ppt >= 96
|| m_pat->m_steps != midiTime::stepsPerTact() ) )
|| m_pat->m_steps != MidiTime::stepsPerTact() ) )
{
QPixmap stepon;
QPixmap stepoverlay;