changed internal MIDI-time-resolution from 64th to 192th resulting for example in better MIDI-import and allowing to use triplet-notes in LMMS

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@908 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-04-09 22:16:52 +00:00
parent 464913a2c4
commit 2fcd8150d9
27 changed files with 453 additions and 374 deletions

View File

@@ -202,13 +202,13 @@ private:
actions m_action;
Uint32 m_selectStartTact64th;
int m_selectedTact64th;
Uint32 m_selectStartTick;
int m_selectedTick;
int m_selectStartLevel;
int m_selectedLevels;
int m_moveStartLevel;
int m_moveStartTact64th;
int m_moveStartTick;
int m_moveXOffset;
int m_ppt;

View File

@@ -137,11 +137,11 @@ public:
return( s_controllerRackView );
}
static float framesPerTact64th( void )
static float framesPerTick( void )
{
return( s_framesPerTact64th );
return( s_framesPerTick );
}
static void updateFramesPerTact64th( void );
static void updateFramesPerTick( void );
static const QMap<QString, QString> & sampleExtensions( void )
{
@@ -151,7 +151,7 @@ public:
private:
static bool s_hasGUI;
static float s_framesPerTact64th;
static float s_framesPerTick;
// core
static mixer * s_mixer;

View File

@@ -2,7 +2,7 @@
* midi_time.h - declaration of class midiTime which provides data-type for
* position- and length-variables
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -29,19 +29,20 @@
#include "types.h"
const int DefaultTicksPerTact = 192;
class midiTime
{
public:
inline midiTime( const tact _tact, const tact64th _tact_64th ) :
inline midiTime( const tact _tact, const tick _ticks ) :
m_tact( _tact ),
m_tact64th( _tact_64th )
m_ticks( _ticks )
{
}
inline midiTime( const Sint32 _abs = 0 ) :
m_tact( _abs / 64 ),
m_tact64th( _abs % 64 )
inline midiTime( const int _abs = 0 ) :
m_tact( _abs / DefaultTicksPerTact ),
m_ticks( _abs % DefaultTicksPerTact )
{
}
@@ -52,30 +53,31 @@ public:
inline midiTime toNearestTact( void ) const
{
if( m_tact64th >= 32 )
if( m_ticks >= DefaultTicksPerTact/2 )
{
return( m_tact * 64 + 64 );
return( m_tact * DefaultTicksPerTact +
DefaultTicksPerTact );
}
return( m_tact * 64 );
return( m_tact * DefaultTicksPerTact );
}
inline midiTime & operator=( const midiTime & _t )
{
m_tact = _t.m_tact;
m_tact64th = _t.m_tact64th;
m_ticks = _t.m_ticks;
return( *this );
}
inline midiTime & operator+=( const midiTime & _t )
{
return( *this = static_cast<Sint32>( *this ) +
static_cast<Sint32>( _t ) );
return( *this = static_cast<int>( *this ) +
static_cast<int>( _t ) );
}
inline midiTime & operator-=( const midiTime & _t )
{
return( *this = static_cast<Sint32>( *this ) -
static_cast<Sint32>( _t ) );
return( *this = static_cast<int>( *this ) -
static_cast<int>( _t ) );
}
inline void setTact( tact _t )
@@ -88,46 +90,47 @@ public:
return( m_tact );
}
inline void setTact64th( tact64th _t )
inline void setTicks( tick _t )
{
m_tact64th = _t;
m_ticks = _t;
}
inline tact64th getTact64th( void ) const
inline tick getTicks( void ) const
{
return( m_tact64th );
return( m_ticks );
}
// converts time-class in an absolute value, useful for calculations,
// comparisons and so on...
inline operator Sint32( void ) const
inline operator int( void ) const
{
return( static_cast<Sint32>( m_tact ) * 64 +
static_cast<Sint32>( m_tact64th ) );
return( static_cast<int>( m_tact ) * DefaultTicksPerTact +
static_cast<int>( m_ticks ) );
}
// calculate number of frame that are needed this time
inline f_cnt_t frames( const float _frames_per_tact64th ) const
inline f_cnt_t frames( const float _frames_per_tick ) const
{
if( m_tact >= 0 )
{
return( static_cast<f_cnt_t>( ( m_tact * 64
+ m_tact64th ) * _frames_per_tact64th ) );
return( static_cast<f_cnt_t>(
( m_tact * DefaultTicksPerTact + m_ticks ) *
_frames_per_tick ) );
}
return( 0 );
}
static inline midiTime fromFrames( const f_cnt_t _frames,
const float _frames_per_tact64th )
const float _frames_per_tick )
{
return( midiTime( static_cast<Sint32>( _frames /
_frames_per_tact64th ) ) );
return( midiTime( static_cast<int>( _frames /
_frames_per_tick ) ) );
}
private:
tact m_tact;
tact64th m_tact64th;
tick m_ticks;
} ;

View File

@@ -48,7 +48,7 @@ class sampleBuffer;
const int DEFAULT_STEPS_PER_TACT = 16;
const int BEATS_PER_TACT = 4;
const int BEATS_PER_TACT = DefaultTicksPerTact/DEFAULT_STEPS_PER_TACT;

View File

@@ -213,13 +213,13 @@ private:
note * m_currentNote;
actions m_action;
Uint32 m_selectStartTact64th;
int m_selectedTact64th;
Uint32 m_selectStartTick;
int m_selectedTick;
int m_selectStartKey;
int m_selectedKeys;
int m_moveStartKey;
int m_moveStartTact64th;
int m_moveStartTick;
int m_moveXOffset;
int m_notesEditHeight;

View File

@@ -210,7 +210,7 @@ private slots:
void doActions( void );
void updateFramesPerTact64th( void );
void updateFramesPerTick( void );
@@ -225,12 +225,11 @@ private:
return( m_playPos[m_playMode].getTact() );
}
inline tact64th currentTact64th( void ) const
inline tick currentTick( void ) const
{
return( m_playPos[m_playMode].getTact64th() );
return( m_playPos[m_playMode].getTicks() );
}
void setPlayPos( tact _tact_num, tact64th _t_64th, PlayModes
_play_mode );
void setPlayPos( tact _tact_num, tick _tick, PlayModes _play_mode );

View File

@@ -139,7 +139,7 @@ private:
inline int markerX( const midiTime & _t ) const
{
return( m_xOffset + static_cast<int>( ( _t - m_begin ) *
m_ppt / 64.0f ) );
m_ppt / DefaultTicksPerTact ) );
}

View File

@@ -39,7 +39,7 @@ typedef signed int Sint32;
typedef Uint32 minute;
typedef Sint8 second;
typedef Sint32 tact;
typedef Sint8 tact64th;
typedef Sint16 tick;
typedef Uint8 volume;
typedef Sint8 panning;