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:
@@ -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() )
|
||||
{
|
||||
|
||||
@@ -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 ),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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() )
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user