Skip to content

Instantly share code, notes, and snippets.

namespace sst::osc_adapter
{
struct OSCAdapter
{
OSCAdapter(const clap_plugin *p); // bind to this plugin
const clap_input_events *getInputEventQueue() { return eventList.clapInputEvents(); }
clap_output_events *getOutputEventQueue(); // auto thread event queue
void startWith(uint32_t inputPort, uint32_t outputPort)
{
/*
The C++ standard library random stuff can be a bit bonkers(*) at times,
so we have this custom class which has a decent enough random base generator
and some simple methods for getting values out as floats etc...
(*) See for example the Microsoft implementation of std::uniform_int_distribution...
Or the Cauchy distribution, which won't allow a scale factor of 0 to be used, while
useful for our audio/music applications as a special case.
*/
inline juce::String renderFile(juce::File inputFile, juce::File outputFile)
{
if (!outputFile.hasFileExtension(("wav")))
return "output file must be .wav";
juce::AudioFormatManager fman;
fman.registerBasicFormats();
auto reader = std::unique_ptr<juce::AudioFormatReader>(fman.createReaderFor(inputFile));
if (reader == nullptr)
return "could not create input file reader";
juce::WavAudioFormat wavformat;
/*
If we were dealing with plain old MIDI, tracking active notes could be
done with something as simple as : bool activeNotes[16][128];
Clap however complicates this as we want to also take into account the
note ports and note ids.
Theoretically we could use std::unordered_set<PCKI> or something
for this but then we couldn't control the number of buckets,
memory allocations etc.
#pragma once
#include "libMTSClient.h"
#include <cmath>
namespace mtsesp_wrapper
{
class MIDIKeyTuner
{
public:
#define WIN32_LEAN_AND_MEAN
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <memory>
#include <iostream>
#include <format>
#include "offlineclaphost.h"
#include "oscpkt.hh"
#include "udp.hh"
bool implementsGui() const noexcept override { return true; }
bool guiIsApiSupported(const char *api, bool isFloating) noexcept override
{
if (strcmp(api, "win32") == 0)
return true;
return false;
}
bool guiCreate(const char *api, bool isFloating) noexcept override
{
Shortcircuit XT.clap!common_assert_to_message_box<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 388 (c:\develop\shortcircuit-xt\build\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:388)
Shortcircuit XT.clap!common_assert<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 424 (c:\develop\shortcircuit-xt\build\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:424)
Shortcircuit XT.clap!_wassert(const wchar_t * expression, const wchar_t * file_name, unsigned int line_number) Line 444 (c:\develop\shortcircuit-xt\build\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:444)
Shortcircuit XT.clap!scxt::SampleRateSupport::assertSampleRateSet() Line 198 (c:\develop\shortcircuit-xt\src\utils.h:198)
Shortcircuit XT.clap!scxt::engine::Group::processWithOS<1>(scxt::engine::Engine & e) Line 72 (c:\develop\shortcircuit-xt\src\engine\group.
void handleNextEvent(const clap_event_header_t *nextEvent, bool is_from_ui)
{
if (nextEvent->space_id != CLAP_CORE_EVENT_SPACE_ID)
return;
switch (nextEvent->type)
{
case CLAP_EVENT_NOTE_OFF:
case CLAP_EVENT_NOTE_CHOKE:
{
FixedMatrix<Config> m;
FixedMatrix<Config>::RoutingTable rt;
auto source0 = Config::SourceIdentifier{Config::SourceIdentifier::SI::LFO1};
auto source1 = Config::SourceIdentifier{Config::SourceIdentifier::SI::LFO2};
auto source2 = Config::SourceIdentifier{Config::SourceIdentifier::SI::LFO3};
auto source3 = Config::SourceIdentifier{Config::SourceIdentifier::SI::LFO4};
auto source4 = Config::SourceIdentifier{Config::SourceIdentifier::SI::BKENV1};
auto target0 = Config::TargetIdentifier{0};
auto target1 = Config::TargetIdentifier{1};