Skip to content

Commit

Permalink
midi remote: fix missing includes here and there
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Dec 27, 2024
1 parent 4f5d8ba commit 4c66fb9
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#pragma once
#include <score/plugins/Interface.hpp>
#include <score/plugins/InterfaceList.hpp>

#include <ossia-qt/time_value.hpp>
#include <ossia-qt/value_metatypes.hpp>

#include <QObject>

#include <score_lib_process_export.h>

#include <verdigris>
namespace score
{
struct DocumentContext;
}

namespace Process
{
Expand Down
13 changes: 8 additions & 5 deletions src/plugins/score-plugin-avnd/AvndProcesses/MIDISync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

/* SPDX-License-Identifier: GPL-3.0-or-later */

#include <cmath>
#include <ossia/dataflow/exec_state_facade.hpp>
#include <ossia/detail/thread.hpp>
#include <ossia/network/base/device.hpp>
#include <ossia/network/base/protocol.hpp>
#include <ossia/protocols/midi/midi_protocol.hpp>

#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/file_port.hpp>
#include <halp/meta.hpp>
#include <halp/midi.hpp>
#include <halp/midifile_port.hpp>
#include <libremidi/message.hpp>
#include <ossia/detail/thread.hpp>
#include <ossia/network/base/device.hpp>
#include <ossia/network/base/protocol.hpp>
#include <ossia/protocols/midi/midi_protocol.hpp>

#include <cmath>

#include <thread>

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/score-plugin-engine/Engine/ApplicationPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <score/plugins/application/GUIApplicationPlugin.hpp>
#include <score/plugins/documentdelegate/plugin/DocumentPlugin.hpp>

#include <QTimer>

#include <score_plugin_engine_export.h>

#include <memory>
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/score-plugin-engine/Execution/DocumentPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#include <ossia/network/generic/generic_device.hpp>
#include <ossia/network/local/local.hpp>

#include <QTimer>

#include <memory>
#include <verdigris>

inline QDataStream& operator<<(QDataStream& i, const ossia::bench_map& sel)
{
SCORE_ABORT;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/score-plugin-js/JS/Qml/EditContext.ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <score/tools/std/StringHash.hpp>
#include <score/widgets/DoubleSlider.hpp>

#include <core/document/Document.hpp>
#include <core/document/DocumentView.hpp>

#include <ossia/detail/hash_map.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QKeyEvent>
#include <QMainWindow>
#include <QMimeData>
#include <QTimer>

#include <RemoteControl/RemoteControlProvider.hpp>
// clang-format off
Expand Down Expand Up @@ -764,13 +765,15 @@ bool MCUDevice::reconnect()
auto& remote_controls
= this->m_doc.app.interfaces<Process::RemoteControlProviderList>();

if(!remote_controls.empty())
if(!remote_controls.empty() && !set.input_handle.empty()
&& !set.output_handle.empty())
{
auto rc = remote_controls[0].make(this->m_doc);
if(rc)
{
auto proto = std::make_unique<mcu_protocol>(
this->m_doc, rc, this->m_ctx, set.api, set.input_handle, set.output_handle);
this->m_doc, rc, this->m_ctx, set.api, set.input_handle[0],
set.output_handle[0]);

auto dev = std::make_unique<ossia::net::generic_device>(
std::move(proto), settings().name.toStdString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ bool MCUProtocolFactory::checkCompatibility(
{
// FIXME check if we can open the same device multiple times ?
auto specif = a.deviceSpecificSettings.value<MCUSpecificSettings>();
return specif.input_handle != libremidi::port_information{}
&& specif.output_handle != libremidi::port_information{};
if(specif.input_handle.empty())
return false;
if(specif.output_handle.empty())
return false;
// FIXME improve when we have multiple devices in one control surface
return specif.input_handle[0] != libremidi::port_information{}
&& specif.output_handle[0] != libremidi::port_information{};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ Device::DeviceSettings MCUSettingsWidget::getSettings() const

const int in_idx = m_midiin->currentIndex();
if(in_idx >= 0 && in_idx < std::ssize(m_ins))
midi.input_handle = m_ins[in_idx];
midi.input_handle = {m_ins[in_idx]};

const int out_idx = m_midiout->currentIndex();
if(out_idx >= 0 && out_idx < std::ssize(m_outs))
midi.output_handle = m_outs[out_idx];
midi.output_handle = {m_outs[out_idx]};

s.protocol = MCUProtocolFactory::static_concreteKey();
s.deviceSpecificSettings = QVariant::fromValue(midi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Protocols
{
struct MCUSpecificSettings
{
libremidi::input_port input_handle;
libremidi::output_port output_handle;
std::vector<libremidi::input_port> input_handle;
std::vector<libremidi::output_port> output_handle;
libremidi::API api{};

enum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ void DataStreamWriter::write(libremidi::port_information& n)
template <>
void JSONReader::read(const libremidi::port_information& n)
{
stream.StartObject();
obj["Port"] = n.port;
obj["Manufacturer"] = n.manufacturer;
obj["DeviceName"] = n.device_name;
obj["PortName"] = n.port_name;
obj["DisplayName"] = n.display_name;
stream.EndObject();
}

template <>
Expand All @@ -40,37 +42,82 @@ void JSONWriter::write(libremidi::port_information& n)
n.display_name = obj["DisplayName"].toStdString();
}

template <>
void DataStreamReader::read(const libremidi::input_port& n)
{
read(static_cast<const libremidi::port_information&>(n));
}

template <>
void DataStreamWriter::write(libremidi::input_port& n)
{
write(static_cast<libremidi::port_information&>(n));
}

template <>
void JSONReader::read(const libremidi::input_port& n)
{
read(static_cast<const libremidi::port_information&>(n));
}

template <>
void JSONWriter::write(libremidi::input_port& n)
{
write(static_cast<libremidi::port_information&>(n));
}

template <>
void DataStreamReader::read(const libremidi::output_port& n)
{
read(static_cast<const libremidi::port_information&>(n));
}

template <>
void DataStreamWriter::write(libremidi::output_port& n)
{
write(static_cast<libremidi::port_information&>(n));
}

template <>
void JSONReader::read(const libremidi::output_port& n)
{
read(static_cast<const libremidi::port_information&>(n));
}

template <>
void JSONWriter::write(libremidi::output_port& n)
{
write(static_cast<libremidi::port_information&>(n));
}

template <>
void DataStreamReader::read(const Protocols::MCUSpecificSettings& n)
{
m_stream << static_cast<const libremidi::port_information&>(n.input_handle)
<< static_cast<const libremidi::port_information&>(n.output_handle) << n.api
<< n.mode;
m_stream << n.input_handle << n.output_handle << n.api << n.mode;
insertDelimiter();
}

template <>
void DataStreamWriter::write(Protocols::MCUSpecificSettings& n)
{
m_stream >> static_cast<libremidi::port_information&>(n.input_handle)
>> static_cast<libremidi::port_information&>(n.output_handle) >> n.api >> n.mode;
m_stream >> n.input_handle >> n.output_handle >> n.api >> n.mode;
checkDelimiter();
}

template <>
void JSONReader::read(const Protocols::MCUSpecificSettings& n)
{
obj["API"] = n.api;
obj["Input"] = static_cast<const libremidi::port_information&>(n.input_handle);
obj["Output"] = static_cast<const libremidi::port_information&>(n.output_handle);
obj["Input"] = n.input_handle;
obj["Output"] = n.output_handle;
// FIXME mode
}

template <>
void JSONWriter::write(Protocols::MCUSpecificSettings& n)
{
n.api <<= obj["API"];
static_cast<libremidi::port_information&>(n.input_handle) <<= obj["Input"];
static_cast<libremidi::port_information&>(n.output_handle) <<= obj["Output"];
n.input_handle <<= obj["Input"];
n.output_handle <<= obj["Output"];
// FIXME mode
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#include <score/tools/IdentifierGeneration.hpp>

#include <ossia/network/domain/domain_functions.hpp>
#include <ossia/network/value/value_conversion.hpp>

#include <RemoteControl/Controller/DocumentPlugin.hpp>
#include <RemoteControl/Controller/RemoteControlProvider.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <Scenario/Document/ScenarioDocument/ScenarioDocumentView.hpp>

#include <score/application/GUIApplicationContext.hpp>

#include <core/document/DocumentView.hpp>

#include <QMainWindow>
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/score-plugin-vst/Vst/Control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <Dataflow/PortItem.hpp>
#include <Vst/EffectModel.hpp>

#include <ossia/network/domain/domain.hpp>
#include <ossia/network/domain/domain_functions.hpp>
#include <ossia/network/value/value_conversion.hpp>

#include <verdigris>

namespace Process
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/score-plugin-vst3/Vst3/Control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <Dataflow/PortItem.hpp>
#include <Vst3/EffectModel.hpp>

#include <ossia/network/domain/domain.hpp>
#include <ossia/network/domain/domain_functions.hpp>
#include <ossia/network/value/value_conversion.hpp>

#include <verdigris>

namespace Process
Expand Down

0 comments on commit 4c66fb9

Please sign in to comment.