mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-18 03:35:12 -04: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.
177 lines
4.2 KiB
C++
177 lines
4.2 KiB
C++
/*
|
|
* FreeBoy.h - GameBoy papu based instrument
|
|
*
|
|
* Copyright (c) 2008 Attila Herman <attila589/at/gmail.com>
|
|
* Csaba Hruska <csaba.hruska/at/gmail.com>
|
|
*
|
|
* 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_FREEBOY_H
|
|
#define LMMS_FREEBOY_H
|
|
|
|
#include "AutomatableModel.h"
|
|
#include "Blip_Buffer.h"
|
|
#include "Instrument.h"
|
|
#include "InstrumentView.h"
|
|
#include "Graph.h"
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
class NotePlayHandle;
|
|
|
|
|
|
namespace gui
|
|
{
|
|
class PixmapButton;
|
|
class FreeBoyInstrumentView;
|
|
class Knob;
|
|
}
|
|
|
|
|
|
class FreeBoyInstrument : public Instrument
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
FreeBoyInstrument( InstrumentTrack * _instrument_track );
|
|
~FreeBoyInstrument() override = default;
|
|
|
|
void playNote(NotePlayHandle* nph, sampleFrame* workingBuffer) override;
|
|
void deleteNotePluginData(NotePlayHandle* nph) override;
|
|
|
|
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
|
|
void loadSettings( const QDomElement & _this ) override;
|
|
|
|
QString nodeName() const override;
|
|
|
|
float desiredReleaseTimeMs() const override;
|
|
|
|
gui::PluginView* instantiateView( QWidget * _parent ) override;
|
|
|
|
|
|
/*public slots:
|
|
void updateKnobHint();
|
|
void updateKnobToolTip();*/
|
|
|
|
private:
|
|
FloatModel m_ch1SweepTimeModel;
|
|
BoolModel m_ch1SweepDirModel;
|
|
FloatModel m_ch1SweepRtShiftModel;
|
|
FloatModel m_ch1WavePatternDutyModel;
|
|
FloatModel m_ch1VolumeModel;
|
|
BoolModel m_ch1VolSweepDirModel;
|
|
FloatModel m_ch1SweepStepLengthModel;
|
|
|
|
FloatModel m_ch2WavePatternDutyModel;
|
|
FloatModel m_ch2VolumeModel;
|
|
BoolModel m_ch2VolSweepDirModel;
|
|
FloatModel m_ch2SweepStepLengthModel;
|
|
|
|
BoolModel m_ch3OnModel;
|
|
FloatModel m_ch3VolumeModel;
|
|
|
|
FloatModel m_ch4VolumeModel;
|
|
BoolModel m_ch4VolSweepDirModel;
|
|
FloatModel m_ch4SweepStepLengthModel;
|
|
FloatModel m_ch4ShiftClockFreqModel;
|
|
BoolModel m_ch4ShiftRegWidthModel;
|
|
FloatModel m_ch4FreqDivRatioModel;
|
|
|
|
FloatModel m_so1VolumeModel;
|
|
FloatModel m_so2VolumeModel;
|
|
BoolModel m_ch1So1Model;
|
|
BoolModel m_ch2So1Model;
|
|
BoolModel m_ch3So1Model;
|
|
BoolModel m_ch4So1Model;
|
|
BoolModel m_ch1So2Model;
|
|
BoolModel m_ch2So2Model;
|
|
BoolModel m_ch3So2Model;
|
|
BoolModel m_ch4So2Model;
|
|
FloatModel m_trebleModel;
|
|
FloatModel m_bassModel;
|
|
|
|
graphModel m_graphModel;
|
|
|
|
friend class gui::FreeBoyInstrumentView;
|
|
};
|
|
|
|
|
|
namespace gui
|
|
{
|
|
|
|
|
|
class FreeBoyInstrumentView : public InstrumentViewFixedSize
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
FreeBoyInstrumentView( Instrument * _instrument, QWidget * _parent );
|
|
~FreeBoyInstrumentView() override = default;
|
|
|
|
private:
|
|
void modelChanged() override;
|
|
|
|
Knob * m_ch1SweepTimeKnob;
|
|
PixmapButton * m_ch1SweepDirButton;
|
|
Knob * m_ch1SweepRtShiftKnob;
|
|
Knob * m_ch1WavePatternDutyKnob;
|
|
Knob * m_ch1VolumeKnob;
|
|
PixmapButton * m_ch1VolSweepDirButton;
|
|
Knob * m_ch1SweepStepLengthKnob;
|
|
|
|
Knob * m_ch2WavePatternDutyKnob;
|
|
Knob * m_ch2VolumeKnob;
|
|
PixmapButton * m_ch2VolSweepDirButton;
|
|
Knob * m_ch2SweepStepLengthKnob;
|
|
|
|
Knob * m_ch3VolumeKnob;
|
|
|
|
Knob * m_ch4VolumeKnob;
|
|
PixmapButton * m_ch4VolSweepDirButton;
|
|
Knob * m_ch4SweepStepLengthKnob;
|
|
PixmapButton * m_ch4ShiftRegWidthButton;
|
|
|
|
Knob * m_so1VolumeKnob;
|
|
Knob * m_so2VolumeKnob;
|
|
PixmapButton * m_ch1So1Button;
|
|
PixmapButton * m_ch2So1Button;
|
|
PixmapButton * m_ch3So1Button;
|
|
PixmapButton * m_ch4So1Button;
|
|
PixmapButton * m_ch1So2Button;
|
|
PixmapButton * m_ch2So2Button;
|
|
PixmapButton * m_ch3So2Button;
|
|
PixmapButton * m_ch4So2Button;
|
|
Knob * m_trebleKnob;
|
|
Knob * m_bassKnob;
|
|
|
|
Graph * m_graph;
|
|
|
|
/*protected slots:
|
|
void updateKnobHint();
|
|
void updateKnobToolTip();*/
|
|
};
|
|
|
|
|
|
} // namespace gui
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_FREEBOY_H
|