mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-25 06:48:55 -05:00
Make instruments report their release time in milliseconds so that it becomes independent of the sample rate and sounds the same at any sample rate. Technically this is done by removing the virtual keyword from `desiredReleaseFrames` so that it cannot be overridden anymore. The method now only serves to compute the number of frames from the given release time in milliseconds. A new virtual method `desiredReleaseTimeMs` is added which instruments can override. The default returns 0 ms just like the default implementation previously returned 0 frames. The method `computeReleaseTimeMsByFrameCount` is added for instruments that still use a hard coded release in frames. As of now this is only `SidInstrument`. Add the helper method `getSampleRate` to `Instrument`. Adjust several instruments to report their release times in milliseconds. The times are computed by taking the release in frames and assuming a sample rate of 44.1 kHz. In most cases the times are rounded to a "nice" next value, e.g.: * 64 frames -> 1.5 ms (66 frames) * 128 frames -> 3.0 ms (132 frames) * 512 frames -> 12. ms (529 frames) * 1000 frames -> 23 ms (1014 samples) In parentheses the number of frames are shown which result from the rounded number of milliseconds when converted back assuming a sample rate of 44.1 kHz. The difference should not be noticeable in existing projects. Remove the overrides for instruments that return the same value as the base class `Instrument` anyway. These are: * GigPlayer * Lb302 * Sf2Player For `MonstroInstrument` the implementation is adjusted to behave in a very similar way. First the maximum of the envelope release times is computed. These are already available in milliseconds. Then the maximum of that value and 1.5 ms is taken and returned as the result.
114 lines
3.1 KiB
C++
114 lines
3.1 KiB
C++
/*
|
|
* AudioFileProcessor.h - declaration of class AudioFileProcessor
|
|
* (instrument-plugin for using audio-files)
|
|
*
|
|
* Copyright (c) 2004-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_AUDIO_FILE_PROCESSOR_H
|
|
#define LMMS_AUDIO_FILE_PROCESSOR_H
|
|
|
|
|
|
#include "AutomatableModel.h"
|
|
#include "ComboBoxModel.h"
|
|
|
|
#include "Instrument.h"
|
|
#include "Sample.h"
|
|
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
class AudioFileProcessor : public Instrument
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
AudioFileProcessor( InstrumentTrack * _instrument_track );
|
|
|
|
void playNote( NotePlayHandle * _n,
|
|
sampleFrame * _working_buffer ) override;
|
|
void deleteNotePluginData( NotePlayHandle * _n ) override;
|
|
|
|
void saveSettings(QDomDocument& doc, QDomElement& elem) override;
|
|
void loadSettings(const QDomElement& elem) override;
|
|
|
|
void loadFile( const QString & _file ) override;
|
|
|
|
QString nodeName() const override;
|
|
|
|
auto beatLen(NotePlayHandle* note) const -> int override;
|
|
|
|
float desiredReleaseTimeMs() const override
|
|
{
|
|
return 3.f;
|
|
}
|
|
|
|
gui::PluginView* instantiateView( QWidget * _parent ) override;
|
|
|
|
Sample const & sample() const { return m_sample; }
|
|
|
|
FloatModel & ampModel() { return m_ampModel; }
|
|
FloatModel & startPointModel() { return m_startPointModel; }
|
|
FloatModel & endPointModel() { return m_endPointModel; }
|
|
FloatModel & loopPointModel() { return m_loopPointModel; }
|
|
BoolModel & reverseModel() { return m_reverseModel; }
|
|
IntModel & loopModel() { return m_loopModel; }
|
|
BoolModel & stutterModel() { return m_stutterModel; }
|
|
ComboBoxModel & interpolationModel() { return m_interpolationModel; }
|
|
|
|
|
|
public slots:
|
|
void setAudioFile(const QString& _audio_file, bool _rename = true);
|
|
|
|
private slots:
|
|
void reverseModelChanged();
|
|
void ampModelChanged();
|
|
void loopPointChanged();
|
|
void startPointChanged();
|
|
void endPointChanged();
|
|
void pointChanged();
|
|
void stutterModelChanged();
|
|
|
|
|
|
signals:
|
|
void isPlaying( lmms::f_cnt_t _current_frame );
|
|
void sampleUpdated();
|
|
|
|
private:
|
|
Sample m_sample;
|
|
|
|
FloatModel m_ampModel;
|
|
FloatModel m_startPointModel;
|
|
FloatModel m_endPointModel;
|
|
FloatModel m_loopPointModel;
|
|
BoolModel m_reverseModel;
|
|
IntModel m_loopModel;
|
|
BoolModel m_stutterModel;
|
|
ComboBoxModel m_interpolationModel;
|
|
|
|
f_cnt_t m_nextPlayStartPoint;
|
|
bool m_nextPlayBackwards;
|
|
} ;
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_AUDIO_FILE_PROCESSOR_H
|