frames computation based on 64th of a tact, fixes BB-pattern arbitrary positioning in song editor
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@281 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -105,16 +105,16 @@ public:
|
||||
|
||||
void close( void );
|
||||
|
||||
float framesPerTact( void ) const
|
||||
float framesPerTact64th( void ) const
|
||||
{
|
||||
return( m_frames_per_tact );
|
||||
return( m_frames_per_tact64th );
|
||||
}
|
||||
void updateFramesPerTact( void );
|
||||
void updateFramesPerTact64th( void );
|
||||
|
||||
|
||||
private:
|
||||
bool m_hasGUI;
|
||||
float m_frames_per_tact;
|
||||
float m_frames_per_tact64th;
|
||||
|
||||
mixer * m_mixer;
|
||||
mainWindow * m_mainWindow;
|
||||
|
||||
@@ -107,24 +107,21 @@ public:
|
||||
}
|
||||
|
||||
// calculate number of frame that are needed this time
|
||||
inline f_cnt_t frames( const float _frames_per_tact ) const
|
||||
inline f_cnt_t frames( const float _frames_per_tact64th ) const
|
||||
{
|
||||
if( m_tact >= 0 )
|
||||
{
|
||||
return( static_cast<f_cnt_t>( m_tact *
|
||||
_frames_per_tact +
|
||||
m_tact64th *
|
||||
_frames_per_tact /
|
||||
64.0f ) );
|
||||
return( static_cast<f_cnt_t>( ( m_tact * 64
|
||||
+ m_tact64th ) * _frames_per_tact64th ) );
|
||||
}
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static inline midiTime fromFrames( const f_cnt_t _frames,
|
||||
const float _frames_per_tact )
|
||||
const float _frames_per_tact64th )
|
||||
{
|
||||
return( midiTime( static_cast<Sint32>( _frames * 64.0f /
|
||||
_frames_per_tact ) ) );
|
||||
return( midiTime( static_cast<Sint32>( _frames /
|
||||
_frames_per_tact64th ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -106,10 +106,10 @@ void engine::close( void )
|
||||
|
||||
|
||||
|
||||
void engine::updateFramesPerTact( void )
|
||||
void engine::updateFramesPerTact64th( void )
|
||||
{
|
||||
m_frames_per_tact = m_mixer->sampleRate() * 60.0f * BEATS_PER_TACT
|
||||
/ m_songEditor->getTempo();
|
||||
m_frames_per_tact64th = m_mixer->sampleRate() * 60.0f * BEATS_PER_TACT
|
||||
/ 64.0f / m_songEditor->getTempo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ notePlayHandle::notePlayHandle( instrumentTrack * _it,
|
||||
(Uint16) ( ( getVolume() / 100.0f ) *
|
||||
( m_instrumentTrack->getVolume() / 100.0f ) *
|
||||
127 ), 0, 127 ) ),
|
||||
midiTime::fromFrames( m_framesAhead,
|
||||
m_instrumentTrack->eng()->framesPerTact() ) );
|
||||
midiTime::fromFrames( m_framesAhead, m_instrumentTrack
|
||||
->eng()->framesPerTact64th() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -277,9 +277,9 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
|
||||
m_instrumentTrack->processOutEvent( midiEvent( NOTE_OFF,
|
||||
m_instrumentTrack->m_midiPort->outputChannel(),
|
||||
key(), 0 ),
|
||||
midiTime::fromFrames(
|
||||
m_framesBeforeRelease,
|
||||
m_instrumentTrack->eng()->framesPerTact() ) );
|
||||
midiTime::fromFrames( m_framesBeforeRelease,
|
||||
m_instrumentTrack->eng()
|
||||
->framesPerTact64th() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -384,8 +384,8 @@ bool FASTCALL bbTrack::play( const midiTime & _start,
|
||||
}
|
||||
|
||||
vlist<trackContentObject *> tcos;
|
||||
getTCOsInRange( tcos, _start, _start +static_cast<Sint32>( _frames *
|
||||
64 / eng()->framesPerTact() ) );
|
||||
getTCOsInRange( tcos, _start, _start + static_cast<Sint32>( _frames /
|
||||
eng()->framesPerTact64th() ) );
|
||||
|
||||
if ( tcos.size() == 0 )
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@ void FASTCALL sampleTCO::play( sampleFrame * _ab, f_cnt_t _start_frame,
|
||||
{
|
||||
_start_frame = static_cast<Uint32>( tMax( 0.0f, _start_frame -
|
||||
startPosition() *
|
||||
eng()->framesPerTact() / 64 ) );
|
||||
eng()->framesPerTact64th() ) );
|
||||
m_sampleBuffer.play( _ab, _start_frame, _frames );
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ void sampleTCO::paintEvent( QPaintEvent * _pe )
|
||||
midiTime sampleTCO::getSampleLength( void ) const
|
||||
{
|
||||
return( static_cast<Sint32>( m_sampleBuffer.frames() /
|
||||
eng()->framesPerTact() * 64 ) );
|
||||
eng()->framesPerTact64th() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -443,8 +443,8 @@ bool FASTCALL sampleTrack::play( const midiTime & _start,
|
||||
sendMidiTime( _start );
|
||||
|
||||
vlist<trackContentObject *> tcos;
|
||||
getTCOsInRange( tcos, _start, _start+static_cast<Sint32>( _frames * 64 /
|
||||
eng()->framesPerTact() ) );
|
||||
getTCOsInRange( tcos, _start, _start+static_cast<Sint32>( _frames /
|
||||
eng()->framesPerTact64th() ) );
|
||||
|
||||
if ( tcos.size() == 0 )
|
||||
{
|
||||
@@ -458,7 +458,7 @@ bool FASTCALL sampleTrack::play( const midiTime & _start,
|
||||
, m_volume, m_volume
|
||||
#endif
|
||||
} ;
|
||||
float fpt = eng()->framesPerTact();
|
||||
float fpt64th = eng()->framesPerTact64th();
|
||||
|
||||
for( vlist<trackContentObject *>::iterator it = tcos.begin();
|
||||
it != tcos.end(); ++it )
|
||||
@@ -467,15 +467,11 @@ bool FASTCALL sampleTrack::play( const midiTime & _start,
|
||||
if( st != NULL && !st->muted() )
|
||||
{
|
||||
st->play( buf, _start_frame +
|
||||
static_cast<Uint32>( _start.getTact() *
|
||||
fpt ),
|
||||
static_cast<Uint32>( _start * fpt64th ),
|
||||
_frames );
|
||||
eng()->getMixer()->bufferToPort( buf, _frames,
|
||||
_frame_base +
|
||||
static_cast<Uint32>(
|
||||
st->startPosition().getTact64th() *
|
||||
fpt / 64.0f ), v,
|
||||
m_audioPort );
|
||||
_frame_base, v,
|
||||
m_audioPort );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user