Skip to content

Commit

Permalink
[code] Various code fixes and cleanups. Port the gain object to avend…
Browse files Browse the repository at this point in the history
…ish to support smoothing
  • Loading branch information
jcelerier committed Jun 17, 2024
1 parent f85adf7 commit 93424ed
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 73 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libossia
Submodule libossia updated 1 files
+1 −1 3rdparty/libremidi
18 changes: 9 additions & 9 deletions src/app/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,6 @@ void Application::initDocuments()
m_presenter->documentManager().loadFile(ctx, doc);
}

// The plug-ins have the ability to override the boot process.
for(auto plug : ctx.guiApplicationPlugins())
{
if(plug->handleStartup())
{
return;
}
}

if(appSettings.gui)
{
auto sqa = safe_cast<SafeQApplication*>(m_app);
Expand Down Expand Up @@ -482,6 +473,15 @@ void Application::initDocuments()
QThreadPool::globalInstance()->setMaxThreadCount(2);
#endif
#endif

// The plug-ins have the ability to override the boot process.
for(auto plug : ctx.guiApplicationPlugins())
{
if(plug->handleStartup())
{
return;
}
}
}

void Application::openNewDocument()
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/application/ApplicationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void ApplicationSettings::parse(QStringList cargs, int& argc, char** argv)

if(!gui)
tryToRestore = false;
autoplay = parser.isSet(autoplayOpt) && args.size() == 1;
autoplay = parser.isSet(autoplayOpt);

