From 181f9b56f6708d1365fd870c185ecdf45d1cf2b4 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 22 Dec 2005 12:57:51 +0000 Subject: [PATCH] small bug-fixes git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@42 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 24 +++++++++++++++++-- TODO | 3 +-- configure.in | 4 ++-- include/tab_widget.h | 18 +++++++------- src/core/file_browser.cpp | 2 +- src/core/song_editor.cpp | 2 +- src/lib/sample_buffer.cpp | 48 +++++++++++++++++++++---------------- src/tracks/pattern.cpp | 8 ++----- src/widgets/lcd_spinbox.cpp | 4 ++++ src/widgets/tab_widget.cpp | 23 ++++++++++++++++-- src/widgets/text_float.cpp | 5 ++++ 11 files changed, 95 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1841623e79..f83f95224c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,29 @@ +2005-12-21 Tobias Doerffel + + * src/lib/sample_buffer.cpp: + - first try to use libsndfile instead of SDL_sound for decoding sample + as SDL_sound sometimes doesn't handle samples (raw- and FLAC-files) + the correct way and returns unusable data while libsndfile seems to + work quite fine with these samples + - when using libsamplerate, use linear-interpolation per default + instead of zero-order-hold-resampling which results in MUCH higher + quality when resampling as it produces much less artifacts + + * src/core/file_browser.cpp: + classify files with extension "flac" as samples + + * src/widgets/tab_widget.cpp: + hide all other tabs when changing active tab - neccessary for working + with Qt 4.1 + 2005-12-20 Danny McRae + * resources/step_btn_on_100.png: + * resources/step_btn_yellow.png: * include/pattern.h: * src/tracks/pattern.cpp: - be able to change volume of step in bb-editor via mouse wheel and - change color of step-button accordingly + make it possible to change volume of steps in bb-editor using mouse + wheel and which changes color of step-button accordingly 2005-12-20 Tobias Doerffel diff --git a/TODO b/TODO index 776c7467a8..64d90828b3 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,9 @@ to be done as soon as possible: +- do not skip samples because of rounding when resampling in src/lib/sample_buffer.cpp - MIDI-program/MIDI-mapping/process program-/channel-change-events from MIDI-files - do not allow to connect output-port of channel to own input-port! - add note-len- and note-alignment-selectbox to piano-roll -- fix audio/midi-settings stuff/translation -- tooltips for controls in MIDI-tab - DSSI-support - save/load parameters of VST-plugin - somehow avoid hidden plugin-descriptor-widgets plugin-browser if height of window is too small -> add scrollbar diff --git a/configure.in b/configure.in index 5d36a30adc..2ac8ac2d1a 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.1.1-cvs20051219, tobydox/at/users.sourceforge.net) -AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051219) +AC_INIT(lmms, 0.1.1-cvs20051221, tobydox/at/users.sourceforge.net) +AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051221) AM_CONFIG_HEADER(config.h) diff --git a/include/tab_widget.h b/include/tab_widget.h index 101f6613a9..282bdc1a5d 100644 --- a/include/tab_widget.h +++ b/include/tab_widget.h @@ -26,6 +26,11 @@ #ifndef _TAB_WIDGET_H #define _TAB_WIDGET_H +#ifdef HAVE_CONFIG_H +#include +#endif + + #include "qt3support.h" #ifdef QT4 @@ -51,17 +56,10 @@ public: tabWidget( const QString & _caption, QWidget * _parent ); ~tabWidget(); - void addTab( QWidget * _w, const QString & _name, int _idx = -1 ); + void FASTCALL addTab( QWidget * _w, const QString & _name, + int _idx = -1 ); - inline void setActiveTab( int _idx ) - { - if( m_widgets.contains( _idx ) ) - { - m_activeTab = _idx; - m_widgets[m_activeTab].w->raise(); - update(); - } - } + void FASTCALL setActiveTab( int _idx ); inline int activeTab( void ) const { diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index 3619f5443c..3fc11125a1 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -803,7 +803,7 @@ void fileItem::determineFileType( void ) } else if( ext == "wav" || ext == "ogg" || ext == "mp3" || ext == "aiff" || ext == "aif" || ext == "voc" || - ext == "au" || ext == "raw" ) + ext == "au" || ext == "raw" || ext == "flac" ) { m_type = SAMPLE_FILE; } diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index bffdab9f1b..8ba1bcd3f6 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -1540,7 +1540,7 @@ bool songEditor::saveProject( void ) else { textFloat::displayMessage( tr( "Project NOT saved." ), - tr( "The project %1 could not be saved!" ).arg( + tr( "The project %1 was not saved!" ).arg( m_fileName ), embed::getIconPixmap( "error" ), 4000 ); return( FALSE ); diff --git a/src/lib/sample_buffer.cpp b/src/lib/sample_buffer.cpp index 53a092e78f..48de355f3e 100644 --- a/src/lib/sample_buffer.cpp +++ b/src/lib/sample_buffer.cpp @@ -144,7 +144,7 @@ sampleBuffer::sampleBuffer( const sampleFrame * _data, Uint32 _frames ) : m_dataMutex() { m_origData = new sampleFrame[_frames]; - memcpy( m_origData, _data, _frames*BYTES_PER_FRAME ); + memcpy( m_origData, _data, _frames * BYTES_PER_FRAME ); m_origFrames = _frames; #ifdef SDL_SDL_SOUND_H // init sound-file-system of SDL @@ -225,18 +225,18 @@ void sampleBuffer::update( bool _keep_settings ) Sint16 * buf = NULL; Uint8 channels; -#ifdef SDL_SDL_SOUND_H - if( m_frames == 0 ) - { - m_frames = decodeSampleSDL( f, buf, channels ); - } -#endif #ifdef HAVE_SNDFILE_H if( m_frames == 0 ) { m_frames = decodeSampleSF( f, buf, channels ); } #endif +#ifdef SDL_SDL_SOUND_H + if( m_frames == 0 ) + { + m_frames = decodeSampleSDL( f, buf, channels ); + } +#endif #ifdef HAVE_VORBIS_VORBISFILE_H if( m_frames == 0 ) { @@ -338,7 +338,7 @@ Uint32 sampleBuffer::decodeSampleSDL( const char * _f, Sint16 * & _buf, Sound_Sample * snd_sample = Sound_NewSampleFromFile( _f, &STD_AUDIO_INFO, 16384 ); - // file not found? + // file found? if( snd_sample != NULL ) { // let SDL_sound decode our file to requested format @@ -561,12 +561,10 @@ SRC_STATE * sampleBuffer::createResamplingContext( void ) { int error; SRC_STATE * state; - if( ( state = src_new( -#ifdef HQ_SINC - SRC_SINC_MEDIUM_QUALITY, -#else - SRC_ZERO_ORDER_HOLD, -#endif + if( ( state = src_new(/* + ( mixer::inst()->highQuality() == TRUE ) ? + SRC_SINC_FASTEST :*/ + SRC_LINEAR, DEFAULT_CHANNELS, &error ) ) == NULL ) { printf( "Error: src_new() failed in sample_buffer.cpp!\n" ); @@ -598,7 +596,7 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab, Uint32 _start_frame, return( FALSE ); } - const float freq_factor = 1.0f / (BASE_FREQ / _freq); + const double freq_factor = (double) _freq / (double) BASE_FREQ; const Sint16 freq_diff = static_cast( BASE_FREQ - _freq ); Uint32 frames_to_process = _frames; @@ -635,11 +633,21 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab, Uint32 _start_frame, { frames_to_process = frames_for_loop; } - + const Uint32 f1 = static_cast( play_frame * freq_factor ); +/* Uint32 f2 = 0; + while( f2 < f1 ) + { + f2 += frames_to_process * freq_factor; + } + if( f2 > f1 && f2 >= frames_to_process ) + { + f2 -= frames_to_process * freq_factor; + }*/ +// static int foo = 0; // calc pointer of first frame - sampleFrame * start_frame = (sampleFrame *) m_data + - static_cast( play_frame * - freq_factor ); + sampleFrame * start_frame = (sampleFrame *) m_data + f1; + //printf("diff:%d %f %d f2: %d input: %d\n", f2 -foo, play_frame * freq_factor, static_cast( play_frame * freq_factor ), f2, (Uint32)( frames_for_loop * freq_factor ) ); +// foo = f2; sampleFrame * loop_start = start_frame; // check whether we have to change pitch... @@ -670,7 +678,7 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab, Uint32 _start_frame, #else Uint32 src_frame_base = 0; // check whether we're in high-quality-mode - if( mixer::inst()->highQuality() ) + if( mixer::inst()->highQuality() == TRUE ) { // we are, so let's use cubic interpolation... for( Uint32 frame = 0; frame < frames_to_process; diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 49a8f8b213..57da3667f0 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -185,7 +185,7 @@ void pattern::init( void ) toolTip::add( this, tr( "double-click to open this pattern in piano-roll\n" - "use mouse wheel to set volume" ) ); + "use mouse wheel to set volume of a step" ) ); } @@ -810,11 +810,6 @@ void pattern::mousePressEvent( QMouseEvent * _me ) void pattern::wheelEvent( QWheelEvent * _we ) { -/* if( _me->button() != Qt::LeftButton ) - { - return; -}*/ - if( m_patternType == pattern::BEAT_PATTERN && ( pixelsPerTact() >= 192 || m_steps != DEFAULT_STEPS_PER_TACT ) && @@ -1015,6 +1010,7 @@ void pattern::paintEvent( QPaintEvent * ) if( ( *it )->length() < 0 ) { + p.drawPixmap( x, y, stepoff ); for( int i = 0; i < vol / 5 + 1; ++i ) { p.drawPixmap( x, y, stepon ); diff --git a/src/widgets/lcd_spinbox.cpp b/src/widgets/lcd_spinbox.cpp index 22ada48060..b2e91a16c7 100644 --- a/src/widgets/lcd_spinbox.cpp +++ b/src/widgets/lcd_spinbox.cpp @@ -160,7 +160,11 @@ void lcdSpinBox::mousePressEvent( QMouseEvent * _me ) void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me ) { +#ifdef QT4 + if( _me->buttons() & Qt::LeftButton ) +#else if( _me->modifiers() == Qt::LeftButton ) +#endif { int dy = _me->globalY() - m_origMousePos.y(); if( dy > 1 || dy < -1 ) diff --git a/src/widgets/tab_widget.cpp b/src/widgets/tab_widget.cpp index ed90166b0d..0d1411d8dd 100644 --- a/src/widgets/tab_widget.cpp +++ b/src/widgets/tab_widget.cpp @@ -89,6 +89,7 @@ void tabWidget::addTab( QWidget * _w, const QString & _name, int _idx ) if( m_widgets.contains( m_activeTab ) ) { // make sure new tab doesn't overlap current widget + m_widgets[m_activeTab].w->show(); m_widgets[m_activeTab].w->raise(); } } @@ -96,6 +97,25 @@ void tabWidget::addTab( QWidget * _w, const QString & _name, int _idx ) +void tabWidget::setActiveTab( int _idx ) +{ + if( m_widgets.contains( _idx ) ) + { + int old_active = m_activeTab; + m_activeTab = _idx; + m_widgets[m_activeTab].w->raise(); + m_widgets[m_activeTab].w->show(); + if( old_active != _idx && m_widgets.contains( old_active ) ) + { + m_widgets[old_active].w->hide(); + } + update(); + } +} + + + + void tabWidget::mousePressEvent( QMouseEvent * _me ) { if( _me->y() > 1 && _me->y() < 13 ) @@ -108,8 +128,7 @@ void tabWidget::mousePressEvent( QMouseEvent * _me ) if( _me->x() >= cx && _me->x() <= cx + ( *it ).nwidth ) { - ( *it ).w->raise(); - m_activeTab = it.key(); + setActiveTab( it.key() ); update(); return; } diff --git a/src/widgets/text_float.cpp b/src/widgets/text_float.cpp index 9a52c0eeca..d8543f4197 100644 --- a/src/widgets/text_float.cpp +++ b/src/widgets/text_float.cpp @@ -43,6 +43,7 @@ #include "text_float.h" #include "gui_templates.h" +#include "lmms_main_win.h" @@ -151,6 +152,10 @@ 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(); #endif