introduced engine-technology

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@81 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-02-10 10:48:27 +00:00
parent 94d5107450
commit 5fd05b16e4
130 changed files with 2528 additions and 1260 deletions

View File

@@ -54,10 +54,12 @@
audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful ) :
audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, tLimit<ch_cnt_t>(
configManager::inst()->value( "audioalsa", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ) ),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
m_handle( NULL ),
m_hwParams( NULL ),
m_swParams( NULL ),
@@ -213,9 +215,9 @@ void audioALSA::run( void )
{
surroundSampleFrame * temp =
bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() );
getMixer()->framesPerAudioBuffer() );
int_sample_t * outbuf = bufferAllocator::alloc<int_sample_t>(
mixer::inst()->framesPerAudioBuffer() *
getMixer()->framesPerAudioBuffer() *
channels() );
m_quit = FALSE;
@@ -223,7 +225,7 @@ void audioALSA::run( void )
{
const f_cnt_t frames = getNextBuffer( temp );
convertToS16( temp, frames, mixer::inst()->masterGain(), outbuf,
convertToS16( temp, frames, getMixer()->masterGain(), outbuf,
m_littleEndian != isLittleEndian() );
f_cnt_t frame = 0;
@@ -336,7 +338,7 @@ int audioALSA::setHWParams( const sample_rate_t _sample_rate,
}
}
m_periodSize = mixer::inst()->framesPerAudioBuffer();
m_periodSize = getMixer()->framesPerAudioBuffer();
m_bufferSize = m_periodSize * 8;
dir = 0;
err = snd_pcm_hw_params_set_period_size_near( m_handle, m_hwParams,

View File

@@ -37,11 +37,12 @@
audioDevice::audioDevice( const sample_rate_t _sample_rate,
const ch_cnt_t _channels ) :
const ch_cnt_t _channels, mixer * _mixer ) :
m_sampleRate( _sample_rate ),
m_channels( _channels ),
m_mixer( _mixer ),
m_buffer( bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() ) )
getMixer()->framesPerAudioBuffer() ) )
{
#ifdef HAVE_SAMPLERATE_H
int error;
@@ -77,7 +78,7 @@ audioDevice::~audioDevice()
void audioDevice::processNextBuffer( void )
{
const fpab_t frames = getNextBuffer( m_buffer );
writeBuffer( m_buffer, frames, mixer::inst()->masterGain() );
writeBuffer( m_buffer, frames, getMixer()->masterGain() );
}
@@ -85,18 +86,18 @@ void audioDevice::processNextBuffer( void )
fpab_t audioDevice::getNextBuffer( surroundSampleFrame * _ab )
{
fpab_t frames = mixer::inst()->framesPerAudioBuffer();
const surroundSampleFrame * b = mixer::inst()->renderNextBuffer();
fpab_t frames = getMixer()->framesPerAudioBuffer();
const surroundSampleFrame * b = getMixer()->renderNextBuffer();
// make sure, no other thread is accessing device
lock();
// now were safe to access the device
if( mixer::inst()->sampleRate() != m_sampleRate )
if( getMixer()->sampleRate() != m_sampleRate )
{
resample( b, frames, _ab, mixer::inst()->sampleRate(),
resample( b, frames, _ab, getMixer()->sampleRate(),
m_sampleRate );
frames = frames * m_sampleRate / mixer::inst()->sampleRate();
frames = frames * m_sampleRate / getMixer()->sampleRate();
}
else
{

View File

@@ -48,8 +48,9 @@ audioFileDevice::audioFileDevice( const sample_rate_t _sample_rate,
const bool _use_vbr,
const bitrate_t _nom_bitrate,
const bitrate_t _min_bitrate,
const bitrate_t _max_bitrate ) :
audioDevice( _sample_rate, _channels),
const bitrate_t _max_bitrate,
mixer * _mixer ) :
audioDevice( _sample_rate, _channels, _mixer ),
m_outputFile( _file ),
m_useVbr( _use_vbr ),
m_nomBitrate( _nom_bitrate ),

View File

@@ -46,9 +46,10 @@ audioFileOgg::audioFileOgg( const sample_rate_t _sample_rate,
const bool _use_vbr,
const bitrate_t _nom_bitrate,
const bitrate_t _min_bitrate,
const bitrate_t _max_bitrate ) :
const bitrate_t _max_bitrate,
mixer * _mixer ) :
audioFileDevice( _sample_rate, _channels, _file, _use_vbr,
_nom_bitrate, _min_bitrate, _max_bitrate )
_nom_bitrate, _min_bitrate, _max_bitrate, _mixer )
{
_success_ful = startEncoding();
}

View File

@@ -38,9 +38,10 @@ audioFileWave::audioFileWave( const sample_rate_t _sample_rate,
const bool _use_vbr,
const bitrate_t _nom_bitrate,
const bitrate_t _min_bitrate,
const bitrate_t _max_bitrate ) :
const bitrate_t _max_bitrate,
mixer * _mixer ) :
audioFileDevice( _sample_rate, _channels, _file, _use_vbr,
_nom_bitrate, _min_bitrate, _max_bitrate )
_nom_bitrate, _min_bitrate, _max_bitrate, _mixer )
{
_success_ful = startEncoding();
}

View File

