Remove header dependency Parser from Synth
This commit is contained in:
parent
8551caebf6
commit
41ab126549
12 changed files with 71 additions and 18 deletions
|
|
@ -202,6 +202,7 @@ set(SFIZZ_PARSER_HEADERS
|
||||||
sfizz/Range.h
|
sfizz/Range.h
|
||||||
sfizz/Opcode.h
|
sfizz/Opcode.h
|
||||||
sfizz/parser/Parser.h
|
sfizz/parser/Parser.h
|
||||||
|
sfizz/parser/ParserListener.h
|
||||||
sfizz/parser/ParserPrivate.h
|
sfizz/parser/ParserPrivate.h
|
||||||
sfizz/parser/ParserPrivate.hpp
|
sfizz/parser/ParserPrivate.hpp
|
||||||
sfizz/SfzHelpers.h)
|
sfizz/SfzHelpers.h)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include "utility/XmlHelpers.h"
|
#include "utility/XmlHelpers.h"
|
||||||
#include "Voice.h"
|
#include "Voice.h"
|
||||||
#include "Interpolators.h"
|
#include "Interpolators.h"
|
||||||
|
#include "parser/Parser.h"
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include <absl/memory/memory.h>
|
#include <absl/memory/memory.h>
|
||||||
#include <absl/strings/str_replace.h>
|
#include <absl/strings/str_replace.h>
|
||||||
|
|
@ -1996,6 +1997,18 @@ void Synth::allSoundOff() noexcept
|
||||||
effectBus->clear();
|
effectBus->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Synth::addExternalDefinition(const std::string& id, const std::string& value)
|
||||||
|
{
|
||||||
|
Impl& impl = *impl_;
|
||||||
|
impl.parser_.addExternalDefinition(id, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Synth::clearExternalDefinitions()
|
||||||
|
{
|
||||||
|
Impl& impl = *impl_;
|
||||||
|
impl.parser_.clearExternalDefinitions();
|
||||||
|
}
|
||||||
|
|
||||||
const BitArray<config::numCCs>& Synth::getUsedCCs() const noexcept
|
const BitArray<config::numCCs>& Synth::getUsedCCs() const noexcept
|
||||||
{
|
{
|
||||||
Impl& impl = *impl_;
|
Impl& impl = *impl_;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include "Messaging.h"
|
#include "Messaging.h"
|
||||||
#include "utility/NumericId.h"
|
#include "utility/NumericId.h"
|
||||||
#include "utility/LeakDetector.h"
|
#include "utility/LeakDetector.h"
|
||||||
#include "parser/Parser.h"
|
|
||||||
#include <ghc/fs_std.hpp>
|
#include <ghc/fs_std.hpp>
|
||||||
#include <absl/strings/string_view.h>
|
#include <absl/strings/string_view.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -22,6 +21,7 @@ template <size_t> class BitArray;
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
|
|
||||||
// Forward declarations for the introspection methods
|
// Forward declarations for the introspection methods
|
||||||
|
class Parser;
|
||||||
class RegionSet;
|
class RegionSet;
|
||||||
class PolyphonyGroup;
|
class PolyphonyGroup;
|
||||||
class EffectBus;
|
class EffectBus;
|
||||||
|
|
@ -29,6 +29,9 @@ struct Region;
|
||||||
struct Layer;
|
struct Layer;
|
||||||
class Voice;
|
class Voice;
|
||||||
|
|
||||||
|
using CCNamePair = std::pair<uint16_t, std::string>;
|
||||||
|
using NoteNamePair = std::pair<uint8_t, std::string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class is the core of the sfizz library. In C++ it is the main point
|
* @brief This class is the core of the sfizz library. In C++ it is the main point
|
||||||
* of entry and in C the interface basically maps the functions of the class into
|
* of entry and in C the interface basically maps the functions of the class into
|
||||||
|
|
@ -642,6 +645,18 @@ public:
|
||||||
*/
|
*/
|
||||||
void allSoundOff() noexcept;
|
void allSoundOff() noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add external definitions prior to loading.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void addExternalDefinition(const std::string& id, const std::string& value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clears external definitions for the next file loading.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void clearExternalDefinitions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the parser.
|
* @brief Get the parser.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
#include "modulations/sources/ChannelAftertouch.h"
|
#include "modulations/sources/ChannelAftertouch.h"
|
||||||
#include "modulations/sources/PolyAftertouch.h"
|
#include "modulations/sources/PolyAftertouch.h"
|
||||||
#include "modulations/sources/LFO.h"
|
#include "modulations/sources/LFO.h"
|
||||||
|
#include "parser/Parser.h"
|
||||||
|
#include "parser/ParserListener.h"
|
||||||
|
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
|
#include "ParserListener.h"
|
||||||
#include "ParserPrivate.h"
|
#include "ParserPrivate.h"
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
|
|
||||||
class Reader;
|
class Reader;
|
||||||
|
class ParserListener;
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
struct SourceRange;
|
struct SourceRange;
|
||||||
|
|
||||||
|
|
@ -50,19 +51,7 @@ public:
|
||||||
size_t getErrorCount() const noexcept { return _errorCount; }
|
size_t getErrorCount() const noexcept { return _errorCount; }
|
||||||
size_t getWarningCount() const noexcept { return _warningCount; }
|
size_t getWarningCount() const noexcept { return _warningCount; }
|
||||||
|
|
||||||
class Listener {
|
using Listener = ParserListener;
|
||||||
public:
|
|
||||||
// low-level parsing
|
|
||||||
virtual void onParseBegin() {}
|
|
||||||
virtual void onParseEnd() {}
|
|
||||||
virtual void onParseHeader(const SourceRange& /*range*/, const std::string& /*header*/) {}
|
|
||||||
virtual void onParseOpcode(const SourceRange& /*rangeOpcode*/, const SourceRange& /*rangeValue*/, const std::string& /*name*/, const std::string& /*value*/) {}
|
|
||||||
virtual void onParseError(const SourceRange& /*range*/, const std::string& /*message*/) {}
|
|
||||||
virtual void onParseWarning(const SourceRange& /*range*/, const std::string& /*message*/) {}
|
|
||||||
|
|
||||||
// high-level parsing
|
|
||||||
virtual void onParseFullBlock(const std::string& /*header*/, const std::vector<Opcode>& /*opcodes*/) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
void setListener(Listener* listener) noexcept { _listener = listener; }
|
void setListener(Listener* listener) noexcept { _listener = listener; }
|
||||||
|
|
||||||
|
|
|
||||||
29
src/sfizz/parser/ParserListener.h
Normal file
29
src/sfizz/parser/ParserListener.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
|
// This code is part of the sfizz library and is licensed under a BSD 2-clause
|
||||||
|
// license. You should have receive a LICENSE.md file along with the code.
|
||||||
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sfz {
|
||||||
|
struct SourceRange;
|
||||||
|
struct Opcode;
|
||||||
|
|
||||||
|
class ParserListener {
|
||||||
|
public:
|
||||||
|
// low-level parsing
|
||||||
|
virtual void onParseBegin() {}
|
||||||
|
virtual void onParseEnd() {}
|
||||||
|
virtual void onParseHeader(const SourceRange& /*range*/, const std::string& /*header*/) {}
|
||||||
|
virtual void onParseOpcode(const SourceRange& /*rangeOpcode*/, const SourceRange& /*rangeValue*/, const std::string& /*name*/, const std::string& /*value*/) {}
|
||||||
|
virtual void onParseError(const SourceRange& /*range*/, const std::string& /*message*/) {}
|
||||||
|
virtual void onParseWarning(const SourceRange& /*range*/, const std::string& /*message*/) {}
|
||||||
|
|
||||||
|
// high-level parsing
|
||||||
|
virtual void onParseFullBlock(const std::string& /*header*/, const std::vector<Opcode>& /*opcodes*/) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sfz
|
||||||
|
|
@ -353,12 +353,12 @@ void sfz::Sfizz::allSoundOff() noexcept
|
||||||
|
|
||||||
void sfz::Sfizz::addExternalDefinition(const std::string& id, const std::string& value)
|
void sfz::Sfizz::addExternalDefinition(const std::string& id, const std::string& value)
|
||||||
{
|
{
|
||||||
synth->synth.getParser().addExternalDefinition(id, value);
|
synth->synth.addExternalDefinition(id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::Sfizz::clearExternalDefinitions()
|
void sfz::Sfizz::clearExternalDefinitions()
|
||||||
{
|
{
|
||||||
synth->synth.getParser().clearExternalDefinitions();
|
synth->synth.clearExternalDefinitions();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sfz::Sfizz::exportMidnam(const std::string& model) const
|
std::string sfz::Sfizz::exportMidnam(const std::string& model) const
|
||||||
|
|
|
||||||
|
|
@ -335,12 +335,12 @@ void sfizz_all_sound_off(sfizz_synth_t* synth)
|
||||||
|
|
||||||
void sfizz_add_external_definitions(sfizz_synth_t* synth, const char* id, const char* value)
|
void sfizz_add_external_definitions(sfizz_synth_t* synth, const char* id, const char* value)
|
||||||
{
|
{
|
||||||
synth->synth.getParser().addExternalDefinition(id, value);
|
synth->synth.addExternalDefinition(id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfizz_clear_external_definitions(sfizz_synth_t* synth)
|
void sfizz_clear_external_definitions(sfizz_synth_t* synth)
|
||||||
{
|
{
|
||||||
synth->synth.getParser().clearExternalDefinitions();
|
synth->synth.clearExternalDefinitions();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int sfizz_get_num_key_labels(sfizz_synth_t* synth)
|
unsigned int sfizz_get_num_key_labels(sfizz_synth_t* synth)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "sfizz/Synth.h"
|
#include "sfizz/Synth.h"
|
||||||
#include "sfizz/Voice.h"
|
#include "sfizz/Voice.h"
|
||||||
#include "sfizz/SfzHelpers.h"
|
#include "sfizz/SfzHelpers.h"
|
||||||
|
#include "sfizz/parser/Parser.h"
|
||||||
#include "sfizz/modulations/ModId.h"
|
#include "sfizz/modulations/ModId.h"
|
||||||
#include "sfizz/modulations/ModKey.h"
|
#include "sfizz/modulations/ModKey.h"
|
||||||
#include "catch2/catch.hpp"
|
#include "catch2/catch.hpp"
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "sfizz/SfzHelpers.h"
|
#include "sfizz/SfzHelpers.h"
|
||||||
#include "sfizz/parser/Parser.h"
|
#include "sfizz/parser/Parser.h"
|
||||||
|
#include "sfizz/parser/ParserListener.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "catch2/catch.hpp"
|
#include "catch2/catch.hpp"
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "TestHelpers.h"
|
#include "TestHelpers.h"
|
||||||
#include "sfizz/modulations/ModId.h"
|
#include "sfizz/modulations/ModId.h"
|
||||||
|
#include <absl/strings/str_cat.h>
|
||||||
|
|
||||||
size_t RegionCCView::size() const
|
size_t RegionCCView::size() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue