Files
lmms/plugins/Oscilloscope/Oscilloscope.cpp
regulus79 668e80dbaa Add Oscilloscope Effect (#7937)
* Adds a new native plugin for incoming waveform display
* Features the ability to pause, zoom in, set window size and set amplification (scale)
* Does not feature a pitch-tracking option

---------

Co-authored-by: Fawn <rubiefawn@gmail.com>
Co-authored-by: Sotonye Atemie <satemiej@gmail.com>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
Co-authored-by: bratpeki <pkatic2003@gmail.com>
2026-04-27 23:51:05 +02:00

76 lines
2.0 KiB
C++

/*
* Oscilloscope.cpp - Oscilloscope effect to preview the incoming waveform
*
* Copyright (c) 2025 Keratin
*
* 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.
*
*/
#include "Oscilloscope.h"
#include "embed.h"
#include "plugin_export.h"
namespace lmms
{
extern "C"
{
Plugin::Descriptor PLUGIN_EXPORT oscilloscope_plugin_descriptor =
{
LMMS_STRINGIFY(PLUGIN_NAME),
"Oscilloscope",
QT_TRANSLATE_NOOP("PluginBrowser", "Oscilloscope plugin to display the incoming audio waveform"),
"Keratin <3",
0x0100,
Plugin::Type::Effect,
new PixmapLoader("lmms-plugin-logo"),
nullptr,
nullptr,
};
PLUGIN_EXPORT Plugin* lmms_plugin_main(Model* parent, void* data)
{
return new Oscilloscope(parent, static_cast<const Plugin::Descriptor::SubPluginFeatures::Key*>(data));
}
}
Oscilloscope::Oscilloscope(Model* parent, const Descriptor::SubPluginFeatures::Key* key) :
Effect(&oscilloscope_plugin_descriptor, parent, key),
m_controls(this),
m_inputBuffer(InputBufferSize)
{
}
Effect::ProcessStatus Oscilloscope::processImpl(SampleFrame* buffer, const f_cnt_t frames)
{
if (!m_controls.m_pauseModel.value())
{
// Send the samples from the audio thread over to the gui via a ring buffer; the gui will do all of the processing.
m_inputBuffer.write(buffer, frames);
}
return ProcessStatus::Continue;
}
} // namespace lmms