@@ -56,15 +56,17 @@
audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) :
audioJACK::audioJACK( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, tLimit<int>( configManager::inst()->value(
"audiojack", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ) ),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
m_client( NULL ),
m_stopped( FALSE ),
m_processCallbackMutex(),
m_outBuf( bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() ) ),
getMixer()->framesPerAudioBuffer() ) ),
m_framesDoneInCurBuf( 0 ),
m_framesToDoInCurBuf( 0 )
{
@@ -177,7 +179,7 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) :
// try to sync JACK's and LMMS's buffer-size
jack_set_buffer_size( m_client, mixer::inst()->framesPerAudioBuffer() );
jack_set_buffer_size( m_client, getMixer()->framesPerAudioBuffer() );
@@ -346,7 +348,7 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata )
}
/* const Uint32 frames = tMin<Uint32>( _nframes,
mixer::inst()->framesPerAudioBuffer() );
getMixer()->framesPerAudioBuffer() );
for( jackPortMap::iterator it = _this->m_portMap.begin();
it != _this->m_portMap.end(); ++it )
{
@@ -382,7 +384,7 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata )
{
outbufs[chnl][done+frame] =
_this->m_outBuf[_this->m_framesDoneInCurBuf+frame][chnl] *
mixer::inst()->masterGain();
_this->getMixer()->masterGain();
}
}
}

View File

@@ -91,10 +91,12 @@
audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful ) :
audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, tLimit<ch_cnt_t>(
configManager::inst()->value( "audiooss", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ) ),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
m_convertEndian( FALSE ),
m_quit( FALSE )
{
@@ -125,7 +127,7 @@ audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful ) :
int frag_spec;
for( frag_spec = 0; static_cast<int>( 0x01 << frag_spec ) <
mixer::inst()->framesPerAudioBuffer() * channels() *
getMixer()->framesPerAudioBuffer() * channels() *
BYTES_PER_INT_SAMPLE;
++frag_spec )
{
@@ -316,9 +318,9 @@ void audioOSS::run( void )
{
surroundSampleFrame * temp =
bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() );
getMixer()->framesPerAudioBuffer() );
int_sample_t * outbuf = bufferAllocator::alloc<int_sample_t>(
mixer::inst()->framesPerAudioBuffer() *
getMixer()->framesPerAudioBuffer() *
channels() );
m_quit = FALSE;
@@ -327,7 +329,7 @@ void audioOSS::run( void )
const Uint32 frames = getNextBuffer( temp );
int bytes = convertToS16( temp, frames,
mixer::inst()->masterGain(), outbuf,
getMixer()->masterGain(), outbuf,
m_convertEndian );
write( m_audioFD, outbuf, bytes );
}

View File

@@ -1,7 +1,7 @@
/*
* audio_port.cpp - base-class for objects providing sound at a port
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -28,21 +28,22 @@
#include "buffer_allocator.h"
audioPort::audioPort( const QString & _name ) :
audioPort::audioPort( const QString & _name, engine * _engine ) :
engineObject( _engine ),
m_bufferUsage( NONE ),
m_firstBuffer( bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() ) ),
eng()->getMixer()->framesPerAudioBuffer() ) ),
m_secondBuffer( bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() ) ),
eng()->getMixer()->framesPerAudioBuffer() ) ),
m_extOutputEnabled( FALSE ),
m_nextFxChannel( -1 ),
m_name( "unnamed port" )
{
mixer::inst()->clearAudioBuffer( m_firstBuffer,
mixer::inst()->framesPerAudioBuffer() );
mixer::inst()->clearAudioBuffer( m_secondBuffer,
mixer::inst()->framesPerAudioBuffer() );
mixer::inst()->addAudioPort( this );
eng()->getMixer()->clearAudioBuffer( m_firstBuffer,
eng()->getMixer()->framesPerAudioBuffer() );
eng()->getMixer()->clearAudioBuffer( m_secondBuffer,
eng()->getMixer()->framesPerAudioBuffer() );
eng()->getMixer()->addAudioPort( this );
setExtOutputEnabled( TRUE );
}
@@ -51,10 +52,10 @@ audioPort::audioPort( const QString & _name ) :
audioPort::~audioPort()
{
mixer::inst()->removeAudioPort( this );
eng()->getMixer()->removeAudioPort( this );
if( m_extOutputEnabled == TRUE )
{
mixer::inst()->audioDev()->unregisterPort( this );
eng()->getMixer()->audioDev()->unregisterPort( this );
}
bufferAllocator::free( m_firstBuffer );
bufferAllocator::free( m_secondBuffer );
@@ -65,8 +66,8 @@ audioPort::~audioPort()
void audioPort::nextPeriod( void )
{
mixer::inst()->clearAudioBuffer( m_firstBuffer,
mixer::inst()->framesPerAudioBuffer() );
eng()->getMixer()->clearAudioBuffer( m_firstBuffer,
eng()->getMixer()->framesPerAudioBuffer() );
qSwap( m_firstBuffer, m_secondBuffer );
// this is how we decrease state of buffer-usage ;-)
m_bufferUsage = ( m_bufferUsage != NONE ) ?
@@ -83,11 +84,11 @@ void audioPort::setExtOutputEnabled( bool _enabled )
m_extOutputEnabled = _enabled;
if( m_extOutputEnabled )
{
mixer::inst()->audioDev()->registerPort( this );
eng()->getMixer()->audioDev()->registerPort( this );
}
else
{
mixer::inst()->audioDev()->unregisterPort( this );
eng()->getMixer()->audioDev()->unregisterPort( this );
}
}
}
@@ -98,6 +99,6 @@ void audioPort::setExtOutputEnabled( bool _enabled )
void audioPort::setName( const QString & _name )
{
m_name = _name;
mixer::inst()->audioDev()->renamePort( this );
eng()->getMixer()->audioDev()->renamePort( this );
}

View File

@@ -35,8 +35,9 @@
audioSampleRecorder::audioSampleRecorder( const sample_rate_t _sample_rate,
const ch_cnt_t _channels,
bool & _success_ful ) :
audioDevice( _sample_rate, _channels ),
bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, _channels, _mixer ),
m_buffers()
{
_success_ful = TRUE;
@@ -57,9 +58,9 @@ audioSampleRecorder::~audioSampleRecorder()
Uint32 audioSampleRecorder::framesRecorded( void ) const
f_cnt_t audioSampleRecorder::framesRecorded( void ) const
{
Uint32 frames = 0;
f_cnt_t frames = 0;
for( bufferList::const_iterator it = m_buffers.begin();
it != m_buffers.end(); ++it )
{
@@ -72,9 +73,8 @@ Uint32 audioSampleRecorder::framesRecorded( void ) const
void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf )
const
{
f_cnt_t frames = framesRecorded();
const f_cnt_t frames = framesRecorded();
// create buffer to store all recorded buffers in
sampleFrame * data = bufferAllocator::alloc<sampleFrame>( frames );
// make sure buffer is cleaned up properly at the end...
@@ -92,7 +92,7 @@ void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf )
data += ( *it ).second;
}
// create according sample-buffer out of big buffer
*_sample_buf = new sampleBuffer( ac.ptr(), frames );
*_sample_buf = new sampleBuffer( ac.ptr(), frames, getMixer()->eng() );
}

View File

@@ -1,7 +1,7 @@
/*
* audio_sdl.cpp - device-class that performs PCM-output via SDL
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -48,10 +48,11 @@
audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful ) :
audioDevice( _sample_rate, DEFAULT_CHANNELS ),
audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, DEFAULT_CHANNELS, _mixer ),
m_outBuf( bufferAllocator::alloc<surroundSampleFrame>(
mixer::inst()->framesPerAudioBuffer() ) ),
getMixer()->framesPerAudioBuffer() ) ),
m_convertEndian( FALSE )
{
_success_ful = FALSE;
@@ -81,7 +82,7 @@ audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful ) :
// of system, so we don't have
// to convert the buffers
m_audioHandle.channels = channels();
m_audioHandle.samples = mixer::inst()->framesPerAudioBuffer();
m_audioHandle.samples = getMixer()->framesPerAudioBuffer();
m_audioHandle.callback = sdlAudioCallback;
m_audioHandle.userdata = this;
@@ -145,7 +146,7 @@ void audioSDL::sdlAudioCallback( void * _udata, Uint8 * _buf, int _len )
const fpab_t frames = _this->getNextBuffer( _this->m_outBuf );
_this->convertToS16( _this->m_outBuf, frames,
mixer::inst()->masterGain(),
_this->getMixer()->masterGain(),
(int_sample_t *)( _buf ),
_this->m_convertEndian );
}
@@ -171,7 +172,6 @@ audioSDL::setupWidget::setupWidget( QWidget * _parent ) :
audioSDL::setupWidget::~setupWidget()
{
}

View File

@@ -200,6 +200,7 @@ const int ARP_GROUPBOX_HEIGHT = 240 - ARP_GROUPBOX_Y;
arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
QWidget( _channel_track->tabWidgetParent() ),
settings(),
engineObject( _channel_track->eng() ),
m_arpDirection( UP )
{
m_chordsGroupBox = new groupBox( tr( "CHORDS" ), this );
@@ -221,7 +222,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
}
m_chordRangeKnob = new knob( knobBright_26, m_chordsGroupBox,
tr( "Chord range" ) );
tr( "Chord range" ), eng() );
m_chordRangeKnob->setLabel( tr( "RANGE" ) );
m_chordRangeKnob->setRange( 1.0, 9.0, 1.0 );
m_chordRangeKnob->setValue( 1.0, TRUE );
@@ -273,7 +274,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
m_arpRangeKnob = new knob( knobBright_26, m_arpGroupBox,
tr( "Arpeggio range" ) );
tr( "Arpeggio range" ), eng() );
m_arpRangeKnob->setLabel( tr( "RANGE" ) );
m_arpRangeKnob->setRange( 1.0, 9.0, 1.0 );
m_arpRangeKnob->setValue( 1.0, TRUE );
@@ -290,7 +291,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
"amount of octaves." ) );
m_arpTimeKnob = new tempoSyncKnob( knobBright_26, m_arpGroupBox,
tr( "Arpeggio time" ) );
tr( "Arpeggio time" ), eng() );
m_arpTimeKnob->setLabel( tr( "TIME" ) );
m_arpTimeKnob->setRange( 10.0, 1000.0, 1.0 );
m_arpTimeKnob->setValue( 100.0, TRUE );
@@ -307,7 +308,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
"each arpeggio-tone should be played." ) );
m_arpGateKnob = new knob( knobBright_26, m_arpGroupBox,
tr( "Arpeggio gate" ) );
tr( "Arpeggio gate" ), eng() );
m_arpGateKnob->setLabel( tr( "GATE" ) );
m_arpGateKnob->setRange( 1.0, 200.0, 1.0 );
m_arpGateKnob->setValue( 100.0, TRUE );
@@ -511,9 +512,9 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
const int total_range = range * cnphv.size();
// number of frames that every note should be played
const Uint32 arp_frames = (Uint32)( m_arpTimeKnob->value() / 1000.0f *
mixer::inst()->sampleRate() );
const Uint32 gated_frames = (Uint32)( m_arpGateKnob->value() *
const f_cnt_t arp_frames = (f_cnt_t)( m_arpTimeKnob->value() / 1000.0f *
eng()->getMixer()->sampleRate() );
const f_cnt_t gated_frames = (f_cnt_t)( m_arpGateKnob->value() *
arp_frames / 100.0f );
// used for calculating remaining frames for arp-note, we have to add
@@ -524,15 +525,15 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
_n->totalFramesPlayed() )
+ arp_frames - 1;
// used for loop
Uint32 frames_processed = 0;
fpab_t frames_processed = 0;
while( frames_processed < mixer::inst()->framesPerAudioBuffer() )
while( frames_processed < eng()->getMixer()->framesPerAudioBuffer() )
{
const Uint32 remaining_frames_for_cur_arp = arp_frames -
const f_cnt_t remaining_frames_for_cur_arp = arp_frames -
( cur_frame % arp_frames );
// does current arp-note fill whole audio-buffer?
if( remaining_frames_for_cur_arp >
mixer::inst()->framesPerAudioBuffer() )
eng()->getMixer()->framesPerAudioBuffer() )
{
// then we don't have to do something!
break;
@@ -721,7 +722,7 @@ void arpAndChordsTabWidget::arpUpToggled( bool _on )
{
m_arpDirection = UP;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -733,7 +734,7 @@ void arpAndChordsTabWidget::arpDownToggled( bool _on )
{
m_arpDirection = DOWN;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -745,7 +746,7 @@ void arpAndChordsTabWidget::arpUpAndDownToggled( bool _on )
{
m_arpDirection = UP_AND_DOWN;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -757,7 +758,7 @@ void arpAndChordsTabWidget::arpRandomToggled( bool _on )
{
m_arpDirection = RANDOM;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}

View File

@@ -36,6 +36,7 @@
#include <qpainter.h>
#include <qlayout.h>
#include <qwhatsthis.h>
#endif
@@ -51,19 +52,16 @@
#include "debug.h"
#include "tooltip.h"
#include "combobox.h"
#include "main_window.h"
const int BBE_PPT = 192;
bbEditor * bbEditor::s_instanceOfMe = NULL;
bbEditor::bbEditor() :
trackContainer()
bbEditor::bbEditor( engine * _engine ) :
trackContainer( _engine )
{
// create toolbar
m_toolBar = new QWidget( this );
@@ -88,7 +86,7 @@ bbEditor::bbEditor() :
setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH +
BBE_PPT + 2 * TCO_BORDER_WIDTH +
DEFAULT_SCROLLBAR_SIZE );
if( lmmsMainWin::inst()->workspace() != NULL )
if( eng()->getMainWindow()->workspace() != NULL )
{
setGeometry( 10, 340, minimumWidth(), 300 );
}
@@ -178,9 +176,9 @@ void bbEditor::setCurrentBB( int _bb )
// now update all track-labels (the current one has to become white,
// the others green)
for( csize i = 0; i < bbEditor::inst()->numOfBBs(); ++i )
for( csize i = 0; i < numOfBBs(); ++i )
{
bbTrack::findBBTrack( i )->trackLabel()->update();
bbTrack::findBBTrack( i, eng() )->trackLabel()->update();
}
emit positionChanged( m_currentPosition = midiTime(
@@ -244,7 +242,7 @@ bool FASTCALL bbEditor::play( midiTime _start, Uint32 _start_frame,
csize bbEditor::numOfBBs( void ) const
{
return( songEditor::inst()->countTracks( track::BB_TRACK ) );
return( eng()->getSongEditor()->countTracks( track::BB_TRACK ) );
}
@@ -275,7 +273,7 @@ void bbEditor::removeBB( csize _bb )
void bbEditor::updateBBTrack( trackContentObject * _tco )
{
bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64 );
bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64, eng() );
if( t != NULL )
{
t->getTrackContentWidget()->updateTCOs();
@@ -291,7 +289,7 @@ void bbEditor::updateComboBox( void )
for( csize i = 0; i < numOfBBs(); ++i )
{
bbTrack * bbt = bbTrack::findBBTrack( i );
bbTrack * bbt = bbTrack::findBBTrack( i, eng() );
m_bbComboBox->addItem( bbt->trackLabel()->text(),
bbt->trackLabel()->pixmap() );
}
@@ -316,7 +314,7 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke )
{
if ( _ke->key() == Qt::Key_Space )
{
if( songEditor::inst()->playing() )
if( eng()->getSongEditor()->playing() )
{
stop();
}
@@ -374,31 +372,31 @@ QRect bbEditor::scrollAreaRect( void ) const
void bbEditor::play( void )
{
if( songEditor::inst()->playing() )
if( eng()->getSongEditor()->playing() )
{
if( songEditor::inst()->playMode() != songEditor::PLAY_BB )
if( eng()->getSongEditor()->playMode() != songEditor::PLAY_BB )
{
songEditor::inst()->stop();
songEditor::inst()->playBB();
eng()->getSongEditor()->stop();
eng()->getSongEditor()->playBB();
m_playButton->setIcon( embed::getIconPixmap(
"pause" ) );
}
else
{
songEditor::inst()->pause();
eng()->getSongEditor()->pause();
m_playButton->setIcon( embed::getIconPixmap(
"play" ) );
}
}
else if( songEditor::inst()->paused() )
else if( eng()->getSongEditor()->paused() )
{
songEditor::inst()->resumeFromPause();
eng()->getSongEditor()->resumeFromPause();
m_playButton->setIcon( embed::getIconPixmap( "pause" ) );
}
else
{
m_playButton->setIcon( embed::getIconPixmap( "pause" ) );
songEditor::inst()->playBB();
eng()->getSongEditor()->playBB();
}
}
@@ -408,7 +406,7 @@ void bbEditor::play( void )
void bbEditor::stop( void )
{
songEditor::inst()->stop();
eng()->getSongEditor()->stop();
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
m_playButton->update();
}

View File

@@ -1,8 +1,8 @@
/*
* envelope_widget.cpp - widget which is m_used by envelope/lfo/filter-tab of
* channel-window
* envelope_and_lfo_widget.cpp - widget which is m_used by envelope/lfo/filter-
* tab of channel-window
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -100,12 +100,15 @@ const int LFO_SHAPES_Y = LFO_GRAPH_Y + 50;
QPixmap * envelopeAndLFOWidget::s_envGraph = NULL;
QPixmap * envelopeAndLFOWidget::s_lfoGraph = NULL;
Uint32 envelopeAndLFOWidget::s_lfoFrame = 0;
QMap<engine *, vvector<envelopeAndLFOWidget *> >
envelopeAndLFOWidget::s_EaLWidgets;
envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
QWidget * _parent ) :
QWidget * _parent,
engine * _engine ) :
QWidget( _parent ),
settings(),
#ifdef QT4
@@ -113,12 +116,15 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
#else
specialBgHandlingWidget( paletteBackgroundColor() ),
#endif
engineObject( _engine ),
m_used( FALSE ),
m_valueForZeroAmount( _value_for_zero_amount ),
m_pahdEnv( NULL ),
m_rEnv( NULL ),
m_lfoFrame( 0 ),
m_lfoAmountIsZero( FALSE ),
m_lfoShapeData( NULL ),
m_userWave( eng() ),
m_lfoShape( SIN ),
m_busy( FALSE )
{
@@ -132,7 +138,11 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
s_lfoGraph = new QPixmap( embed::getIconPixmap( "lfo_graph" ) );
}
m_predelayKnob = new knob( knobBright_26, this, tr( "Predelay-time" ) );
s_EaLWidgets[eng()].push_back( this );
m_predelayKnob = new knob( knobBright_26, this, tr( "Predelay-time" ),
eng() );
m_predelayKnob->setLabel( tr( "DEL" ) );
m_predelayKnob->setRange( 0.0, 1.0, 0.001 );
m_predelayKnob->setValue( 0.0, TRUE );
@@ -149,7 +159,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
connect( m_predelayKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( updateAfterKnobChange( float ) ) );
m_attackKnob = new knob( knobBright_26, this, tr( "Attack-time" ) );
m_attackKnob = new knob( knobBright_26, this, tr( "Attack-time" ),
eng() );
m_attackKnob->setLabel( tr( "ATT" ) );
m_attackKnob->setRange( 0.0, 1.0, 0.001 );
m_attackKnob->setValue( 0.0, TRUE );
@@ -168,7 +179,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
connect( m_attackKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( updateAfterKnobChange( float ) ) );
m_holdKnob = new knob( knobBright_26, this, tr( "Hold-time" ) );
m_holdKnob = new knob( knobBright_26, this, tr( "Hold-time" ), eng() );
m_holdKnob->setLabel( tr( "HOLD" ) );
m_holdKnob->setRange( 0.0, 1.0, 0.001 );
m_holdKnob->setValue( 0.5, TRUE );
@@ -186,7 +197,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
connect( m_holdKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( updateAfterKnobChange( float ) ) );
m_decayKnob = new knob( knobBright_26, this, tr( "Decay-time" ) );
m_decayKnob = new knob( knobBright_26, this, tr( "Decay-time" ),
eng() );
m_decayKnob->setLabel( tr( "DEC" ) );
m_decayKnob->setRange( 0.0, 1.0, 0.001 );
m_decayKnob->setValue( 0.5, TRUE );
@@ -205,7 +217,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
connect( m_decayKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( updateAfterKnobChange( float ) ) );
m_sustainKnob = new knob( knobBright_26, this, tr( "Sustain-level" ) );
m_sustainKnob = new knob( knobBright_26, this, tr( "Sustain-level" ),
eng() );
m_sustainKnob->setLabel( tr( "SUST" ) );
m_sustainKnob->setRange( 0.0, 1.0, 0.001 );
m_sustainKnob->setValue( 0.5, TRUE );
@@ -223,7 +236,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
connect( m_sustainKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( updateAfterKnobChange( float ) ) );
m_releaseKnob = new knob( knobBright_26, this, tr( "Release-time" ) );
m_releaseKnob = new knob( knobBright_26, this, tr( "Release-time" ),
eng() );
m_releaseKnob->setLabel( tr( "REL" ) );
m_releaseKnob->setRange( 0.0, 1.0, 0.001 );
m_releaseKnob->setValue( 0.1, TRUE );
@@ -243,7 +257,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
SLOT( updateAfterKnobChange( float ) ) );
m_amountKnob = new knob( knobBright_26, this,
tr( "Modulation amount" ) );
tr( "Modulation amount" ), eng() );
m_amountKnob->setLabel( tr( "AMT" ) );
m_amountKnob->setRange( -1.0, 1.0, 0.005 );
m_amountKnob->setValue( 0.0, TRUE );
@@ -264,7 +278,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
m_lfoPredelayKnob = new knob( knobBright_26, this,
tr( "LFO-predelay-time" ) );
tr( "LFO-predelay-time" ), eng() );
m_lfoPredelayKnob->setLabel( tr( "DEL" ) );
m_lfoPredelayKnob->setRange( 0.0, 1.0, 0.001 );
m_lfoPredelayKnob->setValue( 0.0, TRUE );
@@ -282,7 +296,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
SLOT( updateAfterKnobChange( float ) ) );
m_lfoAttackKnob = new knob( knobBright_26, this,
tr( "LFO-attack-time" ) );
tr( "LFO-attack-time" ), eng() );
m_lfoAttackKnob->setLabel( tr( "ATT" ) );
m_lfoAttackKnob->setRange( 0.0, 1.0, 0.001 );
m_lfoAttackKnob->setValue( 0.0, TRUE );
@@ -300,7 +314,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
SLOT( updateAfterKnobChange( float ) ) );
m_lfoSpeedKnob = new tempoSyncKnob( knobBright_26, this,
tr( "LFO-speed" ), 20000.0 );
tr( "LFO-speed" ), eng(), 20000.0 );
m_lfoSpeedKnob->setLabel( tr( "SPD" ) );
m_lfoSpeedKnob->setRange( 0.01, 1.0, 0.0001 );
m_lfoSpeedKnob->setValue( 0.1, TRUE );
@@ -318,7 +332,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
SLOT( updateAfterKnobChange( float ) ) );
m_lfoAmountKnob = new knob( knobBright_26, this,
tr( "LFO-modulation-amount" ) );
tr( "LFO-modulation-amount" ), eng() );
m_lfoAmountKnob->setLabel( tr( "AMT" ) );
m_lfoAmountKnob->setRange( -1.0, 1.0, 0.005 );
m_lfoAmountKnob->setValue( 0.0, TRUE );
@@ -468,7 +482,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
#endif
setAcceptDrops( TRUE );
connect( mixer::inst(), SIGNAL( sampleRateChanged() ), this,
connect( eng()->getMixer(), SIGNAL( sampleRateChanged() ), this,
SLOT( updateSampleVars() ) );
updateSampleVars();
@@ -482,29 +496,46 @@ envelopeAndLFOWidget::~envelopeAndLFOWidget()
delete[] m_pahdEnv;
delete[] m_rEnv;
delete[] m_lfoShapeData;
vvector<envelopeAndLFOWidget *> & v = s_EaLWidgets[eng()];
if( qFind( v.begin(), v.end(), this ) != v.end() )
{
v.erase( qFind( v.begin(), v.end(), this ) );
}
}
void envelopeAndLFOWidget::triggerLFO( void )
void envelopeAndLFOWidget::triggerLFO( engine * _engine )
{
s_lfoFrame += mixer::inst()->framesPerAudioBuffer();
vvector<envelopeAndLFOWidget *> & v = s_EaLWidgets[_engine];
for( vvector<envelopeAndLFOWidget *>::iterator it = v.begin();
it != v.end(); ++it )
{
( *it )->m_lfoFrame +=
_engine->getMixer()->framesPerAudioBuffer();
}
}
void envelopeAndLFOWidget::resetLFO( void )
void envelopeAndLFOWidget::resetLFO( engine * _engine )
{
s_lfoFrame = 0;
vvector<envelopeAndLFOWidget *> & v = s_EaLWidgets[_engine];
for( vvector<envelopeAndLFOWidget *>::iterator it = v.begin();
it != v.end(); ++it )
{
( *it )->m_lfoFrame = 0;
}
}
inline float FASTCALL envelopeAndLFOWidget::lfoLevel( Uint32 _frame,
Uint32 _frame_offset ) const
inline float FASTCALL envelopeAndLFOWidget::lfoLevel( f_cnt_t _frame,
const f_cnt_t _frame_offset ) const
{
if( m_lfoAmountIsZero == FALSE && _frame > m_lfoPredelayFrames )
{
@@ -514,10 +545,10 @@ inline float FASTCALL envelopeAndLFOWidget::lfoLevel( Uint32 _frame,
_frame -= m_lfoPredelayFrames;
if( _frame > m_lfoAttackFrames )
{
return( m_lfoShapeData[( s_lfoFrame + _frame_offset ) %
return( m_lfoShapeData[( m_lfoFrame + _frame_offset ) %
m_lfoOscillationFrames] );
}
return( m_lfoShapeData[( s_lfoFrame + _frame_offset ) %
return( m_lfoShapeData[( m_lfoFrame + _frame_offset ) %
m_lfoOscillationFrames] *
_frame / m_lfoAttackFrames );
}
@@ -527,9 +558,9 @@ inline float FASTCALL envelopeAndLFOWidget::lfoLevel( Uint32 _frame,
float FASTCALL envelopeAndLFOWidget::level( Uint32 _frame,
Uint32 _release_begin,
Uint32 _frame_offset ) const
float FASTCALL envelopeAndLFOWidget::level( f_cnt_t _frame,
const f_cnt_t _release_begin,
const f_cnt_t _frame_offset ) const
{
if( m_busy )
{
@@ -825,7 +856,7 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * )
int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2;
const float frames_for_graph = SECS_PER_LFO_OSCILLATION *
mixer::inst()->sampleRate() / 10;
eng()->getMixer()->sampleRate() / 10;
const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() );
p.setPen( QPen( QColor( static_cast<int>( 96 * lfo_gray_amount ),
@@ -851,7 +882,7 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * )
{
float val = 0.0;
float cur_sample = x * frames_for_graph / LFO_GRAPH_W;
if( static_cast<Uint32>( cur_sample ) > m_lfoPredelayFrames )
if( static_cast<f_cnt_t>( cur_sample ) > m_lfoPredelayFrames )
{
float phase = ( cur_sample -= m_lfoPredelayFrames ) /
osc_frames;
@@ -875,7 +906,8 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * )
m_userWave.data(),
m_userWave.frames() );
}
if( (Uint32) cur_sample <= m_lfoAttackFrames )
if( static_cast<f_cnt_t>( cur_sample ) <=
m_lfoAttackFrames )
{
val *= cur_sample / m_lfoAttackFrames;
}
@@ -918,18 +950,21 @@ void envelopeAndLFOWidget::updateSampleVars( void )
m_busy = TRUE;
const float frames_per_env_seg = SECS_PER_ENV_SEGMENT *
mixer::inst()->sampleRate();
Uint32 predelay_frames = static_cast<Uint32>(
eng()->getMixer()->sampleRate();
const f_cnt_t predelay_frames = static_cast<f_cnt_t>(
frames_per_env_seg *
expKnobVal( m_predelayKnob->value() ) );
Uint32 attack_frames = static_cast<Uint32>( frames_per_env_seg *
const f_cnt_t attack_frames = static_cast<f_cnt_t>(
frames_per_env_seg *
expKnobVal( m_attackKnob->value() ) );
Uint32 hold_frames = static_cast<Uint32>( frames_per_env_seg *
const f_cnt_t hold_frames = static_cast<f_cnt_t>(
frames_per_env_seg *
expKnobVal( m_holdKnob->value() ) );
Uint32 decay_frames = static_cast<Uint32>( frames_per_env_seg *
const f_cnt_t decay_frames = static_cast<f_cnt_t>(
frames_per_env_seg *
expKnobVal( m_decayKnob->value() *
m_sustainKnob->value() ) );
@@ -947,7 +982,7 @@ void envelopeAndLFOWidget::updateSampleVars( void )
m_pahdFrames = predelay_frames + attack_frames + hold_frames +
decay_frames;
m_rFrames = static_cast<Uint32>( frames_per_env_seg *
m_rFrames = static_cast<f_cnt_t>( frames_per_env_seg *
expKnobVal( m_releaseKnob->value() ) );
if( static_cast<int>( floorf( m_amount * 1000.0f ) ) == 0 )
@@ -956,30 +991,30 @@ void envelopeAndLFOWidget::updateSampleVars( void )
m_rFrames = 0;
}
float * new_pahd_env = new float[m_pahdFrames];
float * new_r_env = new float[m_rFrames];
sample_t * new_pahd_env = new sample_t[m_pahdFrames];
sample_t * new_r_env = new sample_t[m_rFrames];
for( Uint32 i = 0; i < predelay_frames; ++i )
for( f_cnt_t i = 0; i < predelay_frames; ++i )
{
new_pahd_env[i] = m_amountAdd;
}
Uint32 add = predelay_frames;
f_cnt_t add = predelay_frames;
for( Uint32 i = 0; i < attack_frames; ++i )
for( f_cnt_t i = 0; i < attack_frames; ++i )
{
new_pahd_env[add+i] = ( (float)i / attack_frames ) *
m_amount + m_amountAdd;
}
add += attack_frames;
for( Uint32 i = 0; i < hold_frames; ++i )
for( f_cnt_t i = 0; i < hold_frames; ++i )
{
new_pahd_env[add+i] = m_amount + m_amountAdd;
}
add += hold_frames;
for( Uint32 i = 0; i < decay_frames; ++i )
for( f_cnt_t i = 0; i < decay_frames; ++i )
{
new_pahd_env[add+i] = ( m_sustainLevel + ( 1.0f -
(float)i / decay_frames ) *
@@ -993,7 +1028,7 @@ void envelopeAndLFOWidget::updateSampleVars( void )
m_pahdEnv = new_pahd_env;
m_rEnv = new_r_env;
for( Uint32 i = 0; i < m_rFrames; ++i )
for( f_cnt_t i = 0; i < m_rFrames; ++i )
{
new_r_env[i] = ( (float)( m_rFrames - i ) / m_rFrames *
m_sustainLevel ) * m_amount;
@@ -1005,14 +1040,14 @@ void envelopeAndLFOWidget::updateSampleVars( void )
const float frames_per_lfo_oscillation =
SECS_PER_LFO_OSCILLATION *
mixer::inst()->sampleRate();
m_lfoPredelayFrames = static_cast<Uint32>(
eng()->getMixer()->sampleRate();
m_lfoPredelayFrames = static_cast<f_cnt_t>(
frames_per_lfo_oscillation *
expKnobVal( m_lfoPredelayKnob->value() ) );
m_lfoAttackFrames = static_cast<Uint32>(
m_lfoAttackFrames = static_cast<f_cnt_t>(
frames_per_lfo_oscillation *
expKnobVal( m_lfoAttackKnob->value() ) );
m_lfoOscillationFrames = static_cast<Uint32>(
m_lfoOscillationFrames = static_cast<f_cnt_t>(
frames_per_lfo_oscillation *
m_lfoSpeedKnob->value() );
if( m_x100Cb->isChecked() )
@@ -1039,8 +1074,8 @@ void envelopeAndLFOWidget::updateSampleVars( void )
if( m_lfoAmountIsZero == FALSE )
{
delete[] m_lfoShapeData;
m_lfoShapeData = new float[m_lfoOscillationFrames];
for( Uint32 frame = 0; frame < m_lfoOscillationFrames;
m_lfoShapeData = new sample_t[m_lfoOscillationFrames];
for( f_cnt_t frame = 0; frame < m_lfoOscillationFrames;
++frame )
{
const float phase = frame / static_cast<float>(
@@ -1088,7 +1123,7 @@ void envelopeAndLFOWidget::updateSampleVars( void )
void envelopeAndLFOWidget::x100Toggled( bool )
{
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
updateSampleVars();
}
@@ -1109,7 +1144,7 @@ void envelopeAndLFOWidget::lfoSinWaveCh( bool _on )
{
m_lfoShape = SIN;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
}
@@ -1123,7 +1158,7 @@ void envelopeAndLFOWidget::lfoTriangleWaveCh( bool _on )
{
m_lfoShape = TRIANGLE;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
}
@@ -1137,7 +1172,7 @@ void envelopeAndLFOWidget::lfoSawWaveCh( bool _on )
{
m_lfoShape = SAW;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
}
@@ -1151,7 +1186,7 @@ void envelopeAndLFOWidget::lfoSquareWaveCh( bool _on )
{
m_lfoShape = SQUARE;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
}
@@ -1172,7 +1207,7 @@ void envelopeAndLFOWidget::lfoUserWaveCh( bool _on )
}
m_lfoShape = USER;
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
}

View File

@@ -83,7 +83,8 @@ static const QString targetNames[envelopeTabWidget::TARGET_COUNT][2] =
envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
QWidget( _channel_track->tabWidgetParent() ),
settings()
settings(),
engineObject( _channel_track->eng() )
{
m_targetsTabWidget = new tabWidget( tr( "TARGET" ), this );
@@ -118,7 +119,9 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
value_for_zero_amount = 1.0;
}
m_envLFOWidgets[i] = new envelopeAndLFOWidget(
value_for_zero_amount, m_targetsTabWidget );
value_for_zero_amount,
m_targetsTabWidget,
eng() );
m_targetsTabWidget->addTab( m_envLFOWidgets[i],
tr( targetNames[i][0]
#ifdef QT4
@@ -171,7 +174,7 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
m_filterCutKnob = new knob( knobBright_26, m_filterGroupBox, tr(
"cutoff-frequency" ) );
"cutoff-frequency" ), eng() );
m_filterCutKnob->setLabel( tr( "CUTOFF" ) );
m_filterCutKnob->setRange( 0.0, 16000.0, 1.0 );
m_filterCutKnob->move( 140, 18 );
@@ -191,7 +194,7 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
"frequencies below cutoff-frequency and so on..." ) );
m_filterResKnob = new knob( knobBright_26, m_filterGroupBox, tr(
"Q/Resonance" ) );
"Q/Resonance" ), eng() );
m_filterResKnob->setLabel( tr( "Q/RESO" ) );
m_filterResKnob->setRange( 0.01, 10.0, 0.01 );
m_filterResKnob->move( 190, 18 );
@@ -220,14 +223,14 @@ envelopeTabWidget::~envelopeTabWidget()
float FASTCALL envelopeTabWidget::volumeLevel( notePlayHandle * _n,
Uint32 _frame )
const f_cnt_t _frame )
{
Uint32 release_begin = _frame - _n->releaseFramesDone() +
f_cnt_t release_begin = _frame - _n->releaseFramesDone() +
_n->framesBeforeRelease();
if( _n->released() == FALSE )
{
release_begin += mixer::inst()->framesPerAudioBuffer();
release_begin += eng()->getMixer()->framesPerAudioBuffer();
}
return( m_envLFOWidgets[VOLUME]->level( _frame, release_begin, 0 ) );
@@ -236,16 +239,17 @@ float FASTCALL envelopeTabWidget::volumeLevel( notePlayHandle * _n,
void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab,
const fpab_t _frames,
notePlayHandle * _n )
{
Uint32 total_frames = _n->totalFramesPlayed();
Uint32 release_begin = total_frames - _n->releaseFramesDone() +
f_cnt_t total_frames = _n->totalFramesPlayed();
f_cnt_t release_begin = total_frames - _n->releaseFramesDone() +
_n->framesBeforeRelease();
if( _n->released() == FALSE )
{
release_begin += mixer::inst()->framesPerAudioBuffer();
release_begin += eng()->getMixer()->framesPerAudioBuffer();
}
// because of optimizations, there's special code for several cases:
@@ -265,7 +269,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
if( _n->m_filter == NULL )
{
_n->m_filter = new basicFilters<>(
mixer::inst()->sampleRate() );
eng()->getMixer()->sampleRate() );
}
if( m_filterGroupBox->isActive() )
@@ -281,7 +285,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
m_envLFOWidgets[CUT]->used() &&
m_envLFOWidgets[RES]->used() )
{
for( Uint32 frame = 0; frame < _frames;
for( fpab_t frame = 0; frame < _frames;
++frame, ++total_frames )
{
float new_cut_val = m_envLFOWidgets[CUT]->level( total_frames, release_begin, frame );
@@ -302,7 +306,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame );
vol_level = vol_level*vol_level;
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -310,7 +314,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
}
else if( m_envLFOWidgets[VOLUME]->used() && m_envLFOWidgets[CUT]->used() )
{
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float new_cut_val = m_envLFOWidgets[CUT]->level( total_frames, release_begin, frame );
new_cut_val = envelopeAndLFOWidget::expKnobVal( new_cut_val ) * CUT_FREQ_MULTIPLIER +
@@ -325,7 +329,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame );
vol_level = vol_level*vol_level;
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -334,7 +338,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
else if( m_envLFOWidgets[VOLUME]->used() && m_envLFOWidgets[RES]->used() )
{
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float new_res_val = m_filterResKnob->value() + RES_MULTIPLIER *
m_envLFOWidgets[RES]->level( total_frames, release_begin, frame );
@@ -348,7 +352,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame );
vol_level = vol_level*vol_level;
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -357,7 +361,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
}
else if( m_envLFOWidgets[CUT]->used() )
{
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float new_cut_val = m_envLFOWidgets[CUT]->level( total_frames, release_begin, frame );
new_cut_val = envelopeAndLFOWidget::expKnobVal( new_cut_val ) * CUT_FREQ_MULTIPLIER +
@@ -369,7 +373,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
old_filter_cut = static_cast<int>( new_cut_val );
}
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -377,7 +381,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
}
else if( m_envLFOWidgets[RES]->used() )
{
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float new_res_val = m_filterResKnob->value() + RES_MULTIPLIER *
m_envLFOWidgets[RES]->level( total_frames, release_begin, frame );
@@ -388,7 +392,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
old_filter_res = static_cast<int>( new_res_val*RES_PRECISION );
}
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -398,12 +402,12 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
{
_n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), m_filterResKnob->value() );
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame );
vol_level = vol_level*vol_level;
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -413,9 +417,9 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
{
_n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), m_filterResKnob->value() );
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl );
}
@@ -425,11 +429,11 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
else if( m_envLFOWidgets[VOLUME]->used() /*&& m_envLFOWidgets[PANNING]->used() == FALSE*/ )
{
// only use volume-envelope...
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame );
vol_level = vol_level*vol_level;
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = vol_level * _ab[frame][chnl];
}
@@ -438,11 +442,11 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
/* else if( m_envLFOWidgets[VOLUME]->used() == FALSE && m_envLFOWidgets[PANNING]->used() )
{
// only use panning-envelope...
for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames )
for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames )
{
float vol_level = m_envLFOWidgets[PANNING]->level( total_frames, release_begin, frame );
vol_level = vol_level*vol_level;
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
_ab[frame][chnl] = vol_level * _ab[frame][chnl];
}
@@ -453,9 +457,9 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
Uint32 envelopeTabWidget::envFrames( void )
f_cnt_t envelopeTabWidget::envFrames( void )
{
Uint32 ret_val = m_envLFOWidgets[VOLUME]->m_pahdFrames;
f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->m_pahdFrames;
for( int i = VOLUME+1; i < TARGET_COUNT; ++i )
{
@@ -471,9 +475,9 @@ Uint32 envelopeTabWidget::envFrames( void )
Uint32 envelopeTabWidget::releaseFrames( void )
f_cnt_t envelopeTabWidget::releaseFrames( void )
{
Uint32 ret_val = m_envLFOWidgets[VOLUME]->m_rFrames;
f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->m_rFrames;
for( int i = VOLUME+1; i < TARGET_COUNT; ++i )
{
if( m_envLFOWidgets[i]->used() &&

View File

@@ -49,7 +49,7 @@
#include "export_project_dialog.h"
#include "song_editor.h"
#include "lmms_main_win.h"
#include "main_window.h"
#include "combobox.h"
#include "led_checkbox.h"
#include "embed.h"
@@ -127,8 +127,10 @@ Sint16 exportProjectDialog::s_availableBitrates[] =
// TODO: rewrite that crap using layouts!!
exportProjectDialog::exportProjectDialog( const QString & _file_name,
QWidget * _parent ) :
QWidget * _parent,
engine * _engine ) :
QDialog( _parent ),
engineObject( _engine ),
m_fileName( _file_name ),
m_hourglassLbl( NULL ),
m_deleteFile( FALSE )
@@ -156,7 +158,7 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name,
connect( m_typeCombo, SIGNAL( activated( const QString & ) ), this,
SLOT( changedType( const QString & ) ) );
int idx = 0;
Uint8 idx = 0;
while( fileEncodeDevices[idx].m_fileType != NULL_FILE )
{
m_typeCombo->addItem(
@@ -253,7 +255,7 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke )
{
if( _ke->key() == Qt::Key_Escape )
{
if( songEditor::inst()->exporting() == FALSE )
if( eng()->getSongEditor()->exporting() == FALSE )
{
accept();
}
@@ -269,7 +271,7 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke )
void exportProjectDialog::closeEvent( QCloseEvent * _ce )
{
if( songEditor::inst()->exporting() == TRUE )
if( eng()->getSongEditor()->exporting() == TRUE )
{
abortProjectExport();
_ce->ignore();
@@ -326,8 +328,8 @@ void exportProjectDialog::exportBtnClicked( void )
m_vbrCb->isChecked(),
m_kbpsCombo->currentText().toInt(),
m_kbpsCombo->currentText().toInt() - 64,
m_kbpsCombo->currentText().toInt() + 64
);
m_kbpsCombo->currentText().toInt() + 64,
eng()->getMixer() );
if( success_ful == FALSE )
{
QMessageBox::information( this,
@@ -373,26 +375,26 @@ void exportProjectDialog::exportBtnClicked( void )
mixer::inst()->setAudioDevice( dev, m_hqmCb->isChecked() );
songEditor::inst()->startExport();
eng()->getMixer()->setAudioDevice( dev, m_hqmCb->isChecked() );
eng()->getSongEditor()->startExport();
songEditor::playPos & pp = songEditor::inst()->getPlayPos(
songEditor::playPos & pp = eng()->getSongEditor()->getPlayPos(
songEditor::PLAY_SONG );
while( songEditor::inst()->exportDone() == FALSE &&
songEditor::inst()->exporting() == TRUE )
while( eng()->getSongEditor()->exportDone() == FALSE &&
eng()->getSongEditor()->exporting() == TRUE )
{
dev->processNextBuffer();
int pval = pp * 100 /
( ( songEditor::inst()->lengthInTacts() + 1 ) * 64 );
( ( eng()->getSongEditor()->lengthInTacts() + 1 ) * 64 );
#ifdef QT4
m_exportProgressBar->setValue( pval );
#else
m_exportProgressBar->setProgress( pval );
#endif
// update lmms-main-win-caption
lmmsMainWin::inst()->setWindowTitle( tr( "Rendering:" ) + " " +
eng()->getMainWindow()->setWindowTitle( tr( "Rendering:" ) + " " +
QString::number( pval ) + "%" );
// process paint-events etc.
qApp->processEvents();
@@ -413,7 +415,7 @@ void exportProjectDialog::exportBtnClicked( void )
void exportProjectDialog::cancelBtnClicked( void )
{
// is song-export-thread active?
if( songEditor::inst()->exporting() == TRUE )
if( eng()->getSongEditor()->exporting() == TRUE )
{
// then dispose abort of export
abortProjectExport();
@@ -438,7 +440,7 @@ void exportProjectDialog::abortProjectExport( void )
void exportProjectDialog::finishProjectExport( void )
{
mixer::inst()->restoreAudioDevice();
eng()->getMixer()->restoreAudioDevice();
// if the user aborted export-process, the file has to be deleted
if( m_deleteFile )
@@ -447,9 +449,9 @@ void exportProjectDialog::finishProjectExport( void )
}
// restore window-title
lmmsMainWin::inst()->resetWindowTitle();
eng()->getMainWindow()->resetWindowTitle();
songEditor::inst()->stopExport();
eng()->getSongEditor()->stopExport();
// if we rendered file from command line, quit after export
if( file_to_render != "" )

View File

@@ -2,7 +2,7 @@
* file_browser.cpp - implementation of the project-, preset- and
* sample-file-browser
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -32,12 +32,15 @@
#include <QKeyEvent>
#include <QMenu>
#include <Q3Header>
#include <QCursor>
#else
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include <qheader.h>
#include <qcursor.h>
#include <qworkspace.h>
#endif
@@ -55,19 +58,21 @@
#include "instrument.h"
#include "text_float.h"
#include "string_pair_drag.h"
#include "main_window.h"
fileBrowser::fileBrowser( const QString & _path, const QString & _filter,
const QString & _title, const QPixmap & _pm,
QWidget * _parent ) :
QWidget * _parent, engine * _engine ) :
sideBarWidget( _title, _pm, _parent ),
engineObject( _engine ),
m_contextMenuItem( NULL ),
m_path( _path ),
m_filter( _filter )
{
setWindowTitle( tr( "Browser" ) );
m_l = new listView( contentParent() );
m_l = new listView( contentParent(), eng() );
addContentWidget( m_l );
#ifdef QT4
@@ -190,10 +195,11 @@ void fileBrowser::contextMenuRequest( QListViewItem * i, const QPoint &, int )
void fileBrowser::sendToActiveChannel( void )
{
if( lmmsMainWin::inst()->workspace() != NULL )
if( eng()->getMainWindow()->workspace() != NULL )
{
// get all windows opened in the workspace
QWidgetList pl = lmmsMainWin::inst()->workspace()->windowList(
QWidgetList pl =
eng()->getMainWindow()->workspace()->windowList(
#if QT_VERSION >= 0x030200
QWorkspace::StackingOrder
#endif
@@ -290,7 +296,7 @@ void fileBrowser::openInNewChannel( trackContainer * _tc )
void fileBrowser::openInNewChannelSE( void )
{
openInNewChannel( songEditor::inst() );
openInNewChannel( eng()->getSongEditor() );
}
@@ -298,7 +304,7 @@ void fileBrowser::openInNewChannelSE( void )
void fileBrowser::openInNewChannelBBE( void )
{
openInNewChannel( bbEditor::inst() );
openInNewChannel( eng()->getBBEditor() );
}
@@ -308,8 +314,9 @@ void fileBrowser::openInNewChannelBBE( void )
listView::listView( QWidget * _parent ) :
listView::listView( QWidget * _parent, engine * _engine ) :
Q3ListView( _parent ),
engineObject( _engine ),
m_mousePressed( FALSE ),
m_pressPos(),
m_previewPlayHandle( NULL )
@@ -344,9 +351,8 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
// samples are per default opened in bb-editor because
// they're likely drum-samples etc.
channelTrack * ct = dynamic_cast<channelTrack *>(
track::create(
track::CHANNEL_TRACK,
bbEditor::inst() ) );
track::create( track::CHANNEL_TRACK,
eng()->getBBEditor() ) );
#ifdef LMMS_DEBUG
assert( ct != NULL );
#endif
@@ -364,7 +370,7 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
// presets are per default opened in bb-editor
multimediaProject mmp( f->fullName() );
track * t = track::create( track::CHANNEL_TRACK,
bbEditor::inst() );
eng()->getBBEditor() );
channelTrack * ct = dynamic_cast<channelTrack *>( t );
if( ct != NULL )
{
@@ -376,9 +382,9 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
}
else if( f->type() == fileItem::PROJECT_FILE )
{
if( songEditor::inst()->mayChangeProject() == TRUE )
if( eng()->getSongEditor()->mayChangeProject() == TRUE )
{
songEditor::inst()->loadProject(
eng()->getSongEditor()->loadProject(
f->fullName() );
}
}
@@ -414,7 +420,7 @@ void listView::contentsMousePressEvent( QMouseEvent * _me )
{
if( m_previewPlayHandle != NULL )
{
mixer::inst()->removePlayHandle( m_previewPlayHandle );
eng()->getMixer()->removePlayHandle( m_previewPlayHandle );
m_previewPlayHandle = NULL;
}
if( f->type() == fileItem::SAMPLE_FILE )
@@ -431,7 +437,7 @@ void listView::contentsMousePressEvent( QMouseEvent * _me )
qApp->processEvents();
#endif
samplePlayHandle * s = new samplePlayHandle(
f->fullName() );
f->fullName(), eng() );
s->setDoneMayReturnTrue( FALSE );
m_previewPlayHandle = s;
delete tf;
@@ -439,11 +445,11 @@ void listView::contentsMousePressEvent( QMouseEvent * _me )
else if( f->type() == fileItem::PRESET_FILE )
{
m_previewPlayHandle = new presetPreviewPlayHandle(
f->fullName() );
f->fullName(), eng() );
}
if( m_previewPlayHandle != NULL )
{
mixer::inst()->addPlayHandle( m_previewPlayHandle );
eng()->getMixer()->addPlayHandle( m_previewPlayHandle );
}
}
}
@@ -469,7 +475,7 @@ void listView::contentsMouseMoveEvent( QMouseEvent * _me )
f->fullName(),
embed::getIconPixmap(
"preset_file" ),
this );
this, eng() );
break;
case fileItem::SAMPLE_FILE:
@@ -477,7 +483,7 @@ void listView::contentsMouseMoveEvent( QMouseEvent * _me )
f->fullName(),
embed::getIconPixmap(
"sound_file" ),
this );
this, eng() );
break;
case fileItem::MIDI_FILE:
@@ -485,7 +491,7 @@ void listView::contentsMouseMoveEvent( QMouseEvent * _me )
f->fullName(),
embed::getIconPixmap(
"midi_file" ),
this );
this, eng() );
break;
default:
@@ -511,14 +517,14 @@ void listView::contentsMouseReleaseEvent( QMouseEvent * _me )
{
if( s->totalFrames() - s->framesDone() <=
static_cast<Uint32>(
mixer::inst()->sampleRate() * 3 ) )
eng()->getMixer()->sampleRate() * 3 ) )
{
s->setDoneMayReturnTrue( TRUE );
m_previewPlayHandle = NULL;
return;
}
}
mixer::inst()->removePlayHandle( m_previewPlayHandle );
eng()->getMixer()->removePlayHandle( m_previewPlayHandle );
m_previewPlayHandle = NULL;
}
}

View File

@@ -1,7 +1,7 @@
/*
* instrument.cpp - base-class for all instrument-plugins (synths, samplers etc)
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -31,7 +31,7 @@
instrument::instrument( channelTrack * _channel_track,
const descriptor * _descriptor ) :
QWidget( _channel_track->tabWidgetParent() ),
plugin( _descriptor ),
plugin( _descriptor, _channel_track->eng() ),
m_channelTrack( _channel_track ),
m_valid( TRUE )
{
@@ -73,7 +73,7 @@ void instrument::deleteNotePluginData( notePlayHandle * )
Uint32 instrument::beatLen( notePlayHandle * ) const
f_cnt_t instrument::beatLen( notePlayHandle * ) const
{
return( 0 );
}

View File

@@ -46,7 +46,7 @@
#endif
#include "lmms_main_win.h"
#include "main_window.h"
#include "embed.h"
#include "config_mgr.h"
#include "export_project_dialog.h"
@@ -54,19 +54,20 @@
#include "gui_templates.h"
QString file_to_render;
#if QT_VERSION >= 0x030100
int splash_alignment_flags = Qt::AlignTop | Qt::AlignLeft;
#endif
QString file_to_load;
QString file_to_render;
int main( int argc, char * * argv )
{
QApplication app( argc, argv );
QString extension = "wav";
QString file_to_load;
for( int i = 1; i < app.argc(); ++i )
{
@@ -187,10 +188,10 @@ int main( int argc, char * * argv )
#if QT_VERSION >= 0x030200
// init splash screen
QPixmap splash = embed::getIconPixmap( "splash" );
lmmsMainWin::s_splashScreen = new QSplashScreen( splash );
lmmsMainWin::s_splashScreen->show();
mainWindow::s_splashScreen = new QSplashScreen( splash );
mainWindow::s_splashScreen->show();
lmmsMainWin::s_splashScreen->showMessage( lmmsMainWin::tr(
mainWindow::s_splashScreen->showMessage( mainWindow::tr(
"Setting up main-"
"window and "
"workspace..." ),
@@ -198,33 +199,45 @@ int main( int argc, char * * argv )
Qt::white );
#endif
engine * main_engine = new engine();
// we try to load given file
if( file_to_load != "" )
{
main_engine->getSongEditor()->loadProject( file_to_load );
}
else
{
main_engine->getSongEditor()->createNewProject();
}
#ifndef QT4
app.setMainWidget( lmmsMainWin::inst() );
app.setMainWidget( main_engine->getMainWindow() );
#endif
// MDI-mode?
if( lmmsMainWin::inst()->workspace() != NULL )
if( main_engine->getMainWindow()->workspace() != NULL )
{
// then maximize
lmmsMainWin::inst()->showMaximized();
main_engine->getMainWindow()->showMaximized();
}
else
{
// otherwise arrange at top-left edge of screen
lmmsMainWin::inst()->show();
lmmsMainWin::inst()->move( 0, 0 );
lmmsMainWin::inst()->resize( 200, 500 );
main_engine->getMainWindow()->show();
main_engine->getMainWindow()->move( 0, 0 );
main_engine->getMainWindow()->resize( 200, 500 );
}
#if QT_VERSION >= 0x030200
delete lmmsMainWin::s_splashScreen;
lmmsMainWin::s_splashScreen = NULL;
delete mainWindow::s_splashScreen;
mainWindow::s_splashScreen = NULL;
#endif
if( file_to_render != "" )
{
exportProjectDialog * e = new exportProjectDialog(
file_to_render,
lmmsMainWin::inst() );
file_to_render,
main_engine->getMainWindow(),
main_engine );
e->show();
e->exportBtnClicked();
}

864
src/core/main_window.cpp Normal file
View File

@@ -0,0 +1,864 @@
/*
* main_window.cpp - implementation of LMMS-main-window
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "qt3support.h"
#ifdef QT4
#include <QApplication>
#include <QFileDialog>
#include <QCloseEvent>
#include <QSplitter>
#include <QSplashScreen>
#include <QMessageBox>
#include <QMenuBar>
#else
#include <qsplitter.h>
#include <qapplication.h>
#include <qdir.h>
#include <qfiledialog.h>
#include <qpopupmenu.h>
#include <qmessagebox.h>
#include <qmenubar.h>
#if QT_VERSION >= 0x030200
#include <qsplashscreen.h>
#endif
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "main_window.h"
#include "bb_editor.h"
#include "song_editor.h"
#include "piano_roll.h"
#include "embed.h"
#include "about_dialog.h"
#include "file_browser.h"
#include "plugin_browser.h"
#include "side_bar.h"
#include "config_mgr.h"
#include "mixer.h"
#include "project_notes.h"
#include "buffer_allocator.h"
#include "setup_dialog.h"
#include "audio_dummy.h"
#include "tool_button.h"
#if QT_VERSION >= 0x030100
QSplashScreen * mainWindow::s_splashScreen = NULL;
extern int splash_alignment_flags;
#endif
mainWindow::mainWindow( engine * _engine ) :
QMainWindow(
#ifndef QT4
0 , NULL, WDestructiveClose
#endif
),
engineObject( _engine ),
m_workspace( NULL ),
m_templatesMenu( NULL )
{
#ifdef QT4
setAttribute( Qt::WA_DeleteOnClose );
#endif
bool no_mdi = configManager::inst()->value( "app", "gimplikewindows"
).toInt();
QWidget * main_widget = new QWidget( this );
QVBoxLayout * vbox = new QVBoxLayout( main_widget );
vbox->setSpacing( 0 );
vbox->setMargin( 0 );
QWidget * w = new QWidget( main_widget );
QHBoxLayout * hbox = new QHBoxLayout( w );
hbox->setSpacing( 0 );
hbox->setMargin( 0 );
sideBar * side_bar = new sideBar( sideBar::Vertical, w );
side_bar->setStyle( sideBar::VSNET/*KDEV3ICON*/ );
side_bar->setPosition( sideBar::Left );
QSplitter * splitter = new QSplitter( Qt::Horizontal, w );
#if QT_VERSION >= 0x030200
splitter->setChildrenCollapsible( FALSE );
#endif
int id = 0;
QString wdir = configManager::inst()->workingDir();
side_bar->appendTab( new pluginBrowser( splitter, eng() ), ++id );
side_bar->appendTab( new fileBrowser( wdir+"projects",
"*.mmp *.xml *.mid",
tr( "My projects" ),
embed::getIconPixmap( "project_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( wdir+"samples", "*.wav *.ogg *.au"
"*.voc *.aif *.aiff *.flac *.raw",
tr( "My samples" ),
embed::getIconPixmap( "sound_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( wdir+"presets", "*.cs.xml",
tr( "My presets" ),
embed::getIconPixmap( "preset_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( QDir::homePath(), "*",
tr( "My home" ),
embed::getIconPixmap( "home" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( QDir::rootPath(), "*",
tr( "Root directory" ),
embed::getIconPixmap( "root" ),
splitter, eng() ),
++id );
if( no_mdi == FALSE )
{
m_workspace = new QWorkspace( splitter );
m_workspace->setScrollBarsEnabled( TRUE );
#ifdef QT4
/* m_workspace->setBackground( embed::getIconPixmap(
"background_artwork" ) );*/
#else
m_workspace->setPaletteBackgroundPixmap( embed::getIconPixmap(
"background_artwork" ) );
#endif
}
hbox->addWidget( side_bar );
hbox->addWidget( splitter );
// create global-toolbar at the top of our window
m_toolBar = new QWidget( main_widget );
m_toolBar->setFixedHeight( 64 );
m_toolBar->move( 0, 0 );
#ifdef QT4
QPalette pal;
pal.setBrush( m_toolBar->backgroundRole(), QBrush(
embed::getIconPixmap( "main_toolbar_bg" ) ) );
m_toolBar->setPalette( pal );
#else
m_toolBar->setPaletteBackgroundPixmap(
embed::getIconPixmap( "main_toolbar_bg" ) );
#endif
// add layout for organizing quite complex toolbar-layouting
m_toolBarLayout = new QGridLayout( m_toolBar/*, 2, 1*/ );
m_toolBarLayout->setMargin( 0 );
m_toolBarLayout->setSpacing( 0 );
vbox->addWidget( m_toolBar );
vbox->addWidget( w );
setCentralWidget( main_widget );
}
mainWindow::~mainWindow()
{
/* // first make sure, there're no mixing/audio-device-threads any more
eng()->getMixer()->stopProcessing();
// destroy editors with all their children
delete eng()->getSongEditor();
delete eng()->getBBEditor();
// destroy mixer
delete eng()->getMixer();
// destroy config-manager (which automatically saves config-file)
*/
delete eng();
}
void mainWindow::finalize( void )
{
#if QT_VERSION >= 0x030200
if( qApp->argc() > 1 )
{
s_splashScreen->showMessage( tr( "Loading song..." ),
splash_alignment_flags,
Qt::white );
}
else
{
s_splashScreen->showMessage( tr( "Creating new song..." ),
splash_alignment_flags,
Qt::white );
}
#endif
eng()->getSongEditor();
#if QT_VERSION >= 0x030200
s_splashScreen->showMessage( tr( "Creating GUI..." ),
splash_alignment_flags,
Qt::white );
#endif
resetWindowTitle( "" );
setWindowIcon( embed::getIconPixmap( "icon" ) );
// create tool-buttons
toolButton * project_new = new toolButton(
embed::getIconPixmap( "project_new" ),
tr( "Create new project" ),
this, SLOT( createNewProject() ),
m_toolBar );
QDir d( configManager::inst()->projectsDir() + "templates" );
QStringList templates = d.entryList(
#ifdef QT4
QStringList( "*.mpt" ),
#else
"*.mpt",
#endif
QDir::Files | QDir::Readable );
if( !templates.isEmpty() )
{
m_templatesMenu = new QMenu( project_new );
for( QStringList::iterator it = templates.begin();
it != templates.end(); ++it )
{
m_templatesMenu->addAction(
embed::getIconPixmap( "project_file" ),
( *it ).left( ( *it ).length() - 4 ) );
}
connect( m_templatesMenu, SIGNAL( activated( int ) ),
this, SLOT( createNewProjectFromTemplate( int ) ) );
project_new->setMenu( m_templatesMenu );
#ifdef QT4
project_new->setPopupMode( toolButton::MenuButtonPopup );
#else
project_new->setPopupDelay( 0 );
#endif
}
toolButton * project_open = new toolButton(
embed::getIconPixmap( "project_open" ),
tr( "Open existing project" ),
this, SLOT( openProject() ),
m_toolBar );
toolButton * project_save = new toolButton(
embed::getIconPixmap( "project_save" ),
tr( "Save current project" ),
this, SLOT( saveProject() ),
m_toolBar );
toolButton * project_export = new toolButton(
embed::getIconPixmap( "project_export" ),
tr( "Export current project" ),
eng()->getSongEditor(),
SLOT( exportProject() ),
m_toolBar );
m_toolBarLayout->setColumnMinimumWidth( 0, 5 );
m_toolBarLayout->addWidget( project_new, 0, 1 );
m_toolBarLayout->addWidget( project_open, 0, 2 );
m_toolBarLayout->addWidget( project_save, 0, 3 );
m_toolBarLayout->addWidget( project_export, 0, 4 );
// window-toolbar
toolButton * bb_editor_window = new toolButton(
embed::getIconPixmap( "bb_track" ),
tr( "Show/hide Beat+Bassline Editor" ) +
" (F6)",
this, SLOT( toggleBBEditorWin() ),
m_toolBar );
bb_editor_window->setShortcut( Qt::Key_F6 );
#ifdef QT4
bb_editor_window->setWhatsThis(
#else
QWhatsThis::add( bb_editor_window,
#endif
tr( "By pressing this button, you can show or hide the "
"Beat+Bassline Editor. The Beat+Bassline Editor is "
"needed for setting beats, opening, adding and "
"removing channels, cutting, copying and pasting "
"beat- and bassline-patterns and other things like "
"that." ) );
toolButton * piano_roll_window = new toolButton(
embed::getIconPixmap( "piano" ),
tr( "Show/hide Piano-Roll" ) +
" (F7)",
this, SLOT( togglePianoRollWin() ),
m_toolBar );
piano_roll_window->setShortcut( Qt::Key_F7 );
#ifdef QT4
piano_roll_window->setWhatsThis(
#else
QWhatsThis::add( piano_roll_window,
#endif
tr( "By pressing this button, you can show or hide the "
"Piano-Roll. With the help of the Piano-Roll "
"you can edit melody-patterns in an easy way."
) );
toolButton * song_editor_window = new toolButton(
embed::getIconPixmap( "songeditor" ),
tr( "Show/hide Song-Editor" ) + " (F8)",
this, SLOT( toggleSongEditorWin() ),
m_toolBar );
song_editor_window->setShortcut( Qt::Key_F8 );
#ifdef QT4
song_editor_window->setWhatsThis(
#else
QWhatsThis::add( song_editor_window,
#endif
tr( "By pressing this button, you can show or hide the "
"Song-Editor. With the help of the Song-Editor you can "
"edit song-playlist and specify when which track "
"should be played. "
"You can also insert and move samples (e.g. "
"rap-samples) directly into the playlist." ) );
/* toolButton * effect_board_window = new toolButton(
embed::getIconPixmap( "effect_board" ),
tr( "Show/hide EffectBoard" ) + " (F9)",
this, SLOT( emptySlot() ), m_toolBar );
effect_board_window->setShortcut( Qt::Key_F9 );
#ifdef QT4
effect_board_window->setWhatsThis(
#else
QWhatsThis::add( effect_board_window,
#endif
tr( "By pressing this button, you can show or hide the "
"EffectBoard. The EffectBoard is a very powerful tool "
"for managing effects for your song. You can insert "
"effects into different effect-channels." ) );*/
toolButton * project_notes_window = new toolButton(
embed::getIconPixmap( "project_notes" ),
tr( "Show/hide project notes" ) +
" (F10)",
this, SLOT( toggleProjectNotesWin() ),
m_toolBar );
project_notes_window->setShortcut( Qt::Key_F10 );
#ifdef QT4
project_notes_window->setWhatsThis(
#else
QWhatsThis::add( project_notes_window,
#endif
tr( "By pressing this button, you can show or hide the "
"project notes window. In this window you can put "
"down your project notes.") );
m_toolBarLayout->addWidget( bb_editor_window, 1, 1 );
m_toolBarLayout->addWidget( piano_roll_window, 1, 2 );
m_toolBarLayout->addWidget( song_editor_window, 1, 3 );
//m_toolBarLayout->addWidget( effect_board_window, 1, 4 );
m_toolBarLayout->addWidget( project_notes_window, 1, 5 );
m_toolBarLayout->setColumnStretch( 100, 1 );
// project-popup-menu
QMenu * project_menu = new QMenu( this );
#ifdef QT4
menuBar()->addMenu( project_menu )->setText( tr( "&Project" ) );
#else
menuBar()->insertItem( tr( "&Project" ), project_menu );
#endif
project_menu->addAction( embed::getIconPixmap( "project_new" ),
tr( "&New" ),
this, SLOT( createNewProject() ),
Qt::CTRL + Qt::Key_N );
project_menu->addAction( embed::getIconPixmap( "project_open" ),
tr( "&Open..." ),
this, SLOT( openProject() ),
Qt::CTRL + Qt::Key_O );
project_menu->addAction( embed::getIconPixmap( "project_save" ),
tr( "&Save" ),
this, SLOT( saveProject() ),
Qt::CTRL + Qt::Key_S );
project_menu->addAction( embed::getIconPixmap( "project_saveas" ),
tr( "Save &As..." ),
this, SLOT( saveProjectAs() ),
Qt::CTRL + Qt::SHIFT + Qt::Key_S );
#ifdef QT4
project_menu->addSeparator();
#else
project_menu->insertSeparator();
#endif
project_menu->addAction( /*embed::getIconPixmap( "project_import" ),*/
tr( "Import file" ),
eng()->getSongEditor(),
SLOT( importProject() ) );
#ifdef QT4
project_menu->addSeparator();
#else
project_menu->insertSeparator();
#endif
project_menu->addAction( embed::getIconPixmap( "project_export" ),
tr( "E&xport" ),
eng()->getSongEditor(),
SLOT( exportProject() ),
Qt::CTRL + Qt::Key_E );
#ifdef QT4
project_menu->addSeparator();
#else
project_menu->insertSeparator();
#endif
project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ),
qApp, SLOT( closeAllWindows() ),
Qt::CTRL+Qt::Key_Q );
QMenu * settings_menu = new QMenu( this );
#ifdef QT4
menuBar()->addMenu( settings_menu )->setText( tr( "&Settings" ) );
#else
menuBar()->insertItem( tr( "&Settings" ), settings_menu );
#endif
settings_menu->addAction( embed::getIconPixmap( "setup_general" ),
tr( "Show settings dialog" ),
this, SLOT( showSettingsDialog() ) );
settings_menu->addAction( embed::getIconPixmap( "wizard" ),
tr( "Show setup wizard" ),
configManager::inst(), SLOT( exec() ) );
// help-popup-menu
QMenu * help_menu = new QMenu( this );
#ifdef QT4
menuBar()->addMenu( help_menu )->setText( tr( "&Help" ) );
#else
menuBar()->insertItem( tr( "&Help" ), help_menu );
#endif
help_menu->addAction( embed::getIconPixmap( "help" ), tr( "Help" ),
this, SLOT( help() ) );
help_menu->addAction( embed::getIconPixmap( "whatsthis" ),
tr( "What's this?" ),
this, SLOT( enterWhatsThisMode() ) );
#ifdef QT4
help_menu->addSeparator();
#else
help_menu->insertSeparator();
#endif
help_menu->addAction( embed::getIconPixmap( "icon" ), tr( "About" ),
this, SLOT( aboutLMMS() ) );
// setup-dialog opened before?
if( !configManager::inst()->value( "app", "configured" ).toInt() )
{
// no, so show it that user can setup everything
setupDialog( eng() ).exec();
configManager::inst()->setValue( "app", "configured", "1" );
}
// look whether mixer could use a audio-interface beside audioDummy
else if( eng()->getMixer()->audioDevName() == audioDummy::name() )
{
// no, so we offer setup-dialog with audio-settings...
setupDialog sd( eng(), setupDialog::AUDIO_SETTINGS );
sd.exec();
}
}
int mainWindow::addWidgetToToolBar( QWidget * _w, int _row, int _col )
{
int col = ( _col == -1 ) ? m_toolBarLayout->columnCount() + 6 : _col;
if( _w->height() > 32 || _row == -1 )
{
#ifdef QT4
m_toolBarLayout->addWidget( _w, 0, col, 2, 1 );
#else
m_toolBarLayout->addMultiCellWidget( _w, 0, 1, col, col );
#endif
}
else
{
m_toolBarLayout->addWidget( _w, _row, col );
}
return( col );
}
void mainWindow::addSpacingToToolBar( int _size )
{
m_toolBarLayout->setColumnMinimumWidth( m_toolBarLayout->columnCount() +
6, _size );
}
void mainWindow::resetWindowTitle( const QString & _add )
{
QString title = _add;
if( _add == "" && eng()->getSongEditor()->projectFileName() != "" )
{
title = QFileInfo( eng()->getSongEditor()->projectFileName()
#ifdef QT4
).completeBaseName();
#else
).baseName( TRUE );
#endif
}
if( title != "" )
{
title += " - ";
}
setWindowTitle( title + tr( "LMMS %1" ).arg( VERSION ) );
}
void mainWindow::clearKeyModifiers( void )
{
m_keyMods.m_ctrl = FALSE;
m_keyMods.m_shift = FALSE;
m_keyMods.m_alt = FALSE;
}
void mainWindow::createNewProject( void )
{
if( eng()->getSongEditor()->mayChangeProject() == TRUE )
{
eng()->getSongEditor()->createNewProject();
}
}
void mainWindow::createNewProjectFromTemplate( int _idx )
{
#ifdef QT4
// TODO!!!
#else
if( m_templatesMenu != NULL &&
eng()->getSongEditor()->mayChangeProject() == TRUE )
{
eng()->getSongEditor()->createNewProjectFromTemplate(
configManager::inst()->projectsDir() + "templates/" +
m_templatesMenu->text( _idx ) + ".mpt" );
}
#endif
}
void mainWindow::openProject( void )
{
if( eng()->getSongEditor()->mayChangeProject() == TRUE )
{
#ifdef QT4
QFileDialog ofd( this, tr( "Open project" ), "",
tr( "MultiMedia Project (*.mmp *.xml)" ) );
#else
QFileDialog ofd( QString::null,
tr( "MultiMedia Project (*.mmp *.xml)" ),
this, "", TRUE );
ofd.setWindowTitle( tr( "Open project" ) );
#endif
ofd.setDirectory( configManager::inst()->projectsDir() );
ofd.setFileMode( QFileDialog::ExistingFiles );
if( ofd.exec () == QDialog::Accepted &&
!ofd.selectedFiles().isEmpty() )
{
eng()->getSongEditor()->loadProject(
ofd.selectedFiles()[0] );
}
}
}
bool mainWindow::saveProject( void )
{
if( eng()->getSongEditor()->projectFileName() == "" )
{
return( saveProjectAs() );
}
else
{
eng()->getSongEditor()->saveProject();
}
return( TRUE );
}
bool mainWindow::saveProjectAs( void )
{
#ifdef QT4
QFileDialog sfd( this, tr( "Save project" ), "",
tr( "MultiMedia Project (*.mmp);;"
"MultiMedia Project Template (*.mpt)" ) );
#else
QFileDialog sfd( QString::null,
tr( "MultiMedia Project (*.mmp);;"
"MultiMedia Project Template (*.mpt)" ),
this, "", TRUE );
sfd.setWindowTitle( tr( "Save project" ) );
#endif
sfd.setFileMode( QFileDialog::AnyFile );
QString f = eng()->getSongEditor()->projectFileName();
if( f != "" )
{
sfd.selectFile( QFileInfo( f ).fileName() );
#ifdef QT4
sfd.setDirectory( QFileInfo( f ).absolutePath() );
#else
sfd.setDirectory( QFileInfo( f ).dirPath( TRUE ) );
#endif
}
else
{
sfd.setDirectory( configManager::inst()->projectsDir() );
}
if( sfd.exec () == QFileDialog::Accepted &&
#ifdef QT4
!sfd.selectedFiles().isEmpty() && sfd.selectedFiles()[0] != ""
#else
sfd.selectedFile() != ""
#endif
)
{
#ifdef QT4
eng()->getSongEditor()->saveProjectAs( sfd.selectedFiles()[0] );
#else
eng()->getSongEditor()->saveProjectAs( sfd.selectedFile() );
#endif
return( TRUE );
}
return( FALSE );
}
void mainWindow::showSettingsDialog( void )
{
setupDialog( eng() ).exec();
}
void mainWindow::aboutLMMS( void )
{
aboutDialog().exec();
}
void mainWindow::help( void )
{
QMessageBox::information( this, tr( "Help not available" ),
tr( "Currently there's no help "
"available in LMMS.\n"
"Please visit "
"http://wiki.mindrules.net "
"for documentation on LMMS." ),
QMessageBox::Ok );
}
void mainWindow::toggleBBEditorWin( void )
{
if( eng()->getBBEditor()->isHidden() == TRUE ||
( m_workspace != NULL &&
m_workspace->activeWindow() != eng()->getBBEditor() ) )
{
eng()->getBBEditor()->show();
eng()->getBBEditor()->setFocus();
}
else
{
eng()->getBBEditor()->hide();
}
}
void mainWindow::toggleSongEditorWin( void )
{
if( eng()->getSongEditor()->isHidden() == TRUE ||
( m_workspace != NULL &&
m_workspace->activeWindow() != eng()->getSongEditor() ) )
{
eng()->getSongEditor()->show();
eng()->getSongEditor()->setFocus();
}
else
{
eng()->getSongEditor()->hide();
}
}
void mainWindow::toggleProjectNotesWin( void )
{
if( eng()->getProjectNotes()->isHidden() == TRUE ||
( m_workspace != NULL && m_workspace->activeWindow() !=
eng()->getProjectNotes() ) )
{
eng()->getProjectNotes()->show();
eng()->getProjectNotes()->setFocus();
}
else
{
eng()->getProjectNotes()->hide();
}
}
void mainWindow::togglePianoRollWin( void )
{
if( eng()->getPianoRoll()->isHidden() == TRUE ||
( m_workspace != NULL &&
m_workspace->activeWindow() != eng()->getPianoRoll() ) )
{
eng()->getPianoRoll()->show();
eng()->getPianoRoll()->setFocus();
}
else
{
eng()->getPianoRoll()->hide();
}
}
void mainWindow::closeEvent( QCloseEvent * _ce )
{
if( eng()->getSongEditor()->mayChangeProject() == TRUE )
{
_ce->accept();
}
else
{
_ce->ignore();
}
}
void mainWindow::focusOutEvent( QFocusEvent * _fe )
{
// when loosing focus we do not receive key-(release!)-events anymore,
// so we might miss release-events of one the modifiers we're watching!
clearKeyModifiers();
QMainWindow::leaveEvent( _fe );
}
void mainWindow::keyPressEvent( QKeyEvent * _ke )
{
switch( _ke->key() )
{
case Qt::Key_Control: m_keyMods.m_ctrl = TRUE; break;
case Qt::Key_Shift: m_keyMods.m_shift = TRUE; break;
case Qt::Key_Alt: m_keyMods.m_alt = TRUE; break;
default:
QMainWindow::keyPressEvent( _ke );
}
}
void mainWindow::keyReleaseEvent( QKeyEvent * _ke )
{
switch( _ke->key() )
{
case Qt::Key_Control: m_keyMods.m_ctrl = FALSE; break;
case Qt::Key_Shift: m_keyMods.m_shift = FALSE; break;
case Qt::Key_Alt: m_keyMods.m_alt = FALSE; break;
default:
QMainWindow::keyReleaseEvent( _ke );
}
}
#include "main_window.moc"

View File

@@ -62,6 +62,7 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track,
midiPort * _port ) :
QWidget( _channel_track->tabWidgetParent() ),
settings(),
engineObject( _channel_track->eng() ),
m_channelTrack( _channel_track ),
m_midiPort( _port ),
m_readablePorts( NULL ),
@@ -119,7 +120,7 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track,
// when using with non-raw-clients we can provide buttons showing
// our port-menus when being clicked
midiClient * mc = mixer::inst()->getMIDIClient();
midiClient * mc = eng()->getMixer()->getMIDIClient();
if( mc->isRaw() == FALSE )
{
m_readablePorts = new QMenu( m_setupTabWidget );
@@ -345,7 +346,7 @@ void midiTabWidget::loadSettings( const QDomElement & _this )
void midiTabWidget::inputChannelChanged( int _new_chnl )
{
m_midiPort->setInputChannel( _new_chnl - 1 );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -354,7 +355,7 @@ void midiTabWidget::inputChannelChanged( int _new_chnl )
void midiTabWidget::outputChannelChanged( int _new_chnl )
{
m_midiPort->setOutputChannel( _new_chnl - 1 );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -418,7 +419,7 @@ void midiTabWidget::midiPortModeToggled( bool )
}
#endif
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -450,7 +451,7 @@ void midiTabWidget::readablePortsChanged( void )
#endif
m_readablePorts->clear();
const QStringList & rp = mixer::inst()->getMIDIClient()->
const QStringList & rp = eng()->getMixer()->getMIDIClient()->
readablePorts();
// now insert new ports and restore selections
for( QStringList::const_iterator it = rp.begin(); it != rp.end(); ++it )
@@ -501,7 +502,7 @@ void midiTabWidget::writeablePortsChanged( void )
#endif
m_writeablePorts->clear();
const QStringList & wp = mixer::inst()->getMIDIClient()->
const QStringList & wp = eng()->getMixer()->getMIDIClient()->
writeablePorts();
// now insert new ports and restore selections
for( QStringList::const_iterator it = wp.begin(); it != wp.end(); ++it )
@@ -536,7 +537,7 @@ void midiTabWidget::activatedReadablePort( QAction * _item )
m_receiveCheckBox->setChecked( TRUE );
}
_item->setChecked( !_item->isChecked() );
mixer::inst()->getMIDIClient()->subscribeReadablePort( m_midiPort,
eng()->getMixer()->getMIDIClient()->subscribeReadablePort( m_midiPort,
_item->text(), !_item->isChecked() );
}
@@ -553,7 +554,7 @@ void midiTabWidget::activatedWriteablePort( QAction * _item )
m_sendCheckBox->setChecked( TRUE );
}
_item->setChecked( !_item->isChecked() );
mixer::inst()->getMIDIClient()->subscribeWriteablePort( m_midiPort,
eng()->getMixer()->getMIDIClient()->subscribeWriteablePort( m_midiPort,
_item->text(), !_item->isChecked() );
}
@@ -575,7 +576,7 @@ void midiTabWidget::activatedReadablePort( int _id )
}
m_readablePorts->setItemChecked( _id,
!m_readablePorts->isItemChecked( _id ) );
mixer::inst()->getMIDIClient()->subscribeReadablePort(
eng()->getMixer()->getMIDIClient()->subscribeReadablePort(
m_midiPort, m_readablePorts->text( _id ),
!m_readablePorts->isItemChecked( _id ) );
}
@@ -594,7 +595,7 @@ void midiTabWidget::activatedWriteablePort( int _id )
}
m_writeablePorts->setItemChecked( _id,
!m_writeablePorts->isItemChecked( _id ) );
mixer::inst()->getMIDIClient()->subscribeWriteablePort(
eng()->getMixer()->getMIDIClient()->subscribeWriteablePort(
m_midiPort, m_writeablePorts->text( _id ),
!m_writeablePorts->isItemChecked( _id ) );
}

View File

@@ -57,11 +57,9 @@
sample_rate_t SAMPLE_RATES[QUALITY_LEVELS] = { 44100, 88200 } ;
mixer * mixer::s_instanceOfMe = NULL;
mixer::mixer() :
mixer::mixer( engine * _engine ) :
QObject(),
engineObject( _engine ),
m_framesPerAudioBuffer( DEFAULT_BUFFER_SIZE ),
m_curBuf( NULL ),
m_nextBuf( NULL ),
@@ -73,9 +71,6 @@ mixer::mixer() :
m_mixMutex(),
m_mixMutexLockLevel( 0 )
{
// small hack because code calling mixer::inst() is called out of ctor
s_instanceOfMe = this;
if( configManager::inst()->value( "mixer", "framesperaudiobuffer"
).toInt() >= 32 )
{
@@ -94,17 +89,10 @@ mixer::mixer() :
m_nextBuf = bufferAllocator::alloc<surroundSampleFrame>(
m_framesPerAudioBuffer );
m_audioDev = tryAudioDevices();
m_midiClient = tryMIDIClients();
// now clear our two output-buffers before using them...
clearAudioBuffer( m_curBuf, m_framesPerAudioBuffer );
clearAudioBuffer( m_nextBuf, m_framesPerAudioBuffer );
m_audioDev->startProcessing();
}
@@ -122,6 +110,23 @@ mixer::~mixer()
void mixer::initDevices( void )
{
m_audioDev = tryAudioDevices();
m_midiClient = tryMIDIClients();
}
void mixer::startProcessing( void )
{
m_audioDev->startProcessing();
}
void mixer::stopProcessing( void )
{
m_audioDev->stopProcessing();
@@ -133,7 +138,7 @@ void mixer::stopProcessing( void )
bool mixer::criticalXRuns( void ) const
{
return( ( m_cpuLoad >= 98 &&
songEditor::inst()->realTimeTask() == TRUE ) );
eng()->getSongEditor()->realTimeTask() == TRUE ) );
}
@@ -145,13 +150,14 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
static songEditor::playPos last_metro_pos = -1;
songEditor::playPos p = songEditor::inst()->getPlayPos(
songEditor::playPos p = eng()->getSongEditor()->getPlayPos(
songEditor::PLAY_PATTERN );
if( songEditor::inst()->playMode() == songEditor::PLAY_PATTERN &&
pianoRoll::inst()->isRecording() == TRUE &&
if( eng()->getSongEditor()->playMode() == songEditor::PLAY_PATTERN &&
eng()->getPianoRoll()->isRecording() == TRUE &&
p != last_metro_pos && p.getTact64th() % 16 == 0 )
{
addPlayHandle( new samplePlayHandle( "misc/metronome01.ogg" ) );
addPlayHandle( new samplePlayHandle( "misc/metronome01.ogg",
eng() ) );
last_metro_pos = p;
}
@@ -208,7 +214,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
}
}
songEditor::inst()->processNextBuffer();
eng()->getSongEditor()->processNextBuffer();
for( vvector<audioPort *>::iterator it = m_audioPorts.begin();
it != m_audioPorts.end(); ++it )
@@ -229,7 +235,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
// and trigger LFOs
envelopeAndLFOWidget::triggerLFO();
envelopeAndLFOWidget::triggerLFO( eng() );
const float new_cpu_load = timer.elapsed() / 10000.0f * sampleRate() /
m_framesPerAudioBuffer;
@@ -427,7 +433,7 @@ audioDevice * mixer::tryAudioDevices( void )
if( dev_name == audioALSA::name() || dev_name == "" )
{
dev = new audioALSA( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful );
success_ful, this );
if( success_ful )
{
m_audioDevName = audioALSA::name();
@@ -442,7 +448,7 @@ audioDevice * mixer::tryAudioDevices( void )
if( dev_name == audioOSS::name() || dev_name == "" )
{
dev = new audioOSS( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful );
success_ful, this );
if( success_ful )
{
m_audioDevName = audioOSS::name();
@@ -457,7 +463,7 @@ audioDevice * mixer::tryAudioDevices( void )
if( dev_name == audioJACK::name() || dev_name == "" )
{
dev = new audioJACK( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful );
success_ful, this );
if( success_ful )
{
m_audioDevName = audioJACK::name();
@@ -472,7 +478,7 @@ audioDevice * mixer::tryAudioDevices( void )
if( dev_name == audioSDL::name() || dev_name == "" )
{
dev = new audioSDL( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful );
success_ful, this );
if( success_ful )
{
m_audioDevName = audioSDL::name();
@@ -483,7 +489,7 @@ audioDevice * mixer::tryAudioDevices( void )
#endif
// add more device-classes here...
//dev = new audioXXXX( SAMPLE_RATES[m_qualityLevel], success_ful );
//dev = new audioXXXX( SAMPLE_RATES[m_qualityLevel], success_ful, this );
//if( sucess_ful )
//{
// return( dev );
@@ -496,7 +502,8 @@ audioDevice * mixer::tryAudioDevices( void )
m_audioDevName = audioDummy::name();
return( new audioDummy( SAMPLE_RATES[m_qualityLevel], success_ful ) );
return( new audioDummy( SAMPLE_RATES[m_qualityLevel], success_ful,
this ) );
}
@@ -510,7 +517,7 @@ midiClient * mixer::tryMIDIClients( void )
#ifdef ALSA_SUPPORT
if( client_name == midiALSASeq::name() || client_name == "" )
{
midiALSASeq * malsas = new midiALSASeq();
midiALSASeq * malsas = new midiALSASeq( eng() );
if( malsas->isRunning() )
{
m_midiClientName = midiALSASeq::name();
@@ -521,7 +528,7 @@ midiClient * mixer::tryMIDIClients( void )
if( client_name == midiALSARaw::name() || client_name == "" )
{
midiALSARaw * malsar = new midiALSARaw();
midiALSARaw * malsar = new midiALSARaw( eng() );
if( malsar->isRunning() )
{
m_midiClientName = midiALSARaw::name();
@@ -534,7 +541,7 @@ midiClient * mixer::tryMIDIClients( void )
#ifdef OSS_SUPPORT
if( client_name == midiOSS::name() || client_name == "" )
{
midiOSS * moss = new midiOSS();
midiOSS * moss = new midiOSS( eng() );
if( moss->isRunning() )
{
m_midiClientName = midiOSS::name();
@@ -549,7 +556,7 @@ midiClient * mixer::tryMIDIClients( void )
m_midiClientName = midiDummy::name();
return( new midiDummy() );
return( new midiDummy( eng() ) );
}

View File

@@ -50,8 +50,10 @@
nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent ) :
nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent,
engine * _engine ) :
QLabel( _initial_name, _parent ),
engineObject( _engine ),
m_pixmap(),
m_pixmapFile( "" )
{
@@ -267,7 +269,8 @@ void nameLabel::paintEvent( QPaintEvent * )
}
p.setPen( QColor( 0, 224, 0 ) );
bbTrack * bbt = bbTrack::findBBTrack( bbEditor::inst()->currentBB() );
bbTrack * bbt = bbTrack::findBBTrack(
eng()->getBBEditor()->currentBB(), eng() );
if( bbt != NULL && bbt->getTrackSettingsWidget() ==
dynamic_cast<trackSettingsWidget *>( parentWidget() ) )
{

View File

@@ -1,7 +1,7 @@
/*
* note.cpp - implementation of class note
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*

View File

@@ -24,8 +24,6 @@
*/
#include <qmap.h>
#include "note_play_handle.h"
#include "channel_track.h"
#include "envelope_tab_widget.h"
@@ -38,11 +36,11 @@
notePlayHandle::notePlayHandle( channelTrack * _chnl_trk,
const Uint32 _frames_ahead,
const Uint32 _frames,
const f_cnt_t _frames_ahead,
const f_cnt_t _frames,
note * _n,
const bool _arp_note ) :
playHandle( NOTE_PLAY_HANDLE ),
playHandle( NOTE_PLAY_HANDLE, _chnl_trk->eng() ),
note( *_n ),
m_pluginData( NULL ),
m_filter( NULL ),
@@ -72,8 +70,8 @@ notePlayHandle::notePlayHandle( channelTrack * _chnl_trk,
(Uint16) ( ( getVolume() / 100.0f ) *
( m_channelTrack->getVolume() / 100.0f ) *
127 ), 0, 127 ) ),
midiTime::fromFrames( m_framesAhead,
songEditor::inst()->framesPerTact() ) );
midiTime::fromFrames( m_framesAhead,
eng()->getSongEditor()->framesPerTact() ) );
}
@@ -112,8 +110,8 @@ void notePlayHandle::play( void )
}
if( m_released == FALSE &&
m_totalFramesPlayed + mixer::inst()->framesPerAudioBuffer() >=
m_frames )
m_totalFramesPlayed +
eng()->getMixer()->framesPerAudioBuffer() >= m_frames )
{
noteOff( m_frames - m_totalFramesPlayed );
}
@@ -123,7 +121,7 @@ void notePlayHandle::play( void )
if( m_released == TRUE )
{
Uint32 todo = mixer::inst()->framesPerAudioBuffer();
f_cnt_t todo = eng()->getMixer()->framesPerAudioBuffer();
// if this note is base-note for arpeggio, always set
// m_releaseFramesToDo to bigger value than m_releaseFramesDone
// because we do not allow notePlayHandle::done() to be true
@@ -132,7 +130,7 @@ void notePlayHandle::play( void )
if( arpBaseNote() == TRUE )
{
m_releaseFramesToDo = m_releaseFramesDone + 2 *
mixer::inst()->framesPerAudioBuffer();
eng()->getMixer()->framesPerAudioBuffer();
}
// look whether we have frames left to be done before release
if( m_framesBeforeRelease )
@@ -140,7 +138,7 @@ void notePlayHandle::play( void )
// yes, then look whether these samples can be played
// within one audio-buffer
if( m_framesBeforeRelease <=
mixer::inst()->framesPerAudioBuffer() )
eng()->getMixer()->framesPerAudioBuffer() )
{
// yes, then we did less releaseFramesDone
todo -= m_framesBeforeRelease;
@@ -153,7 +151,7 @@ void notePlayHandle::play( void )
// release-phase yet)
todo = 0;
m_framesBeforeRelease -=
mixer::inst()->framesPerAudioBuffer();
eng()->getMixer()->framesPerAudioBuffer();
}
}
// look whether we're in release-phase
@@ -201,7 +199,7 @@ void notePlayHandle::play( void )
}
// update internal data
m_totalFramesPlayed += mixer::inst()->framesPerAudioBuffer();
m_totalFramesPlayed += eng()->getMixer()->framesPerAudioBuffer();
}
@@ -233,7 +231,7 @@ void notePlayHandle::checkValidity( void )
void notePlayHandle::noteOff( Uint32 _s )
void notePlayHandle::noteOff( const f_cnt_t _s )
{
// first note-off all sub-notes
for( notePlayHandleVector::iterator it = m_subNotes.begin();
@@ -260,7 +258,7 @@ void notePlayHandle::noteOff( Uint32 _s )
key(), 0 ),
midiTime::fromFrames(
m_framesBeforeRelease,
songEditor::inst()->framesPerTact() ) );
eng()->getSongEditor()->framesPerTact() ) );
}
else
{
@@ -273,7 +271,7 @@ void notePlayHandle::noteOff( Uint32 _s )
Uint32 notePlayHandle::actualReleaseFramesToDo( void ) const
f_cnt_t notePlayHandle::actualReleaseFramesToDo( void ) const
{
return( ( m_channelTrack != NULL ) ?
m_channelTrack->m_envWidget->releaseFrames() : 0 );
@@ -282,7 +280,7 @@ Uint32 notePlayHandle::actualReleaseFramesToDo( void ) const
void notePlayHandle::setFrames( Uint32 _frames )
void notePlayHandle::setFrames( const f_cnt_t _frames )
{
m_frames = _frames;
if( m_frames == 0 && m_channelTrack != NULL )
@@ -294,7 +292,7 @@ void notePlayHandle::setFrames( Uint32 _frames )
float notePlayHandle::volumeLevel( Uint32 _frame )
float notePlayHandle::volumeLevel( const f_cnt_t _frame )
{
return( ( m_channelTrack != NULL ) ?
m_channelTrack->m_envWidget->volumeLevel( this, _frame ) : 0 );
@@ -319,7 +317,7 @@ void notePlayHandle::mute( void )
int notePlayHandle::index( void ) const
{
const playHandleVector & phv = mixer::inst()->playHandles();
const playHandleVector & phv = eng()->getMixer()->playHandles();
int idx = 0;
for( constPlayHandleVector::const_iterator it = phv.begin();
it != phv.end(); ++it )
@@ -346,7 +344,7 @@ int notePlayHandle::index( void ) const
constNotePlayHandleVector notePlayHandle::nphsOfChannelTrack(
const channelTrack * _ct )
{
const playHandleVector & phv = mixer::inst()->playHandles();
const playHandleVector & phv = _ct->eng()->getMixer()->playHandles();
constNotePlayHandleVector cnphv;
for( constPlayHandleVector::const_iterator it = phv.begin();

View File

@@ -56,7 +56,7 @@
#include "piano_roll.h"
#include "song_editor.h"
#include "lmms_main_win.h"
#include "main_window.h"
#include "pattern.h"
#include "embed.h"
#include "pixmap_button.h"
@@ -103,9 +103,6 @@ const int NE_LINE_WIDTH = 3;
const int INITIAL_START_KEY = C + OCTAVE_3 * NOTES_PER_OCTAVE;
// init static members of pianoRoll
pianoRoll * pianoRoll::s_instanceOfMe = NULL;
QPixmap * pianoRoll::s_whiteKeySmallPm = NULL;
QPixmap * pianoRoll::s_whiteKeyBigPm = NULL;
QPixmap * pianoRoll::s_blackKeyPm = NULL;
@@ -126,8 +123,9 @@ pianoRoll::pianoRollKeyTypes pianoRoll::prKeyOrder[] =
const int DEFAULT_PR_PPT = KEY_LINE_HEIGHT * DEFAULT_STEPS_PER_TACT;
pianoRoll::pianoRoll( void ) :
QWidget( lmmsMainWin::inst()->workspace() ),
pianoRoll::pianoRoll( engine * _engine ) :
QWidget( _engine->getMainWindow()->workspace() ),
engineObject( _engine ),
m_paintPixmap(),
m_cursorInside( FALSE ),
m_pattern( NULL ),
@@ -185,14 +183,15 @@ pianoRoll::pianoRoll( void ) :
#ifdef QT4
// add us to workspace
lmmsMainWin::inst()->workspace()->addWindow( this );
eng()->getMainWindow()->workspace()->addWindow( this );
#endif
// add time-line
m_timeLine = new timeLine( WHITE_KEY_WIDTH, 32, m_ppt,
songEditor::inst()->getPlayPos(
eng()->getSongEditor()->getPlayPos(
songEditor::PLAY_PATTERN ),
m_currentPosition, this );
m_currentPosition, this,
eng() );
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
m_timeLine, SLOT( updatePosition( const midiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const midiTime & ) ),
@@ -459,12 +458,7 @@ void pianoRoll::setCurrentPattern( pattern * _new_pattern )
if( validPattern() == FALSE )
{
// we must not call resizeEvent with NULL-pointer when
// being called of of ctor
if( s_instanceOfMe == this )
{
resizeEvent( NULL );
}
//resizeEvent( NULL );
setWindowTitle( tr( "Piano-Roll - no pattern" ) );
update();
@@ -1050,7 +1044,7 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
break;
case Qt::Key_Space:
if( songEditor::inst()->playing() )
if( eng()->getSongEditor()->playing() )
{
stop();
}
@@ -1236,7 +1230,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
QApplication::setOverrideCursor( c );
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
else if( ( _me->button() == Qt::RightButton &&
m_editMode == DRAW ) ||
@@ -1256,7 +1250,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
( *it )->setLength( 0 );
m_pattern->update();
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
}
else if( _me->button() == Qt::LeftButton &&
@@ -1295,7 +1289,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
m_action = MOVE_SELECTION;
play_note = FALSE;
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
else if( _me->button() == Qt::RightButton &&
m_editMode == MOVE )
@@ -1311,7 +1305,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
// was there an action where should be played the note?
if( play_note == TRUE && m_recording == FALSE &&
songEditor::inst()->playing() == FALSE )
eng()->getSongEditor()->playing() == FALSE )
{
m_pattern->getChannelTrack()->processInEvent(
midiEvent( NOTE_ON, 0, key_num,
@@ -1403,7 +1397,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
m_action != SELECT_NOTES &&
m_action != MOVE_SELECTION &&
m_recording == FALSE &&
songEditor::inst()->playing() == FALSE )
eng()->getSongEditor()->playing() == FALSE )
{
m_pattern->getChannelTrack()->processInEvent(
midiEvent( NOTE_ON, 0, key_num,
@@ -1483,7 +1477,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
m_pattern->update();
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
else if(
@@ -1907,7 +1901,6 @@ void pianoRoll::paintEvent( QPaintEvent * )
// responsible for moving/resizing scrollbars after window-resizing
void pianoRoll::resizeEvent( QResizeEvent * )
{
m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH, height() -
SCROLLBAR_SIZE,
width()-WHITE_KEY_WIDTH,
@@ -1936,9 +1929,10 @@ void pianoRoll::resizeEvent( QResizeEvent * )
}
m_topBottomScroll->setValue( m_totalKeysToScroll - m_startKey );
songEditor::inst()->getPlayPos( songEditor::PLAY_PATTERN
eng()->getSongEditor()->getPlayPos( songEditor::PLAY_PATTERN
).m_timeLine->setFixedWidth( width() );
m_toolBar->setFixedWidth( width() );
update();
}
@@ -1947,7 +1941,7 @@ void pianoRoll::resizeEvent( QResizeEvent * )
void pianoRoll::wheelEvent( QWheelEvent * _we )
{
_we->accept();
if( lmmsMainWin::isCtrlPressed() == TRUE )
if( eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
if( _we->delta() > 0 )
{
@@ -1967,7 +1961,7 @@ void pianoRoll::wheelEvent( QWheelEvent * _we )
m_timeLine->setPixelsPerTact( m_ppt );
update();
}
else if( lmmsMainWin::isShiftPressed() )
else if( eng()->getMainWindow()->isShiftPressed() )
{
m_leftRightScroll->setValue( m_leftRightScroll->value() -
_we->delta() * 2 / 15 );
@@ -2013,30 +2007,31 @@ void pianoRoll::play( void )
return;
}
if( songEditor::inst()->playing() )
if( eng()->getSongEditor()->playing() )
{
if( songEditor::inst()->playMode() != songEditor::PLAY_PATTERN )
if( eng()->getSongEditor()->playMode() !=
songEditor::PLAY_PATTERN )
{
songEditor::inst()->stop();
songEditor::inst()->playPattern( m_pattern );
eng()->getSongEditor()->stop();
eng()->getSongEditor()->playPattern( m_pattern );
m_playButton->setIcon( embed::getIconPixmap(
"pause" ) );
}
else
{
songEditor::inst()->pause();
eng()->getSongEditor()->pause();
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
}
}
else if( songEditor::inst()->paused() )
else if( eng()->getSongEditor()->paused() )
{
songEditor::inst()->resumeFromPause();
eng()->getSongEditor()->resumeFromPause();
m_playButton->setIcon( embed::getIconPixmap( "pause" ) );
}
else
{
m_playButton->setIcon( embed::getIconPixmap( "pause" ) );
songEditor::inst()->playPattern( m_pattern );
eng()->getSongEditor()->playPattern( m_pattern );
}
}
@@ -2045,7 +2040,7 @@ void pianoRoll::play( void )
void pianoRoll::record( void )
{
if( songEditor::inst()->playing() )
if( eng()->getSongEditor()->playing() )
{
stop();
}
@@ -2055,7 +2050,7 @@ void pianoRoll::record( void )
}
m_recording = TRUE;
songEditor::inst()->playPattern( m_pattern, FALSE );
eng()->getSongEditor()->playPattern( m_pattern, FALSE );
}
@@ -2063,7 +2058,7 @@ void pianoRoll::record( void )
void pianoRoll::stop( void )
{
songEditor::inst()->stop();
eng()->getSongEditor()->stop();
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
m_playButton->update();
m_recording = FALSE;
@@ -2078,7 +2073,7 @@ void pianoRoll::recordNote( const note & _n )
if( m_recording == TRUE && validPattern() == TRUE )
{
note n( _n );
n.setPos( songEditor::inst()->getPlayPos(
n.setPos( eng()->getSongEditor()->getPlayPos(
songEditor::PLAY_PATTERN ) - n.length() );
#ifndef QT4
qApp->lock();
@@ -2088,7 +2083,7 @@ void pianoRoll::recordNote( const note & _n )
#ifndef QT4
qApp->unlock();
#endif
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
}
@@ -2315,7 +2310,7 @@ void pianoRoll::cutSelectedNotes( void )
if( selected_notes.empty() == FALSE )
{
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
midiTime start_pos( selected_notes.front()->pos().getTact(),
0 );
@@ -2334,7 +2329,7 @@ void pianoRoll::cutSelectedNotes( void )
}
update();
songEditor::inst()->update();
eng()->getSongEditor()->update();
}
@@ -2359,9 +2354,9 @@ void pianoRoll::pasteNotes( void )
// we only have to do the following lines if we pasted at
// least one note...
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
songEditor::inst()->update ();
eng()->getSongEditor()->update();
}
}
@@ -2386,11 +2381,11 @@ void pianoRoll::deleteSelectedNotes( void )
selected_notes.erase( selected_notes.begin() );
}
if( update_after_delete )
if( update_after_delete == TRUE )
{
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
songEditor::inst()->update();
eng()->getSongEditor()->update();
}
}
@@ -2399,8 +2394,9 @@ void pianoRoll::deleteSelectedNotes( void )
void pianoRoll::updatePosition( const midiTime & _t )
{
if( ( songEditor::inst()->playing() &&
songEditor::inst()->playMode() == songEditor::PLAY_PATTERN ) ||
if( ( eng()->getSongEditor()->playing() &&
eng()->getSongEditor()->playMode() ==
songEditor::PLAY_PATTERN ) ||
m_scrollBack == TRUE )
{
const int w = width() - WHITE_KEY_WIDTH;

View File

@@ -61,8 +61,9 @@ static plugin::descriptor dummy_plugin_descriptor =
plugin::plugin( const descriptor * _descriptor ) :
plugin::plugin( const descriptor * _descriptor, engine * _engine ) :
settings(),
engineObject( _engine ),
m_descriptor( _descriptor )
{
if( m_descriptor == NULL )

View File

@@ -1,7 +1,7 @@
/*
* plugin_browser.cpp - implementation of the plugin-browser
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -49,9 +49,10 @@
pluginBrowser::pluginBrowser( QWidget * _parent ) :
pluginBrowser::pluginBrowser( QWidget * _parent, engine * _engine ) :
sideBarWidget( tr( "Instrument plugins" ),
embed::getIconPixmap( "plugins" ), _parent )
embed::getIconPixmap( "plugins" ), _parent ),
engineObject( _engine )
{
setWindowTitle( tr( "Plugin browser" ) );
m_view = new QWidget( contentParent() );
@@ -84,7 +85,8 @@ pluginBrowser::pluginBrowser( QWidget * _parent ) :
m_pluginDescriptors.begin();
it != m_pluginDescriptors.end(); ++it )
{
pluginDescWidget * p = new pluginDescWidget( *it, m_view );
pluginDescWidget * p = new pluginDescWidget( *it, m_view,
eng() );
p->show();
view_layout->addWidget( p );
}
@@ -106,8 +108,9 @@ pluginBrowser::~pluginBrowser()
pluginDescWidget::pluginDescWidget( const plugin::descriptor & _pd,
QWidget * _parent ) :
QWidget * _parent, engine * _engine ) :
QWidget( _parent ),
engineObject( _engine ),
m_pluginDescriptor( _pd ),
m_logo(),
m_mouseOver( FALSE )
@@ -234,7 +237,7 @@ void pluginDescWidget::mousePressEvent( QMouseEvent * _me )
if( _me->button() == Qt::LeftButton )
{
new stringPairDrag( "instrument", m_pluginDescriptor.name,
m_logo, this );
m_logo, this, eng() );
m_mouseOver = FALSE;
update();
}

View File

@@ -48,19 +48,26 @@
// invisible track-container which is needed as parents for preview-channels
class blindTrackContainer : public trackContainer
// invisible track-container which is needed as parent for preview-channels
class previewTrackContainer : public trackContainer
{
public:
static inline blindTrackContainer * inst( void )
previewTrackContainer( engine * _engine ) :
trackContainer( _engine ),
m_previewChannelTrack( dynamic_cast<channelTrack *>(
track::create( track::CHANNEL_TRACK,
this ) )),
m_previewNote( NULL ),
m_dataMutex()
{
if( s_instanceOfMe == NULL )
{
s_instanceOfMe = new blindTrackContainer();
}
return( s_instanceOfMe );
hide();
}
virtual ~previewTrackContainer()
{
}
// implement pure-virtual functions...
virtual inline bool fixedTCOs( void ) const
{
@@ -69,83 +76,87 @@ public:
virtual inline QString nodeName( void ) const
{
return( "blindtc" );
return( "previewtc" );
}
channelTrack * previewChannelTrack( void )
{
return( m_previewChannelTrack );
}
notePlayHandle * previewNote( void )
{
return( m_previewNote );
}
void setPreviewNote( notePlayHandle * _note )
{
m_previewNote = _note;
}
void lockData( void )
{
m_dataMutex.lock();
}
void unlockData( void )
{
m_dataMutex.unlock();
}
private:
blindTrackContainer( void ) :
trackContainer()
{
hide();
}
virtual ~blindTrackContainer()
{
}
static blindTrackContainer * s_instanceOfMe;
friend void presetPreviewPlayHandle::cleanUp( void );
channelTrack * m_previewChannelTrack;
notePlayHandle * m_previewNote;
QMutex m_dataMutex;
} ;
QMap<const engine *, previewTrackContainer *>
presetPreviewPlayHandle::s_previewTCs;
blindTrackContainer * blindTrackContainer::s_instanceOfMe = NULL;
channelTrack * presetPreviewPlayHandle::s_globalChannelTrack = NULL;
notePlayHandle * presetPreviewPlayHandle::s_globalPreviewNote = NULL;
QMutex presetPreviewPlayHandle::s_globalDataMutex;
presetPreviewPlayHandle::presetPreviewPlayHandle(
const QString & _preset_file ) :
playHandle( PRESET_PREVIEW_PLAY_HANDLE ),
const QString & _preset_file,
engine * _engine ) :
playHandle( PRESET_PREVIEW_PLAY_HANDLE, _engine ),
m_previewNote( NULL )
{
/* if( s_globalDataMutex == NULL )
if( s_previewTCs.contains( _engine ) == FALSE )
{
s_globalDataMutex = new QMutex;
s_previewTCs[_engine] = new previewTrackContainer( eng() );
}
s_globalDataMutex->lock();*/
s_globalDataMutex.lock();
previewTC()->lockData();
if( s_globalPreviewNote != NULL )
if( previewTC()->previewNote() != NULL )
{
s_globalPreviewNote->mute();
previewTC()->previewNote()->mute();
}
multimediaProject mmp( _preset_file );
if( s_globalChannelTrack == NULL )
{
track * t = track::create( track::CHANNEL_TRACK,
blindTrackContainer::inst() );
s_globalChannelTrack = dynamic_cast<channelTrack *>( t );
#ifdef LMMS_DEBUG
assert( s_globalChannelTrack != NULL );
#endif
}
s_globalChannelTrack->loadTrackSpecificSettings( mmp.content().
firstChild().
toElement() );
previewTC()->previewChannelTrack()->loadTrackSpecificSettings(
mmp.content().firstChild().toElement() );
// make sure, our preset-preview-track does not appear in any MIDI-
// devices list, so just disable receiving/sending MIDI-events at all
s_globalChannelTrack->m_midiPort->setMode( midiPort::DUMMY );
previewTC()->previewChannelTrack()->m_midiPort->setMode(
midiPort::DUMMY );
// create temporary note
note n( 0, 0, static_cast<tones>( A ),
static_cast<octaves>( DEFAULT_OCTAVE-1 ), 100 );
// create note-play-handle for it
m_previewNote = new notePlayHandle( s_globalChannelTrack, 0, ~0, &n );
m_previewNote = new notePlayHandle( previewTC()->previewChannelTrack(),
0, ~0, &n );
s_globalPreviewNote = m_previewNote;
previewTC()->setPreviewNote( m_previewNote );
s_globalDataMutex.unlock();
previewTC()->unlockData();
}
@@ -153,13 +164,15 @@ presetPreviewPlayHandle::presetPreviewPlayHandle(
presetPreviewPlayHandle::~presetPreviewPlayHandle()
{
s_globalDataMutex.lock();
previewTC()->lockData();
// not muted by other preset-preview-handle?
if( m_previewNote->muted() == FALSE )
{
s_globalPreviewNote = NULL;
// then set according state
previewTC()->setPreviewNote( NULL );
}
delete m_previewNote;
s_globalDataMutex.unlock();
previewTC()->unlockData();
}
@@ -181,9 +194,13 @@ bool presetPreviewPlayHandle::done( void ) const
void presetPreviewPlayHandle::cleanUp( void )
void presetPreviewPlayHandle::cleanUp( engine * _engine )
{
delete blindTrackContainer::inst();
if( s_previewTCs.contains( _engine ) == TRUE )
{
delete s_previewTCs[_engine];
s_previewTCs.remove( _engine );
}
}
@@ -193,13 +210,17 @@ constNotePlayHandleVector presetPreviewPlayHandle::nphsOfChannelTrack(
const channelTrack * _ct )
{
constNotePlayHandleVector cnphv;
s_globalDataMutex.lock();
if( s_globalPreviewNote != NULL &&
s_globalPreviewNote->getChannelTrack() == _ct )
if( s_previewTCs.contains( _ct->eng() ) == TRUE )
{
cnphv.push_back( s_globalPreviewNote );
previewTrackContainer * tc = s_previewTCs[_ct->eng()];
tc->lockData();
if( tc->previewNote() != NULL &&
tc->previewNote()->getChannelTrack() == _ct )
{
cnphv.push_back( tc->previewNote() );
}
tc->unlockData();
}
s_globalDataMutex.unlock();
return( cnphv );
}

View File

@@ -1,7 +1,7 @@
/*
* sample_play_handle.cpp - implementation of class samplePlayHandle
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -23,11 +23,6 @@
*/
#include "qt3support.h"
#ifndef QT4
#include <qpair.h>
#endif
#include "sample_play_handle.h"
#include "sample_buffer.h"
#include "buffer_allocator.h"
@@ -35,13 +30,14 @@
samplePlayHandle::samplePlayHandle( const QString & _sample_file ) :
playHandle( SAMPLE_PLAY_HANDLE ),
m_sampleBuffer( new sampleBuffer( _sample_file ) ),
samplePlayHandle::samplePlayHandle( const QString & _sample_file,
engine * _engine ) :
playHandle( SAMPLE_PLAY_HANDLE, _engine ),
m_sampleBuffer( new sampleBuffer( eng(), _sample_file ) ),
m_ownSampleBuffer( TRUE ),
m_doneMayReturnTrue( TRUE ),
m_frame( 0 ),
m_audioPort( new audioPort( "samplePlayHandle" ) )
m_audioPort( new audioPort( "samplePlayHandle", eng() ) )
{
}
@@ -49,17 +45,18 @@ samplePlayHandle::samplePlayHandle( const QString & _sample_file ) :
samplePlayHandle::samplePlayHandle( sampleBuffer * _sample_buffer ) :
playHandle( SAMPLE_PLAY_HANDLE ),
playHandle( SAMPLE_PLAY_HANDLE, _sample_buffer->eng() ),
m_sampleBuffer( _sample_buffer ),
m_ownSampleBuffer( FALSE ),
m_doneMayReturnTrue( TRUE ),
m_frame( 0 ),
m_audioPort( new audioPort( "samplePlayHandle" ) )
m_audioPort( new audioPort( "samplePlayHandle", eng() ) )
{
}
samplePlayHandle::~samplePlayHandle()
{
if( m_ownSampleBuffer == TRUE )
@@ -79,21 +76,19 @@ void samplePlayHandle::play( void )
return;
}
sampleFrame * buf = bufferAllocator::alloc<sampleFrame>(
mixer::inst()->framesPerAudioBuffer() *
DEFAULT_CHANNELS );
const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer();
sampleFrame * buf = bufferAllocator::alloc<sampleFrame>( frames );
volumeVector v = { 1.0f, 1.0f
#ifndef DISABLE_SURROUND
, 1.0f, 1.0f
#endif
} ;
m_sampleBuffer->play( buf, m_frame );
mixer::inst()->bufferToPort( buf, mixer::inst()->framesPerAudioBuffer(),
0, v, m_audioPort );
m_sampleBuffer->play( buf, m_frame, frames );
eng()->getMixer()->bufferToPort( buf, frames, 0, v, m_audioPort );
bufferAllocator::free( buf );
m_frame += mixer::inst()->framesPerAudioBuffer();
m_frame += frames;
}
@@ -107,7 +102,7 @@ bool samplePlayHandle::done( void ) const
Uint32 samplePlayHandle::totalFrames( void ) const
f_cnt_t samplePlayHandle::totalFrames( void ) const
{
return( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() );
}

View File

@@ -96,9 +96,10 @@ inline void labelWidget( QWidget * _w, const QString & _txt )
setupDialog::setupDialog( configTabs _tab_to_open ) :
setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
QDialog(),
m_bufferSize( mixer::inst()->framesPerAudioBuffer() ),
engineObject( _engine ),
m_bufferSize( eng()->getMixer()->framesPerAudioBuffer() ),
m_disableToolTips( configManager::inst()->value( "tooltips",
"disabled" ).toInt() ),
m_classicalKnobUsability( configManager::inst()->value( "knobs",
@@ -401,11 +402,11 @@ setupDialog::setupDialog( configTabs _tab_to_open ) :
}
#ifdef QT4
m_audioInterfaces->setCurrentIndex( m_audioInterfaces->findText(
mixer::inst()->audioDevName() ) );
eng()->getMixer()->audioDevName() ) );
#else
m_audioInterfaces->setCurrentText( mixer::inst()->audioDevName() );
m_audioInterfaces->setCurrentText( eng()->getMixer()->audioDevName() );
#endif
m_audioIfaceSetupWidgets[mixer::inst()->audioDevName()]->show();
m_audioIfaceSetupWidgets[eng()->getMixer()->audioDevName()]->show();
connect( m_audioInterfaces, SIGNAL( activated( const QString & ) ),
this, SLOT( audioInterfaceChanged( const QString & ) ) );
@@ -482,11 +483,11 @@ setupDialog::setupDialog( configTabs _tab_to_open ) :
#ifdef QT4
m_midiInterfaces->setCurrentIndex( m_midiInterfaces->findText(
mixer::inst()->midiClientName() ) );
eng()->getMixer()->midiClientName() ) );
#else
m_midiInterfaces->setCurrentText( mixer::inst()->midiClientName() );
m_midiInterfaces->setCurrentText( eng()->getMixer()->midiClientName() );
#endif
m_midiIfaceSetupWidgets[mixer::inst()->midiClientName()]->show();
m_midiIfaceSetupWidgets[eng()->getMixer()->midiClientName()]->show();
connect( m_midiInterfaces, SIGNAL( activated( const QString & ) ),
this, SLOT( midiInterfaceChanged( const QString & ) ) );
@@ -642,7 +643,7 @@ void setupDialog::setBufferSize( int _value )
m_bufSizeLbl->setText( tr( "Frames: %1\nLatency: %2 ms" ).arg(
m_bufferSize ).arg(
1000.0f * m_bufferSize /
mixer::inst()->sampleRate(),
eng()->getMixer()->sampleRate(),
0, 'f', 1 ) );
}

View File

@@ -89,20 +89,15 @@
#include "cpuload_widget.h"
#include "text_float.h"
#include "combobox.h"
#include "main_window.h"
#include "debug.h"
extern QString file_to_load;
songEditor * songEditor::s_instanceOfMe = NULL;
songEditor::songEditor() :
trackContainer(),
songEditor::songEditor( engine * _engine ) :
trackContainer( _engine ),
m_fileName( "" ),
m_oldFileName( "" ),
m_exporting( FALSE ),
@@ -115,14 +110,9 @@ songEditor::songEditor() :
m_loopPattern( FALSE ),
m_scrollBack( FALSE )
{
// hack, because code called out of this function uses
// songEditor::inst(), which assigns s_instanceOfMe this function
// returns...
s_instanceOfMe = this;
setWindowTitle( tr( "Song-Editor" ) );
setWindowIcon( embed::getIconPixmap( "songeditor" ) );
if( lmmsMainWin::inst()->workspace() != NULL )
if( eng()->getMainWindow()->workspace() != NULL )
{
setGeometry( 10, 10, 680, 300 );
}
@@ -146,7 +136,7 @@ songEditor::songEditor() :
timeLine * tl = new timeLine( TRACK_OP_WIDTH +
DEFAULT_SETTINGS_WIDGET_WIDTH, 32,
pixelsPerTact(), m_playPos[PLAY_SONG],
m_currentPosition, cw );
m_currentPosition, cw, eng() );
connect( this, SIGNAL( positionChanged( const midiTime & ) ),
m_playPos[PLAY_SONG].m_timeLine,
SLOT( updatePosition( const midiTime & ) ) );
@@ -155,14 +145,14 @@ songEditor::songEditor() :
// add some essential widgets to global tool-bar
QWidget * tb = lmmsMainWin::inst()->toolBar();
QWidget * tb = eng()->getMainWindow()->toolBar();
lmmsMainWin::inst()->addSpacingToToolBar( 10 );
eng()->getMainWindow()->addSpacingToToolBar( 10 );
m_bpmSpinBox = new lcdSpinBox( MIN_BPM, MAX_BPM, 3, tb );
m_bpmSpinBox->setLabel( tr( "TEMPO/BPM" ) );
connect( m_bpmSpinBox, SIGNAL( valueChanged( int ) ), this,
SLOT( setBPM( int ) ) );
SLOT( setTempo( int ) ) );
toolTip::add( m_bpmSpinBox, tr( "tempo of song" ) );
#ifdef QT4
@@ -177,20 +167,20 @@ songEditor::songEditor() :
"should be played within a minute (or how many tacts "
"should be played within four minutes)." ) );
int col = lmmsMainWin::inst()->addWidgetToToolBar( m_bpmSpinBox, 0 );
int col = eng()->getMainWindow()->addWidgetToToolBar( m_bpmSpinBox, 0 );
toolButton * hq_btn = new toolButton( embed::getIconPixmap( "hq_mode" ),
tr( "High quality mode" ),
NULL, NULL, tb );
hq_btn->setCheckable( TRUE );
connect( hq_btn, SIGNAL( toggled( bool ) ), mixer::inst(),
connect( hq_btn, SIGNAL( toggled( bool ) ), eng()->getMixer(),
SLOT( setHighQuality( bool ) ) );
hq_btn->setFixedWidth( 42 );
lmmsMainWin::inst()->addWidgetToToolBar( hq_btn, 1, col );
eng()->getMainWindow()->addWidgetToToolBar( hq_btn, 1, col );
lmmsMainWin::inst()->addSpacingToToolBar( 10 );
eng()->getMainWindow()->addSpacingToToolBar( 10 );
@@ -224,11 +214,11 @@ songEditor::songEditor() :
m_mvsStatus->setTitle( tr( "Master volume" ) );
m_mvsStatus->setPixmap( embed::getIconPixmap( "master_volume" ) );
lmmsMainWin::inst()->addWidgetToToolBar( master_vol_lbl );
lmmsMainWin::inst()->addWidgetToToolBar( m_masterVolumeSlider );
eng()->getMainWindow()->addWidgetToToolBar( master_vol_lbl );
eng()->getMainWindow()->addWidgetToToolBar( m_masterVolumeSlider );
lmmsMainWin::inst()->addSpacingToToolBar( 10 );
eng()->getMainWindow()->addSpacingToToolBar( 10 );
QLabel * master_pitch_lbl = new QLabel( tb );
master_pitch_lbl->setPixmap( embed::getIconPixmap( "master_pitch" ) );
@@ -259,10 +249,10 @@ songEditor::songEditor() :
m_mpsStatus->setTitle( tr( "Master pitch" ) );
m_mpsStatus->setPixmap( embed::getIconPixmap( "master_pitch" ) );
lmmsMainWin::inst()->addWidgetToToolBar( master_pitch_lbl );
lmmsMainWin::inst()->addWidgetToToolBar( m_masterPitchSlider );
eng()->getMainWindow()->addWidgetToToolBar( master_pitch_lbl );
eng()->getMainWindow()->addWidgetToToolBar( m_masterPitchSlider );
lmmsMainWin::inst()->addSpacingToToolBar( 10 );
eng()->getMainWindow()->addSpacingToToolBar( 10 );
// create widget for visualization- and cpu-load-widget
QWidget * vc_w = new QWidget( tb );
@@ -272,12 +262,12 @@ songEditor::songEditor() :
vcw_layout->addStretch();
vcw_layout->addWidget( new visualizationWidget(
embed::getIconPixmap( "output_graph" ), vc_w ) );
embed::getIconPixmap( "output_graph" ), vc_w, eng() ) );
vcw_layout->addWidget( new cpuloadWidget( vc_w ) );
vcw_layout->addWidget( new cpuloadWidget( vc_w, eng() ) );
vcw_layout->addStretch();
lmmsMainWin::inst()->addWidgetToToolBar( vc_w );
eng()->getMainWindow()->addWidgetToToolBar( vc_w );
// create own toolbar
@@ -423,31 +413,8 @@ songEditor::songEditor() :
this, SLOT( scrolled( int ) ) );
show();
m_projectNotes = new projectNotes();
m_projectNotes->resize( 300, 200 );
if( lmmsMainWin::inst()->workspace() != NULL )
{
m_projectNotes->move( 700, 10 );
}
else
{
m_projectNotes->move( 800, 10 );
}
m_projectNotes->show();
// we try to load given file
if( file_to_load != "" )
{
loadProject( file_to_load );
}
else
{
createNewProject();
}
}
@@ -517,13 +484,13 @@ void songEditor::resizeEvent( QResizeEvent * _re )
void songEditor::keyPressEvent( QKeyEvent * _ke )
{
if( /*_ke->modifiers() & Qt::ShiftModifier*/
lmmsMainWin::isShiftPressed() == TRUE &&
eng()->getMainWindow()->isShiftPressed() == TRUE &&
_ke->key() == Qt::Key_Insert )
{
insertBar();
}
else if(/* _ke->modifiers() & Qt::ShiftModifier &&*/
lmmsMainWin::isShiftPressed() == TRUE &&
eng()->getMainWindow()->isShiftPressed() == TRUE &&
_ke->key() == Qt::Key_Delete )
{
removeBar();
@@ -584,7 +551,7 @@ void songEditor::scrolled( int _new_pos )
void songEditor::wheelEvent( QWheelEvent * _we )
{
if( lmmsMainWin::isCtrlPressed() == TRUE )
if( eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
if( _we->delta() > 0 )
{
@@ -606,7 +573,7 @@ void songEditor::wheelEvent( QWheelEvent * _we )
// and make sure, all TCO's are resized and relocated
realignTracks( TRUE );
}
else if( lmmsMainWin::isShiftPressed() == TRUE )
else if( eng()->getMainWindow()->isShiftPressed() == TRUE )
{
m_leftRightScroll->setValue( m_leftRightScroll->value() -
_we->delta() / 30 );
@@ -634,7 +601,7 @@ void songEditor::masterVolumeChanged( int _new_val )
QPoint( m_masterVolumeSlider->width() + 2, -2 ) );
m_mvsStatus->setVisibilityTimeOut( 1000 );
}
mixer::inst()->setMasterGain( 2.0f - _new_val / 100.0f );
eng()->getMixer()->setMasterGain( 2.0f - _new_val / 100.0f );
setModified();
}
@@ -755,11 +722,11 @@ void songEditor::zoomingChanged( const QString & _zfac )
void songEditor::setBPM( int _new_bpm )
void songEditor::setTempo( int _new_bpm )
{
m_bpmSpinBox->setValue( tLimit( _new_bpm, MIN_BPM, MAX_BPM ) );
m_bpmSpinBox->setValue( tLimit<bpm_t>( _new_bpm, MIN_BPM, MAX_BPM ) );
setModified();
emit bpmChanged( _new_bpm );
emit tempoChanged( _new_bpm );
}
@@ -821,7 +788,7 @@ void songEditor::doActions( void )
updateTimeLinePosition();
// remove all note-play-handles that are active
mixer::inst()->clear();
eng()->getMixer()->clear();
break;
}
@@ -909,7 +876,7 @@ void songEditor::processNextBuffer( void )
// at song-start we have to reset the LFOs
if( m_playPos[PLAY_SONG] == 0 )
{
envelopeAndLFOWidget::resetLFO();
envelopeAndLFOWidget::resetLFO( eng() );
}
break;
@@ -918,10 +885,11 @@ void songEditor::processNextBuffer( void )
break;
case PLAY_BB:
if( bbEditor::inst()->numOfBBs() > 0 )
if( eng()->getBBEditor()->numOfBBs() > 0 )
{
tco_num = bbEditor::inst()->currentBB();
tv.push_back( bbTrack::findBBTrack( tco_num ) );
tco_num = eng()->getBBEditor()->currentBB();
tv.push_back( bbTrack::findBBTrack( tco_num,
eng() ) );
}
break;
@@ -969,9 +937,9 @@ void songEditor::processNextBuffer( void )
frames_per_tact / 64 );
}
while( total_frames_played < mixer::inst()->framesPerAudioBuffer() )
while( total_frames_played < eng()->getMixer()->framesPerAudioBuffer() )
{
Uint32 played_frames = mixer::inst()->framesPerAudioBuffer() -
Uint32 played_frames = eng()->getMixer()->framesPerAudioBuffer() -
total_frames_played;
// did we play a whole tact?
@@ -986,7 +954,7 @@ void songEditor::processNextBuffer( void )
if( m_playMode == PLAY_BB )
{
max_tact =
bbEditor::inst()->lengthOfCurrentBB();
eng()->getBBEditor()->lengthOfCurrentBB();
}
else if( m_playMode == PLAY_PATTERN &&
m_loopPattern == TRUE &&
@@ -1011,7 +979,7 @@ void songEditor::processNextBuffer( void )
// or do we have some samples left in this tact but this are
// less then samples we have to play?
else if( frames_per_tact - m_playPos[m_playMode].currentFrame()
< mixer::inst()->framesPerAudioBuffer() )
< eng()->getMixer()->framesPerAudioBuffer() )
{
// then set played_samples to remaining samples, the
// rest will be played in next loop
@@ -1066,7 +1034,7 @@ void songEditor::play( void )
if( m_playMode != PLAY_SONG )
{
// make sure, bb-editor updates/resets it play-button
bbEditor::inst()->stop();
eng()->getBBEditor()->stop();
//pianoRoll::inst()->stop();
}
else
@@ -1289,14 +1257,14 @@ float songEditor::framesPerTact( void ) const
// when fooling around with tempo while playing, we sometimes get
// 0 here which leads to FP-exception, so handle it separately
const int bpm = tMax( 1, m_bpmSpinBox->value() );
return( mixer::inst()->sampleRate() * 60.0f * BEATS_PER_TACT /
return( eng()->getMixer()->sampleRate() * 60.0f * BEATS_PER_TACT /
bpm );
}
int songEditor::getBPM( void )
bpm_t songEditor::getTempo( void )
{
return( m_bpmSpinBox->value() );
}
@@ -1317,7 +1285,7 @@ bool songEditor::mayChangeProject( void )
#else
information
#endif
( lmmsMainWin::inst(),
( eng()->getMainWindow(),
tr( "Project not saved" ),
tr( "The current project was "
"modified since last "
@@ -1338,12 +1306,12 @@ bool songEditor::mayChangeProject( void )
QMessageBox::Yes,
QMessageBox::No,
QMessageBox::Cancel,
lmmsMainWin::inst() );
eng()->getMainWindow() );
int answer = mb.exec();
if( answer == QMessageBox::Yes )
{
return( lmmsMainWin::inst()->saveProject() );
return( eng()->getMainWindow()->saveProject() );
}
else if( answer == QMessageBox::No )
{
@@ -1368,8 +1336,8 @@ void songEditor::clearProject( void )
// make sure all running notes are cleared, otherwise the whole
// thing will end up in a SIGSEGV...
mixer::inst()->clear( TRUE );
while( mixer::inst()->haveNoRunningNotes() == FALSE )
eng()->getMixer()->clear( TRUE );
while( eng()->getMixer()->haveNoRunningNotes() == FALSE )
{
#ifdef QT4
QApplication::processEvents( QEventLoop::AllEvents );
@@ -1378,17 +1346,10 @@ void songEditor::clearProject( void )
#endif
}
trackVector tv = tracks();
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
{
removeTrack( *it );
}
tv = bbEditor::inst()->tracks();
for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it )
{
bbEditor::inst()->removeTrack( *it );
}
m_projectNotes->clear();
clearAllTracks();
eng()->getBBEditor()->clearAllTracks();
eng()->getProjectNotes()->clear();
}
@@ -1405,13 +1366,13 @@ void songEditor::createNewProject( void )
dynamic_cast< channelTrack * >( t )->loadInstrument(
"tripleoscillator" );
track::create( track::SAMPLE_TRACK, this );
t = track::create( track::CHANNEL_TRACK, bbEditor::inst() );
t = track::create( track::CHANNEL_TRACK, eng()->getBBEditor() );
dynamic_cast< channelTrack * >( t )->loadInstrument(
"tripleoscillator" );
track::create( track::BB_TRACK, this );
m_loadingProject = TRUE;
setBPM( DEFAULT_BPM );
setTempo( DEFAULT_BPM );
m_masterVolumeSlider->setValue( 100 );
m_masterPitchSlider->setValue( 0 );
m_loadingProject = FALSE;
@@ -1420,7 +1381,7 @@ void songEditor::createNewProject( void )
m_modified = FALSE;
lmmsMainWin::inst()->resetWindowTitle( "" );
eng()->getMainWindow()->resetWindowTitle( "" );
}
@@ -1441,8 +1402,8 @@ void FASTCALL songEditor::createNewProjectFromTemplate( const QString &
// load given song
void FASTCALL songEditor::loadProject( const QString & _file_name )
{
clearProject();
m_fileName = _file_name;
m_oldFileName = _file_name;
@@ -1466,7 +1427,7 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
if( node.nodeName() == "bpm" &&
node.toElement().attribute( "value" ).toInt() > 0 )
{
setBPM( node.toElement().attribute( "value"
setTempo( node.toElement().attribute( "value"
).toInt() );
}
else if( node.nodeName() == "mastervol" )
@@ -1502,9 +1463,10 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
{
loadSettings( node.toElement() );
}
else if( node.nodeName() == m_projectNotes->nodeName() )
else if( node.nodeName() ==
eng()->getProjectNotes()->nodeName() )
{
m_projectNotes->loadSettings(
eng()->getProjectNotes()->loadSettings(
node.toElement() );
}
}
@@ -1516,7 +1478,7 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
m_loadingProject = FALSE;
lmmsMainWin::inst()->resetWindowTitle( "" );
eng()->getMainWindow()->resetWindowTitle( "" );
}
@@ -1541,7 +1503,7 @@ bool songEditor::saveProject( void )
saveSettings( mmp, mmp.content() );
m_projectNotes->saveSettings( mmp, mmp.content() );
eng()->getProjectNotes()->saveSettings( mmp, mmp.content() );
if( mmp.writeFile( m_fileName, m_oldFileName == "" ||
m_fileName != m_oldFileName ) == TRUE )
@@ -1553,7 +1515,7 @@ bool songEditor::saveProject( void )
).arg( m_fileName ),
embed::getIconPixmap( "project_save", 24, 24 ),
2000 );
lmmsMainWin::inst()->resetWindowTitle( "" );
eng()->getMainWindow()->resetWindowTitle( "" );
}
else
{
@@ -1624,7 +1586,7 @@ void songEditor::exportProject( void )
}
base_filename += fileEncodeDevices[0].m_extension;
QFileDialog efd( lmmsMainWin::inst() );
QFileDialog efd( eng()->getMainWindow() );
efd.setFileMode( QFileDialog::AnyFile );
int idx = 0;
@@ -1662,7 +1624,7 @@ void songEditor::exportProject( void )
const QString export_file_name = efd.selectedFile();
#endif
if( QFileInfo( export_file_name ).exists() == TRUE &&
QMessageBox::warning( lmmsMainWin::inst(),
QMessageBox::warning( eng()->getMainWindow(),
tr( "File already exists" ),
tr( "The file \"%1\" already "
"exists. Do you want "
@@ -1678,7 +1640,7 @@ void songEditor::exportProject( void )
return;
}
exportProjectDialog epd( export_file_name,
lmmsMainWin::inst() );
eng()->getMainWindow(), eng() );
epd.exec();
}
}

View File

@@ -1,7 +1,7 @@
/*
* timeline.cpp - class timeLine, representing a time-line with position marker
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -47,7 +47,7 @@
#include "embed.h"
#include "templates.h"
#include "nstate_button.h"
#include "lmms_main_win.h"
#include "main_window.h"
#include "text_float.h"
@@ -60,8 +60,9 @@ QPixmap * timeLine::s_loopPointDisabledPixmap = NULL;
timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
songEditor::playPos & _pos, const midiTime & _begin,
QWidget * _parent ) :
QWidget * _parent, engine * _engine ) :
QWidget( _parent ),
engineObject( _engine ),
m_autoScroll( AUTOSCROLL_ENABLED ),
m_loopPoints( LOOP_POINTS_DISABLED ),
m_behaviourAtStop( BACK_TO_ZERO ),
@@ -79,23 +80,23 @@ timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
m_loopPos[0] = 0;
m_loopPos[1] = 64;
if( s_timeLinePixmap == NULL)
if( s_timeLinePixmap == NULL )
{
s_timeLinePixmap = new QPixmap( embed::getIconPixmap(
"timeline" ) );
}
if( s_posMarkerPixmap == NULL)
if( s_posMarkerPixmap == NULL )
{
s_posMarkerPixmap = new QPixmap( embed::getIconPixmap(
"playpos_marker" ) );
}
if( s_loopPointPixmap == NULL)
if( s_loopPointPixmap == NULL )
{
s_loopPointPixmap = new QPixmap( embed::getIconPixmap(
"loop_point" ) );
}
if( s_loopPointDisabledPixmap == NULL)
if( s_loopPointDisabledPixmap == NULL )
{
s_loopPointDisabledPixmap = new QPixmap( embed::getIconPixmap(
"loop_point_disabled" ) );
@@ -307,7 +308,7 @@ void timeLine::mousePressEvent( QMouseEvent * _me )
qSwap( pmin, pmax );
m_action = MOVE_LOOP_END;
}
if( lmmsMainWin::isShiftPressed() == TRUE )
if( eng()->getMainWindow()->isShiftPressed() == TRUE )
{
m_loopPos[pmax] = t;
m_action = ( m_action == MOVE_LOOP_BEGIN ) ?
@@ -360,8 +361,8 @@ void timeLine::mouseMoveEvent( QMouseEvent * _me )
case MOVE_LOOP_BEGIN:
case MOVE_LOOP_END:
{
Uint8 i = m_action - MOVE_LOOP_BEGIN;
if( lmmsMainWin::isCtrlPressed() == TRUE )
const Uint8 i = m_action - MOVE_LOOP_BEGIN;
if( eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
// no ctrl-press-hint when having ctrl pressed
delete m_hint;

View File

@@ -60,7 +60,7 @@
#include "tooltip.h"
#include "string_pair_drag.h"
#include "mmp.h"
#include "lmms_main_win.h"
#include "main_window.h"
#include "text_float.h"
@@ -85,6 +85,7 @@ trackContentObject::trackContentObject( track * _track ) :
, Qt::WDestructiveClose
#endif
),
engineObject( _track->eng() ),
m_track( _track ),
m_startPosition(),
m_length(),
@@ -136,7 +137,7 @@ void trackContentObject::movePosition( const midiTime & _pos )
{
if( m_startPosition != _pos )
{
songEditor::inst()->setModified();
getTrack()->eng()->getSongEditor()->setModified();
}
m_startPosition = _pos;
m_track->getTrackWidget()->changePosition();
@@ -152,7 +153,7 @@ void trackContentObject::changeLength( const midiTime & _length )
{
if( m_length != _length )
{
songEditor::inst()->setModified();
getTrack()->eng()->getSongEditor()->setModified();
}
m_length = _length;
setFixedWidth( static_cast<int>( m_length * pixelsPerTact() / 64 ) +
@@ -232,7 +233,8 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
{
if( m_track->getTrackContainer()->rubberBandActive() == FALSE )
{
if( lmmsMainWin::isCtrlPressed() == TRUE )
if(
getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
setSelected( !isSelected() );
}
@@ -248,12 +250,12 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
}
return;
}
else if( lmmsMainWin::isShiftPressed() == TRUE )
else if( getTrack()->eng()->getMainWindow()->isShiftPressed() == TRUE )
{
selectableObject::mousePressEvent( _me );
}
else if( _me->button() == Qt::LeftButton &&
lmmsMainWin::isCtrlPressed() == TRUE )
getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA );
saveSettings( mmp, mmp.content() );
@@ -270,10 +272,11 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
#endif
new stringPairDrag( "tco_" +
QString::number( m_track->type() ),
mmp.toString(), thumbnail, this );
mmp.toString(), thumbnail, this,
m_track->eng() );
}
else if( _me->button() == Qt::LeftButton &&
/* lmmsMainWin::isShiftPressed() == FALSE &&*/
/* eng()->getMainWindow()->isShiftPressed() == FALSE &&*/
fixedTCOs() == FALSE )
{
m_initialMouseX = _me->x();
@@ -299,7 +302,7 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
}
else if( ( _me->button() == Qt::MidButton/* ||
( _me->button() == Qt::LeftButton &&
lmmsMainWin::isShiftPressed() == TRUE )*/ ) &&
eng()->getMainWindow()->isShiftPressed() == TRUE )*/ ) &&
fixedTCOs() == FALSE )
{
close();
@@ -544,7 +547,7 @@ trackContentObject * FASTCALL trackContentWidget::addTCO(
m_trackContentObjects.push_back( _tco );
_tco->move( 0, 1 );
m_trackWidget->changePosition();
songEditor::inst()->setModified();
getTrack()->eng()->getSongEditor()->setModified();
return( _tco ); // just for convenience
}
@@ -572,7 +575,7 @@ void trackContentWidget::removeTCO( trackContentObject * _tco,
delete _tco;
}
m_trackContentObjects.erase( it );
songEditor::inst()->setModified();
getTrack()->eng()->getSongEditor()->setModified();
}
}
@@ -711,7 +714,7 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me )
{
QWidget::mousePressEvent( _me );
}
else if( lmmsMainWin::isShiftPressed() == TRUE )
else if( getTrack()->eng()->getMainWindow()->isShiftPressed() == TRUE )
{
QWidget::mousePressEvent( _me );
}
@@ -871,7 +874,7 @@ bool trackOperationsWidget::muted( void ) const
void trackOperationsWidget::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
lmmsMainWin::isCtrlPressed() == TRUE &&
m_trackWidget->getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE &&
m_trackWidget->getTrack()->type() != track::BB_TRACK )
{
multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA );
@@ -880,7 +883,7 @@ void trackOperationsWidget::mousePressEvent( QMouseEvent * _me )
QString::number( m_trackWidget->getTrack()->type() ),
mmp.toString(), QPixmap::grabWidget(
&m_trackWidget->getTrackSettingsWidget() ),
this );
this, m_trackWidget->getTrack()->eng() );
}
else if( _me->button() == Qt::LeftButton )
{
@@ -1099,7 +1102,7 @@ void trackWidget::mousePressEvent( QMouseEvent * _me )
}
else if( _me->button() == Qt::LeftButton )
{
if( lmmsMainWin::isShiftPressed() == TRUE )
if( m_track->eng()->getMainWindow()->isShiftPressed() == TRUE )
{
m_action = RESIZE_TRACK;
QCursor::setPos( mapToGlobal( QPoint( _me->x(),
@@ -1240,6 +1243,7 @@ midiTime trackWidget::endPosition( const midiTime & _pos_start )
track::track( trackContainer * _tc ) :
settings(),
engineObject( _tc->eng() ),
m_trackContainer( _tc )
{
m_trackWidget = new trackWidget( this,
@@ -1266,7 +1270,7 @@ track * FASTCALL track::create( trackTypes _tt, trackContainer * _tc )
{
// while adding track, pause mixer for not getting into any trouble
// because of track being not created completely so far
mixer::inst()->pause();
_tc->eng()->getMixer()->pause();
track * t = NULL;
@@ -1283,7 +1287,7 @@ track * FASTCALL track::create( trackTypes _tt, trackContainer * _tc )
assert( t != NULL );
// allow mixer to continue
mixer::inst()->play();
_tc->eng()->getMixer()->play();
return( t );
}

View File

@@ -2,7 +2,7 @@
* track_container.cpp - implementation of base-class for all track-containers
* like Song-Editor, BB-Editor...
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -49,7 +49,7 @@
#include "track.h"
#include "templates.h"
#include "bb_track.h"
#include "lmms_main_win.h"
#include "main_window.h"
#include "mixer.h"
#include "song_editor.h"
#include "string_pair_drag.h"
@@ -62,13 +62,14 @@
trackContainer::trackContainer() :
QMainWindow( lmmsMainWin::inst()->workspace()
trackContainer::trackContainer( engine * _engine ) :
QMainWindow( _engine->getMainWindow()->workspace()
#ifdef QT3
, 0, Qt::WStyle_Title
#endif
),
settings(),
engineObject( _engine ),
m_currentPosition( 0, 0 ),
m_scrollArea( new scrollArea( this ) ),
m_ppt( DEFAULT_PIXELS_PER_TACT ),
@@ -76,9 +77,9 @@ trackContainer::trackContainer() :
m_origin()
{
#ifdef QT4
if( lmmsMainWin::inst()->workspace() != NULL )
if( eng()->getMainWindow()->workspace() != NULL )
{
lmmsMainWin::inst()->workspace()->addWindow( this );
eng()->getMainWindow()->workspace()->addWindow( this );
}
#endif
@@ -214,7 +215,7 @@ void trackContainer::removeTrack( track * _track )
m_trackWidgets.end(), _track->getTrackWidget() );
if( it != m_trackWidgets.end() )
{
mixer::inst()->pause();
eng()->getMixer()->pause();
#ifndef QT4
m_scrollArea->removeChild( _track->getTrackWidget() );
#endif
@@ -222,10 +223,10 @@ void trackContainer::removeTrack( track * _track )
delete _track;
mixer::inst()->play();
eng()->getMixer()->play();
realignTracks();
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
}
@@ -306,6 +307,17 @@ void trackContainer::realignTracks( bool _complete_update )
void trackContainer::clearAllTracks( void )
{
while( m_trackWidgets.size() )
{
removeTrack( m_trackWidgets.front()->getTrack() );
}
}
const trackWidget * trackContainer::trackWidgetAt( const int _y ) const
{
int y_cnt = 0;

View File

@@ -150,7 +150,8 @@ void bufferAllocator::free( void * _buf )
// do clean-up if neccessary
static const Uint32 CLEANUP_LEVEL = static_cast<Uint32>( 768 / ( logf(
mixer::inst()->framesPerAudioBuffer() ) /
/*mixer::inst()->framesPerAudioBuffer()*/
128 ) /
logf( 2 ) ) );
static int count = 0;
// only cleanup every 10th time, because otherwise there's a lot of

View File

@@ -29,10 +29,13 @@
oscillator::oscillator( const modulationAlgos _modulation_algo,
const float _freq, const Sint16 _phase_offset,
const float _volume_factor, oscillator * _sub_osc ) :
const float _volume_factor,
const sample_rate_t _sample_rate,
oscillator * _sub_osc ) :
m_freq( _freq ),
m_volumeFactor( _volume_factor ),
m_phaseOffset( _phase_offset ),
m_sampleRate( _sample_rate ),
m_subOsc( _sub_osc ),
m_userWaveData( &ZERO_FRAME ),
m_userWaveFrames( 1 )
@@ -155,9 +158,10 @@ class x : public oscillator \
public: \
x( const modulationAlgos modulation_algo, const float _freq, \
const Sint16 _phase_offset, const float _volume_factor, \
const sample_rate_t _sample_rate, \
oscillator * _sub_osc ) FASTCALL : \
oscillator( modulation_algo, _freq, _phase_offset, \
_volume_factor, _sub_osc ) \
_volume_factor, _sample_rate, _sub_osc ) \
{ \
} \
virtual ~x() \
@@ -201,6 +205,7 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape,
const float _freq,
const Sint16 _phase_offset,
const float _volume_factor,
const sample_rate_t _sample_rate,
oscillator * _sub_osc )
{
switch( _wave_shape )
@@ -208,39 +213,39 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape,
case SIN_WAVE:
return( new sinWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case TRIANGLE_WAVE:
return( new triangleWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case SAW_WAVE:
return( new sawWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case SQUARE_WAVE:
return( new squareWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case MOOG_SAW_WAVE:
return( new moogSawWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case EXP_WAVE:
return( new expWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case WHITE_NOISE_WAVE:
return( new noiseWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
case USER_DEF_WAVE:
return( new userWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
default:
return( new sinWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_sub_osc ) );
_sample_rate, _sub_osc ) );
}
}
@@ -251,12 +256,11 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape,
// should be called every time phase-offset or frequency is changed...
void oscillator::recalcOscCoeff( const float additional_phase_offset )
{
m_oscCoeff = m_freq / static_cast<float>( mixer::inst()->sampleRate() );
m_oscCoeff = m_freq / static_cast<float>( m_sampleRate );
m_sample = static_cast<f_cnt_t>( ( m_phaseOffset * ( 1.0f / 360.0f ) +
additional_phase_offset ) *
( mixer::inst()->sampleRate() /
m_freq ) );
( m_sampleRate / m_freq ) );
// because we pre-increment m_sample in update-function, we should
// decrement it here... (not possible when 0 because it is
// unsigned - overflow!!!)

View File

@@ -100,9 +100,10 @@
sampleBuffer::sampleBuffer( const QString & _audio_file,
sampleBuffer::sampleBuffer( engine * _engine, const QString & _audio_file,
bool _is_base64_data ) :
QObject(),
engineObject( _engine ),
m_audioFile( ( _is_base64_data == TRUE ) ? "" : _audio_file ),
m_origData( NULL ),
m_origFrames( 0 ),
@@ -131,8 +132,10 @@ sampleBuffer::sampleBuffer( const QString & _audio_file,
sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames ) :
sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames,
engine * _engine ) :
QObject(),
engineObject( _engine ),
m_audioFile( "" ),
m_origData( NULL ),
m_origFrames( 0 ),
@@ -160,8 +163,9 @@ sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames ) :
sampleBuffer::sampleBuffer( const f_cnt_t _frames ) :
sampleBuffer::sampleBuffer( const f_cnt_t _frames, engine * _engine ) :
QObject(),
engineObject( _engine ),
m_audioFile( "" ),
m_origData( NULL ),
m_origFrames( 0 ),
@@ -623,7 +627,7 @@ SRC_STATE * sampleBuffer::createResamplingContext( void )
int error;
SRC_STATE * state;
if( ( state = src_new(/*
( mixer::inst()->highQuality() == TRUE ) ?
( eng()->getMixer()->highQuality() == TRUE ) ?
SRC_SINC_FASTEST :*/
SRC_LINEAR,
DEFAULT_CHANNELS, &error ) ) == NULL )
@@ -652,7 +656,7 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab,
const bool _looped,
void * * _resampling_data )
{
mixer::inst()->clearAudioBuffer( _ab, _frames );
eng()->getMixer()->clearAudioBuffer( _ab, _frames );
if( m_data == NULL || m_frames == 0 || m_endFrame == 0 || _frames == 0 )
{
@@ -741,7 +745,7 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab,
#else
f_cnt_t src_frame_base = 0;
// check whether we're in high-quality-mode
if( mixer::inst()->highQuality() == TRUE )
if( eng()->getMixer()->highQuality() == TRUE )
{
// we are, so let's use cubic interpolation...
for( f_cnt_t frame = 0; frame < frames_to_process;
@@ -1091,7 +1095,7 @@ QString & sampleBuffer::toBase64( QString & _dst ) const
/* FLAC__stream_encoder_set_do_exhaustive_model_search( flac_enc, TRUE );
FLAC__stream_encoder_set_do_mid_side_stereo( flac_enc, TRUE );*/
FLAC__stream_encoder_set_sample_rate( flac_enc,
mixer::inst()->sampleRate() );
eng()->getMixer()->sampleRate() );
QBuffer ba_writer;
#ifdef QT4
ba_writer.open( QBuffer::WriteOnly );
@@ -1152,11 +1156,12 @@ QString & sampleBuffer::toBase64( QString & _dst ) const
sampleBuffer * sampleBuffer::resample( sampleFrame * _data,
const f_cnt_t _frames,
const sample_rate_t _src_sr,
const sample_rate_t _dst_sr )
const sample_rate_t _dst_sr,
engine * _engine )
{
const f_cnt_t dst_frames = static_cast<f_cnt_t>( _frames /
(float) _src_sr * (float) _dst_sr );
sampleBuffer * dst_sb = new sampleBuffer( dst_frames );
sampleBuffer * dst_sb = new sampleBuffer( dst_frames, _engine );
sampleFrame * dst_buf = dst_sb->m_origData;
#ifdef HAVE_SAMPLERATE_H
// yeah, libsamplerate, let's rock with sinc-interpolation!

View File

@@ -26,7 +26,7 @@
#include "string_pair_drag.h"
#include "lmms_main_win.h"
#include "main_window.h"
#ifdef QT4
@@ -38,12 +38,14 @@
stringPairDrag::stringPairDrag( const QString & _key, const QString & _value,
const QPixmap & _icon, QWidget * _w ) :
const QPixmap & _icon, QWidget * _w,
engine * _engine ) :
#ifdef QT4
QDrag( _w )
QDrag( _w ),
#else
QStoredDrag( "lmms/stringpair", _w )
QStoredDrag( "lmms/stringpair", _w ),
#endif
engineObject( _engine )
{
setPixmap( _icon );
QString txt = _key + ":" + _value;
@@ -65,7 +67,7 @@ stringPairDrag::~stringPairDrag()
{
// during a drag, we might have lost key-press-events, so reset
// modifiers of main-win
lmmsMainWin::inst()->clearKeyModifiers();
eng()->getMainWindow()->clearKeyModifiers();
// TODO: do we have to delete anything???
}

View File

@@ -1,7 +1,7 @@
/*
* midi_alsa_raw.cpp - midi-client for RawMIDI via ALSA
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -47,8 +47,8 @@
#ifdef ALSA_SUPPORT
midiALSARaw::midiALSARaw( void ) :
midiClientRaw(),
midiALSARaw::midiALSARaw( engine * _engine ) :
midiClientRaw( _engine ),
QThread(),
m_inputp( &m_input ),
m_outputp( &m_output ),

View File

@@ -50,11 +50,11 @@
#ifdef ALSA_SUPPORT
midiALSASeq::midiALSASeq( void ) :
midiALSASeq::midiALSASeq( engine * _engine ) :
#ifndef QT4
QObject(),
#endif
midiClient(),
midiClient( _engine ),
QThread(),
m_seqHandle( NULL ),
m_queueID( -1 ),
@@ -82,14 +82,14 @@ midiALSASeq::midiALSASeq( void ) :
snd_seq_queue_tempo_t * tempo;
snd_seq_queue_tempo_alloca( &tempo );
snd_seq_queue_tempo_set_tempo( tempo, 6000000 /
songEditor::inst()->getBPM() );
eng()->getSongEditor()->getTempo() );
snd_seq_queue_tempo_set_ppq( tempo, 16 );
snd_seq_set_queue_tempo( m_seqHandle, m_queueID, tempo );
snd_seq_start_queue( m_seqHandle, m_queueID, NULL );
changeQueueTempo( songEditor::inst()->getBPM() );
connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ),
this, SLOT( changeQueueTempo( int ) ) );
changeQueueTempo( eng()->getSongEditor()->getTempo() );
connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ),
this, SLOT( changeQueueTempo( bpm_t ) ) );
// initial list-update
updatePortList();
@@ -503,10 +503,10 @@ void midiALSASeq::run( void )
void midiALSASeq::changeQueueTempo( int _bpm )
void midiALSASeq::changeQueueTempo( bpm_t _bpm )
{
snd_seq_change_queue_tempo( m_seqHandle, m_queueID, 60000000 / _bpm,
NULL );
snd_seq_change_queue_tempo( m_seqHandle, m_queueID,
60000000 / (int) _bpm, NULL );
snd_seq_drain_output( m_seqHandle );
}

View File

@@ -1,7 +1,7 @@
/*
* midi_client.cpp - base-class for MIDI-clients like ALSA-sequencer-client
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* This file partly contains code from Fluidsynth, Peter Hanappe
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
@@ -38,7 +38,8 @@
midiClient::midiClient( void )
midiClient::midiClient( engine * _engine ) :
engineObject( _engine )
{
}
@@ -66,6 +67,7 @@ void midiClient::applyPortName( midiPort * )
midiPort * midiClient::addPort( midiEventProcessor * _mep,
const QString & _name )
{
@@ -126,8 +128,8 @@ void midiClient::subscribeWriteablePort( midiPort * , const QString & , bool)
midiClientRaw::midiClientRaw() :
midiClient()
midiClientRaw::midiClientRaw( engine * _engine ) :
midiClient( _engine )
{
}

View File

@@ -1,7 +1,7 @@
/*
* midi_oss.cpp - OSS-raw-midi-client
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -53,8 +53,8 @@
midiOSS::midiOSS( void ) :
midiClientRaw(),
midiOSS::midiOSS( engine * _engine ) :
midiClientRaw( _engine ),
QThread(),
m_midiDev( probeDevice() ),
m_quit( FALSE )

View File

@@ -66,7 +66,7 @@ bbTCO::bbTCO( track * _track, const QColor & _c ) :
#ifndef QT4
setBackgroundMode( Qt::NoBackground );
#endif
tact t = bbEditor::inst()->lengthOfBB(
tact t = eng()->getBBEditor()->lengthOfBB(
bbTrack::numOfBBTrack( getTrack() ) );
if( t > 0 )
{
@@ -158,7 +158,7 @@ void bbTCO::paintEvent( QPaintEvent * )
}
#endif
tact t = bbEditor::inst()->lengthOfBB( bbTrack::numOfBBTrack(
tact t = eng()->getBBEditor()->lengthOfBB( bbTrack::numOfBBTrack(
getTrack() ) );
if( length() > 64 && t > 0 )
{
@@ -227,9 +227,10 @@ void bbTCO::loadSettings( const QDomElement & _this )
void bbTCO::openInBBEditor( bool )
{
bbEditor::inst()->setCurrentBB( bbTrack::numOfBBTrack( getTrack() ) );
bbEditor::inst()->show();
bbEditor::inst()->setFocus();
eng()->getBBEditor()->setCurrentBB( bbTrack::numOfBBTrack(
getTrack() ) );
eng()->getBBEditor()->show();
eng()->getBBEditor()->setFocus();
}
@@ -270,7 +271,7 @@ void bbTCO::changeColor( void )
if( _new_color.isValid() && _new_color != m_color )
{
m_color = _new_color;
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
}
}
@@ -291,7 +292,7 @@ bbTrack::bbTrack( trackContainer * _tc ) :
s_infoMap[this] = bbNum;
m_trackLabel = new nameLabel( tr( "Beat/Bassline %1" ).arg( bbNum ),
getTrackSettingsWidget() );
getTrackSettingsWidget(), eng() );
m_trackLabel->setPixmap( embed::getIconPixmap( "bb_track" ) );
m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH - 2,
29 );
@@ -299,13 +300,13 @@ bbTrack::bbTrack( trackContainer * _tc ) :
connect( m_trackLabel, SIGNAL( clicked() ),
this, SLOT( clickedTrackLabel() ) );
connect( m_trackLabel, SIGNAL( nameChanged() ),
bbEditor::inst(), SLOT( updateComboBox() ) );
eng()->getBBEditor(), SLOT( updateComboBox() ) );
connect( m_trackLabel, SIGNAL( pixmapChanged() ),
bbEditor::inst(), SLOT( updateComboBox() ) );
eng()->getBBEditor(), SLOT( updateComboBox() ) );
bbEditor::inst()->setCurrentBB( bbNum );
bbEditor::inst()->updateComboBox();
eng()->getBBEditor()->setCurrentBB( bbNum );
eng()->getBBEditor()->updateComboBox();
_tc->updateAfterTrackAdd();
}
@@ -316,7 +317,7 @@ bbTrack::bbTrack( trackContainer * _tc ) :
bbTrack::~bbTrack()
{
csize bb = s_infoMap[this];
bbEditor::inst()->removeBB( bb );
eng()->getBBEditor()->removeBB( bb );
for( infoMap::iterator it = s_infoMap.begin(); it != s_infoMap.end();
++it )
{
@@ -346,20 +347,22 @@ track::trackTypes bbTrack::type( void ) const
// play _frames frames of given TCO within starting with _start/_start_frame
bool FASTCALL bbTrack::play( const midiTime & _start, Uint32 _start_frame,
Uint32 _frames, Uint32 _frame_base,
bool FASTCALL bbTrack::play( const midiTime & _start,
const f_cnt_t _start_frame,
const fpab_t _frames,
const f_cnt_t _frame_base,
Sint16 _tco_num )
{
if( _tco_num >= 0 )
{
return( bbEditor::inst()->play( _start, _start_frame, _frames,
return( eng()->getBBEditor()->play( _start, _start_frame, _frames,
_frame_base,
s_infoMap[this] ) );
}
vlist<trackContentObject *> tcos;
getTCOsInRange( tcos, _start, _start +static_cast<Sint32>( _frames *
64 / songEditor::inst()->framesPerTact() ) );
64 / eng()->getSongEditor()->framesPerTact() ) );
if ( tcos.size() == 0 )
{
@@ -379,7 +382,7 @@ bool FASTCALL bbTrack::play( const midiTime & _start, Uint32 _start_frame,
}
if( _start - lastPosition < lastLen )
{
return( bbEditor::inst()->play( _start - lastPosition,
return( eng()->getBBEditor()->play( _start - lastPosition,
_start_frame, _frames,
_frame_base,
s_infoMap[this] ) );
@@ -418,12 +421,12 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc,
bbt_de.setAttribute( "name", m_trackLabel->text() );
bbt_de.setAttribute( "icon", m_trackLabel->pixmapFile() );
/* bbt_de.setAttribute( "current", s_infoMap[this] ==
bbEditor::inst()->currentBB() );*/
eng()->getBBEditor()->currentBB() );*/
_parent.appendChild( bbt_de );
if( s_infoMap[this] == 0 &&
_parent.parentNode().nodeName() != "clone" )
{
bbEditor::inst()->saveSettings( _doc, bbt_de );
eng()->getBBEditor()->saveSettings( _doc, bbt_de );
}
}
@@ -439,7 +442,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
}
if( _this.firstChild().isElement() )
{
bbEditor::inst()->loadSettings(
eng()->getBBEditor()->loadSettings(
_this.firstChild().toElement() );
}
/* doesn't work yet because bbTrack-ctor also sets current bb so if
@@ -447,7 +450,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
help at all....
if( _this.attribute( "current" ).toInt() )
{
bbEditor::inst()->setCurrentBB( s_infoMap[this] );
eng()->getBBEditor()->setCurrentBB( s_infoMap[this] );
}*/
}
@@ -455,15 +458,15 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
// return pointer to bbTrack specified by _bb_num
bbTrack * bbTrack::findBBTrack( csize _bb_num )
bbTrack * bbTrack::findBBTrack( csize _bb_num, engine * _engine )
{
for( infoMap::iterator it = s_infoMap.begin(); it != s_infoMap.end();
++it )
{
#ifdef QT4
if( it.value() == _bb_num )
if( it.value() == _bb_num && it.key()->eng() == _engine )
#else
if( it.data() == _bb_num )
if( it.data() == _bb_num && it.key()->eng() == _engine )
#endif
{
return( it.key() );
@@ -494,8 +497,9 @@ void bbTrack::swapBBTracks( track * _track1, track * _track2 )
if( t1 != NULL && t2 != NULL )
{
qSwap( s_infoMap[t1], s_infoMap[t2] );
bbEditor::inst()->swapBB( s_infoMap[t1], s_infoMap[t2] );
bbEditor::inst()->setCurrentBB( s_infoMap[t2] );
_track1->eng()->getBBEditor()->swapBB( s_infoMap[t1],
s_infoMap[t2] );
_track1->eng()->getBBEditor()->setCurrentBB( s_infoMap[t2] );
}
}
@@ -504,8 +508,8 @@ void bbTrack::swapBBTracks( track * _track1, track * _track2 )
void bbTrack::clickedTrackLabel( void )
{
bbEditor::inst()->setCurrentBB( s_infoMap[this] );
bbEditor::inst()->show();
eng()->getBBEditor()->setCurrentBB( s_infoMap[this] );
eng()->getBBEditor()->show();
}

View File

@@ -68,6 +68,7 @@
#include "bb_editor.h"
#include "string_pair_drag.h"
#include "buffer_allocator.h"
#include "main_window.h"
QPixmap * pattern::s_stepBtnOn = NULL;
@@ -123,9 +124,9 @@ pattern::pattern( const pattern & _pat_to_copy ) :
pattern::~pattern()
{
if( pianoRoll::inst()->currentPattern() == this )
if( eng()->getPianoRoll()->currentPattern() == this )
{
pianoRoll::inst()->setCurrentPattern( NULL );
eng()->getPianoRoll()->setCurrentPattern( NULL );
}
for( noteVector::iterator it = m_notes.begin();
it != m_notes.end(); ++it )
@@ -312,9 +313,9 @@ void pattern::clearNotes( void )
m_notes.clear();
checkType();
update();
if( pianoRoll::inst()->currentPattern() == this )
if( eng()->getPianoRoll()->currentPattern() == this )
{
pianoRoll::inst()->update();
eng()->getPianoRoll()->update();
}
}
@@ -377,8 +378,8 @@ void pattern::checkType( void )
void pattern::playFrozenData( sampleFrame * _ab, Uint32 _start_frame,
Uint32 _frames )
void pattern::playFrozenData( sampleFrame * _ab, const f_cnt_t _start_frame,
const fpab_t _frames )
{
m_frozenPatternMutex.lock();
if( m_frozenPattern != NULL )
@@ -491,9 +492,9 @@ void pattern::openInPianoRoll( void )
void pattern::openInPianoRoll( bool )
{
pianoRoll::inst()->setCurrentPattern( this );
pianoRoll::inst()->show();
pianoRoll::inst()->setFocus();
eng()->getPianoRoll()->setCurrentPattern( this );
eng()->getPianoRoll()->show();
eng()->getPianoRoll()->setFocus();
}
@@ -527,7 +528,7 @@ void pattern::changeName( void )
void pattern::freeze( void )
{
if( songEditor::inst()->playing() )
if( eng()->getSongEditor()->playing() )
{
QMessageBox::information( 0, tr( "Cannot freeze pattern" ),
tr( "The pattern currently "
@@ -794,19 +795,21 @@ void pattern::mousePressEvent( QMouseEvent * _me )
{
n->setLength( -64 );
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
if( pianoRoll::inst()->currentPattern() == this )
if( eng()->getPianoRoll()->currentPattern() == this )
{
pianoRoll::inst()->update();
eng()->getPianoRoll()->update();
}
}
else if( m_frozenPattern != NULL && _me->button() == Qt::LeftButton &&
lmmsMainWin::isShiftPressed() == TRUE )
eng()->getMainWindow()->isShiftPressed() == TRUE )
{
QString s;
new stringPairDrag( "sampledata", m_frozenPattern->toBase64( s ),
embed::getIconPixmap( "freeze" ), this );
new stringPairDrag( "sampledata",
m_frozenPattern->toBase64( s ),
embed::getIconPixmap( "freeze" ),
this, eng() );
}
else
{
@@ -856,11 +859,11 @@ void pattern::wheelEvent( QWheelEvent * _we )
n->setLength( 0 );
}
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
update();
if( pianoRoll::inst()->currentPattern() == this )
if( eng()->getPianoRoll()->currentPattern() == this )
{
pianoRoll::inst()->update();
eng()->getPianoRoll()->update();
}
_we->accept();
}
@@ -1132,9 +1135,9 @@ void pattern::ensureBeatNotes( void )
void pattern::updateBBTrack( void )
{
if( getTrack()->getTrackContainer() == bbEditor::inst() )
if( getTrack()->getTrackContainer() == eng()->getBBEditor() )
{
bbEditor::inst()->updateBBTrack( this );
eng()->getBBEditor()->updateBBTrack( this );
}
}
@@ -1249,6 +1252,7 @@ void patternFreezeStatusDialog::updateProgress( void )
patternFreezeThread::patternFreezeThread( pattern * _pattern ) :
QThread(),
engineObject( _pattern->eng() ),
m_pattern( _pattern )
{
// create status-dialog
@@ -1280,13 +1284,15 @@ void patternFreezeThread::run( void )
// mixer::restoreAudioDevice(...) deletes old audio-dev and thus
// audioSampleRecorder would be destroyed two times...
audioSampleRecorder * freeze_recorder = new audioSampleRecorder(
mixer::inst()->sampleRate(), DEFAULT_CHANNELS, b );
mixer::inst()->setAudioDevice( freeze_recorder,
mixer::inst()->highQuality() );
eng()->getMixer()->sampleRate(),
DEFAULT_CHANNELS, b,
eng()->getMixer() );
eng()->getMixer()->setAudioDevice( freeze_recorder,
eng()->getMixer()->highQuality() );
// prepare stuff for playing correct things later
songEditor::inst()->playPattern( m_pattern, FALSE );
songEditor::playPos & ppp = songEditor::inst()->getPlayPos(
eng()->getSongEditor()->playPattern( m_pattern, FALSE );
songEditor::playPos & ppp = eng()->getSongEditor()->getPlayPos(
songEditor::PLAY_PATTERN );
ppp.setTact( 0 );
ppp.setTact64th( 0 );
@@ -1309,7 +1315,7 @@ void patternFreezeThread::run( void )
m_pattern->m_freezing = FALSE;
// reset song-editor settings
songEditor::inst()->stop();
eng()->getSongEditor()->stop();
ppp.m_timeLineUpdate = TRUE;
// create final sample-buffer if freezing was successful
@@ -1324,7 +1330,7 @@ void patternFreezeThread::run( void )
bufferAllocator::disableAutoCleanup( FALSE );
// restore original audio-device
mixer::inst()->restoreAudioDevice();
eng()->getMixer()->restoreAudioDevice();
m_statusDlg->setProgress( -1 ); // we're finished

View File

@@ -56,7 +56,7 @@
sampleTCO::sampleTCO( track * _track ) :
trackContentObject( _track ),
m_sampleBuffer()
m_sampleBuffer( eng() )
{
#ifndef QT4
setBackgroundMode( Qt::NoBackground );
@@ -66,8 +66,8 @@ sampleTCO::sampleTCO( track * _track ) :
// we need to receive bpm-change-events, because then we have to
// change length of this TCO
connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ), this,
SLOT( updateLength( int ) ) );
connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ), this,
SLOT( updateLength( bpm_t ) ) );
}
@@ -89,12 +89,12 @@ void sampleTCO::changeLength( const midiTime & _length )
void FASTCALL sampleTCO::play( sampleFrame * _ab, Uint32 _start_frame,
Uint32 _frames )
void FASTCALL sampleTCO::play( sampleFrame * _ab, f_cnt_t _start_frame,
const fpab_t _frames )
{
_start_frame = static_cast<Uint32>( tMax( 0.0f, _start_frame -
startPosition() *
songEditor::inst()->framesPerTact() / 64 ) );
eng()->getSongEditor()->framesPerTact() / 64 ) );
m_sampleBuffer.play( _ab, _start_frame, _frames );
}
@@ -124,7 +124,7 @@ void sampleTCO::setSampleFile( const QString & _sf )
void sampleTCO::updateLength( int )
void sampleTCO::updateLength( bpm_t )
{
changeLength( getSampleLength() );
}
@@ -155,7 +155,7 @@ void sampleTCO::dropEvent( QDropEvent * _de )
{
m_sampleBuffer.loadFromBase64(
stringPairDrag::decodeValue( _de ) );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
updateLength();
update();
_de->accept();
@@ -175,7 +175,7 @@ void sampleTCO::mouseDoubleClickEvent( QMouseEvent * )
if( af != "" && af != m_sampleBuffer.audioFile() )
{
setSampleFile( af );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
}
@@ -240,7 +240,7 @@ void sampleTCO::paintEvent( QPaintEvent * )
midiTime sampleTCO::getSampleLength( void ) const
{
return( static_cast<Sint32>( m_sampleBuffer.frames() /
songEditor::inst()->framesPerTact() *
eng()->getSongEditor()->framesPerTact() *
64 ) );
}
@@ -346,7 +346,7 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f )
{
m_fileLbl->setText( _f );
m_sampleTCO->setSampleFile( _f );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
*/
@@ -356,12 +356,12 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f )
sampleTrack::sampleTrack( trackContainer * _tc ) :
track( _tc ),
m_audioPort( new audioPort( tr( "Sample track" ) ) )
m_audioPort( new audioPort( tr( "Sample track" ), eng() ) )
{
getTrackWidget()->setFixedHeight( 32 );
m_trackLabel = new nameLabel( tr( "Sample track" ),
getTrackSettingsWidget() );
getTrackSettingsWidget(), eng() );
m_trackLabel->setPixmap( embed::getIconPixmap( "sample_track" ) );
m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 );
m_trackLabel->show();
@@ -388,13 +388,15 @@ track::trackTypes sampleTrack::type( void ) const
bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame,
Uint32 _frames, Uint32 _frame_base,
bool FASTCALL sampleTrack::play( const midiTime & _start,
const f_cnt_t _start_frame,
const fpab_t _frames,
const f_cnt_t _frame_base,
Sint16 /*_tco_num*/ )
{
vlist<trackContentObject *> tcos;
getTCOsInRange( tcos, _start, _start+static_cast<Sint32>( _frames * 64 /
songEditor::inst()->framesPerTact() ) );
eng()->getSongEditor()->framesPerTact() ) );
if ( tcos.size() == 0 )
{
@@ -408,7 +410,7 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame,
, 1.0f, 1.0f
#endif
} ;
float fpt = songEditor::inst()->framesPerTact();
float fpt = eng()->getSongEditor()->framesPerTact();
for( vlist<trackContentObject *>::iterator it = tcos.begin();
it != tcos.end(); ++it )
@@ -420,7 +422,8 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame,
static_cast<Uint32>( _start.getTact() *
fpt ),
_frames );
mixer::inst()->bufferToPort( buf, _frames, _frame_base +
eng()->getMixer()->bufferToPort( buf, _frames,
_frame_base +
static_cast<Uint32>(
st->startPosition().getTact64th() *
fpt / 64.0f ), v,

View File

@@ -2,7 +2,7 @@
* cpuload_widget.cpp - widget for displaying CPU-load (partly based on
* Hydrogen's CPU-load-widget)
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -42,8 +42,9 @@
#include "mixer.h"
cpuloadWidget::cpuloadWidget( QWidget * _parent ) :
cpuloadWidget::cpuloadWidget( QWidget * _parent, engine * _engine ) :
QWidget( _parent ),
engineObject( _engine ),
m_currentLoad( 0 ),
m_temp(),
m_background( embed::getIconPixmap( "cpuload_bg" ) ),
@@ -103,7 +104,7 @@ void cpuloadWidget::paintEvent( QPaintEvent * )
void cpuloadWidget::updateCpuLoad()
{
// smooth load-values a bit
Uint8 new_load = ( m_currentLoad + mixer::inst()->cpuLoad() ) / 2;
Uint8 new_load = ( m_currentLoad + eng()->getMixer()->cpuLoad() ) / 2;
if( new_load != m_currentLoad )
{
m_currentLoad = new_load;

View File

@@ -1,7 +1,7 @@
/*
* group_box.cpp - groupbox for LMMS
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*

View File

@@ -4,7 +4,7 @@
* This file is based on the knob-widget of the Qwt Widget Library from
* Josef Wilgen
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -53,6 +53,8 @@
#include <qfontmetrics.h>
#include <qapplication.h>
#include <qinputdialog.h>
#include <qcursor.h>
#include <qwhatsthis.h>
#define addSeparator insertSeparator
@@ -74,6 +76,7 @@
#include "gui_templates.h"
#include "templates.h"
#include "string_pair_drag.h"
#include "main_window.h"
@@ -87,12 +90,14 @@ textFloat * knob::s_textFloat = NULL;
knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
knob::knob( int _knob_num, QWidget * _parent, const QString & _name,
engine * _engine ) :
QWidget( _parent
#ifndef QT4
, _name.ascii()
#endif
),
engineObject( _engine ),
m_mouseOffset( 0.0f ),
m_buttonPressed( FALSE ),
m_angle( 0.0f ),
@@ -140,9 +145,9 @@ knob::~knob()
{
/* // make sure pointer to this knob isn't used anymore in active
// midi-device-class
if( mixer::inst()->getMIDIClient()->pitchBendKnob() == this )
if( eng()->getMixer()->getMIDIClient()->pitchBendKnob() == this )
{
mixer::inst()->getMIDIClient()->setPitchBendKnob( NULL );
eng()->getMixer()->getMIDIClient()->setPitchBendKnob( NULL );
}*/
}
@@ -401,7 +406,7 @@ void knob::dropEvent( QDropEvent * _de )
void knob::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
lmmsMainWin::inst()->isCtrlPressed() == FALSE )
eng()->getMainWindow()->isCtrlPressed() == FALSE )
{
const QPoint & p = _me->pos();
m_origMousePos = p;
@@ -428,10 +433,10 @@ void knob::mousePressEvent( QMouseEvent * _me )
m_buttonPressed = TRUE;
}
else if( _me->button() == Qt::LeftButton &&
lmmsMainWin::isCtrlPressed() == TRUE )
eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
new stringPairDrag( "float_value", QString::number( value() ),
QPixmap(), this );
QPixmap(), this, eng() );
}
else if( _me->button() == Qt::MidButton )
{
@@ -454,7 +459,7 @@ void knob::mouseMoveEvent( QMouseEvent * _me )
{
QCursor::setPos( mapToGlobal( m_origMousePos ) );
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
s_textFloat->setText( m_hintTextBeforeValue +
@@ -546,7 +551,7 @@ void knob::wheelEvent( QWheelEvent * _we )
_we->accept();
const int inc = ( _we->delta() > 0 ) ? 1 : -1;
incValue( inc );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
s_textFloat->reparent( this );
@@ -747,7 +752,7 @@ void knob::setStep( float _vstep )
void knob::reset( void )
{
setValue( m_initValue );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
s_textFloat->reparent( this );
s_textFloat->setText( m_hintTextBeforeValue +
QString::number( value() ) +
@@ -771,7 +776,7 @@ void knob::copyValue( void )
void knob::pasteValue( void )
{
setValue( s_copiedValue );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
s_textFloat->reparent( this );
s_textFloat->setText( m_hintTextBeforeValue +
QString::number( value() ) +
@@ -812,7 +817,7 @@ void knob::enterValue( void )
void knob::connectToMidiDevice( void )
{
//mixer::inst()->getMIDIDevice()->setPitchBendKnob( this );
//eng()->getMixer()->getMIDIDevice()->setPitchBendKnob( this );
}

View File

@@ -2,7 +2,7 @@
* pixmap_button.cpp - implementation of pixmap-button (often used as "themed"
* checkboxes/radiobuttons etc)
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*

View File

@@ -1,7 +1,7 @@
/*
* project_notes.cpp - implementation of project-notes-editor
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -67,20 +67,21 @@
#include "project_notes.h"
#include "embed.h"
#include "lmms_main_win.h"
#include "main_window.h"
#include "song_editor.h"
projectNotes::projectNotes() :
QMainWindow( lmmsMainWin::inst()->workspace()
projectNotes::projectNotes( engine * _engine) :
QMainWindow( _engine->getMainWindow()->workspace()
#ifndef QT4
, 0, Qt::WStyle_Title
#endif
)
),
engineObject( _engine )
{
#ifdef QT4
lmmsMainWin::inst()->workspace()->addWindow( this );
eng()->getMainWindow()->workspace()->addWindow( this );
#endif
m_edit = new QTextEdit( this );
@@ -101,13 +102,33 @@ projectNotes::projectNotes() :
connect( m_edit, SIGNAL( currentAlignmentChanged( int ) ),
this, SLOT( alignmentChanged( int ) ) );
connect( m_edit, SIGNAL( textChanged() ),
songEditor::inst(), SLOT( setModified() ) );
eng()->getSongEditor(), SLOT( setModified() ) );
setupActions();
setCentralWidget( m_edit );
setWindowTitle( tr( "Project notes" ) );
setWindowIcon( embed::getIconPixmap( "project_notes" ) );
resize( 300, 200 );
if( eng()->getMainWindow()->workspace() != NULL )
{
move( 700, 10 );
}
else
{
move( 800, 10 );
}
show();
}
projectNotes::~projectNotes()
{
}
@@ -405,7 +426,7 @@ void projectNotes::setupActions()
void projectNotes::textBold()
{
m_edit->setFontWeight( m_actionTextBold->isChecked() );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -414,7 +435,7 @@ void projectNotes::textBold()
void projectNotes::textUnderline()
{
m_edit->setFontUnderline( m_actionTextUnderline->isChecked() );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -423,7 +444,7 @@ void projectNotes::textUnderline()
void projectNotes::textItalic()
{
m_edit->setFontItalic( m_actionTextItalic->isChecked() );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -433,7 +454,7 @@ void projectNotes::textFamily( const QString & _f )
{
m_edit->setFontFamily( _f );
m_edit->viewport()->setFocus();
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -443,7 +464,7 @@ void projectNotes::textSize( const QString & _p )
{
m_edit->setFontPointSize( _p.toInt() );
m_edit->viewport()->setFocus();
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -499,7 +520,7 @@ void projectNotes::fontChanged( const QFont & _f )
m_actionTextBold->setChecked( _f.bold() );
m_actionTextItalic->setChecked( _f.italic() );
m_actionTextUnderline->setChecked( _f.underline() );
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -514,7 +535,7 @@ void projectNotes::colorChanged( const QColor & _c )
#else
m_actionTextColor->setIconSet( pix );
#endif
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}
@@ -542,7 +563,7 @@ void projectNotes::alignmentChanged( int _a )
{
m_actionAlignJustify->setChecked( TRUE );
}
songEditor::inst()->setModified();
eng()->getSongEditor()->setModified();
}

View File

@@ -52,16 +52,18 @@
tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent,
const QString & _name, float _scale ) :
knob( _knob_num, _parent, _name ),
const QString & _name,
engine * _engine,
float _scale ) :
knob( _knob_num, _parent, _name, _engine ),
m_tempoSyncMode( NO_SYNC ),
m_scale( _scale ),
m_tempoSyncIcon( embed::getIconPixmap( "xclock" ) ),
m_tempoSyncDescription( tr( "Tempo Sync" ) ),
m_tempoLastSyncMode( NO_SYNC )
{
connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ),
this, SLOT( calculateTempoSyncTime( int ) ) );
connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ),
this, SLOT( calculateTempoSyncTime( bpm_t ) ) );
}
@@ -189,7 +191,7 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * )
void tempoSyncKnob::mouseMoveEvent( QMouseEvent * _me )
{
m_tempoSyncMode = NO_SYNC;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
calculateTempoSyncTime( eng()->getSongEditor()->getTempo() );
knob::mouseMoveEvent( _me );
}
@@ -200,7 +202,7 @@ void tempoSyncKnob::wheelEvent( QWheelEvent * _we )
{
knob::wheelEvent( _we );
m_tempoSyncMode = NO_SYNC;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
calculateTempoSyncTime( eng()->getSongEditor()->getTempo() );
}
@@ -219,17 +221,18 @@ void tempoSyncKnob::setTempoSync( QAction * ) { }
#endif
void tempoSyncKnob::setTempoSync( int _note_type )
{
m_tempoSyncMode = ( tempoSyncMode ) _note_type;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
songEditor::inst()->setModified();
calculateTempoSyncTime( eng()->getSongEditor()->getTempo() );
eng()->getSongEditor()->setModified();
}
void tempoSyncKnob::calculateTempoSyncTime( int _bpm )
void tempoSyncKnob::calculateTempoSyncTime( bpm_t _bpm )
{
float conversionFactor = 1.0;
@@ -324,7 +327,7 @@ tempoSyncKnob::tempoSyncMode tempoSyncKnob::getSyncMode( void )
void tempoSyncKnob::setSyncMode( tempoSyncMode _new_mode )
{
m_tempoSyncMode = _new_mode;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
calculateTempoSyncTime( eng()->getSongEditor()->getTempo() );
}
@@ -341,7 +344,7 @@ float tempoSyncKnob::getScale( void )
void tempoSyncKnob::setScale( float _new_scale )
{
m_scale = _new_scale;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
calculateTempoSyncTime( eng()->getSongEditor()->getTempo() );
emit scaleChanged( _new_scale );
}

View File

@@ -1,7 +1,7 @@
/*
* text_float.cpp - class textFloat, a floating text-label
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -43,7 +43,6 @@
#include "text_float.h"
#include "gui_templates.h"
#include "lmms_main_win.h"
@@ -152,10 +151,6 @@ textFloat * textFloat::displayMessage( const QString & _msg, int _timeout,
{
#ifdef QT4
QWidget * mw = QApplication::activeWindow();
if( mw == NULL )
{
mw = lmmsMainWin::inst();
}
#else
QWidget * mw = qApp->mainWidget();
if( mw == NULL )

View File

@@ -1,7 +1,7 @@
/*
* tool_button.cpp - implementation of LMMS-tool-button for common (cool) look
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*

View File

@@ -1,7 +1,7 @@
/*
* visualization_widget.cpp - widget for visualization of sound-data
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -53,8 +53,10 @@ const int UPDATE_TIME = 1000 / 20; // 20 fps
visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p,
engine * _engine,
visualizationTypes _vtype ) :
QWidget( _p ),
engineObject( _engine ),
s_background( _bg ),
m_enabled( TRUE )
{
@@ -64,10 +66,10 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p,
setFixedSize( s_background.width(), s_background.height() );
const fpab_t frames = mixer::inst()->framesPerAudioBuffer();
const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer();
m_buffer = bufferAllocator::alloc<surroundSampleFrame>( frames );
mixer::inst()->clearAudioBuffer( m_buffer, frames );
eng()->getMixer()->clearAudioBuffer( m_buffer, frames );
m_updateTimer = new QTimer( this );
@@ -77,7 +79,7 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p,
m_updateTimer->start( UPDATE_TIME );
}
connect( mixer::inst(), SIGNAL( nextAudioBuffer(
connect( eng()->getMixer(), SIGNAL( nextAudioBuffer(
const surroundSampleFrame *, const fpab_t ) ),
this, SLOT( setAudioBuffer(
const surroundSampleFrame *, const fpab_t ) ) );
@@ -121,7 +123,7 @@ void visualizationWidget::paintEvent( QPaintEvent * )
if( m_enabled == TRUE )
{
float master_output = mixer::inst()->masterGain();
float master_output = eng()->getMixer()->masterGain();
Uint16 w = width()-4;
float half_h = -( height() - 6 ) / 3.0 * master_output - 1;
Uint16 x_base = 2;
@@ -136,12 +138,13 @@ void visualizationWidget::paintEvent( QPaintEvent * )
float max_level = 0.0;
const fpab_t frames = mixer::inst()->framesPerAudioBuffer();
const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer();
// analyse wave-stream for max-level
for( fpab_t frame = 0; frame < frames; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS;
++chnl )
{
if( tAbs<float>( m_buffer[frame][chnl] ) >
max_level )
@@ -211,5 +214,5 @@ void visualizationWidget::mousePressEvent( QMouseEvent * _me )
#include <visualization_widget.moc>
#include "visualization_widget.moc"