diff --git a/ChangeLog b/ChangeLog index e19fd00b2..d59588f9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-05 Danny McRae + + * include/sample_track.h: + * src/tracks/sample_track.cpp: + - add volume knob to sample tracks + 2006-04-05 Danny McRae * plugins/vibed/impulse_editor.cpp: diff --git a/include/sample_track.h b/include/sample_track.h index 276500fcd..048d24d2d 100644 --- a/include/sample_track.h +++ b/include/sample_track.h @@ -47,6 +47,7 @@ class nameLabel; class audioPort; class QLabel; +class knob; //class sampleTCOSettingsDialog; @@ -75,7 +76,6 @@ public slots: void setSampleFile( const QString & _sf ); void updateLength( bpm_t = 0 ); - protected: virtual void dragEnterEvent( QDragEnterEvent * _dee ); virtual void dropEvent( QDropEvent * _de ); @@ -140,17 +140,20 @@ public: virtual void FASTCALL loadTrackSpecificSettings( const QDomElement & _this ); - public slots: virtual QString nodeName( void ) const { return( "sampletrack" ); } + void setVolume( float _new_volume ); private: nameLabel * m_trackLabel; audioPort * m_audioPort; + + knob * m_volumeKnob; + float m_volume; } ; diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index 21b1402e3..46d3814fd 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -53,7 +53,8 @@ #include "tooltip.h" #include "audio_port.h" #include "string_pair_drag.h" - +#include "knob.h" +#include "volume.h" sampleTCO::sampleTCO( track * _track ) : @@ -359,16 +360,36 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f ) sampleTrack::sampleTrack( trackContainer * _tc ) : track( _tc ), - m_audioPort( new audioPort( tr( "Sample track" ), eng() ) ) + m_audioPort( new audioPort( tr( "Sample track" ), eng() ) ), + m_volume( 1.0f ) { getTrackWidget()->setFixedHeight( 32 ); m_trackLabel = new nameLabel( tr( "Sample track" ), getTrackSettingsWidget(), eng() ); m_trackLabel->setPixmap( embed::getIconPixmap( "sample_track" ) ); - m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 ); + m_trackLabel->setGeometry( 26, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 ); m_trackLabel->show(); + m_volumeKnob = new knob( knobSmall_17, getTrackSettingsWidget(), + tr( "Channel volume" ), eng() ); + m_volumeKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f ); + m_volumeKnob->setInitValue( DEFAULT_VOLUME ); + m_volumeKnob->setHintText( tr( "Channel volume:" ) + " ", "%" ); + m_volumeKnob->move( 4, 4 ); + m_volumeKnob->setLabel( tr( "VOL" ) ); + m_volumeKnob->show(); + connect( m_volumeKnob, SIGNAL( valueChanged( float ) ), + this, SLOT( setVolume( float ) ) ); +#ifdef QT4 + m_volumeKnob->setWhatsThis( +#else + QWhatsThis::add( m_volumeKnob, +#endif + tr( "With this knob you can set " + "the volume of the opened " + "channel." ) ); + _tc->updateAfterTrackAdd(); } @@ -382,6 +403,16 @@ sampleTrack::~sampleTrack() +void sampleTrack::setVolume( float _new_volume ) +{ + if( _new_volume <= MAX_VOLUME ) + { + m_volume = _new_volume / 100.0f; + } +} + + + track::trackTypes sampleTrack::type( void ) const { @@ -408,9 +439,9 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, sampleFrame * buf = bufferAllocator::alloc( _frames ); - volumeVector v = { 1.0f, 1.0f + volumeVector v = { m_volume, m_volume #ifndef DISABLE_SURROUND - , 1.0f, 1.0f + , m_volume, m_volume #endif } ; float fpt = eng()->getSongEditor()->framesPerTact(); @@ -456,6 +487,7 @@ void sampleTrack::saveTrackSpecificSettings( QDomDocument & _doc, { _this.setAttribute( "name", m_trackLabel->text() ); _this.setAttribute( "icon", m_trackLabel->pixmapFile() ); + _this.setAttribute( "vol", m_volume ); } @@ -468,6 +500,16 @@ void sampleTrack::loadTrackSpecificSettings( const QDomElement & _this ) { m_trackLabel->setPixmapFile( _this.attribute( "icon" ) ); } + if( _this.attribute( "vol" ) != "" ) + { + m_volume = _this.attribute( "vol" ).toFloat(); + m_volumeKnob->setValue( m_volume * 100.0f ); + } + else + { + m_volumeKnob->setValue( 100.0f ); + m_volume = 1.0; + } }