адаптация s13bby/osc под vst и gui. (вайбкод)
вайбкод потому что мне в моменте стало понятно. что проще было сразу писать на фреймворке JUCE, чем адаптировать консольное приложение на MiniAudio. обновляться данный репозиторий не будет. СmakeLists адаптирован онли под linux.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
template <typename... Ts>
|
||||
constexpr bool isValueOrLvalueReferenceToConst()
|
||||
{
|
||||
return (( (! std::is_reference_v<Ts>)
|
||||
|| (std::is_lvalue_reference_v<Ts> && std::is_const_v<std::remove_reference_t<Ts>>)) && ...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
class CallbackListenerList
|
||||
{
|
||||
public:
|
||||
static_assert (isValueOrLvalueReferenceToConst<Args...>(),
|
||||
"CallbackListenerList can only forward values or const lvalue references");
|
||||
|
||||
using Callback = std::function<void (Args...)>;
|
||||
|
||||
ErasedScopeGuard addListener (Callback callback)
|
||||
{
|
||||
jassert (callback != nullptr);
|
||||
|
||||
const auto it = callbacks.insert (callbacks.end(), std::move (callback));
|
||||
listeners.add (&*it);
|
||||
|
||||
return ErasedScopeGuard { [this, it]
|
||||
{
|
||||
listeners.remove (&*it);
|
||||
callbacks.erase (it);
|
||||
} };
|
||||
}
|
||||
|
||||
void call (Args... args)
|
||||
{
|
||||
listeners.call ([&] (auto& l) { l (std::forward<Args> (args)...); });
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<Callback> callbacks;
|
||||
LightweightListenerList<Callback> listeners;
|
||||
};
|
||||
|
||||
} // namespace juce::detail
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
/** @cond */
|
||||
namespace juce
|
||||
{
|
||||
|
||||
template <auto* Fn>
|
||||
struct FunctionPointerDestructor
|
||||
{
|
||||
template <typename Ptr>
|
||||
void operator() (Ptr* ptr) const
|
||||
{
|
||||
if (ptr != nullptr)
|
||||
Fn (ptr);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
/** @endcond */
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
/** @internal */
|
||||
enum class IncrementRef
|
||||
{
|
||||
no,
|
||||
yes
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
/** @cond */
|
||||
namespace juce
|
||||
{
|
||||
|
||||
template <typename Key, typename Value, size_t maxEntries = 128>
|
||||
class LruCache
|
||||
{
|
||||
public:
|
||||
template <typename Fn>
|
||||
const Value& get (Key key, Fn&& fn)
|
||||
{
|
||||
std::unique_lock lock { *mutex };
|
||||
|
||||
if (const auto iter = map.find (key); iter != map.end())
|
||||
{
|
||||
list.erase (iter->second.listIterator);
|
||||
iter->second.listIterator = list.insert (list.end(), iter);
|
||||
return iter->second.value;
|
||||
}
|
||||
|
||||
const auto localInsertionCounter = insertionCounter;
|
||||
|
||||
// There are two reasons we don't want to have the mutex locked while
|
||||
// getting the value
|
||||
// 1. If the operation itself results in a call to the same cache it
|
||||
// would cause a deadlock.
|
||||
// 2. The generation of the value is likely to be slow therefore we
|
||||
// don't want to force other threads to wait on this operation
|
||||
lock.unlock();
|
||||
auto value = fn (key);
|
||||
lock.lock();
|
||||
|
||||
// While the mutex was unlocked the value may have already been added to
|
||||
// the cache. In this case we can skip placing the value at the front as
|
||||
// it should've already recently been placed at the front. However, we
|
||||
// still need to skip adding the value to the cache for a second time.
|
||||
if (localInsertionCounter != insertionCounter)
|
||||
if (const auto iter = map.find (key); iter != map.end())
|
||||
return iter->second.value;
|
||||
|
||||
++insertionCounter;
|
||||
|
||||
while (map.size() >= maxEntries)
|
||||
{
|
||||
const auto toRemove = list.begin();
|
||||
map.erase (*toRemove);
|
||||
list.erase (toRemove);
|
||||
}
|
||||
|
||||
const auto mapIteratorPair = map.emplace (std::move (key), Pair { std::move (value), {} });
|
||||
|
||||
jassert (mapIteratorPair.second);
|
||||
|
||||
mapIteratorPair.first->second.listIterator = list.insert (list.end(), mapIteratorPair.first);
|
||||
return mapIteratorPair.first->second.value;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
const std::scoped_lock lock { *mutex };
|
||||
list.clear();
|
||||
map.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
struct Pair
|
||||
{
|
||||
using Map = std::map<Key, Pair>;
|
||||
using MapIterator = typename Map::const_iterator;
|
||||
using List = std::list<MapIterator>;
|
||||
using ListIterator = typename List::const_iterator;
|
||||
|
||||
Value value;
|
||||
ListIterator listIterator;
|
||||
};
|
||||
|
||||
typename Pair::Map map;
|
||||
typename Pair::List list;
|
||||
uint32_t insertionCounter{};
|
||||
std::unique_ptr<std::mutex> mutex = std::make_unique<std::mutex>();
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
/** @endcond */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
#if JUCE_WINDOWS
|
||||
using NativeFileHandle = void*;
|
||||
#else
|
||||
class NativeFileHandle
|
||||
{
|
||||
static constexpr int invalidFd = -1;
|
||||
|
||||
public:
|
||||
int get() const noexcept { return fd; }
|
||||
bool isValid() const noexcept { return 0 <= fd; }
|
||||
|
||||
void set (int newFd) noexcept { fd = newFd; }
|
||||
void invalidate() noexcept { fd = invalidFd; }
|
||||
|
||||
private:
|
||||
int fd = invalidFd;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace juce::detail
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-9-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce::detail
|
||||
{
|
||||
|
||||
template <typename Invokable, std::enable_if_t<std::is_same_v<std::invoke_result_t<Invokable&>, void>, int> = 0>
|
||||
ThreadPoolJob::JobStatus runThreadPoolLambdaJob (Invokable& job)
|
||||
{
|
||||
job();
|
||||
return ThreadPoolJob::jobHasFinished;
|
||||
}
|
||||
|
||||
template <typename Invokable, std::enable_if_t<std::is_same_v<std::invoke_result_t<Invokable&>, ThreadPoolJob::JobStatus>, int> = 0>
|
||||
ThreadPoolJob::JobStatus runThreadPoolLambdaJob (Invokable& job)
|
||||
{
|
||||
return job();
|
||||
}
|
||||
|
||||
template <typename, typename = void>
|
||||
constexpr auto canRunThreadPoolLambdaJob = false;
|
||||
|
||||
template <typename Invokable>
|
||||
constexpr auto canRunThreadPoolLambdaJob<Invokable, Void<decltype (runThreadPoolLambdaJob (std::declval<Invokable&>()))>> = true;
|
||||
|
||||
template <typename Invokable>
|
||||
struct ThreadPoolLambdaJob final : public ThreadPoolJob
|
||||
{
|
||||
explicit ThreadPoolLambdaJob (Invokable&& jobToRun)
|
||||
: ThreadPoolJob ("lambda"), job (std::move (jobToRun)) {}
|
||||
|
||||
JobStatus runJob() final
|
||||
{
|
||||
return runThreadPoolLambdaJob (job);
|
||||
}
|
||||
|
||||
Invokable job;
|
||||
};
|
||||
|
||||
} // namespace juce::detail
|
||||
Reference in New Issue
Block a user