if(parser.isSet(waitLoadOpt))
waitAfterLoad = parser.value(waitLoadOpt).toInt();
Expand Down
27 changes: 15 additions & 12 deletions src/lib/core/document/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,21 @@ Document::Document(

void Document::init()
{
con(m_selectionStack, &SelectionStack::currentSelectionChanged, this,
[&](const Selection& old, const Selection& s) {
Selection oldfiltered = old;
oldfiltered.removeAll(nullptr);
Selection filtered = s;
filtered.removeAll(nullptr);
for(auto& panel : m_context.app.panels())
{
panel.setNewSelection(filtered);
}
m_presenter->setNewSelection(oldfiltered, filtered);
});
if(this->m_context.app.applicationSettings.gui)
{
con(m_selectionStack, &SelectionStack::currentSelectionChanged, this,
[&](const Selection& old, const Selection& s) {
Selection oldfiltered = old;
oldfiltered.removeAll(nullptr);
Selection filtered = s;
filtered.removeAll(nullptr);
for(auto& panel : m_context.app.panels())
{
panel.setNewSelection(filtered);
}
m_presenter->setNewSelection(oldfiltered, filtered);
});
}

updateTimers();

Expand Down
8 changes: 7 additions & 1 deletion src/plugins/score-plugin-avnd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ avnd_make_score(
MAIN_CLASS Flanger
NAMESPACE ao
)
avnd_make_score(
SOURCES "${AVND_FOLDER}/examples/Advanced/Utilities/Gain.hpp"
TARGET gain
MAIN_CLASS Gain
NAMESPACE ao
)
avnd_make_score(
SOURCES "${AVND_FOLDER}/examples/Advanced/Utilities/StereoMixer.hpp"
TARGET stereo_mixer
Expand Down Expand Up @@ -527,7 +533,7 @@ avnd_make_score(
)

avnd_make_score(
SOURCES "${AVND_FOLDER}/examples/Raw/Trigger.hpp"
SOURCES "${AVND_FOLDER}/examples/Advanced/Utilities/Trigger.hpp"
TARGET trigger
MAIN_CLASS Trigger
NAMESPACE examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void DeviceList::removeDevice(const QString& name)
SCORE_ASSERT(it != m_devices.end());

deviceRemoved(*it);
delete *it;
m_devices.erase(it);
delete *it;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ void DeviceDocumentPlugin::setupConnections(
{
vec.push_back(
con(device, &Device::DeviceInterface::pathAdded, this,
[&](const State::Address& addr) {
[&, ptr = QPointer{&device}](const State::Address& addr) {
if(!ptr)
return;
// FIXME A subtle bug is introduced if we want to add the root
// node...
if(addr.path.size() > 0)
Expand All @@ -354,7 +356,7 @@ void DeviceDocumentPlugin::setupConnections(
}
}
}
}));
}, Qt::QueuedConnection));

vec.push_back(con(
device, &Device::DeviceInterface::pathRemoved, this,
Expand Down
19 changes: 9 additions & 10 deletions src/plugins/score-plugin-fx/score_plugin_fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ std::vector<score::InterfaceBase*> score_plugin_fx::factories(
Nodes::Arpeggiator::Node, Nodes::PulseToNote::Node, Nodes::ClassicalBeat::Node,
Nodes::LFO::v1::Node, Nodes::LFO::v2::Node, Nodes::Chord::Node,
Nodes::MidiHiRes::Input, Nodes::MidiHiRes::Output, Nodes::MidiUtil::Node,
Nodes::Gain::Node, Nodes::Metro::Node, Nodes::Envelope::Node,
Nodes::Quantifier::Node, Nodes::MathGenerator::Node,
Nodes::MathAudioGenerator::Node, Nodes::MathMapping::Node,
Nodes::MicroMapping::Node, Nodes::ArrayMapping::Node, Nodes::MathAudioFilter::Node,
Nodes::EmptyValueMapping::Node, Nodes::EmptyMidiMapping::Node,
Nodes::EmptyAudioMapping::Node, Nodes::FactorOracle::Node,
Nodes::FactorOracle2::Node, Nodes::FactorOracle2MIDI::Node,
Nodes::PitchToValue::Node, Nodes::ValueFilter::v1::Node,
Nodes::ValueFilter::v2::Node, Nodes::RateLimiter::Node, Nodes::AudioLooper::Node>(
ctx, key);
Nodes::Metro::Node, Nodes::Envelope::Node, Nodes::Quantifier::Node,
Nodes::MathGenerator::Node, Nodes::MathAudioGenerator::Node,
Nodes::MathMapping::Node, Nodes::MicroMapping::Node, Nodes::ArrayMapping::Node,
Nodes::MathAudioFilter::Node, Nodes::EmptyValueMapping::Node,
Nodes::EmptyMidiMapping::Node, Nodes::EmptyAudioMapping::Node,
Nodes::FactorOracle::Node, Nodes::FactorOracle2::Node,
Nodes::FactorOracle2MIDI::Node, Nodes::PitchToValue::Node,
Nodes::ValueFilter::v1::Node, Nodes::ValueFilter::v2::Node,
Nodes::RateLimiter::Node, Nodes::AudioLooper::Node>(ctx, key);
}

auto score_plugin_fx::required() const -> std::vector<score::PluginKey>
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/score-plugin-gfx/Gfx/Graph/RenderedISFNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ std::optional<Sampler> AudioTextureUpload::updateAudioTexture(
if(audio.channels > 0)
{
int samples = audio.data.size() / audio.channels;
if(samples % 2 != 0)
samples++;
int pixelWidth = samples / (audio.fft ? 2 : 1);

float* rectUniform
Expand Down
37 changes: 2 additions & 35 deletions src/plugins/score-plugin-protocols/Protocols/CoAP/CoAPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <ossia/network/generic/generic_device.hpp>
#include <ossia/network/generic/generic_parameter.hpp>
#include <ossia/network/rate_limiting_protocol.hpp>
#include <ossia/protocols/mqtt/mqtt_protocol.hpp>

#include <memory>
namespace Protocols
Expand Down Expand Up @@ -86,40 +85,8 @@ void CoAPDevice::recreate(const Device::Node& n)

bool CoAPDevice::isLearning() const
{
auto& proto = static_cast<ossia::net::mqtt5_protocol&>(m_dev->get_protocol());
return proto.learning();
return false;
}

void CoAPDevice::setLearning(bool b)
{
if(!m_dev)
return;
auto& proto = static_cast<ossia::net::mqtt5_protocol&>(m_dev->get_protocol());
auto& dev = *m_dev;
if(b)
{
dev.on_node_created.connect<&DeviceInterface::nodeCreated>((DeviceInterface*)this);
dev.on_node_removing.connect<&DeviceInterface::nodeRemoving>((DeviceInterface*)this);
dev.on_node_renamed.connect<&DeviceInterface::nodeRenamed>((DeviceInterface*)this);
dev.on_parameter_created.connect<&DeviceInterface::addressCreated>(
(DeviceInterface*)this);
dev.on_attribute_modified.connect<&DeviceInterface::addressUpdated>(
(DeviceInterface*)this);
}
else
{
dev.on_node_created.disconnect<&DeviceInterface::nodeCreated>(
(DeviceInterface*)this);
dev.on_node_removing.disconnect<&DeviceInterface::nodeRemoving>(
(DeviceInterface*)this);
dev.on_node_renamed.disconnect<&DeviceInterface::nodeRenamed>(
(DeviceInterface*)this);
dev.on_parameter_created.disconnect<&DeviceInterface::addressCreated>(
(DeviceInterface*)this);
dev.on_attribute_modified.disconnect<&DeviceInterface::addressUpdated>(
(DeviceInterface*)this);
}

proto.set_learning(b);
}
void CoAPDevice::setLearning(bool b) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ void OSCQueryDevice::slot_createDevice()
// run the commands in the Qt event loop
// FIXME they should be disabled upon manual disconnection

Device::releaseDevice(*m_ctx, std::move(m_dev));
m_dev = std::make_unique<ossia::net::generic_device>(
std::move(ossia_settings), settings().name.toStdString());

Expand Down

0 comments on commit 93424ed

Please sign in to comment.