mirror of
https://github.com/LMMS/lmms.git
synced 2026-02-23 17:56:31 -05:00
* Add Tap Tempo Feature (#6375) Resolves #5181 * Update formatting, use namespaces, etc. * Use Qt Designer .ui file to handle the UI Thanks to irrenhaus for the idea Also added a few buttons I will add functionality for * Play metronome sound when tapped * Improve stabilization speed by comparing differences in length between intervals To improve the speed at which the BPM counter stabilizes at a certain number, we now compare the differences in length between the last two taps and the most recent two taps and reset the counter if the threshold is passed. I made it so that a difference of 500 ms resets the counter. * Remove duplicate m_ui An artifact from my battle with Git and merge conflicts.. * Format TapTempoUi header file * Add lmms namespace in UI file * Remove taptempo.ui XML file Not needed * Add LMMS_EXPORT to SamplePlayHandle * Use std::chrono::duration<double, std::milli> for intervals Co-authored-by: irrenhaus3 <irrenhaus3@gmail.com> * Use alias for steady_clock Co-authored-by: irrenhaus3 <irrenhaus3@gmail.com> * Speed up convergence by accounting for recent intervals This uses a combination of keeping track of a more accurate BPM, while also using a BPM difference threshold to move towards the true BPM more quickly. After three taps, a "recent interval" is calculated, which is similar to the latest interval, but less fluctuating since it accounts for three taps instead of one. This allows for comparing between the BPM on the display with the recent BPM more closely. We then compare the difference in magnitude of both BPM's with the threshold. If the threshold is passed, the counter gets reset. * Remove semicolon from "QOBJECT;" in plugins/TapTempo/TapTempo.h Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> * Add newline between using alias and constructor * Cleanup header files * Add // namespace lmms::gui comment * Rename header guards in plugins/TapTempo/TapTempo.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Rename header guards in plugins/TapTempo/TapTempo.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Rename header guards in plugins/TapTempo/TapTempoUi.h Will merge this file with ``TapTempoView`` soon. Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Rename header guards in plugins/TapTempo/TapTempoUi.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Update plugins/TapTempo/TapTempo.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Replace virtual with override in plugins/TapTempo/TapTempo.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Merge UI file into TapTempoView * Pass TapTempo* directly into constructor in plugins/TapTempo/TapTempoView.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Update style in plugins/TapTempo/TapTempoView.h Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Add parameter name for keyPressEvent function in plugins/TapTempo/TapTempoView.h Also reorder the function declarations to match the order in the source file. Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Remove dynamic_cast to TapTempo* in plugins/TapTempo/TapTempoView.cpp Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Restrict C linkage to only lmms_plugin_main and plugin descriptor Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Simplify algorithm * Update labels when calling closeEvent * Add reset button * Adjust layout * Format document * Only allow the tap button to gain focus * Use icon provided by LMMS * Add sync button and adjust formatting * Make the metronome downbeat the first beat Also simplify code Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Round BPM values when syncing with project tempo Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com> * Change Plugin::Tool to Plugin::Type::Tool --------- Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com> Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>
104 lines
2.2 KiB
C++
104 lines
2.2 KiB
C++
|
|
/*
|
|
* SamplePlayHandle.h - play-handle for playing a sample
|
|
*
|
|
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* 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., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef LMMS_SAMPLE_PLAY_HANDLE_H
|
|
#define LMMS_SAMPLE_PLAY_HANDLE_H
|
|
|
|
#include "SampleBuffer.h"
|
|
#include "AutomatableModel.h"
|
|
#include "PlayHandle.h"
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
|
|
class PatternTrack;
|
|
class SampleClip;
|
|
class Track;
|
|
class AudioPort;
|
|
|
|
|
|
class LMMS_EXPORT SamplePlayHandle : public PlayHandle
|
|
{
|
|
public:
|
|
SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort = true );
|
|
SamplePlayHandle( const QString& sampleFile );
|
|
SamplePlayHandle( SampleClip* clip );
|
|
~SamplePlayHandle() override;
|
|
|
|
inline bool affinityMatters() const override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
|
|
void play( sampleFrame * buffer ) override;
|
|
bool isFinished() const override;
|
|
|
|
bool isFromTrack( const Track * _track ) const override;
|
|
|
|
f_cnt_t totalFrames() const;
|
|
inline f_cnt_t framesDone() const
|
|
{
|
|
return( m_frame );
|
|
}
|
|
void setDoneMayReturnTrue( bool _enable )
|
|
{
|
|
m_doneMayReturnTrue = _enable;
|
|
}
|
|
|
|
void setPatternTrack(PatternTrack* pt)
|
|
{
|
|
m_patternTrack = pt;
|
|
}
|
|
|
|
void setVolumeModel( FloatModel * _model )
|
|
{
|
|
m_volumeModel = _model;
|
|
}
|
|
|
|
|
|
private:
|
|
SampleBuffer * m_sampleBuffer;
|
|
bool m_doneMayReturnTrue;
|
|
|
|
f_cnt_t m_frame;
|
|
SampleBuffer::handleState m_state;
|
|
|
|
const bool m_ownAudioPort;
|
|
|
|
FloatModel m_defaultVolumeModel;
|
|
FloatModel * m_volumeModel;
|
|
Track * m_track;
|
|
|
|
PatternTrack* m_patternTrack;
|
|
|
|
} ;
|
|
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_SAMPLE_PLAY_HANDLE_H
|