адаптация s13bby/osc под vst и gui. (вайбкод)
вайбкод потому что мне в моменте стало понятно. что проще было сразу писать на фреймворке JUCE, чем адаптировать консольное приложение на MiniAudio. обновляться данный репозиторий не будет. СmakeLists адаптирован онли под linux.
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
FileLogger::FileLogger (const File& file,
|
||||
const String& welcomeMessage,
|
||||
const int64 maxInitialFileSizeBytes)
|
||||
: logFile (file)
|
||||
{
|
||||
if (maxInitialFileSizeBytes >= 0)
|
||||
trimFileSize (logFile, maxInitialFileSizeBytes);
|
||||
|
||||
if (! file.exists())
|
||||
file.create(); // (to create the parent directories)
|
||||
|
||||
String welcome;
|
||||
welcome << newLine
|
||||
<< "**********************************************************" << newLine
|
||||
<< welcomeMessage << newLine
|
||||
<< "Log started: " << Time::getCurrentTime().toString (true, true) << newLine;
|
||||
|
||||
FileLogger::logMessage (welcome);
|
||||
}
|
||||
|
||||
FileLogger::~FileLogger() {}
|
||||
|
||||
//==============================================================================
|
||||
void FileLogger::logMessage (const String& message)
|
||||
{
|
||||
const ScopedLock sl (logLock);
|
||||
DBG (message);
|
||||
FileOutputStream out (logFile, 256);
|
||||
out << message << newLine;
|
||||
}
|
||||
|
||||
void FileLogger::trimFileSize (const File& file, int64 maxFileSizeBytes)
|
||||
{
|
||||
if (maxFileSizeBytes <= 0)
|
||||
{
|
||||
file.deleteFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
const int64 fileSize = file.getSize();
|
||||
|
||||
if (fileSize > maxFileSizeBytes)
|
||||
{
|
||||
TemporaryFile tempFile (file);
|
||||
|
||||
{
|
||||
FileOutputStream out (tempFile.getFile());
|
||||
FileInputStream in (file);
|
||||
|
||||
if (! (out.openedOk() && in.openedOk()))
|
||||
return;
|
||||
|
||||
in.setPosition (fileSize - maxFileSizeBytes);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const char c = in.readByte();
|
||||
if (c == 0)
|
||||
return;
|
||||
|
||||
if (c == '\n' || c == '\r')
|
||||
{
|
||||
out << c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out.writeFromInputStream (in, -1);
|
||||
}
|
||||
|
||||
tempFile.overwriteTargetFileWithTemporary();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
File FileLogger::getSystemLogFileFolder()
|
||||
{
|
||||
#if JUCE_MAC
|
||||
return File ("~/Library/Logs");
|
||||
#else
|
||||
return File::getSpecialLocation (File::userApplicationDataDirectory);
|
||||
#endif
|
||||
}
|
||||
|
||||
FileLogger* FileLogger::createDefaultAppLogger (const String& logFileSubDirectoryName,
|
||||
const String& logFileName,
|
||||
const String& welcomeMessage,
|
||||
const int64 maxInitialFileSizeBytes)
|
||||
{
|
||||
return new FileLogger (getSystemLogFileFolder().getChildFile (logFileSubDirectoryName)
|
||||
.getChildFile (logFileName),
|
||||
welcomeMessage, maxInitialFileSizeBytes);
|
||||
}
|
||||
|
||||
FileLogger* FileLogger::createDateStampedLogger (const String& logFileSubDirectoryName,
|
||||
const String& logFileNameRoot,
|
||||
const String& logFileNameSuffix,
|
||||
const String& welcomeMessage)
|
||||
{
|
||||
return new FileLogger (getSystemLogFileFolder().getChildFile (logFileSubDirectoryName)
|
||||
.getChildFile (logFileNameRoot + Time::getCurrentTime().formatted ("%Y-%m-%d_%H-%M-%S"))
|
||||
.withFileExtension (logFileNameSuffix)
|
||||
.getNonexistentSibling(),
|
||||
welcomeMessage, 0);
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A simple implementation of a Logger that writes to a file.
|
||||
|
||||
@see Logger
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
class JUCE_API FileLogger : public Logger
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates a FileLogger for a given file.
|
||||
|
||||
@param fileToWriteTo the file that to use - new messages will be appended
|
||||
to the file. If the file doesn't exist, it will be created,
|
||||
along with any parent directories that are needed.
|
||||
@param welcomeMessage when opened, the logger will write a header to the log, along
|
||||
with the current date and time, and this welcome message
|
||||
@param maxInitialFileSizeBytes if this is zero or greater, then if the file already exists
|
||||
but is larger than this number of bytes, then the start of the
|
||||
file will be truncated to keep the size down. This prevents a log
|
||||
file getting ridiculously large over time. The file will be truncated
|
||||
at a new-line boundary. If this value is less than zero, no size limit
|
||||
will be imposed; if it's zero, the file will always be deleted. Note that
|
||||
the size is only checked once when this object is created - any logging
|
||||
that is done later will be appended without any checking
|
||||
*/
|
||||
FileLogger (const File& fileToWriteTo,
|
||||
const String& welcomeMessage,
|
||||
const int64 maxInitialFileSizeBytes = 128 * 1024);
|
||||
|
||||
/** Destructor. */
|
||||
~FileLogger() override;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the file that this logger is writing to. */
|
||||
const File& getLogFile() const noexcept { return logFile; }
|
||||
|
||||
//==============================================================================
|
||||
/** Helper function to create a log file in the correct place for this platform.
|
||||
|
||||
The method might return nullptr if the file can't be created for some reason.
|
||||
|
||||
@param logFileSubDirectoryName the name of the subdirectory to create inside the logs folder (as
|
||||
returned by getSystemLogFileFolder). It's best to use something
|
||||
like the name of your application here.
|
||||
@param logFileName the name of the file to create, e.g. "MyAppLog.txt".
|
||||
@param welcomeMessage a message that will be written to the log when it's opened.
|
||||
@param maxInitialFileSizeBytes (see the FileLogger constructor for more info on this)
|
||||
*/
|
||||
static FileLogger* createDefaultAppLogger (const String& logFileSubDirectoryName,
|
||||
const String& logFileName,
|
||||
const String& welcomeMessage,
|
||||
const int64 maxInitialFileSizeBytes = 128 * 1024);
|
||||
|
||||
/** Helper function to create a log file in the correct place for this platform.
|
||||
|
||||
The filename used is based on the root and suffix strings provided, along with a
|
||||
time and date string, meaning that a new, empty log file will be always be created
|
||||
rather than appending to an existing one.
|
||||
|
||||
The method might return nullptr if the file can't be created for some reason.
|
||||
|
||||
@param logFileSubDirectoryName the name of the subdirectory to create inside the logs folder (as
|
||||
returned by getSystemLogFileFolder). It's best to use something
|
||||
like the name of your application here.
|
||||
@param logFileNameRoot the start of the filename to use, e.g. "MyAppLog_". This will have
|
||||
a timestamp and the logFileNameSuffix appended to it
|
||||
@param logFileNameSuffix the file suffix to use, e.g. ".txt"
|
||||
@param welcomeMessage a message that will be written to the log when it's opened.
|
||||
*/
|
||||
static FileLogger* createDateStampedLogger (const String& logFileSubDirectoryName,
|
||||
const String& logFileNameRoot,
|
||||
const String& logFileNameSuffix,
|
||||
const String& welcomeMessage);
|
||||
|
||||
//==============================================================================
|
||||
/** Returns an OS-specific folder where log-files should be stored.
|
||||
|
||||
On Windows this will return a logger with a path such as:
|
||||
c:\\Documents and Settings\\username\\Application Data\\[logFileSubDirectoryName]\\[logFileName]
|
||||
|
||||
On the Mac it'll create something like:
|
||||
~/Library/Logs/[logFileSubDirectoryName]/[logFileName]
|
||||
|
||||
@see createDefaultAppLogger
|
||||
*/
|
||||
static File getSystemLogFileFolder();
|
||||
|
||||
// (implementation of the Logger virtual method)
|
||||
void logMessage (const String&) override;
|
||||
|
||||
//==============================================================================
|
||||
/** This is a utility function which removes lines from the start of a text
|
||||
file to make sure that its total size is below the given size.
|
||||
*/
|
||||
static void trimFileSize (const File& file, int64 maxFileSize);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
File logFile;
|
||||
CriticalSection logLock;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileLogger)
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Logger::Logger() {}
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
// You're deleting this logger while it's still being used!
|
||||
// Always call Logger::setCurrentLogger (nullptr) before deleting the active logger.
|
||||
jassert (currentLogger != this);
|
||||
}
|
||||
|
||||
Logger* Logger::currentLogger = nullptr;
|
||||
|
||||
void Logger::setCurrentLogger (Logger* const newLogger) noexcept { currentLogger = newLogger; }
|
||||
Logger* Logger::getCurrentLogger() noexcept { return currentLogger; }
|
||||
|
||||
void Logger::writeToLog (const String& message)
|
||||
{
|
||||
if (currentLogger != nullptr)
|
||||
currentLogger->logMessage (message);
|
||||
else
|
||||
outputDebugString (message);
|
||||
}
|
||||
|
||||
#if JUCE_LOG_ASSERTIONS || JUCE_DEBUG
|
||||
void JUCE_API JUCE_CALLTYPE logAssertion (const char* const filename, const int lineNum) noexcept
|
||||
{
|
||||
String m ("JUCE Assertion failure in ");
|
||||
m << File::createFileWithoutCheckingPath (CharPointer_UTF8 (filename)).getFileName() << ':' << lineNum;
|
||||
|
||||
#if JUCE_LOG_ASSERTIONS
|
||||
Logger::writeToLog (m);
|
||||
#else
|
||||
DBG (m);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Acts as an application-wide logging class.
|
||||
|
||||
A subclass of Logger can be created and passed into the Logger::setCurrentLogger
|
||||
method and this will then be used by all calls to writeToLog.
|
||||
|
||||
The logger class also contains methods for writing messages to the debugger's
|
||||
output stream.
|
||||
|
||||
@see FileLogger
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
class JUCE_API Logger
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Destructor. */
|
||||
virtual ~Logger();
|
||||
|
||||
//==============================================================================
|
||||
/** Sets the current logging class to use.
|
||||
|
||||
Note that the object passed in will not be owned or deleted by the logger, so
|
||||
the caller must make sure that it is not deleted while still being used.
|
||||
A null pointer can be passed-in to reset the system to the default logger.
|
||||
*/
|
||||
static void JUCE_CALLTYPE setCurrentLogger (Logger* newLogger) noexcept;
|
||||
|
||||
/** Returns the current logger, or nullptr if no custom logger has been set. */
|
||||
static Logger* JUCE_CALLTYPE getCurrentLogger() noexcept;
|
||||
|
||||
/** Writes a string to the current logger.
|
||||
|
||||
This will pass the string to the logger's logMessage() method if a logger
|
||||
has been set.
|
||||
|
||||
@see logMessage
|
||||
*/
|
||||
static void JUCE_CALLTYPE writeToLog (const String& message);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** Writes a message to the standard error stream.
|
||||
|
||||
This can be called directly, or by using the DBG() macro in
|
||||
juce_PlatformDefs.h (which will avoid calling the method in non-debug builds).
|
||||
*/
|
||||
static void JUCE_CALLTYPE outputDebugString (const String& text);
|
||||
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
Logger();
|
||||
|
||||
/** This is overloaded by subclasses to implement custom logging behaviour.
|
||||
@see setCurrentLogger
|
||||
*/
|
||||
virtual void logMessage (const String& message) = 0;
|
||||
|
||||
private:
|
||||
static Logger* currentLogger;
|
||||
};
|
||||
|
||||
} // namespace juce
|
||||
Reference in New Issue
Block a user