feat: add WebsSocket API for mixer engine control

New files:
- MixerApi.hpp/cpp: Model-level API bridging WebSocket messages to
  MixerEngine control (channel volume/pan/mute/solo/hpf, bus control,
  routing, state queries)
- 15 new WebSocket message handlers in PiPedalSocket.cpp for full
  mixer control surface

Integration:
- MixerEngine member added to PiPedalModel with Get/Set accessors
- SetMixerEngine propagates to AudioHost rt processing pipeline
- Socket handler auto-wires MixerEngine to MixerApi on connect

Messages implemented:
  mixerSetChannelVolume, mixerSetChannelPan, mixerSetChannelMute,
  mixerSetChannelSolo, mixerSetChannelLabel, mixerSetChannelHpf,
  mixerGetState, mixerAddChannel, mixerRemoveChannel,
  mixerSetBusVolume, mixerSetBusMute, mixerAddBus, mixerRemoveBus,
  mixerRouteChannelToBus
This commit is contained in:
2026-06-20 14:15:37 -04:00
parent 0422c91b4e
commit 1854d03c58
6 changed files with 524 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
// Copyright (c) 2026 Ourpad Network
// See LICENSE file in the project root for full license text.
#pragma once
#include <string>
#include <memory>
#include <functional>
namespace pipedal {
class MixerEngine;
/// Mixer API — bridges WebSocket messages to the MixerEngine.
///
/// Follows the existing PiPedalSocket pattern where handlers are registered
/// via REGISTER_MESSAGE_HANDLER and dispatched by message name.
///
/// This class provides the model-level methods that the socket handlers call.
class MixerApi {
public:
MixerApi();
~MixerApi();
/// Set the mixer engine this API talks to.
void setMixerEngine(MixerEngine* engine) { mixerEngine_ = engine; }
MixerEngine* mixerEngine() const { return mixerEngine_; }
/// --- Channel Control ---
/// Set channel volume in dB (-inf to +12)
void setChannelVolume(int channelIndex, float volumeDb);
/// Set channel pan (-1.0 left to +1.0 right)
void setChannelPan(int channelIndex, float pan);
/// Set channel mute state
void setChannelMute(int channelIndex, bool mute);
/// Set channel solo state
void setChannelSolo(int channelIndex, bool solo);
/// Set channel label
void setChannelLabel(int channelIndex, const std::string& label);
/// Set channel type (Instrument, Mic, Line)
void setChannelType(int channelIndex, const std::string& type);
/// Set channel HPF state
void setChannelHpf(int channelIndex, bool enabled, float frequency);
/// --- Channel Lifecycle ---
/// Add a new channel for the given physical input
int addChannel(int physicalInputIndex);
/// Remove a channel
void removeChannel(int channelIndex);
/// --- Bus Control ---
/// Set bus volume
void setBusVolume(int64_t busId, float volumeDb);
/// Set bus mute
void setBusMute(int64_t busId, bool mute);
/// Add a new bus
int64_t addBus(const std::string& type, const std::string& name, int channels);
/// Remove a bus
void removeBus(int64_t busId);
/// --- Routing ---
/// Route a channel to a bus
void routeChannelToBus(int channelIndex, int64_t busId, float levelDb);
/// Route a bus to another bus
void routeBusToBus(int64_t sourceBusId, int64_t targetBusId, float levelDb);
/// Remove a route
void removeRoute(int64_t sourceId, int64_t targetBusId);
/// --- State Queries ---
/// Get the full mixer state as a JSON string
std::string getStateJson() const;
/// --- Scenes ---
/// Save current mixer state as a scene
std::string saveScene(const std::string& name);
/// Load a scene by name
bool loadScene(const std::string& sceneId);
/// List available scenes
std::string listScenes() const;
/// Delete a scene
bool deleteScene(const std::string& sceneId);
private:
MixerEngine* mixerEngine_ = nullptr;
};
} // namespace pipedal