id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,532,410
|
pluginaction.cpp
|
canorusmusic_canorus/src/interface/pluginaction.cpp
|
/*!
Copyright (c) 2007-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#include "interface/pluginaction.h"
#ifndef SWIGCPP
#include "ui/mainwin.h"
#endif
/*!
\class CAPluginAction
CAPluginAction class represents each <action> stanza found in Canorus Plugin descriptor XML file.
Every action has its unique name, scripting language, function, its arguments and filename.
Other attributes are Canorus internal action which it reacts on, export filter, menu/toolbar text.
*/
/*!
Default constructor.
*/
CAPluginAction::CAPluginAction(CAPlugin* plugin, QString name, QString lang, QString function, QList<QString> args, QString filename)
: QAction(nullptr)
{
_plugin = plugin;
_name = name;
_lang = lang;
_function = function;
_filename = filename;
_args = args;
connect(this, SIGNAL(triggered(bool)), this, SLOT(triggeredSlot(bool)));
}
/*!
This method and the class itself exists mainly because you can't connect signal actionMyAction_triggered()
and others than connecting them with slots. And to do that, you need a Q_OBJECT class with pre-set
function slots. This function is a pretty elegant solution to connect plugin's reactions to internal
Canorus GUI signals.
*/
void CAPluginAction::triggeredSlot(bool)
{
#ifndef SWIGCPP
QObject* curObject = this;
while (dynamic_cast<CAMainWin*>(curObject) == nullptr && curObject != nullptr) // find the parent which is mainwindow
curObject = curObject->parent();
_plugin->callAction(this, static_cast<CAMainWin*>(curObject), static_cast<CAMainWin*>(curObject)->document(), nullptr, nullptr);
#endif
}
| 1,755
|
C++
|
.cpp
| 44
| 37.272727
| 133
| 0.762324
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,411
|
swigruby.cpp
|
canorusmusic_canorus/src/scripting/swigruby.cpp
|
/*!
Copyright (c) 2006-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifdef USE_RUBY
#ifndef SWIGCPP
#include "canorus.h"
#endif
#include "scripting/swigruby.h"
#include <QDir>
#include <QFile>
/// Load 'CanorusRuby' module and initialize classes - defined in SWIG wrapper class
extern "C" void Init_CanorusRuby();
void CASwigRuby::init()
{
ruby_init();
Init_CanorusRuby();
// add path to scripts to Scripting path
if (QDir::searchPaths("scripts").size())
rb_eval_string((QString("$: << '") + QDir::searchPaths("scripts")[0] + "'").toStdString().c_str());
// add path to CanorusRuby module to Scripting path
#ifdef Q_OS_WIN
if (QFileInfo("base:CanorusRuby.dll").exists())
rb_eval_string((QString("$: << '") + QFileInfo("base:CanorusRuby.dll").absolutePath() + "'").toStdString().c_str());
#else
if (QFileInfo("base:CanorusRuby.so").exists())
rb_eval_string((QString("$: << '") + QFileInfo("base:CanorusRuby.so").absolutePath() + "'").toStdString().c_str());
#endif
}
VALUE CASwigRuby::callFunction(QString fileName, QString function, QList<VALUE> args)
{
if (!QFile::exists(fileName))
return 0;
// require module (loads a method)
rb_require(QDir::toNativeSeparators(fileName).toStdString().c_str());
// call function
VALUE recv = 0;
VALUE argsArray[args.size()];
for (int i = 0; i < args.size(); i++)
argsArray[i] = args[i];
return rb_funcall2(recv, rb_intern(function.toStdString().c_str()), args.size(), argsArray);
}
#endif
| 1,689
|
C++
|
.cpp
| 44
| 34.659091
| 124
| 0.678287
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,412
|
swigpython.cpp
|
canorusmusic_canorus/src/scripting/swigpython.cpp
|
/*!
Copyright (c) 2006-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifdef USE_PYTHON
#include "scripting/swigpython.h"
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QThread>
#ifndef SWIGCPP
#include "canorus.h"
#endif
#include <iostream> // used for reporting errors in scripts
using namespace std;
//#include <pthread.h>
class CAPyconsoleThread : public QThread {
protected:
void run() { CASwigPython::callPycli(nullptr); }
};
PyThreadState* CASwigPython::mainThreadState;
PyThreadState* CASwigPython::pycliThreadState;
/// Load 'CanorusPython' module and initialize classes - defined in SWIG wrapper class
extern "C" void PyInit__CanorusPython();
/*!
Initializes Python and loads base 'CanorusPython' module. Call this before any other
Python operations! Call this before calling toPythonObject() or any other conversation
functions as well!
*/
void CASwigPython::init()
{
Py_Initialize();
PyEval_InitThreads(); // our python will use GIL
PyInit__CanorusPython();
PyRun_SimpleString("import sys");
// add path to scripts to Scripting path
if (QDir::searchPaths("scripts").size()) {
PyRun_SimpleString((QString("sys.path.append('") + QDir::searchPaths("scripts")[0] + "')").toStdString().c_str());
} else {
std::cerr << "Error: scripts/ not found" << std::endl;
}
// add path to CanorusPython modules to Scripting path
if (QFileInfo("base:CanorusPython.py").exists()) {
PyRun_SimpleString((QString("sys.path.append('") + QFileInfo("base:CanorusPython.py").absolutePath() + "')").toStdString().c_str());
}
#ifdef Q_OS_WIN
if (QFileInfo("base:_CanorusPython.dll").exists()) {
PyRun_SimpleString((QString("sys.path.append('") + QFileInfo("base:_CanorusPython.dll").absolutePath() + "')").toStdString().c_str());
} else {
std::cerr << "Error: _CanorusPython.dll not found" << std::endl;
}
if (QDir("base:pythonLib").exists()) {
PyRun_SimpleString((QString("sys.path.append('") + QDir("base:pythonLib").absolutePath() + "')").toStdString().c_str());
} else {
std::cerr << "Error: pythonLib/ not found" << std::endl;
}
#else
if (QFileInfo("base:_CanorusPython.so").exists()) {
PyRun_SimpleString((QString("sys.path.append('") + QFileInfo("base:_CanorusPython.so").absolutePath() + "')").toStdString().c_str());
} else {
std::cerr << "Error: _CanorusPython.so not found" << std::endl;
}
#endif
// Load proxy classes.
PyRun_SimpleString("import CanorusPython");
mainThreadState = PyThreadState_Get();
PyEval_ReleaseThread(mainThreadState);
// my section with thread initialization
PyEval_RestoreThread(mainThreadState);
PyInterpreterState* mainInterpreterState = mainThreadState->interp;
pycliThreadState = PyThreadState_New(mainInterpreterState);
PyThreadState_Swap(mainThreadState);
PyEval_ReleaseThread(mainThreadState);
}
/*!
Calls an external Python function in the given module with the list of arguments and return the Python object the function returned.
\param fileName Absolute path to the filename of the script
\param function Function or method name.
\param args List of arguments in Python's PyObject pointer format. Use toPythonObject() to convert C++ classes to Python objects.
\param autoReload automatically reload module if it was imported before, defaults to false
\warning You have to add path of the plugin to Python path before, manually! This is usually done by CAPlugin::callAction("onInit").
*/
//pthread_t *tid=nullptr;
QThread* qtid = nullptr;
QString thr_fileName;
QString thr_function;
QList<PyObject*> thr_args;
PyObject* CASwigPython::callFunction(QString fileName, QString function, QList<PyObject*> args, bool autoReload)
{
if (!QFile::exists(fileName))
return nullptr;
// run pycli in pthread, this is temporary solution
if (fileName.contains("pycli") && (!function.contains("init"))) {
//tid = new pthread_t;
qtid = new CAPyconsoleThread();
thr_fileName = fileName;
thr_args = args;
thr_function = function;
qtid->start();
//pthread_create(tid, nullptr, &callPycli, nullptr);
return args.first();
}
PyEval_RestoreThread(mainThreadState);
PyObject* pyArgs = PyTuple_New(args.size());
if (!pyArgs)
return nullptr;
for (int i = 0; i < args.size(); i++)
PyTuple_SetItem(pyArgs, i, args[i]);
// Load module, if not yet
QString moduleName = fileName.left(fileName.lastIndexOf(".py"));
moduleName = moduleName.remove(0, moduleName.lastIndexOf("/") + 1);
PyObject* pyModule;
if (autoReload) {
PyObject* moduleDict = PyImport_GetModuleDict(); // borrowed ref.
PyObject* ourModuleName = PyBytes_FromString(static_cast<const char*>(moduleName.toStdString().c_str())); // new ref.
pyModule = PyDict_GetItem(moduleDict, ourModuleName); // borrowed ref.
// Py_DECREF(ourModuleName); // -Matevz
if (pyModule == nullptr) // not imported yet
pyModule = PyImport_ImportModule(static_cast<const char*>(moduleName.toStdString().c_str()));
else
Py_XDECREF(PyImport_ReloadModule(pyModule)); // we don't need the reference returned from ReloadModule
} else {
pyModule = PyImport_ImportModule(static_cast<const char*>(moduleName.toStdString().c_str()));
}
if (PyErr_Occurred()) {
PyErr_Print();
PyEval_ReleaseThread(mainThreadState);
return nullptr;
}
// Get function object
PyObject* pyFunction = PyObject_GetAttrString(pyModule, static_cast<const char*>(function.toStdString().c_str()));
if (PyErr_Occurred()) {
PyErr_Print();
PyEval_ReleaseThread(mainThreadState);
return nullptr;
}
// Call the actual function
PyObject* ret;
if (args.size())
ret = PyEval_CallObject(pyFunction, pyArgs);
else
ret = PyEval_CallObject(pyFunction, nullptr);
if (PyErr_Occurred()) {
PyErr_Print();
PyEval_ReleaseThread(mainThreadState);
return nullptr;
}
// Py_DECREF(pyFunction); // -Matevz
// Py_DECREF(pyModule); // -Matevz
/// \todo Crashes if uncommented?!
// Py_DECREF(pyArgs);
// for (int i=0; i<args.size(); i++)
// Py_DECREF(args[i]); // -Matevz
PyEval_ReleaseThread(mainThreadState);
return ret;
}
/*!
Function for intializing python-CLI pycli, called asynchronously from 'callFunction' (it's a copy to avoid confusion)
temporary solution
\param fileName Absolute path to the filename of the script
\param args -> document reference, pyCli widget referece **
*/
void* CASwigPython::callPycli(void*)
{
PyEval_RestoreThread(mainThreadState);
PyThreadState_Swap(pycliThreadState);
QString fileName = thr_fileName;
QString function = thr_function;
QList<PyObject*> args = thr_args;
if (!QFile::exists(fileName)) {
// pthread_exit((void*)nullptr);
}
PyObject* pyArgs = Py_BuildValue("(OO)", args[0], args[1]);
// Load module, if not yet
QString moduleName = fileName.left(fileName.lastIndexOf(".py"));
moduleName = moduleName.remove(0, moduleName.lastIndexOf("/") + 1);
PyObject* pyModule = PyImport_ImportModule(static_cast<const char*>(moduleName.toStdString().c_str()));
if (PyErr_Occurred()) {
PyErr_Print();
PyEval_ReleaseThread(mainThreadState);
return nullptr;
}
// Get function object
//PyObject *pyFunction = PyObject_GetAttrString(pyModule, "pycli");
PyObject* pyFunction = PyObject_GetAttrString(pyModule, static_cast<const char*>(function.toStdString().c_str()));
if (PyErr_Occurred()) {
PyErr_Print();
PyEval_ReleaseThread(mainThreadState);
return nullptr;
}
// Call the actual function
//
PyObject* ret;
ret = PyEval_CallObject(pyFunction, pyArgs);
if (PyErr_Occurred()) {
PyErr_Print();
PyEval_ReleaseThread(mainThreadState);
return nullptr;
}
// Py_DECREF(pyFunction); // -Matevz
/// \todo Crashes if uncommented?!
// Py_DECREF(pyArgs);
// Py_DECREF(pyModule); // -Matevz
// for (int i=0; i<args.size(); i++)
// Py_DECREF(args[i]); // -Matevz
PyThreadState_Swap(mainThreadState);
PyEval_ReleaseThread(mainThreadState);
// pthread_exit((void*)nullptr);
return ret;
}
/*!
\fn static PyObject* CASwigPython::toPythonObject(void *object, CAClassType type)
Python uses its wrapper classes over C++ objects. Use this function to create a Python wrapper object out of the C++ one of type \a type.
See CAClassType for details on the types. This function uses SWIG internals and is injected inside swig CXX wrapper file.
\warning GIL thread lock must be acquired before calling this function.
*/
#endif
| 9,087
|
C++
|
.cpp
| 219
| 36.383562
| 142
| 0.689514
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,413
|
helpctl.cpp
|
canorusmusic_canorus/src/control/helpctl.cpp
|
/*!
Copyright (c) 2009, 2016 Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#include <QDesktopServices>
#include <QDockWidget>
#include <QStringList>
#include "canorus.h"
#include "control/helpctl.h"
#include "ui/mainwin.h"
#ifdef QT_WEBENGINEWIDGETS_LIB
#include "widgets/helpbrowser.h"
#endif
/*!
\class CAHelpCtl
\brief Class for showing User's guide, What's new, Did you know tips etc.
*/
/*!
Initializes Help and loads User's guide.
*/
CAHelpCtl::CAHelpCtl()
{
_homeUrl = detectHomeUrl();
}
CAHelpCtl::~CAHelpCtl()
{
}
/*!
Helper function which returns the preferred User's guide language.
*/
QUrl CAHelpCtl::detectHomeUrl()
{
QUrl url;
QFileInfo i;
i = QFileInfo("doc:usersguide2/build/" + QLocale::system().name() + "/index.html");
if (!i.exists()) {
i = QFileInfo("doc:usersguide2/" + QLocale::system().name() + "/index.html");
}
if (!i.exists()) {
i = QFileInfo("doc:usersguide2/build/" + QLocale::system().name().left(2) + "/index.html");
}
if (!i.exists()) {
i = QFileInfo("doc:usersguide2/" + QLocale::system().name().left(2) + "/index.html");
}
if (!i.exists()) {
i = QFileInfo("doc:usersguide2/build/en/index.html");
}
if (!i.exists()) {
i = QFileInfo("doc:usersguide2/en/index.html");
}
if (i.exists()) {
url = QUrl::fromLocalFile(i.absoluteFilePath());
}
return url;
}
/*!
Show user's guide at the given chapter.
\return True, if a user's guide was found and shown; False otherwise.
*/
bool CAHelpCtl::showUsersGuide(QString chapter, QWidget* helpWidget)
{
QUrl url = _homeUrl;
if (!chapter.isEmpty()) {
url.setFragment(chapter);
}
if (!url.path().isEmpty()) {
#ifdef QT_WEBENGINEWIDGETS_LIB
displayHelp(url, helpWidget);
#else
QDesktopServices::openUrl(url);
#endif
return true;
}
return false;
}
/*!
Activates the user's guide help at the given url.
*/
void CAHelpCtl::displayHelp(QUrl url, QWidget* helpWidget)
{
#ifdef QT_WEBENGINEWIDGETS_LIB
CAHelpBrowser* browser = nullptr;
if (!helpWidget) {
browser = new CAHelpBrowser;
browser->setAttribute(Qt::WA_DeleteOnClose);
} else if (dynamic_cast<CAMainWin*>(helpWidget)) {
browser = static_cast<CAMainWin*>(helpWidget)->helpWidget();
static_cast<CAMainWin*>(helpWidget)->helpDock()->show();
}
if (browser) {
browser->setUrl(url);
}
#endif
}
| 2,643
|
C++
|
.cpp
| 95
| 23.673684
| 99
| 0.660452
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,414
|
typesetctl.cpp
|
canorusmusic_canorus/src/control/typesetctl.cpp
|
/*!
Copyright (c) 2006-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
// Includes
#include "control/typesetctl.h"
#include "control/externprogram.h"
#include "export/export.h"
//#include "core/document.h"
/*! \class CATypesetCtl
\brief Interface to start a typesetter in the background
This class is used to run a typesetter in the background while receiving
the output of it. The output of the typesetter can be fetched via signal/slots.
If the typesetter does not support creation of pdf files another process can
be started to do the conversion.
Constructor:
*/
CATypesetCtl::CATypesetCtl()
{
_poTypesetter = new CAExternProgram;
_poConvPS2PDF = new CAExternProgram;
_poExport = nullptr;
_poOutputFile = nullptr;
_bPDFConversion = false;
_bOutputFileNameFirst = false;
connect(_poTypesetter, SIGNAL(programExited(int)), this, SLOT(typsetterExited(int)));
connect(_poTypesetter, SIGNAL(nextOutput(const QByteArray&)), this, SLOT(rcvTypesetterOutput(const QByteArray&)));
}
// Destructor
CATypesetCtl::~CATypesetCtl()
{
if (_poTypesetter)
delete _poTypesetter;
_poTypesetter = nullptr;
if (_poConvPS2PDF)
delete _poConvPS2PDF;
_poConvPS2PDF = nullptr;
if (_poOutputFile)
delete _poOutputFile;
_poOutputFile = nullptr;
}
/*!
Defines the typesetter executable name to be run
This method let's you define the typesetter
executable name (with optionally included path name)
\sa setTSetOption( QVariant oName, QVariant oValue );
\sa CAExternProgram::execProgram( QString oCwd )
*/
void CATypesetCtl::setTypesetter(const QString& roProgramName, const QString& roProgramPath)
{
if (!roProgramName.isEmpty()) {
_poTypesetter->setProgramName(roProgramName);
if (!roProgramPath.isEmpty())
_poTypesetter->setProgramPath(roProgramPath);
}
}
/*!
Defines the postscript->pdf executable name to be run
This method let's you define the executble name of an optional
postscript->pdf converter in case the typesetter does not
support the output of pdf. (with optionally included path name
and a list of parameters)
\sa createPDF();
\sa CAExternProgram::execProgram( QString oCwd )
*/
void CATypesetCtl::setPS2PDF(const QString& roProgramName, const QString& roProgramPath, const QStringList& roParams)
{
if (!roProgramName.isEmpty() && !roProgramPath.isEmpty()) {
_poConvPS2PDF->setProgramName(roProgramName);
if (!roProgramPath.isEmpty())
_poConvPS2PDF->setProgramPath(roProgramPath);
if (!roParams.isEmpty())
_poConvPS2PDF->setParameters(roParams);
}
}
/*!
Defines the export options
For the run of one exporter additional options can be defined using
this method. The \a oName does define the name of the option
and the \a oValue defines the value of the option name to be
passed to the exporter. There is no conversion / transformation
done in the base class.
\sa exportDocument();
*/
void CATypesetCtl::setExpOption(const QVariant& roName, const QVariant& roValue)
{
_oExpOptList.append(roName);
_oExpOptList.append(roValue);
}
/*!
Defines the typesetter options
For the run of one typesetter additional parameters can be defined using
this method. The \a oName does define the name of the parameter
and the \a oValue defines the value of the parameter name to be
passed to the typesetter.
If the optional parameter \a bSpace is set to true a space between the
name and value is set, else the "=" character is set. If \a bShortParam
is set to true nothing is set between the parameter name and value.
The name and values are converted to a string (so only QVariants that can
be converted to QString are supported) in the form "-<name>=<option>"
(without < and > signs) with no additional apostrophes.
\sa runTypesetter();
*/
void CATypesetCtl::setTSetOption(const QVariant& roName, const QVariant& roValue, bool bSpace, bool bShortParam)
{
_oTSetOptList.append(roName);
_oTSetOptList.append(roValue);
// Subclass needs to transform the stored options to program parameters and
// call _poTypesetter->setParameters( oTPSParameters )
// Primitive solution is here: Convert Name and Value to string and store it to string list
if (!roName.toString().isEmpty() && !roValue.toString().isEmpty()) {
if (bShortParam)
_poTypesetter->addParameter(QString("-") + roName.toString() + roValue.toString(), false);
else if (bSpace)
_poTypesetter->addParameter(QString("-") + roName.toString() + " " + roValue.toString(), false);
else
_poTypesetter->addParameter(QString("-") + roName.toString() + "=" + roValue.toString(), false);
} else
qWarning("TypesetCtl: Ignoring typesetter option name being empty! %s/%s",
roName.toString().toLatin1().data(), roValue.toString().toLatin1().data());
}
/*!
Export the file to disk to be run by the typesetter
This method creates a random file name as a stream file name
for the exporter. Then it exports the document \a poDoc.
\sa setExpOption( QVariant oName, QVariant oValue )
*/
void CATypesetCtl::exportDocument(CADocument* poDoc)
{
/// \todo: Add export options to the document directly ?
if (_poExport) {
if (_poOutputFile) {
delete _poOutputFile;
_poTypesetter->clearParameters();
}
_poOutputFile = new QTemporaryFile;
// Create the unique file as the file name is only defined when opening the file
_poOutputFile->open();
// Add the input file name as default parameter.
// @ToDo: There might be problems with typesetter expecting file extensions,
// if so, methods have to be added handling this
_oOutputFileName = _poOutputFile->fileName();
// Only add output file name as first parameter file name if it is needed
if (true == _bOutputFileNameFirst)
_poTypesetter->addParameter(_oOutputFileName, false);
_poExport->setStreamToDevice(_poOutputFile);
_poExport->exportDocument(poDoc);
// @ToDo use signal/slot mechanism to wait for the file
_poExport->wait();
_poOutputFile->close();
} else
qCritical("TypesetCtl: No export was done - no exporter defined");
}
/*!
Export the file to disk to be run by the typesetter
This method creates a random file name as a stream file name
for the exporter. Then it exports the sheet \a poSheet.
\sa setExpOption( QVariant oName, QVariant oValue )
*/
void CATypesetCtl::exportSheet(CASheet* poSheet)
{
/// \todo: Add export options to the document directly ?
if (_poExport) {
if (_poOutputFile) {
delete _poOutputFile;
_poTypesetter->clearParameters();
}
_poOutputFile = new QTemporaryFile;
// Create the unique file as the file name is only defined when opening the file
_poOutputFile->open();
// Add the input file name as default parameter.
// @ToDo: There might be problems with typesetter expecting file extensions,
// if so, methods have to be added handling this
_oOutputFileName = _poOutputFile->fileName();
// Only add output file name as first parameter file name if it is needed
if (true == _bOutputFileNameFirst)
_poTypesetter->addParameter(_oOutputFileName, false);
_poExport->setStreamToDevice(_poOutputFile);
_poExport->exportSheet(poSheet);
// @ToDo use signal/slot mechanism to wait for the file
_poExport->wait();
_poOutputFile->close();
} else
qCritical("TypesetCtl: No export was done - no exporter defined");
}
/*!
Start the typesetter
This method runs the typesetter. Make sure that all the
required name, path and parameters are set
\sa setTypesetter( const QString &roProgramName, const QString &roProgramPath )
*/
void CATypesetCtl::runTypesetter()
{
// Only add output file name as first parameter file name if it is needed
if (false == _bOutputFileNameFirst)
_poTypesetter->addParameter(_oOutputFileName, false);
if (!_poTypesetter->execProgram())
qCritical("TypesetCtl: Running typesetter failed!");
}
/*!
Runs the conversion from postscript to pdf in the background
Currently neither progress nor output messages are supported
when doing this conversion step. Only startup failures are handled.
*/
bool CATypesetCtl::createPDF()
{
return _poConvPS2PDF->execProgram();
}
/*!
Sends new received output to a connected slot
If slots are connected to the signal nextOutput the
output received by the typesetter are sent to that slot.
No distinction is made between standard error and output.
*/
void CATypesetCtl::rcvTypesetterOutput(const QByteArray& roData)
{
emit nextOutput(roData);
}
/*!
Blocks until the process has finished and the finished() signal has been emitted
or until msecs milliseconds have passed.
Returns true if the process finished; otherwise returns false (if the operation timed
out or if an error occurred).
*/
bool CATypesetCtl::waitForFinished(int iMSecs)
{
return _poTypesetter->waitForFinished(iMSecs);
}
/*!
Send the exit code of the finished typesetter to a connected slot.
As soon as the typesetter finished it's job in the background this
method sends the typesetterFinished method to all connected
slots. The method assumes that on a successful finish the exit
code of the typesetter is set to 0.
If a typesetter only does support postscript output, the pdf
creation process can be started afterwards (this also requires
that the exit code of the typesetter was 0!)
*/
void CATypesetCtl::typsetterExited(int iExitCode)
{
if (iExitCode != 0)
qCritical("TypesetCtl: Typesetter finished with code %d", iExitCode);
else if (_bPDFConversion) {
if (!createPDF())
qCritical("TypesetCtl: Creating pdf file failed!");
}
emit typesetterFinished(iExitCode);
}
| 10,197
|
C++
|
.cpp
| 249
| 36.437751
| 118
| 0.726915
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,415
|
mainwinprogressctl.cpp
|
canorusmusic_canorus/src/control/mainwinprogressctl.cpp
|
/*!
Copyright (c) 2009-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#include <QTimer>
#include "control/mainwinprogressctl.h"
#include "core/file.h"
#include "ui/mainwin.h"
#include "widgets/progressstatusbar.h"
CAMainWinProgressCtl::CAMainWinProgressCtl(CAMainWin* mainWin)
: _mainWin(mainWin)
, _bar(nullptr)
, _updateTimer(nullptr)
, _file(nullptr)
{
}
CAMainWinProgressCtl::~CAMainWinProgressCtl() = default;
void CAMainWinProgressCtl::on_updateTimer_timeout()
{
if (_file) {
_bar->setProgress(_file->readableStatus(), _file->progress());
if (_file->isFinished()) {
restoreStatusBar();
_updateTimer->stop();
}
}
}
void CAMainWinProgressCtl::on_cancelButton_clicked(bool)
{
if (_file) {
_file->exit();
restoreStatusBar();
_updateTimer->stop();
_file->wait();
}
}
void CAMainWinProgressCtl::restoreStatusBar()
{
_mainWin->statusBar()->removeWidget(_bar.get());
_bar.reset();
}
void CAMainWinProgressCtl::startProgress(CAFile &f)
{
_file = &f;
_mainWin->setMode(CAMainWin::ProgressMode);
if (_updateTimer) {
_updateTimer.reset();
}
_updateTimer = std::make_unique<QTimer>(new QTimer());
_updateTimer->setInterval(150);
_updateTimer->setSingleShot(false);
connect(_updateTimer.get(), SIGNAL(timeout()), this, SLOT(on_updateTimer_timeout()));
_bar = std::make_unique<CAProgressStatusBar>(new CAProgressStatusBar(_mainWin));
_mainWin->statusBar()->addWidget(_bar.get());
connect(_bar.get(), SIGNAL(cancelButtonClicked(bool)), this, SLOT(on_cancelButton_clicked(bool)));
_updateTimer->start();
}
| 1,831
|
C++
|
.cpp
| 58
| 27.206897
| 102
| 0.688674
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,416
|
printctl.cpp
|
canorusmusic_canorus/src/control/printctl.cpp
|
/*!
Copyright (c) 2006-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
// Includes
#include <QDesktopServices>
#include <QMessageBox>
#include <QPainter>
#include <QPrintDialog>
#include <QPrinter>
#include <QSvgRenderer>
#include <QUrl>
#include "canorus.h"
#include "control/printctl.h"
#include "core/settings.h"
#include "export/svgexport.h"
#include "ui/mainwin.h"
CAPrintCtl::CAPrintCtl(CAMainWin* poMainWin)
{
setObjectName("oPrintCtl");
_poMainWin = poMainWin;
_poSVGExport = std::make_unique<CASVGExport>();
_showDialog = true;
if (poMainWin == nullptr)
qCritical("PrintCtl: No mainwindow instance available!");
else
CACanorus::connectSlotsByName(_poMainWin, this);
connect(_poSVGExport.get(), SIGNAL(svgIsFinished(int)), this, SLOT(printSVG(int)));
}
// Destructor
CAPrintCtl::~CAPrintCtl() = default;
void CAPrintCtl::on_uiPrint_triggered()
{
_showDialog = true;
printDocument();
}
void CAPrintCtl::on_uiPrintDirectly_triggered()
{
_showDialog = false;
printDocument();
}
void CAPrintCtl::printDocument()
{
QDir oPath(QDir::tempPath());
QFile oTempFile(oPath.absolutePath() + "/print.svg");
QString oTempFileName(oPath.absolutePath() + "/print.svg");
if (!oTempFile.remove()) {
qWarning("PrintCtl: Could not remove old print file %s, error %s", oTempFile.fileName().toLatin1().constData(),
oTempFile.errorString().toLatin1().constData());
oTempFile.unsetError();
}
qDebug("PrintCtl: Print triggered via main window");
// The exportDocument method defines the temporary file name and
// directory, so we can only read it after the creation
_poSVGExport->setStreamToFile(oTempFileName);
//_poSVGExport->exportDocument( _poMainWin->document() );
_poSVGExport->exportSheet(_poMainWin->currentSheet());
_poSVGExport->wait();
const QString roTempPath = _poSVGExport->getTempFilePath();
// Copy the name for later output on the printer
_oOutputSVGName = roTempPath;
}
void CAPrintCtl::printSVG(int iExitCode)
{
if (iExitCode) {
QMessageBox::critical(_poMainWin, tr("Error while printing"), tr("Error while running the typesetter.\n\nPlease install LilyPond (visit http://www.lilypond.org) and check the settings."));
return;
}
// High resolution requires huge amount of memory :-(
//QPrinter oPrinter;
QPrinter oPrinter(QPrinterInfo::defaultPrinter(), QPrinter::ScreenResolution);
QPainter oPainter;
oPrinter.setFullPage(true);
QPrintDialog oPrintDlg(&oPrinter);
QDir oPath(QDir::tempPath());
QFile oTempFile(oPath.absolutePath() + "/print.svg");
QSvgRenderer oRen;
oTempFile.setFileName(_oOutputSVGName + ".svg");
// Start by letting the user select the print settings
if (oRen.load(oPath.absolutePath() + "/print.svg") && (!_showDialog || oPrintDlg.exec())) {
// Actual printing with the help of the painter
oPainter.begin(&oPrinter);
// Draw the SVG image
//oPainter.drawImage(0,0,poSVGPage->renderToImage(oPrinter.resolution(),oPrinter.resolution()));
oPainter.setRenderHints(QPainter::Antialiasing);
oRen.render(&oPainter);
oPainter.end();
}
}
| 3,427
|
C++
|
.cpp
| 90
| 33.577778
| 196
| 0.709561
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,417
|
resourcectl.cpp
|
canorusmusic_canorus/src/control/resourcectl.cpp
|
/*!
Copyright (c) 2008-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include "control/resourcectl.h"
#include "score/document.h"
#ifndef SWIGCPP
#include "canorus.h"
#include "core/undo.h"
#endif
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QTemporaryFile>
#include <QUrl>
#include <iostream> // debug
/*!
\class CAResourceCtl
\brief Resource control class
This class is used for creation of new resources out of files on the disk or
web URLs.
Resources are rarely created directly (maybe using the plugin interface), but
usually are part of the document (eg. audio file of the whole score), sheet
(eg. audio file of a theme), staff (eg. svg images in contemporary music),
voice etc.
You can simply add a resource by calling
CADocument::addResource( new CAResource( "/home/user/title.jpeg", "My image") );
CAResourceContainer takes care of creating copies for non-linked resources.
It picks a random unique name for a new resource in the system temporary file.
\sa CAResource
*/
/*!
Default constructor. Currently empty.
*/
CAResourceCtl::CAResourceCtl()
{
}
CAResourceCtl::~CAResourceCtl()
{
}
/*!
Imports the resource located at \a fileName and adds it to the document \a parent and all its
undo/redo instances.
If the resource is linked, the \a fileName should be url and a resource is only registered.
If the resource is not linked, the \a fileName should be absolute path to the file, resource
is copied and registered.
*/
std::shared_ptr<CAResource> CAResourceCtl::importResource(QString name, QString fileName, bool isLinked, CADocument* parent, CAResource::CAResourceType t)
{
std::shared_ptr<CAResource> r;
if (isLinked) {
r = std::make_shared<CAResource>(fileName, name, true, t, parent);
} else {
std::unique_ptr<QTemporaryFile> f = std::make_unique<QTemporaryFile>(QDir::tempPath() + "/" + name);
f->open();
QString targetFile = QFileInfo(*f).absoluteFilePath();
f->close();
f.reset();
if (QFile::exists(fileName)) {
QFile::copy(fileName, targetFile);
r = std::make_shared<CAResource>(QUrl::fromLocalFile(targetFile), name, false, t, parent);
} else {
// file doesn't exist yet (eg. hasn't been extracted yet)
// create a dummy resource using fileName url
r = std::make_shared<CAResource>(fileName, name, false, t, parent);
}
}
if (parent) {
#ifndef SWIGCPP
QList<CADocument*> documents = CACanorus::undo()->getAllDocuments(parent);
for (int i = 0; i < documents.size(); i++) {
documents[i]->addResource(r);
}
#else
parent->addResource(r);
#endif
}
return r;
}
/*!
Creates an empty resource file.
This function is usually called when launching Midi recorder.
*/
std::shared_ptr<CAResource> CAResourceCtl::createEmptyResource(QString name, CADocument* parent, CAResource::CAResourceType t)
{
QTemporaryFile f(QDir::tempPath() + "/" + name);
f.open();
QString fileName = QFileInfo(f).absoluteFilePath();
f.close();
std::shared_ptr<CAResource> r = std::make_shared<CAResource>(QUrl::fromLocalFile(fileName), name, false, t, parent);
if (parent) {
#ifndef SWIGCPP
QList<CADocument*> documents = CACanorus::undo()->getAllDocuments(parent);
for (int i = 0; i < documents.size(); i++) {
documents[i]->addResource(r);
}
r->document()->setModified(true);
#else
parent->addResource(r);
#endif
}
return r;
}
/*!
Removes the given resource \a r from all the undo/redo document instances and destroys it.
*/
void CAResourceCtl::deleteResource(std::shared_ptr<CAResource> r)
{
if (r->document()) {
#ifndef SWIGCPP
QList<CADocument*> documents = CACanorus::undo()->getAllDocuments(r->document());
for (int i = 0; i < documents.size(); i++) {
documents[i]->removeResource(r);
}
r->document()->setModified(true);
#else
r->document()->removeResource(r);
#endif
}
r.reset();
}
| 4,238
|
C++
|
.cpp
| 122
| 30.442623
| 154
| 0.68979
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,418
|
previewctl.cpp
|
canorusmusic_canorus/src/control/previewctl.cpp
|
/*!
Copyright (c) 2006-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
// Includes
#include <QDesktopServices>
#include <QMessageBox>
#include <QProcess> // needed for custom pdf viewer application
#include <QUrl>
#include "canorus.h" // needed for settings
#include "canorus.h"
#include "control/previewctl.h"
#include "core/settings.h"
#include "export/pdfexport.h"
#include "ui/mainwin.h"
CAPreviewCtl::CAPreviewCtl(CAMainWin* poMainWin)
{
setObjectName("oPreviewCtl");
_poMainWin = poMainWin;
_poPDFExport = std::make_unique<CAPDFExport>();
if (!poMainWin) {
qCritical("PreviewCtl: No mainwindow instance available!");
}
else {
CACanorus::connectSlotsByName(_poMainWin, this);
}
connect(_poPDFExport.get(), SIGNAL(pdfIsFinished(int)), this, SLOT(showPDF(int)));
}
CAPreviewCtl::~CAPreviewCtl() = default;
void CAPreviewCtl::on_uiPrintPreview_triggered()
{
QDir oPath(QDir::tempPath());
QFile oTempFile(oPath.absolutePath() + "/preview.pdf");
QString oTempFileName(oPath.absolutePath() + "/preview.pdf");
if (!oTempFile.remove()) {
qWarning("PreviewCtl: Could not remove old preview file %s, error %s", oTempFile.fileName().toLatin1().constData(),
oTempFile.errorString().toLatin1().constData());
oTempFile.unsetError();
}
qDebug("PreviewCtl: Preview triggered via main window");
// The exportDocument method defines the temporary file name and
// directory, so we can only read it after the creation
_poPDFExport->setStreamToFile(oTempFileName);
//_poPDFExport->exportDocument( _poMainWin->document() );
_poPDFExport->exportSheet(_poMainWin->currentSheet());
_poPDFExport->wait();
const QString roTempPath = _poPDFExport->getTempFilePath();
// Copy the name for later output on the printer
_oOutputPDFName = roTempPath;
}
void CAPreviewCtl::showPDF(int iExitCode)
{
if (iExitCode) {
QMessageBox::critical(_poMainWin, tr("Error running preview"), tr("Error while running the typesetter.\n\nPlease install LilyPond (visit http://www.lilypond.org) and check the settings."));
return;
}
bool success;
// Show the pdf file with the default pdf system viewer
if (CACanorus::settings()->useSystemDefaultPdfViewer()) {
success = QDesktopServices::openUrl(QUrl::fromLocalFile(QDir::tempPath() + "/preview.pdf"));
} else { // Use viewer specified in settings (location and command) to show the pdf file
success = QProcess::startDetached(CACanorus::settings()->pdfViewerLocation(), QStringList() << QDir::tempPath() + "/preview.pdf");
}
if (!success) {
QMessageBox::critical(_poMainWin, tr("Error running preview"), tr("Unable to show %1.\n\nPlease install a PDF viewer and check the settings.").arg(QDir::tempPath() + "/preview.pdf"));
}
}
| 3,038
|
C++
|
.cpp
| 68
| 40.073529
| 197
| 0.709895
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,419
|
externprogram.cpp
|
canorusmusic_canorus/src/control/externprogram.cpp
|
/*!
Copyright (c) 2006-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
// Includes
#include "control/externprogram.h"
#include <QDebug>
/*! \class CAExternProgram
\brief Start a program as extern background process
This class is used to start an extern program as background process.
Parameters are the program name and it's parameters
The output of the program can be fetched via signal/slots
Another signal is sent when the program finished including it's state
Constructor: If the stderr output should not be shown, \a bRcvStdErr has
has to be set to false.
*/
CAExternProgram::CAExternProgram(bool bRcvStdErr /* = true */, bool bRcvStdOut /* = true */)
: _poExternProgram(new QProcess())
{
_bRcvStdErr = bRcvStdErr;
_oParamDelimiter = " ";
connect(_poExternProgram.get(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(programError(QProcess::ProcessError)));
connect(_poExternProgram.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(programFinished(int, QProcess::ExitStatus)));
if (bRcvStdOut)
connect(_poExternProgram.get(), SIGNAL(readyReadStandardOutput()), this, SLOT(rcvProgramStdOut()));
if (bRcvStdErr)
connect(_poExternProgram.get(), SIGNAL(readyReadStandardError()), this, SLOT(rcvProgramStdErr()));
}
/*!
Defines the program executable name to be run
This method let's you define the \a oProgramm
executable name. If the program cannot be found
in the PATH then you either need to add it to the
program name or define it separately via setProgramPath
\sa setParameters( QString oParams )
\sa setProgramPath( QString oPath )
\sa execProgram( QString oCwd )
*/
void CAExternProgram::setProgramName(const QString& roProgram)
{
// Make sure that the program name is defined
if (!roProgram.isEmpty())
_oProgramName = roProgram;
else
qWarning("ExternProgram: Ignoring program name being empty!");
}
/*!
Defines the program path of the program executable
This method let's you define the \a oPath name where
the executable name can be found. You only need to set it
if the program executable name cannot be found in the PATH.
\sa setProgramName( QString oProgram )
*/
void CAExternProgram::setProgramPath(const QString& roPath)
{
// Make sure that the program path is defined
if (!roPath.isEmpty())
_oProgramPath = roPath;
else
qWarning("ExternProgram: Ignoring program path being empty!");
}
/*!
Defines the parameters of the program to be run
This method let's you define all the \a oParams being added
to the executable name at once. It removed all existant parameters.
If you need a finer parameter control you can use this method to just
define the first parameter if you need to change them.
\sa addParameter( QString oParam, bool bAddSpaces = true )
\sa setProgramName( QString oProgram )
*/
void CAExternProgram::setParameters(const QStringList& roParams)
{
// Make sure that the parameters are defined
if (!roParams.isEmpty())
_oParameters = roParams;
else
qWarning("ExternProgram: Ignoring parameters being empty!");
}
/*!
Returns the exit status of the finished program
Returns "-1" if the program is still running, else
the exist status of the process
\sa setProgramName( QString oProgram )
\sa QProcess::exitStatus()
*/
int CAExternProgram::getExitState()
{
int iExitStatus = -1;
if (getRunning())
qWarning("ExternProgram: Getting exit state while program is still running!");
else
iExitStatus = static_cast<int>(_poExternProgram->exitStatus());
return iExitStatus;
}
/*!
Adds a new parameter to the list of parameters
This method allows a fine grain control of the parameters
being added to the program. Beside the \a oParam the delimiter
is automatically add inserted if you don't set \a bAddDelimiter
to false (the delimiter defaults to a single space character)
\sa setParameters( QString oParams )
\sa setParamDelimiter( QString oDelimiter )
*/
void CAExternProgram::addParameter(const QString& roParam, bool bAddDelimiter /* = true */)
{
// Make sure that the parameters are defined
if (!roParam.isEmpty()) {
if (bAddDelimiter)
_oParameters += QString(_oParamDelimiter + roParam);
else
_oParameters += roParam;
} else
qWarning("ExternProgram: Ignoring additional parameter being empty!");
}
/*!
Runs the program in the specified \a oCwd (working directory)
This method tries to start the specified program using the
specified parameters. If a working directory is specified the
it is applied to the process before the program starts.
Errors on start are immediately reported to the error console.
\sa setParameters( QString oParams )
\sa setProgram( QString oProgram )
*/
bool CAExternProgram::execProgram(const QString& roCwd /* = "." */)
{
if (_oProgramName.isEmpty()) {
qCritical("ExternProgram: Could not run program, no program name specified!");
return false;
}
if (!roCwd.isEmpty())
_poExternProgram->setWorkingDirectory(roCwd);
// Add optional path (including dash, so there doesn't need to be a dash at the end of the path)
if (_oProgramPath.isEmpty()) {
_poExternProgram->start(_oProgramName, _oParameters);
qDebug("Started %s with parameters %s", _oProgramName.toLatin1().data(),
_oParameters.join(" ").toLatin1().data());
} else
_poExternProgram->start(_oProgramPath + "/" + _oProgramName, _oParameters);
// Wa it until program was started
if (!_poExternProgram->waitForStarted()) {
qCritical("ExternProgram: Could not run program %s! Error %s", _oProgramName.toLatin1().constData(),
QString("%1 " + _poExternProgram->errorString()).arg(_poExternProgram->error()).toLatin1().constData());
return false;
}
return true;
}
/*!
This method sends a signal when data is received by the extern program
To receive data from the extern program create a signal/slot connection
to the nextOutput signal. This class does not cache any data!
The \o roData contains the data received by the process output to
either stdout or stderr. Use the constructor to define if you don't wish to
either receive standartd output or standard error.
\sa QProcess::setProgram( QString oProgram )
*/
void CAExternProgram::rcvProgramOutput(const QByteArray& roData)
{
// The data is not stored but has to be immediately read by the using object
// Else the data ist lost.
// If you need a data caching please create a sub class from this class like
// CACacheExternProgram or include it in a CACacheProgramData class or use
// the cache class Qt provides named QCache for such a purpose.
emit nextOutput(roData);
}
/*!
This slot sends a signal when the extern program is finished or reports an error
To get acknowledged by the program end and when an error occurs connect to the
signal programExited. Only errors leading to a program crash are reported this
way others are only put out to the console
\sa QProcess::setProgram( QString oProgram )
*/
void CAExternProgram::programExited()
{
if (getRunning()) {
qCritical("%s",
QString("ExternProgram: program %1 reported error %2!" + _poExternProgram->errorString()).arg(_poExternProgram->error()).toLatin1().constData());
return;
}
// Check if the program exited normally else put out error message
if (_poExternProgram->exitStatus() != QProcess::NormalExit) {
qCritical() << "ExternProgram: program" << _oProgramName << " didn't finish correctly! Exit code"
<< _poExternProgram->exitCode() << " " << _poExternProgram->errorString();
emit programExited(_poExternProgram->exitCode());
}
if (_poExternProgram->error() == QProcess::FailedToStart) {
qCritical() << "ExternProgram: program" << _oProgramName << "didn't start correctly! Error code"
<< _poExternProgram->error() << " " << _poExternProgram->errorString();
emit programExited(-1);
}
emit programExited(_poExternProgram->exitCode());
}
| 8,337
|
C++
|
.cpp
| 192
| 39.239583
| 157
| 0.728674
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,420
|
pdfexport.cpp
|
canorusmusic_canorus/src/export/pdfexport.cpp
|
/*!
Copyright (c) 2008-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
// Includes
#include "export/pdfexport.h"
#include "control/typesetctl.h"
#include "export/lilypondexport.h"
#ifndef SWIGCPP
#include "canorus.h" // needed for settings()
#endif
#include "core/settings.h"
/*!
\class CAPDFExport
\brief PDF export filter
This class is used to export the document or parts of the document to PDF format.
The most common use is to simply call the constructor
\code
CAPDFExport( &textStream );
\endcode
\a textStream is usually the file stream or the content of the score source view widget.
*/
/*!
Constructor for PDF export.
Exports a document to LilyPond and create a PDF from it using the given text \a stream.
*/
CAPDFExport::CAPDFExport(QTextStream* stream)
: CAExport(stream)
{
_poTypesetCtl = nullptr;
}
// Destructor
CAPDFExport::~CAPDFExport()
{
if (_poTypesetCtl) {
delete _poTypesetCtl->getExporter();
delete _poTypesetCtl;
}
_poTypesetCtl = nullptr;
}
void CAPDFExport::startExport()
{
_poTypesetCtl = new CATypesetCtl();
// For now we support only lilypond export
#ifndef SWIGCPP
_poTypesetCtl->setTypesetter((CACanorus::settings()->useSystemDefaultTypesetter()) ? (CASettings::DEFAULT_TYPESETTER_LOCATION) : (CACanorus::settings()->typesetterLocation()));
#else
_poTypesetCtl->setTypesetter(CASettings::DEFAULT_TYPESETTER_LOCATION);
#endif
_poTypesetCtl->setExporter(new CALilyPondExport());
// Put lilypond output to console, could be shown on a canorus console later
connect(_poTypesetCtl, SIGNAL(nextOutput(const QByteArray&)), this, SLOT(outputTypsetterOutput(const QByteArray&)));
connect(_poTypesetCtl, SIGNAL(typesetterFinished(int)), this, SLOT(pdfFinished(int)));
}
void CAPDFExport::finishExport()
{
if (_poTypesetCtl) {
// Put lilypond output to console, could be shown on a canorus console later
disconnect(_poTypesetCtl, SIGNAL(nextOutput(const QByteArray&)), this, SLOT(outputTypsetterOutput(const QByteArray&)));
disconnect(_poTypesetCtl, SIGNAL(typesetterFinished(int)), this, SLOT(pdfFinished(int)));
delete _poTypesetCtl;
_poTypesetCtl = nullptr; // Destruktor may not delete the same object again
}
}
/*!
Exports the document \a poDoc to LilyPond first and create a PDF from it
using the Typesetter instance.
*/
void CAPDFExport::exportDocumentImpl(CADocument* poDoc)
{
if (poDoc->sheetList().size() < 1) {
//TODO: no sheets, raise an error
return;
}
// We cannot create the typesetter instance (a QProcess in the end)
// in the constructor as it's parent would be in a different thread!
startExport();
// The exportDocument method defines the temporary file name and
// directory, so we can only read it after the creation
_poTypesetCtl->exportDocument(poDoc);
// actual PDF creation is done now
runTypesetter();
}
/*!
Exports the sheet \a poSheet to LilyPond first and create a PDF from it
using the Typesetter instance.
*/
void CAPDFExport::exportSheetImpl(CASheet* poSheet)
{
// We cannot create the typesetter instance (a QProcess in the end)
// in the constructor as it's parent would be in a different thread!
startExport();
// The exportSheet method defines the temporary file name and
// directory, so we can only read it after the creation
_poTypesetCtl->exportSheet(poSheet);
// actual PDF creation is done now
runTypesetter();
}
/*!
Run creation of PDF file after deleting a potential old one
*/
void CAPDFExport::runTypesetter()
{
const QString roTempPath = _poTypesetCtl->getTempFilePath();
_poTypesetCtl->setTSetOption(QString("o"), roTempPath);
// Remove old pdf file first, but ignore error (file might not exist)
if (!file()->remove()) {
qWarning("PDFExport: Could not remove old pdf file %s, error %s", qPrintable(file()->fileName()),
qPrintable(file()->errorString()));
file()->unsetError();
}
_poTypesetCtl->runTypesetter(); // create pdf
// as we are not in the main thread wait until we are finished
if (_poTypesetCtl->waitForFinished(-1) == false) {
qWarning("PDFExport: Typesetter %s was not finished", "lilypond");
}
}
/*!
Show the output \a roOutput of the typesetter on the console
*/
void CAPDFExport::outputTypsetterOutput(const QByteArray& roOutput)
{
// Output to error console
qDebug("%s", roOutput.data());
}
/*!
When the typesetter is finished copy the pdf file to the defined destination
*/
void CAPDFExport::pdfFinished(int iExitCode)
{
setStatus(iExitCode);
QFile oTempFile(getTempFilePath() + ".pdf");
oTempFile.setFileName(getTempFilePath() + ".pdf");
qDebug("Exporting PDF file %s", file()->fileName().toLatin1().data());
if (!iExitCode && !oTempFile.copy(file()->fileName())) // Rename it, so we can delete the temporary file
{
qCritical("PDFExport: Could not copy temporary file %s, error %s", qPrintable(oTempFile.fileName()),
qPrintable(oTempFile.errorString()));
return;
}
emit pdfIsFinished(iExitCode);
// Remove temporary files.
if (!oTempFile.remove()) {
qWarning("PDFExport: Could not remove temporary file %s, error %s", qPrintable(oTempFile.fileName()),
qPrintable(oTempFile.errorString()));
oTempFile.unsetError();
}
oTempFile.setFileName(getTempFilePath() + ".ps");
// No warning as not every typesetter leaves postscript files behind
oTempFile.remove();
oTempFile.setFileName(getTempFilePath());
if (!oTempFile.remove()) {
qWarning("PDFExport: Could not remove temporary file %s, error %s", qPrintable(oTempFile.fileName()),
qPrintable(oTempFile.errorString()));
oTempFile.unsetError();
}
finishExport();
}
QString CAPDFExport::getTempFilePath()
{
return (_poTypesetCtl ? _poTypesetCtl->getTempFilePath() : "");
}
| 6,161
|
C++
|
.cpp
| 163
| 33.736196
| 180
| 0.716243
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,421
|
canorusmlexport.cpp
|
canorusmusic_canorus/src/export/canorusmlexport.cpp
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include <QDebug>
#include <QDir>
#include <QDomDocument>
#include <QString>
#include <QTextStream>
#include <QVariant>
#include "export/canorusmlexport.h"
#include "score/barline.h"
#include "score/clef.h"
#include "score/context.h"
#include "score/document.h"
#include "score/keysignature.h"
#include "score/muselement.h"
#include "score/note.h"
#include "score/resource.h"
#include "score/rest.h"
#include "score/sheet.h"
#include "score/staff.h"
#include "score/timesignature.h"
#include "score/voice.h"
#include "score/articulation.h"
#include "score/bookmark.h"
#include "score/crescendo.h"
#include "score/dynamic.h"
#include "score/fermata.h"
#include "score/fingering.h"
#include "score/instrumentchange.h"
#include "score/mark.h"
#include "score/repeatmark.h"
#include "score/ritardando.h"
#include "score/tempo.h"
#include "score/text.h"
#include "score/lyricscontext.h"
#include "score/syllable.h"
#include "score/figuredbasscontext.h"
#include "score/figuredbassmark.h"
#include "score/functionmark.h"
#include "score/functionmarkcontext.h"
#include "score/chordname.h"
#include "score/chordnamecontext.h"
CACanorusMLExport::CACanorusMLExport(QTextStream* stream)
: CAExport(stream)
{
}
CACanorusMLExport::~CACanorusMLExport()
{
}
/*!
Saves the document to CanorusML XML format.
It uses DOM object internally for writing the XML output.
*/
void CACanorusMLExport::exportDocumentImpl(CADocument* doc)
{
//int depth = 0;
out().setCodec("UTF-8");
// CADocument
QDomDocument dDoc("canorusml");
// Add encoding
dDoc.appendChild(dDoc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" "));
// Root node - <canorus-document>
QDomElement dCanorusDocument = dDoc.createElement("canorus-document");
dDoc.appendChild(dCanorusDocument);
// Add program version
QDomElement dCanorusVersion = dDoc.createElement("canorus-version");
dCanorusDocument.appendChild(dCanorusVersion);
dCanorusVersion.appendChild(dDoc.createTextNode(CANORUS_VERSION));
// Document content node - <document>
QDomElement dDocument = dDoc.createElement("document");
dCanorusDocument.appendChild(dDocument);
if (!doc->title().isEmpty())
dDocument.setAttribute("title", doc->title());
if (!doc->subtitle().isEmpty())
dDocument.setAttribute("subtitle", doc->subtitle());
if (!doc->composer().isEmpty())
dDocument.setAttribute("composer", doc->composer());
if (!doc->arranger().isEmpty())
dDocument.setAttribute("arranger", doc->arranger());
if (!doc->poet().isEmpty())
dDocument.setAttribute("poet", doc->poet());
if (!doc->textTranslator().isEmpty())
dDocument.setAttribute("text-translator", doc->textTranslator());
if (!doc->dedication().isEmpty())
dDocument.setAttribute("dedication", doc->dedication());
if (!doc->copyright().isEmpty())
dDocument.setAttribute("copyright", doc->copyright());
if (!doc->comments().isEmpty())
dDocument.setAttribute("comments", doc->comments());
dDocument.setAttribute("date-created", doc->dateCreated().toString(Qt::ISODate));
dDocument.setAttribute("date-last-modified", doc->dateLastModified().toString(Qt::ISODate));
dDocument.setAttribute("time-edited", doc->timeEdited());
for (int sheetIdx = 0; sheetIdx < doc->sheetList().size(); sheetIdx++) {
setProgress(qRound((static_cast<float>(sheetIdx) / doc->sheetList().size()) * 100));
// CASheet
QDomElement dSheet = dDoc.createElement("sheet");
dDocument.appendChild(dSheet);
dSheet.setAttribute("name", doc->sheetList()[sheetIdx]->name());
for (int contextIdx = 0; contextIdx < doc->sheetList()[sheetIdx]->contextList().size(); contextIdx++) {
// (CAContext)
CAContext* c = doc->sheetList()[sheetIdx]->contextList()[contextIdx];
switch (c->contextType()) {
case CAContext::Staff: {
// CAStaff
CAStaff* staff = static_cast<CAStaff*>(c);
QDomElement dStaff = dDoc.createElement("staff");
dSheet.appendChild(dStaff);
dStaff.setAttribute("name", staff->name());
dStaff.setAttribute("number-of-lines", staff->numberOfLines());
for (int voiceIdx = 0; voiceIdx < staff->voiceList().size(); voiceIdx++) {
// CAVoice
CAVoice* v = staff->voiceList()[voiceIdx];
QDomElement dVoice = dDoc.createElement("voice");
dStaff.appendChild(dVoice);
dVoice.setAttribute("name", v->name());
dVoice.setAttribute("midi-channel", v->midiChannel());
dVoice.setAttribute("midi-program", v->midiProgram());
dVoice.setAttribute("midi-pitch-offset", v->midiPitchOffset());
dVoice.setAttribute("stem-direction", CANote::stemDirectionToString(v->stemDirection()));
exportVoiceImpl(v, dVoice); // writes notes, clefs etc.
}
break;
}
case CAContext::LyricsContext: {
// CALyricsContext
CALyricsContext* lc = static_cast<CALyricsContext*>(c);
QDomElement dlc = dDoc.createElement("lyrics-context");
dSheet.appendChild(dlc);
dlc.setAttribute("name", lc->name());
dlc.setAttribute("stanza-number", lc->stanzaNumber());
dlc.setAttribute("associated-voice-idx", doc->sheetList()[sheetIdx]->voiceList().indexOf(lc->associatedVoice()));
QList<CASyllable*> syllables = lc->syllableList();
for (int i = 0; i < syllables.size(); i++) {
QDomElement s = dDoc.createElement("syllable");
dlc.appendChild(s);
s.setAttribute("time-start", syllables[i]->timeStart());
s.setAttribute("time-length", syllables[i]->timeLength());
s.setAttribute("text", syllables[i]->text());
s.setAttribute("hyphen", syllables[i]->hyphenStart());
s.setAttribute("melisma", syllables[i]->melismaStart());
if (syllables[i]->associatedVoice() && doc->sheetList()[sheetIdx]->voiceList().contains(syllables[i]->associatedVoice())) {
s.setAttribute("associated-voice-idx", doc->sheetList()[sheetIdx]->voiceList().indexOf(syllables[i]->associatedVoice()));
}
}
break;
}
case CAContext::FiguredBassContext: {
exportFiguredBass(static_cast<CAFiguredBassContext*>(c), dSheet);
break;
}
case CAContext::FunctionMarkContext: {
// CAFunctionMarkContext
CAFunctionMarkContext* fmc = static_cast<CAFunctionMarkContext*>(c);
QDomElement dFmc = dDoc.createElement("function-mark-context");
dSheet.appendChild(dFmc);
dFmc.setAttribute("name", fmc->name());
QList<CAFunctionMark*> elts = fmc->functionMarkList();
for (int i = 0; i < elts.size(); i++) {
QDomElement dFm = dDoc.createElement("function-mark");
dFmc.appendChild(dFm);
dFm.setAttribute("time-start", elts[i]->timeStart());
dFm.setAttribute("time-length", elts[i]->timeLength());
dFm.setAttribute("function", CAFunctionMark::functionTypeToString(elts[i]->function()));
dFm.setAttribute("minor", elts[i]->isMinor());
dFm.setAttribute("chord-area", CAFunctionMark::functionTypeToString(elts[i]->chordArea()));
dFm.setAttribute("chord-area-minor", elts[i]->isChordAreaMinor());
dFm.setAttribute("tonic-degree", CAFunctionMark::functionTypeToString(elts[i]->tonicDegree()));
dFm.setAttribute("tonic-degree-minor", elts[i]->isTonicDegreeMinor());
exportDiatonicKey(elts[i]->key(), dFm);
//dFm.setAttribute( "altered-degrees", elts[i]->alteredDegrees() );
//dFm.setAttribute( "added-degrees", elts[i]->addedDegrees() );
dFm.setAttribute("ellipse", elts[i]->isPartOfEllipse());
}
break;
}
case CAContext::ChordNameContext: {
// CAChordNameContext
CAChordNameContext* cnc = static_cast<CAChordNameContext*>(c);
QDomElement dCnc = dDoc.createElement("chord-name-context");
dSheet.appendChild(dCnc);
dCnc.setAttribute("name", cnc->name());
QList<CAChordName*> elts = cnc->chordNameList();
for (int i = 0; i < elts.size(); i++) {
QDomElement dCn = dDoc.createElement("chord-name");
dCnc.appendChild(dCn);
dCn.setAttribute("time-start", elts[i]->timeStart());
dCn.setAttribute("time-length", elts[i]->timeLength());
exportDiatonicPitch(elts[i]->diatonicPitch(), dCn);
dCn.setAttribute("quality-modifier", elts[i]->qualityModifier());
}
break;
}
}
}
}
exportResources(doc, dCanorusDocument);
out() << dDoc.toString();
}
/*!
Used for writing the voice node in XML output.
It uses DOM object internally for writing the XML output.
This method is usually called by saveDocument().
\sa exportDocumentImpl()
*/
void CACanorusMLExport::exportVoiceImpl(CAVoice* voice, QDomElement& dVoice)
{
QDomDocument dDoc = dVoice.ownerDocument();
for (int i = 0; i < voice->musElementList().size(); i++) {
CAMusElement* curElt = voice->musElementList()[i];
QDomElement dElt;
switch (curElt->musElementType()) {
case CAMusElement::Note: {
CANote* note = static_cast<CANote*>(curElt);
if (note->isFirstInTuplet()) {
_dTuplet = dDoc.createElement("tuplet");
_dTuplet.setAttribute("number", note->tuplet()->number());
_dTuplet.setAttribute("actual-number", note->tuplet()->actualNumber());
dVoice.appendChild(_dTuplet);
}
dElt = dDoc.createElement("note");
if (note->tuplet()) {
_dTuplet.appendChild(dElt);
} else {
dVoice.appendChild(dElt);
}
if (note->stemDirection() != CANote::StemPreferred)
dElt.setAttribute("stem-direction", CANote::stemDirectionToString(note->stemDirection()));
exportPlayableLength(note->playableLength(), dElt);
exportDiatonicPitch(note->diatonicPitch(), dElt);
if (note->tieStart()) {
QDomElement dTie = dDoc.createElement("tie");
dElt.appendChild(dTie);
dTie.setAttribute("slur-style", CASlur::slurStyleToString(note->tieStart()->slurStyle()));
dTie.setAttribute("slur-direction", CASlur::slurDirectionToString(note->tieStart()->slurDirection()));
}
if (note->slurStart()) {
QDomElement dSlur = dDoc.createElement("slur-start");
dElt.appendChild(dSlur);
dSlur.setAttribute("slur-style", CASlur::slurStyleToString(note->slurStart()->slurStyle()));
dSlur.setAttribute("slur-direction", CASlur::slurDirectionToString(note->slurStart()->slurDirection()));
}
if (note->slurEnd()) {
QDomElement dSlur = dDoc.createElement("slur-end");
dElt.appendChild(dSlur);
}
if (note->phrasingSlurStart()) {
QDomElement dPhrasingSlur = dDoc.createElement("phrasing-slur-start");
dElt.appendChild(dPhrasingSlur);
dPhrasingSlur.setAttribute("slur-style", CASlur::slurStyleToString(note->phrasingSlurStart()->slurStyle()));
dPhrasingSlur.setAttribute("slur-direction", CASlur::slurDirectionToString(note->phrasingSlurStart()->slurDirection()));
}
if (note->phrasingSlurEnd()) {
QDomElement dPhrasingSlur = dDoc.createElement("phrasing-slur-end");
dElt.appendChild(dPhrasingSlur);
}
break;
}
case CAMusElement::Rest: {
CARest* rest = static_cast<CARest*>(curElt);
if (rest->isFirstInTuplet()) {
_dTuplet = dDoc.createElement("tuplet");
_dTuplet.setAttribute("number", rest->tuplet()->number());
_dTuplet.setAttribute("actual-number", rest->tuplet()->actualNumber());
dVoice.appendChild(_dTuplet);
}
dElt = dDoc.createElement("rest");
if (rest->tuplet()) {
_dTuplet.appendChild(dElt);
} else {
dVoice.appendChild(dElt);
}
dElt.setAttribute("rest-type", CARest::restTypeToString(rest->restType()));
exportPlayableLength(rest->playableLength(), dElt);
break;
}
case CAMusElement::Clef: {
CAClef* clef = static_cast<CAClef*>(curElt);
dElt = dDoc.createElement("clef");
dVoice.appendChild(dElt);
dElt.setAttribute("clef-type", CAClef::clefTypeToString(clef->clefType()));
dElt.setAttribute("c1", clef->c1());
dElt.setAttribute("offset", clef->offset());
break;
}
case CAMusElement::KeySignature: {
CAKeySignature* key = static_cast<CAKeySignature*>(curElt);
dElt = dDoc.createElement("key-signature");
dVoice.appendChild(dElt);
dElt.setAttribute("key-signature-type", CAKeySignature::keySignatureTypeToString(key->keySignatureType()));
if (key->keySignatureType() == CAKeySignature::MajorMinor) {
exportDiatonicKey(key->diatonicKey(), dElt);
} else if (key->keySignatureType() == CAKeySignature::Modus) {
dElt.setAttribute("modus", CAKeySignature::modusToString(key->modus()));
}
//! \todo Custom accidentals in key signature saving -Matevz
// exportDiatonicPitch( key->diatonicKey().diatonicPitch(), dKey );
break;
}
case CAMusElement::TimeSignature: {
CATimeSignature* time = static_cast<CATimeSignature*>(curElt);
dElt = dDoc.createElement("time-signature");
dVoice.appendChild(dElt);
dElt.setAttribute("time-signature-type", CATimeSignature::timeSignatureTypeToString(time->timeSignatureType()));
dElt.setAttribute("beats", time->beats());
dElt.setAttribute("beat", time->beat());
break;
}
case CAMusElement::Barline: {
CABarline* barline = static_cast<CABarline*>(curElt);
dElt = dDoc.createElement("barline");
dVoice.appendChild(dElt);
dElt.setAttribute("barline-type", CABarline::barlineTypeToString(barline->barlineType()));
break;
}
case CAMusElement::MidiNote:
case CAMusElement::Slur:
case CAMusElement::Tuplet:
case CAMusElement::Syllable:
case CAMusElement::FunctionMark:
case CAMusElement::FiguredBassMark:
case CAMusElement::Mark:
case CAMusElement::ChordName:
case CAMusElement::Undefined:
qDebug() << "Error: Element" << curElt << "should not be member of the voice. musElementType:" << curElt->musElementType();
break;
}
exportTime(curElt, dElt);
exportColor(curElt, dElt);
exportMarks(curElt, dElt);
}
}
void CACanorusMLExport::exportFiguredBass(CAFiguredBassContext* fbc, QDomElement& dSheet)
{
QDomElement dFbc = dSheet.ownerDocument().createElement("figured-bass-context");
dSheet.appendChild(dFbc);
dFbc.setAttribute("name", fbc->name());
QList<CAFiguredBassMark*> elts = fbc->figuredBassMarkList();
for (int i = 0; i < elts.size(); i++) {
QDomElement dFbm = dSheet.ownerDocument().createElement("figured-bass-mark");
dFbc.appendChild(dFbm);
dFbm.setAttribute("time-start", elts[i]->timeStart());
dFbm.setAttribute("time-length", elts[i]->timeLength());
exportColor(elts[i], dFbm);
for (int j = 0; j < elts[i]->numbers().size(); j++) {
QDomElement dFbn = dSheet.ownerDocument().createElement("figured-bass-number");
dFbm.appendChild(dFbn);
dFbn.setAttribute("number", elts[i]->numbers()[j]);
if (elts[i]->accs().contains(elts[i]->numbers()[j])) {
dFbn.setAttribute("accs", elts[i]->accs()[elts[i]->numbers()[j]]);
}
}
}
}
void CACanorusMLExport::exportMarks(CAMusElement* elt, QDomElement& domElt)
{
for (int i = 0; i < elt->markList().size(); i++) {
CAMark* mark = elt->markList()[i];
if (!mark->isCommon() || elt->musElementType() != CAMusElement::Note || (elt->musElementType() == CAMusElement::Note && static_cast<CANote*>(elt)->isFirstInChord())) {
QDomElement dMark = domElt.ownerDocument().createElement("mark");
domElt.appendChild(dMark);
dMark.setAttribute("time-start", mark->timeStart());
dMark.setAttribute("time-length", mark->timeLength());
dMark.setAttribute("mark-type", CAMark::markTypeToString(mark->markType()));
switch (mark->markType()) {
case CAMark::Text: {
CAText* text = static_cast<CAText*>(mark);
dMark.setAttribute("text", text->text());
break;
}
case CAMark::Tempo: {
CATempo* tempo = static_cast<CATempo*>(mark);
dMark.setAttribute("bpm", tempo->bpm());
exportPlayableLength(tempo->beat(), dMark);
break;
}
case CAMark::Ritardando: {
CARitardando* rit = static_cast<CARitardando*>(mark);
dMark.setAttribute("ritardando-type", CARitardando::ritardandoTypeToString(rit->ritardandoType()));
dMark.setAttribute("final-tempo", rit->finalTempo());
break;
}
case CAMark::Dynamic: {
CADynamic* dyn = static_cast<CADynamic*>(mark);
dMark.setAttribute("volume", dyn->volume());
dMark.setAttribute("text", dyn->text());
break;
}
case CAMark::Crescendo: {
CACrescendo* cresc = static_cast<CACrescendo*>(mark);
dMark.setAttribute("final-volume", cresc->finalVolume());
dMark.setAttribute("crescendo-type", CACrescendo::crescendoTypeToString(cresc->crescendoType()));
break;
}
case CAMark::Pedal: {
// none
break;
}
case CAMark::InstrumentChange: {
CAInstrumentChange* ic = static_cast<CAInstrumentChange*>(mark);
dMark.setAttribute("instrument", ic->instrument());
break;
}
case CAMark::BookMark: {
CABookMark* b = static_cast<CABookMark*>(mark);
dMark.setAttribute("text", b->text());
break;
}
case CAMark::RehersalMark: {
// none
break;
}
case CAMark::Fermata: {
CAFermata* f = static_cast<CAFermata*>(mark);
dMark.setAttribute("fermata-type", CAFermata::fermataTypeToString(f->fermataType()));
break;
}
case CAMark::RepeatMark: {
CARepeatMark* r = static_cast<CARepeatMark*>(mark);
dMark.setAttribute("repeat-mark-type", CARepeatMark::repeatMarkTypeToString(r->repeatMarkType()));
if (r->repeatMarkType() == CARepeatMark::Volta) {
dMark.setAttribute("volta-number", r->voltaNumber());
}
break;
}
case CAMark::Articulation: {
CAArticulation* a = static_cast<CAArticulation*>(mark);
dMark.setAttribute("articulation-type", CAArticulation::articulationTypeToString(a->articulationType()));
break;
}
case CAMark::Fingering: {
CAFingering* f = static_cast<CAFingering*>(mark);
dMark.setAttribute("original", f->isOriginal());
for (int i = 0; i < f->fingerList().size(); i++)
dMark.setAttribute(QString("finger%1").arg(i), CAFingering::fingerNumberToString(f->fingerList()[i]));
break;
}
case CAMark::Undefined:
break;
}
exportColor(mark, dMark);
}
}
}
void CACanorusMLExport::exportColor(CAMusElement* elt, QDomElement& domParent)
{
if (elt->color().isValid()) {
domParent.setAttribute("color", QVariant(elt->color()).toString());
}
}
void CACanorusMLExport::exportTime(CAMusElement* elt, QDomElement& domParent)
{
domParent.setAttribute("time-start", elt->timeStart());
if (elt->isPlayable()) {
domParent.setAttribute("time-length", elt->timeLength());
}
}
void CACanorusMLExport::exportPlayableLength(CAPlayableLength l, QDomElement& domParent)
{
QDomElement dl = domParent.ownerDocument().createElement("playable-length");
domParent.appendChild(dl);
dl.setAttribute("music-length", CAPlayableLength::musicLengthToString(l.musicLength()));
dl.setAttribute("dotted", l.dotted());
}
void CACanorusMLExport::exportDiatonicPitch(CADiatonicPitch p, QDomElement& domParent)
{
QDomElement dp = domParent.ownerDocument().createElement("diatonic-pitch");
domParent.appendChild(dp);
dp.setAttribute("note-name", p.noteName());
dp.setAttribute("accs", p.accs());
}
void CACanorusMLExport::exportDiatonicKey(CADiatonicKey k, QDomElement& domParent)
{
QDomElement dk = domParent.ownerDocument().createElement("diatonic-key");
domParent.appendChild(dk);
dk.setAttribute("gender", CADiatonicKey::genderToString(k.gender()));
exportDiatonicPitch(k.diatonicPitch(), dk);
}
/*!
Exports the resources to exported filename files/ directory.
There are 4 possible scenarios:
1) Linked resource, resource is remote (eg. http, https resource on the web):
Only resource url is stored inside the xml file.
2) Linked resource, resource is local (eg. large video on the disk):
Relative path to the resource is calculated from the directory where the
document is being saved.
3) Attached resource:
Resource is copied from the tmp/ directory to the directory where the document
is being saved + "filename files/". eg. "content.xml files/myImageXXXX.png"
*/
void CACanorusMLExport::exportResources(CADocument* doc, QDomElement& dCanorusDocument)
{
for (int i = 0; i < doc->resourceList().size(); i++) {
std::shared_ptr<CAResource> r = doc->resourceList()[i];
QUrl url;
if (r->isLinked()) {
// linked resource, calculate relative path of the resource to the document where it's being saved
if (r->url().scheme() == "file" && file()) {
// local file
QDir outDir(QFileInfo(*file()).absolutePath());
url = QUrl::fromLocalFile(outDir.relativeFilePath(r->url().toLocalFile()));
} else {
// remote file
url = r->url();
}
} else if (file()) {
// attached resource, copy the resource to "filename files/" directory
QString targetDir = QFileInfo(*file()).absolutePath();
QString targetFileName = QFileInfo(*file()).fileName();
// create directory if it doesn't exist
if (!QDir(targetDir + "/" + targetFileName + " files").exists()) {
QDir(targetDir).mkdir(targetFileName + " files");
}
// copies resource /tmp/qt_tempXXXX -> myDocument files/qt_tempXXXX
r->copy(targetDir + "/" + targetFileName + " files/" + QFileInfo(r->url().toLocalFile()).fileName());
// generates relative path
url = QUrl::fromLocalFile(targetFileName + " files/" + QFileInfo(r->url().toLocalFile()).fileName());
} else {
// saving to stream - usually when compressing to .can format
// copying is done in CACanExport class
url = QUrl::fromLocalFile(QString("content.xml files/") + QFileInfo(r->url().toLocalFile()).fileName());
}
QDomElement dResource = dCanorusDocument.ownerDocument().createElement("resource");
dResource.setAttribute("name", r->name());
dResource.setAttribute("description", r->description());
dResource.setAttribute("linked", r->isLinked());
dResource.setAttribute("resource-type", CAResource::resourceTypeToString(r->resourceType()));
dResource.setAttribute("url", url.toString());
dCanorusDocument.appendChild(dResource);
}
}
| 25,774
|
C++
|
.cpp
| 533
| 37.373358
| 175
| 0.604045
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,422
|
lilypondexport.cpp
|
canorusmusic_canorus/src/export/lilypondexport.cpp
|
/*!
Copyright (c) 2007-2022, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include <QFileInfo>
#include <QList>
#include <QRegExp>
#include <QTextStream>
#include "export/lilypondexport.h"
#include "score/chordnamecontext.h"
#include "score/document.h"
#include "score/sheet.h"
#include "score/staff.h"
#include "score/voice.h"
#include "score/articulation.h"
#include "score/barline.h"
#include "score/chordname.h"
#include "score/dynamic.h"
#include "score/fingering.h"
#include "score/mark.h"
#include "score/repeatmark.h"
#include "score/ritardando.h"
#include "score/tempo.h"
#include "score/text.h"
#include "score/tuplet.h"
/*!
\class CALilyPondExport
\brief LilyPond export filter
This class is used to export the document or parts of the document to LilyPond syntax.
The most common use is to simply call one of the constructors
\code
CALilyPondExport( myDocument, &textStream );
\endcode
\a textStream is usually the file stream or the content of the score source view widget.
\sa CALilyPondImport
*/
/*!
Constructor for the lilypond export. Called when viewing a single voice source in
Lily syntax or exporting the whole document to a file.
Uses \a out for the output.
*/
CALilyPondExport::CALilyPondExport(QTextStream* out)
: CAExport(out)
{
setIndentLevel(0);
setCurDocument(nullptr);
_voltaBracketOccured = false;
_voltaBracketIsOpen = false;
_voltaFunctionWritten = false;
_voltaBracketFinishAtRepeat = false;
_voltaBracketFinishAtBar = false;
_timeSignatureFound = false;
}
/*!
Exports the given voice music elements to LilyPond syntax.
\sa CALilypondImport
*/
void CALilyPondExport::exportVoiceImpl(CAVoice* v)
{
setCurVoice(v);
_curStreamTime = 0;
_lastPlayableLength = CAPlayableLength::Undefined;
bool anacrusisCheck = true; // process upbeat eventually
CATimeSignature* time = nullptr;
int barNumber = 1;
// Write \relative note for the first note
_lastNotePitch = writeRelativeIntro();
// start of the voice block
out() << "{\n";
indentMore();
indent();
for (int i = 0; i < v->musElementList().size(); i++, out() << " ") { // append blank after each element
// (CAMusElement)
switch (v->musElementList()[i]->musElementType()) {
case CAMusElement::Clef: {
// CAClef
CAClef* clef = static_cast<CAClef*>(v->musElementList()[i]);
if (clef->timeStart() != _curStreamTime)
break; //! \todo If the time isn't the same, insert hidden rests to fill the needed time
out() << "\\clef \"";
out() << clefTypeToLilyPond(clef->clefType(), clef->c1(), clef->offset());
out() << "\"";
break;
}
case CAMusElement::KeySignature: {
// CAKeySignature
CAKeySignature* key = static_cast<CAKeySignature*>(v->musElementList()[i]);
if (key->timeStart() != _curStreamTime)
break; //! \todo If the time isn't the same, insert hidden rests to fill the needed time
out() << "\\key "
<< diatonicPitchToLilyPond(key->diatonicKey().diatonicPitch()) << " "
<< diatonicKeyGenderToLilyPond(key->diatonicKey().gender());
break;
}
case CAMusElement::TimeSignature: {
// CATimeSignature, remember for anacrusis processing
time = static_cast<CATimeSignature*>(v->musElementList()[i]);
if (time->timeStart() != _curStreamTime)
break; //! \todo If the time isn't the same, insert hidden rests to fill the needed time
out() << "\\time " << time->beats() << "/" << time->beat();
// set this flag to allow the time signature engraver
_timeSignatureFound = true;
break;
}
case CAMusElement::Barline: {
// CABarline
CABarline* bar = static_cast<CABarline*>(v->musElementList()[i]);
if (bar->timeStart() != _curStreamTime)
break; //! \todo If the time isn't the same, insert hidden rests to fill the needed time
if (_voltaBracketFinishAtRepeat && (bar->barlineType() == CABarline::RepeatClose || bar->barlineType() == CABarline::RepeatCloseOpen)) {
out() << " \\set Score.repeatCommands = #'((volta #f)) ";
_voltaBracketFinishAtRepeat = false;
}
if (_voltaBracketFinishAtBar) {
out() << " \\set Score.repeatCommands = #'((volta #f)) ";
_voltaBracketFinishAtBar = false;
}
if (bar->barlineType() == CABarline::Single)
out() << "| % bar " << barNumber << "\n ";
else
out() << "\\bar \"" << barlineTypeToLilyPond(bar->barlineType()) << "\""
<< " % bar " << barNumber << "\n ";
barNumber++;
// set this flag to allow the time signature engraver and bar line engraver
_timeSignatureFound = true;
if (bar->barlineType() == CABarline::RepeatOpen || bar->barlineType() == CABarline::RepeatCloseOpen) {
_voltaBracketOccured = false;
}
if (_voltaBracketIsOpen) {
out() << " \\set Score.repeatCommands = #'((volta #f)) ";
_voltaBracketIsOpen = false;
}
break;
}
case CAMusElement::Note:
case CAMusElement::Rest:
case CAMusElement::MidiNote:
case CAMusElement::Slur:
case CAMusElement::Tuplet:
case CAMusElement::Syllable:
case CAMusElement::FunctionMark:
case CAMusElement::FiguredBassMark:
case CAMusElement::Mark:
case CAMusElement::ChordName:
case CAMusElement::Undefined:
break;
}
if (v->musElementList()[i]->isPlayable()) {
if (anacrusisCheck) { // first check upbeat bar, only once
doAnacrusisCheck(time);
anacrusisCheck = false;
}
exportMarksBeforeElement(v->musElementList()[i]); // A volta bracket has to come before a playable
exportPlayable(static_cast<CAPlayable*>(v->musElementList()[i]));
} else {
exportMarksAfterElement(v->musElementList()[i]);
}
}
// end of the voice block
indentLess();
indent();
out() << "\n}";
}
void CALilyPondExport::exportPlayable(CAPlayable* elt)
{
if (elt->isFirstInTuplet()) {
out() << "\\times " << elt->tuplet()->actualNumber() << "/" << elt->tuplet()->number() << " { ";
}
switch (elt->musElementType()) {
case CAMusElement::Note: {
// CANote
CANote* note = static_cast<CANote*>(elt);
if (note->timeStart() != _curStreamTime)
break; //! \todo If the time isn't the same, insert hidden rests to fill the needed time
if (note->isPartOfChord() && note->isFirstInChord()) {
out() << "<";
}
// write the note name
out() << relativePitchToString(note->diatonicPitch(), _lastNotePitch);
if (note->forceAccidentals()) {
out() << "!";
}
if (!note->isPartOfChord() && _lastPlayableLength != note->playableLength()) {
out() << playableLengthToLilyPond(note->playableLength());
}
if (note->tieStart())
out() << "~";
// export note-specific marks
exportNoteMarks(note);
_lastNotePitch = note->diatonicPitch();
if (!note->isPartOfChord())
_lastPlayableLength = note->playableLength();
// finish the chord stanza if that's the last note of the chord
if (note->isPartOfChord() && note->isLastInChord()) {
out() << ">";
if (_lastPlayableLength != note->playableLength()) {
out() << playableLengthToLilyPond(note->playableLength());
}
_lastNotePitch = note->getChord().at(0)->diatonicPitch();
_lastPlayableLength = note->playableLength();
}
// place slurs and phrasing slurs
if ((!note->isPartOfChord() && note->slurEnd()) || (note->isPartOfChord() && note->isLastInChord() && note->getChord().at(0)->slurEnd())) {
out() << ")";
}
if ((!note->isPartOfChord() && note->phrasingSlurEnd()) || (note->isPartOfChord() && note->isLastInChord() && note->getChord().at(0)->phrasingSlurEnd())) {
out() << "\\)";
}
if ((!note->isPartOfChord() && note->slurStart()) || (note->isPartOfChord() && note->isLastInChord() && note->getChord().at(0)->slurStart())) {
out() << "(";
}
if ((!note->isPartOfChord() && note->phrasingSlurStart()) || (note->isPartOfChord() && note->isLastInChord() && note->getChord().at(0)->phrasingSlurStart())) {
out() << "\\(";
}
// export chord marks at the end
if (!note->isPartOfChord() || note->isLastInChord()) {
exportMarksAfterElement(note->getChord()[0]);
}
// add to the stream time, if the note is not part of the chord or is the last one in the chord
if (!note->isPartOfChord() || (note->isPartOfChord() && note->isLastInChord()))
_curStreamTime += note->timeLength();
break;
}
case CAMusElement::Rest: {
// CARest
CARest* rest = static_cast<CARest*>(elt);
if (rest->timeStart() != _curStreamTime)
break; //! \todo If the time isn't the same, insert hidden rests to fill the needed time
out() << restTypeToLilyPond(rest->restType());
if (_lastPlayableLength != rest->playableLength()) {
out() << playableLengthToLilyPond(rest->playableLength());
}
exportMarksAfterElement(rest);
_lastPlayableLength = rest->playableLength();
_curStreamTime += rest->timeLength();
break;
}
case CAMusElement::Clef:
case CAMusElement::Barline:
case CAMusElement::TimeSignature:
case CAMusElement::KeySignature:
case CAMusElement::MidiNote:
case CAMusElement::Slur:
case CAMusElement::Tuplet:
case CAMusElement::Syllable:
case CAMusElement::FunctionMark:
case CAMusElement::FiguredBassMark:
case CAMusElement::Mark:
case CAMusElement::ChordName:
case CAMusElement::Undefined:
break;
}
if (elt->isLastInTuplet()) {
out() << "} ";
}
}
/*!
Exports the marks for the given \a elt chord, rest or non-playable music
element.
For exporting note-specific marks (eg. fingering), see exportNoteMarks().
\sa exportNoteMarks()
*/
void CALilyPondExport::exportMarksAfterElement(CAMusElement* elt)
{
for (CAMark* curMark : elt->markList()) {
switch (curMark->markType()) {
case CAMark::Text: {
// Don't export the mark when it is an volta bracket and was sent out already before the playable.
QRegExp vr = QRegExp(_regExpVoltaRepeat);
QRegExp vb = QRegExp(_regExpVoltaBar);
if (vr.indexIn(qPrintable(static_cast<CAText*>(curMark)->text())) < 0 && vb.indexIn(qPrintable(static_cast<CAText*>(curMark)->text())) < 0) {
out() << "^\"" << static_cast<CAText*>(curMark)->text() << "\" ";
}
break;
}
case CAMark::Dynamic: {
CADynamic* d = static_cast<CADynamic*>(curMark);
if (CADynamic::dynamicTextFromString(d->text()) == CADynamic::Custom)
break;
out() << "\\";
out() << d->text();
out() << " ";
break;
}
case CAMark::RehersalMark: {
out() << "\\mark \\default ";
break;
}
case CAMark::Fermata: {
out() << "\\fermata ";
break;
}
case CAMark::Articulation: {
switch (static_cast<CAArticulation*>(curMark)->articulationType()) {
case CAArticulation::Accent:
out() << "-> ";
break;
case CAArticulation::Marcato:
out() << "-^ ";
break;
case CAArticulation::Staccato:
out() << "-. ";
break;
case CAArticulation::Tenuto:
out() << "-- ";
break;
case CAArticulation::Prall:
out() << "\\prall ";
break;
case CAArticulation::PrallUp:
out() << "\\prallup ";
break;
case CAArticulation::PrallDown:
out() << "\\pralldown ";
break;
case CAArticulation::UpPrall:
out() << "\\upprall ";
break;
case CAArticulation::DownPrall:
out() << "\\downprall ";
break;
case CAArticulation::PrallPrall:
out() << "\\prallprall ";
break;
case CAArticulation::LinePrall:
out() << "\\lineprall ";
break;
case CAArticulation::PrallMordent:
out() << "\\prallmordent ";
break;
case CAArticulation::Mordent:
out() << "\\mordent ";
break;
case CAArticulation::UpMordent:
out() << "\\upmordent ";
break;
case CAArticulation::DownMordent:
out() << "\\downmordent ";
break;
case CAArticulation::Trill:
out() << "\\trill ";
break;
case CAArticulation::Turn:
out() << "\\turn ";
break;
case CAArticulation::ReverseTurn:
out() << "\\reverseturn ";
break;
case CAArticulation::Breath:
// Breath is handled at the very end.
break;
case CAArticulation::Staccatissimo:
case CAArticulation::Espressivo:
case CAArticulation::Portato:
case CAArticulation::UpBow:
case CAArticulation::DownBow:
case CAArticulation::Flageolet:
case CAArticulation::Open:
case CAArticulation::Stopped:
case CAArticulation::Undefined:
// TODO: Not implemented yet.
break;
}
break;
}
case CAMark::Ritardando: {
CARitardando* r = static_cast<CARitardando*>(curMark);
out() << "^\\markup{ \\text \\italic \"" << ((r->ritardandoType() == CARitardando::Ritardando) ? "rit." : "accel.") << "\"} ";
break;
}
case CAMark::RepeatMark: {
CARepeatMark* v = static_cast<CARepeatMark*>(curMark);
switch (v->repeatMarkType()) {
case CARepeatMark::Volta: {
int vn = v->voltaNumber();
if (_voltaBracketIsOpen || _voltaBracketOccured) {
out() << " \\set Score.repeatCommands = #'((volta #f) (volta \"" << vn << "\")) ";
_voltaBracketIsOpen = true;
} else {
out() << " \\set Score.repeatCommands = #'((volta \"" << vn << ".\"))";
_voltaBracketIsOpen = true;
_voltaBracketOccured = true;
}
break;
}
case CARepeatMark::Coda:
case CARepeatMark::Segno:
case CARepeatMark::VarCoda: {
out() << " \\mark \\markup { \\musicglyph \"scripts." <<
CARepeatMark::repeatMarkTypeToString(v->repeatMarkType()).toLower() <<
"\" }";
break;
}
case CARepeatMark::DalCoda:
case CARepeatMark::DalSegno:
case CARepeatMark::DalVarCoda: {
out() << " \\mark \\markup { \\italic \"Dal \" \\tiny \\raise #1 \\musicglyph \"scripts." <<
CARepeatMark::repeatMarkTypeToString(v->repeatMarkType()).mid(3).toLower() <<
"\" }";
break;
}
}
break;
}
case CAMark::Tempo:
case CAMark::Crescendo:
case CAMark::Pedal:
case CAMark::InstrumentChange:
case CAMark::Undefined:
case CAMark::BookMark:
case CAMark::Fingering:
break;
}
}
// Export breath articulation mark at the very end. Otherwise Lilypond complains.
for (CAMark* curMark : elt->markList()) {
switch (curMark->markType()) {
case CAMark::Articulation: {
switch (static_cast<CAArticulation*>(curMark)->articulationType()) {
case CAArticulation::Breath:
out() << "\\breathe ";
break;
default:
break;
}
}
default:
break;
}
}
}
/*!
Exports the note-specific marks like fingering.
\sa exportMarksAfterElement()
*/
void CALilyPondExport::exportNoteMarks(CANote* elt)
{
for (int i = 0; i < elt->markList().size(); i++) {
CAMark* curMark = elt->markList()[i];
switch (curMark->markType()) {
case CAMark::Fingering: {
CAFingering::CAFingerNumber n = static_cast<CAFingering*>(curMark)->finger();
if (n < 1 || n > 5)
break;
out() << "-";
out() << QString::number(static_cast<CAFingering*>(curMark)->finger());
out() << " ";
break;
}
case CAMark::Text:
case CAMark::Tempo:
case CAMark::Ritardando:
case CAMark::Crescendo:
case CAMark::Pedal:
case CAMark::InstrumentChange:
case CAMark::Undefined:
case CAMark::BookMark:
case CAMark::RepeatMark:
case CAMark::Dynamic:
case CAMark::RehersalMark:
case CAMark::Articulation:
case CAMark::Fermata:
break;
}
}
}
/*!
Exports a volta bracket which is currently just a \a elt mark beginning with voltaBar or voltaRepeat.
*/
void CALilyPondExport::exportMarksBeforeElement(CAMusElement* elt)
{
for (int i = 0; i < elt->markList().size(); i++) {
CAMark* curMark = elt->markList()[i];
switch (curMark->markType()) {
case CAMark::Text: {
QRegExp vr = QRegExp(_regExpVoltaRepeat);
QRegExp vb = QRegExp(_regExpVoltaBar);
QString txt;
if (vb.indexIn(qPrintable(static_cast<CAText*>(curMark)->text())) >= 0) {
txt = vb.cap(1);
_voltaBracketFinishAtBar = true;
} else if (vr.indexIn(qPrintable(static_cast<CAText*>(curMark)->text())) >= 0) {
txt = vr.cap(1);
_voltaBracketFinishAtRepeat = true;
}
if (_voltaBracketFinishAtRepeat || _voltaBracketFinishAtBar) {
out() << "\\voltaStart \\markup \\text { \"" << txt << "\" } ";
}
break;
}
case CAMark::Tempo: {
CATempo* t = static_cast<CATempo*>(curMark);
out() << "\\tempo " << playableLengthToLilyPond(t->beat()) << " = " << t->bpm() << " ";
break;
}
case CAMark::Fingering:
case CAMark::Ritardando:
case CAMark::Crescendo:
case CAMark::Pedal:
case CAMark::InstrumentChange:
case CAMark::Undefined:
case CAMark::BookMark:
case CAMark::RepeatMark:
case CAMark::Dynamic:
case CAMark::RehersalMark:
case CAMark::Articulation:
case CAMark::Fermata:
break;
}
}
}
/*!
Exports the lyrics in form:
\code
SopranoLyricsOne = \\lyricmode {
My bu -- ny is o -- ver the o -- cean __ My bu -- ny.
}
\endcode
*/
void CALilyPondExport::exportLyricsContextBlock(CALyricsContext* lc)
{
// Print Canorus voice name as a comment to help with debugging/tweaking
indent();
out() << "\n% " << lc->name() << "\n";
QString name = lc->name();
spellNumbers(name);
out() << name << " = \\lyricmode {\n";
indentMore();
indent();
exportLyricsContextImpl(lc);
indentLess();
out() << "\n}\n";
}
/*!
Exports the syllables only without the \\lyricmode {} frame.
*/
void CALilyPondExport::exportLyricsContextImpl(CALyricsContext* lc)
{
bool stanzaNumberExported = lc->stanzaNumber() == 0;
for (int i = 0; i < lc->syllableList().size(); i++) {
// Add space between the previous and the current syllable.
if (i > 0) {
out() << " ";
}
// Print stanza number right before the first syllable.
if (!stanzaNumberExported && !lc->syllableList()[i]->text().isEmpty()) {
out() << "\n";
indent();
out() << "\\set stanza = \"" << lc->stanzaNumber() << ".\"\n";
indent();
stanzaNumberExported = true;
}
out() << syllableToLilyPond(lc->syllableList()[i]);
}
}
/*!
Exports the chord names in form:
\code
ChordNamesOne = \\chordmode {
c2 f4:m cis:sus4
}
\endcode
*/
void CALilyPondExport::exportChordNameContextBlock(CAChordNameContext* cnc)
{
indent();
out() << "\n% " << cnc->name() << "\n";
QString name = cnc->name();
spellNumbers(name);
out() << name << " = \\chordmode {\n";
indentMore();
indent();
exportChordNameContextImpl(cnc);
indentLess();
out() << "\n}\n";
}
/*!
Exports the chord names of \a cnc without the \\chordmode {} wrappers.
*/
void CALilyPondExport::exportChordNameContextImpl(CAChordNameContext* cnc)
{
for (int i = 0; i < cnc->chordNameList().size(); i++) {
if (i > 0)
out() << " "; // space between chord names
CAChordName* cn = cnc->chordNameList()[i];
// determine length
//! \todo How do we treat tuplets?
QList<CAPlayableLength> pl = CAPlayableLength::timeLengthToPlayableLengthList(cn->timeLength());
if (pl.size()) {
if (cn->diatonicPitch().noteName() != CADiatonicPitch::Undefined) {
// chord change
out() << CADiatonicPitch::diatonicPitchToString(cn->diatonicPitch()) << playableLengthToLilyPond(pl[0]);
if (!cn->qualityModifier().isEmpty()) {
out() << ":" << cn->qualityModifier();
}
} else {
// diatonicPitch is Undefined - either chord name is empty or a syntax error.
// In either case, don't print the chord.
out() << "s" << playableLengthToLilyPond(pl[0]);
}
}
}
}
/*!
Writes the partial command before the first note if there is an upbeat.
*/
void CALilyPondExport::doAnacrusisCheck(CATimeSignature* time)
{
if (!time)
return; // without time signature no upbeat
// compute the lenght of the beat note, eigth/quarter/half are supported
int beatNoteLen = CAPlayableLength::playableLengthToTimeLength(CAPlayableLength::Quarter);
switch (time->beat()) {
case 4:
break;
case 8:
beatNoteLen /= 2;
break;
case 2:
beatNoteLen *= 2;
break;
default:
return; // at strange base notes no upbeat
}
int oneBar = time->beats() * beatNoteLen;
int barlen = 0;
for (int i = 0; i < curVoice()->musElementList().size(); i++) {
if (curVoice()->musElementList()[i]->isPlayable()) {
barlen += curVoice()->musElementList()[i]->timeLength();
}
// if it's a whole bar or beyond no upbeat (probably a staff without barlines)
if (barlen >= oneBar)
return;
if (curVoice()->musElementList()[i]->musElementType() == CAMusElement::Barline)
break;
}
CAPlayableLength res = CAPlayableLength(CAPlayableLength::HundredTwentyEighth);
out() << "\\partial "
<< res.musicLength()
<< "*" << barlen / res.playableLengthToTimeLength(res)
<< " ";
}
/*!
Writes the voice's \relative note intro and returns the note pitch for the current voice.
This function is usually used for writing the beginning of the voice.
\warning This function doesn't write "{" paranthesis to mark the start of the voice!
*/
CADiatonicPitch CALilyPondExport::writeRelativeIntro()
{
int i;
// find the first playable element and set the key signature if found any
for (i = 0;
(i < curVoice()->musElementList().size() && (curVoice()->musElementList()[i]->musElementType() != CAMusElement::Note));
i++)
;
// no playable elements present, return default c' pitch
if (i == curVoice()->musElementList().size())
return CADiatonicPitch(28);
CADiatonicPitch notePitch = static_cast<CANote*>(curVoice()->musElementList()[i])->diatonicPitch();
notePitch.setNoteName(((notePitch.noteName() + 3) / 7) * 7);
out() << "\\relative "
<< relativePitchToString(notePitch, CADiatonicPitch(21)) << " "; // LilyPond default C is c1
return notePitch;
}
/*!
This function returns the relative note pitch in LilyPond syntax on the given
Canorus pitch and previous note pitch.
eg. pitch=10, accs=1, prevPitch=5 => returns "f'"
\sa notePitchToLilyPond()
*/
const QString CALilyPondExport::relativePitchToString(CADiatonicPitch p, CADiatonicPitch prevPitch)
{
// write the note name
QString stringPitch = diatonicPitchToLilyPond(p);
// write , or ' to lower/higher a note
int delta = prevPitch.noteName() - p.noteName();
while (delta > 3) { // add the needed amount of the commas
stringPitch += ",";
delta -= 7;
}
while (delta < -3) { // add the needed amount of the apostrophes
stringPitch += "'";
delta += 7;
}
return stringPitch;
}
/*!
Converts the given clefType to LilyPond syntax.
*/
const QString CALilyPondExport::clefTypeToLilyPond(CAClef::CAClefType clefType, int c1orig, int offset)
{
QString type;
int c1 = c1orig + offset;
switch (clefType) {
case CAClef::G:
if (c1 == -2)
type = "treble";
else if (c1 == -4)
type = "french";
break;
case CAClef::F:
if (c1 == 10)
type = "bass";
else if (c1 == 8)
type = "varbaritone";
else if (c1 == 12)
type = "subbass";
break;
case CAClef::C:
if (c1 == 0)
type = "soprano";
else if (c1 == 2)
type = "mezzosoprano";
else if (c1 == 4)
type = "alto";
else if (c1 == 6)
type = "tenor";
else if (c1 == 8)
type = "baritone";
break;
case CAClef::PercussionHigh:
case CAClef::PercussionLow:
type = "percussion";
break;
case CAClef::Tab:
type = "tab";
break;
}
if (offset > 0)
type.append(QString("^") + QString::number(offset + 1));
if (offset < 0)
type.append(QString("_") + QString::number((offset - 1) * (-1)));
return type;
}
/*!
Returns the key signature gender major/minor in LilyPond syntax.
\sa keySignaturePitchToLilyPond()
*/
const QString CALilyPondExport::diatonicKeyGenderToLilyPond(CADiatonicKey::CAGender gender)
{
switch (gender) {
case CADiatonicKey::Major:
return QString("\\major");
case CADiatonicKey::Minor:
return QString("\\minor");
}
return QString();
}
/*!
Converts the note length to LilyPond syntax.
*/
const QString CALilyPondExport::playableLengthToLilyPond(CAPlayableLength playableLength)
{
QString length = "4";
switch (playableLength.musicLength()) {
case CAPlayableLength::Breve:
length = "\\breve";
break;
case CAPlayableLength::Whole:
length = "1";
break;
case CAPlayableLength::Half:
length = "2";
break;
case CAPlayableLength::Quarter:
length = "4";
break;
case CAPlayableLength::Eighth:
length = "8";
break;
case CAPlayableLength::Sixteenth:
length = "16";
break;
case CAPlayableLength::ThirtySecond:
length = "32";
break;
case CAPlayableLength::SixtyFourth:
length = "64";
break;
case CAPlayableLength::HundredTwentyEighth:
length = "128";
break;
case CAPlayableLength::Undefined:
length = "4";
break;
}
for (int j = 0; j < playableLength.dotted(); j++)
length += ".";
return length;
}
/*!
Converts the note pitch to LilyPond syntax.
*/
const QString CALilyPondExport::diatonicPitchToLilyPond(CADiatonicPitch pitch)
{
QString name;
name = static_cast<char>(((pitch.noteName() + 2) % 7 + 'a'));
for (int i = 0; i < pitch.accs(); i++)
name += "is"; // append as many -is-es as necessary
for (int i = 0; i > pitch.accs(); i--) {
if ((name == "e") || (name == "a"))
name += "s"; // for pitches E and A, only append single -s the first time
/*
// this seems to be language dependent, or just not like this, taken out for now -- Georg
//
else if (name[0]=='a')
name += "as"; // for pitch A, append -as instead of -es
*/
else
name += "es"; // otherwise, append normally as many es-es as necessary
}
return name;
}
/*!
Converts the rest type to LilyPond syntax.
*/
const QString CALilyPondExport::restTypeToLilyPond(CARest::CARestType type)
{
switch (type) {
case CARest::Normal:
return "r";
case CARest::Hidden:
return "s";
case CARest::Undefined:
return "r";
}
return "r";
}
/*!
Converts the barline type to LilyPond syntax.
*/
const QString CALilyPondExport::barlineTypeToLilyPond(CABarline::CABarlineType type)
{
switch (type) {
case CABarline::Single:
return "|";
case CABarline::Double:
return "||";
case CABarline::End:
return "|.";
case CABarline::RepeatOpen: // possible repeat bar lines: ".|:" ":..:" ":|.|:" ":|.:" ":|."
return ".|:";
case CABarline::RepeatClose:
return ":|.";
case CABarline::RepeatCloseOpen:
return ":|.|:";
case CABarline::Dotted:
return ":";
case CABarline::Undefined:
return "|";
}
return "|";
}
const QString CALilyPondExport::syllableToLilyPond(CASyllable* s)
{
QString text = s->text();
// escape Lilys non-parsable characters
text = text.replace("\"", "\\\"");
// wrap the text with quotes
text = (QString("\"") + text + "\"");
// replace underscore with space
text = text.replace("_", " ");
if (s->hyphenStart())
text += " --";
else if (s->melismaStart())
text += " __";
return text;
}
/*!
Exports the current sheet to LilyPond syntax.
*/
void CALilyPondExport::exportSheetImpl(CASheet* sheet)
{
out().setCodec("UTF-8");
setCurSheet(sheet);
// we need to check if the document is not set, for example at exporting the first sheet
if (sheet->document()) {
setCurDocument(sheet->document());
}
// Print file name and Canorus version in comments at the top of the file
out() << "% This document was generated by Canorus, version " << CANORUS_VERSION << "\n";
// Version of Lilypond syntax being generated.
out() << "\\version \"2.10.0\"\n";
writeDocumentHeader();
for (int c = 0; c < sheet->contextList().size(); ++c) {
if (sheet->contextList()[c]->contextType() == CAContext::Staff) {
// scanForRepeats(static_cast<CAStaff*>(sheet->contextList()[c]));
break;
}
}
/* Write the volta helper function in case we need it
if (!_voltaFunctionWritten)
voltaFunction();
*/
// Export voices as Lilypond variables: \StaffOneVoiceOne = \relative c { ... }
for (int c = 0; c < sheet->contextList().size(); ++c) {
setCurContextIndex(c);
switch (sheet->contextList()[c]->contextType()) {
case CAContext::Staff:
exportStaffVoices(static_cast<CAStaff*>(sheet->contextList()[c]));
break;
case CAContext::LyricsContext:
exportLyricsContextBlock(static_cast<CALyricsContext*>(sheet->contextList()[c]));
break;
case CAContext::ChordNameContext:
exportChordNameContextBlock(static_cast<CAChordNameContext*>(sheet->contextList()[c]));
break;
case CAContext::FunctionMarkContext:
case CAContext::FiguredBassContext:
break;
}
}
exportScoreBlock(sheet);
}
/*!
Export document title, subtitle, composer, copyright etc.
*/
void CALilyPondExport::writeDocumentHeader()
{
out() << "\n\\header {\n";
indentMore();
indent();
out() << "title = " << markupString(curDocument()->title()) << "\n";
indent();
out() << "subtitle = " << markupString(curDocument()->subtitle()) << "\n";
indent();
out() << "composer = " << markupString(curDocument()->composer()) << "\n";
indent();
out() << "arranger = " << markupString(curDocument()->arranger().isEmpty() ? "" : (tr("arr.", "arrangement") + " " + curDocument()->arranger())) << "\n";
indent();
out() << "poet = " << markupString(curDocument()->poet()) << "\n";
indent();
out() << "texttranslator = " << markupString(curDocument()->textTranslator()) << "\n";
indent();
out() << "dedication = " << markupString(curDocument()->dedication()) << "\n";
indent();
out() << "copyright = " << markupString(curDocument()->copyright()) << "\n";
indentLess();
out() << "}\n";
}
/*!
Export document title, subtitle, composer, copyright etc.
*/
void CALilyPondExport::scanForRepeats(CAStaff* staff)
{
out() << "\n % \\repeat volta xxx \n";
CABarline* bl;
QList<CAMark*> ml;
// barlineRefs aus score/staff.h
for (int b = 0; b < staff->barlineRefs().size(); b++) {
out() << "% " << (staff->barlineRefs()[b])->musElementType() << " ";
bl = static_cast<CABarline*>(staff->barlineRefs()[b]);
bl->barlineType();
out() << CABarline::barlineTypeToString(bl->barlineType());
if (bl->barlineType() == CABarline::RepeatClose || bl->barlineType() == CABarline::RepeatOpen || bl->barlineType() == CABarline::RepeatCloseOpen) {
out() << "\n % \\repeat volta X " << CABarline::barlineTypeToString(bl->barlineType()) << "\n";
}
ml = bl->markList();
for (int e = 0; e < ml.size(); e++) {
if (ml[e]->markType() == CAMark::RepeatMark && static_cast<CARepeatMark*>(ml[e])->repeatMarkType() == CARepeatMark::Volta) {
out() << "\n % \\repeat volta X " << CARepeatMark::repeatMarkTypeToString(static_cast<CARepeatMark*>(ml[e])->repeatMarkType()) << "\n";
}
}
}
// inline QList<CAMusElement *>& barlineRefs() { return _barlineList; }
}
/*!
Encapsulates the given string into \\markup {}.
*/
QString CALilyPondExport::markupString(QString in)
{
return QString("\\markup {\"") + escapeWeirdChars(in) + QString("\"}");
}
/*!
Replaces characters like backslashes and double brackets with their escaped variant.
*/
QString CALilyPondExport::escapeWeirdChars(QString in)
{
return in.replace("\\", "\\\\").replace("\"", "\\\"");
}
/*!
Exports all the voices in the staff to Lilypond.
Each voice in the staff is stored as a Lilypond variable:
StaffOneVoiceOne = \relative c { ... }
*/
void CALilyPondExport::exportStaffVoices(CAStaff* staff)
{
for (int v = 0; v < staff->voiceList().size(); ++v) {
setCurVoice(staff->voiceList()[v]);
// Print Canorus voice name as a comment to help with debugging/tweaking
indent();
out() << "\n% " << curVoice()->name() << "\n";
// Write out the voice name and the equals signexportVoice
// Variable name is staff index and voice index
QString voiceName;
voiceVariableName(voiceName, curContextIndex(), v);
out() << voiceName << " = ";
exportVoiceImpl(curVoice());
out() << "\n"; // exportVoiceImpl doesn't put endline at the end
}
}
/*!
Modify \a name to contain a string "StaffXVoiceY" where
X and Y are spelled-out versions of \a staffNum and \a voiceNum, respectively.
This is for generating names of Lilypond variables from Canorus staff and voices indices,
since Lilypond variable names must contain only alphabetical characters.
Example: voiceVariableName( name, 1, 2 );
--> name is "StaffOneVoiceTwo"
*/
void CALilyPondExport::voiceVariableName(QString& name, int staffNum, int voiceNum)
{
QTextStream(&name) << "Context" << staffNum << "Voice" << voiceNum;
spellNumbers(name);
}
/*!
Exports the \\score block for LilyPond from the current sheet.
Looks like this:
\code
\score {
<<
\new Staff {
<<
\new Voice { \voiceOne \StaffOneVoiceOne }
\new Voice { \voiceTwo \StaffOneVoiceTwo }
>>
}
\new Staff {
<<
\new Voice { \voiceOne \StaffTwoVoiceOne }
\new Voice { \voiceTwo \StaffTwoVoiceTwo }
>>
}
...
>>
}
\endcode
*/
void CALilyPondExport::exportScoreBlock(CASheet* sheet)
{
out() << "\n\\score {\n";
indentMore();
int contextCount = sheet->contextList().size();
if (contextCount < 1) {
out() << "% No Contexts. This should probably raise an error.\n";
} else {
// open multiple contexts
indent();
out() << "<<\n";
indentMore();
// remove point-and-click to decrease PDF size
indent();
out() << "\\pointAndClickOff\n";
// draw nice box around rehersal marks as in Canorus GUI
indent();
out() << "\\set Score.markFormatter = #format-mark-box-alphabet\n";
// needed for automatic treating of slurs as melisma for lyrics - multiple syllables below the slured notes are allowed in Canorus, but not recommended
indent();
out() << "\\set Score.melismaBusyProperties = #'()\n";
// Output each staff
for (int c = 0; c < contextCount; ++c) {
setCurContext(sheet->contextList()[c]);
switch (curContext()->contextType()) {
case CAContext::Staff: {
CAStaff* s = static_cast<CAStaff*>(curContext());
indent();
out() << "\\new Staff {\n";
indentMore();
indent();
out() << "\\set Staff.instrumentName = #\"" << escapeWeirdChars(s->name()) << "\"\n";
// More than one voice? Add simultaneous symbol
int voiceCount = s->voiceList().size();
if (voiceCount > 1) {
indent();
out() << "<<\n";
indentMore();
}
// Output voices
for (int v = 0; v < voiceCount; ++v) {
// Print Canorus voice name as a comment to aid with debugging etc.
QString curVoiceName(s->voiceList()[v]->name());
indent();
out() << "% " << curVoiceName << "\n";
// curVoiceLilyCommand is "\voiceOne", "\voiceTwo", etc. to get proper stem directions
// Only use this if there is more than one voice and less then five (Lily limitation).
QString curVoiceLilyCommand;
if (voiceCount > 1 && v < 4) {
curVoiceLilyCommand.setNum(v + 1);
curVoiceLilyCommand = "\\voice" + curVoiceLilyCommand;
spellNumbers(curVoiceLilyCommand);
}
// disable autoBeam, if lyrics applied to voice because beams mean melisma singing for singers
if (s->voiceList()[v]->lyricsContextList().size()) {
if (!curVoiceLilyCommand.isEmpty()) {
curVoiceLilyCommand += " ";
}
curVoiceLilyCommand += "\\autoBeamOff";
}
// Print Lily variable name
QString voiceName;
voiceVariableName(voiceName, c, v);
indent();
out() << "\\new Voice = \"" << voiceName << "Virtual\" { " << curVoiceLilyCommand << " \\" << voiceName << " }\n";
}
indentLess();
// End simultaneous voice
if (voiceCount > 1) {
indent();
out() << ">>\n";
indentLess();
}
// End \new Staff {
indent();
out() << "}\n";
break;
}
case CAContext::LyricsContext: { // only position the lyrics contexts. Voice assignment at the end of the score block!
CALyricsContext* lc = static_cast<CALyricsContext*>(curContext());
QString lcName = lc->name();
spellNumbers(lcName);
indent();
out() << "% " << lc->name() << "\n";
indent();
out() << "\\new Lyrics = \"" << lcName << "Virtual\"\n";
break;
}
case CAContext::ChordNameContext: {
CAChordNameContext* cnc = static_cast<CAChordNameContext*>(curContext());
QString cncName = cnc->name();
spellNumbers(cncName);
indent();
out() << "% " << cnc->name() << "\n";
indent();
out() << "\\new ChordNames {\n";
indentMore();
indent();
out() << "\\" << cncName << "\n";
indentLess();
indent();
out() << "}\n";
break;
}
case CAContext::FunctionMarkContext:
case CAContext::FiguredBassContext:
break;
}
} // for(contexts)
// After positioning the lyrics contexts, set their associated voices!
for (int i = 0; i < contextCount; i++) {
if (i == 0) {
indent();
out() << "\n";
indent();
out() << "% Voice assignment:\n";
}
CALyricsContext* lc;
lc = dynamic_cast<CALyricsContext*>(sheet->contextList()[i]);
if (lc) {
QString lcName = lc->name();
spellNumbers(lcName);
QString voiceName;
voiceVariableName(
voiceName,
curSheet()->contextList().indexOf(lc->associatedVoice()->staff()),
lc->associatedVoice()->staff()->voiceList().indexOf(lc->associatedVoice()));
indent();
out() << "\\context Lyrics = \"" << lcName << "Virtual\" { \\lyricsto \"" << voiceName << "Virtual\" \\" << lcName << " }\n";
}
}
// End simultaneous contexts
indentLess();
// close multiple contexts
indent();
out() << ">>\n";
indentLess();
}
// End score block
out() << "}\n";
// Conditional layout block to supress default time signature and default bar lines.
if (!_timeSignatureFound) {
out() << "\n";
out() << "\\layout {\n";
out() << " \\context {\n";
out() << " \\Staff\n";
out() << " \\remove \"Time_signature_engraver\"\n";
out() << " \\remove \"Bar_engraver\"\n";
out() << " }\n";
out() << "}\n";
}
// We put some syntax reminders how to adjust the music on the page.
// Can go away if we have a proper gui for setting this.
out() << "\n";
out() << "% To adjust the points size of notes and fonts, it can be done like this:\n";
out() << "% #(set-global-staff-size 16.0)\n";
out() << "\n";
out() << "% Some examples to adjust the page size:\n";
out() << "% \\paper { #(set-paper-size \"a3\") }\n";
out() << "% \\paper { #(set-paper-size \"a4\" 'landscape) }\n";
out() << "% But to move the music on the page this needs to be done:\n";
out() << "% \\paper{\n";
out() << "% paper-width = 16\\cm\n";
out() << "% line-width = 12\\cm\n";
out() << "% left-margin = 2\\cm\n";
out() << "% top-margin = 3\\cm\n";
out() << "% bottom-margin = 3\\cm\n";
out() << "% ragged-last-bottom = ##t\n";
out() << "% page-count = #2\n";
out() << "% }\n\n";
}
/*!
Output tabs according to _indentLevel.
*/
void CALilyPondExport::indent()
{
for (int i = 0; i < curIndentLevel(); ++i) {
out() << "\t";
}
}
/*!
Spell out numbers in a QString: "Staff1Voice2" -> "StaffOneVoiceTwo"
This is necessary because Lilypond variable names can only contain letters.
*/
void CALilyPondExport::spellNumbers(QString& s)
{
s.replace("0", "Zero");
s.replace("1", "One");
s.replace("2", "Two");
s.replace("3", "Three");
s.replace("4", "Four");
s.replace("5", "Five");
s.replace("6", "Six");
s.replace("7", "Seven");
s.replace("8", "Eight");
s.replace("9", "Nine");
}
void CALilyPondExport::voltaFunction(void)
{
out() << "\n";
out() << "% Volta: Read about a preliminary hack to export volta brackets to lilypond:\n";
out() << "% If you put a text mark with the name 'voltaRepeat xyz' or 'voltaBar xyz' on a note,\n";
out() << "% then a volta bracket will appear.\n";
out() << "% voltaRepeat lasts until the next repeat bar line, voltaBar until the next bar line.\n";
out() << "% See lilypond example voltaCustom.\n";
out() << "%\n";
out() << "voltaStart =\n";
out() << " #(define-music-function (parser location repMarkupA ) (markup? )\n";
out() << " #{\n";
out() << " \\set Score.repeatCommands = #(list (list 'volta $repMarkupA) )\n";
out() << " #})\n";
out() << "% Usage in lilypond:\n";
out() << "% Start volta: \\voltaStart \\markup \\text \\italic { \"first time\" }\n";
out() << "% End volta: \\set Score.repeatCommands = #'((volta #f))\n";
out() << "\n";
_voltaFunctionWritten = true;
}
const QString CALilyPondExport::_regExpVoltaRepeat = QString("voltaRepeat (.*)");
const QString CALilyPondExport::_regExpVoltaBar = QString("voltaBar (.*)");
| 46,830
|
C++
|
.cpp
| 1,257
| 28.665076
| 167
| 0.560107
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,423
|
musicxmlexport.cpp
|
canorusmusic_canorus/src/export/musicxmlexport.cpp
|
/*!
Copyright (c) 2008-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include <QDomDocument>
#include <QDomElement>
#include <QDomImplementation>
#include <QString>
#include <QTextStream>
#include "export/musicxmlexport.h"
#include "score/barline.h"
#include "score/clef.h"
#include "score/context.h"
#include "score/document.h"
#include "score/keysignature.h"
#include "score/muselement.h"
#include "score/note.h"
#include "score/rest.h"
#include "score/sheet.h"
#include "score/staff.h"
#include "score/timesignature.h"
#include "score/voice.h"
#include "score/articulation.h"
#include "score/bookmark.h"
#include "score/crescendo.h"
#include "score/dynamic.h"
#include "score/fermata.h"
#include "score/fingering.h"
#include "score/instrumentchange.h"
#include "score/mark.h"
#include "score/repeatmark.h"
#include "score/ritardando.h"
#include "score/tempo.h"
#include "score/text.h"
#include "score/lyricscontext.h"
#include "score/syllable.h"
#include "score/functionmark.h"
#include "score/functionmarkcontext.h"
CAMusicXmlExport::CAMusicXmlExport(QTextStream* stream)
: CAExport(stream)
{
_xmlDoc = nullptr;
}
CAMusicXmlExport::~CAMusicXmlExport()
{
}
/*!
Exports the document to MusicXML 3.0 format.
It uses DOM object internally for writing the XML output.
The implementation relies heavily on the tutorial found at musicxml.com.
*/
void CAMusicXmlExport::exportSheetImpl(CASheet* sheet)
{
out().setCodec("UTF-8");
setCurSheet(sheet);
// we need to check if the document is not set, for example at exporting the first sheet
if (sheet->document()) {
setCurDocument(sheet->document());
}
// DOCTYPE
QDomImplementation di;
QDomDocument xmlDoc(
di.createDocumentType("score-partwise", "-//Recordare//DTD MusicXML 3.0 Partwise//EN", "http://www.musicxml.org/dtds/partwise.dtd"));
_xmlDoc = &xmlDoc;
// Add encoding
xmlDoc.appendChild(xmlDoc.createProcessingInstruction("xml",
"version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\""));
// Root node - <canorus-document>
QDomElement xmlScorePartwise = xmlDoc.createElement("score-partwise");
xmlScorePartwise.setAttribute("version", "3.0");
QDomElement xmlPartList = xmlDoc.createElement("part-list");
QList<CAStaff*> staffList = sheet->staffList();
// first export part information
for (int i = 0; i < staffList.size(); i++) {
QDomElement xmlScorePart = xmlDoc.createElement("score-part");
xmlScorePart.setAttribute("id", QString("P") + QString::number(i + 1));
QDomElement xmlPartName = xmlDoc.createElement("part-name");
QDomText xmlPartNameText = xmlDoc.createTextNode(staffList[i]->name());
xmlPartName.appendChild(xmlPartNameText);
xmlScorePart.appendChild(xmlPartName);
xmlPartList.appendChild(xmlScorePart);
}
xmlScorePartwise.appendChild(xmlPartList);
// then export the part content
for (int i = 0; i < staffList.size(); i++) {
QDomElement xmlPart = xmlDoc.createElement("part");
xmlPart.setAttribute("id", QString("P") + QString::number(i + 1));
exportStaffImpl(staffList[i], xmlPart);
xmlScorePartwise.appendChild(xmlPart);
}
xmlDoc.appendChild(xmlScorePartwise);
out() << xmlDoc.toString();
}
/*!
* Exports the given staff to the provided DOM part element.
*/
void CAMusicXmlExport::exportStaffImpl(CAStaff* staff, QDomElement& xmlPart)
{
int measureNumber = 1;
int voicesFinished = 0;
QList<CAVoice*> voiceList = staff->voiceList();
int* curIndex = new int[voiceList.size()]; // frontline of exported elements
for (int i = 0; i < voiceList.size(); i++) {
curIndex[i] = 0;
}
while (voicesFinished < voiceList.size()) {
// write the measure content
QDomElement xmlMeasure = _xmlDoc->createElement("measure");
xmlMeasure.setAttribute("number", measureNumber);
exportMeasure(voiceList, curIndex, xmlMeasure);
xmlPart.appendChild(xmlMeasure);
// check the end of staff
voicesFinished = 0;
for (int i = 0; i < voiceList.size(); i++) {
if (curIndex[i] >= voiceList[i]->musElementList().size() - 1) {
// voice is finished, if a final barline is reached (curIndex=size()-1)
// or, if a final note is reached and there is no barline afterwards (curIndex=size())
voicesFinished++;
}
}
measureNumber++;
}
}
/*!
* Exports the voice elements at provided indices to the given DOM measure
* element.
*/
void CAMusicXmlExport::exportMeasure(QList<CAVoice*>& voiceList, int* curIndex, QDomElement& xmlMeasure)
{
QList<CAMusElement*> attributeChanges;
// find the target barline which closes the measure
// since barlines are common to all voices, scanning the first voice suffices
// meanwhile, remember any clef/key/time changes
CABarline* targetBarline = nullptr;
int j = curIndex[0] + 1;
while (j < voiceList[0]->musElementList().size() && voiceList[0]->musElementList()[j]->musElementType() != CAMusElement::Barline) {
CAMusElement::CAMusElementType t = voiceList[0]->musElementList()[j - 1]->musElementType();
if (t == CAMusElement::Clef || t == CAMusElement::TimeSignature || t == CAMusElement::KeySignature) {
attributeChanges << voiceList[0]->musElementList()[j - 1];
}
j++;
}
if (j < voiceList[0]->musElementList().size()) {
targetBarline = static_cast<CABarline*>(voiceList[0]->musElementList()[j]);
}
// check for attributes changes in the first pass
QDomElement xmlAttributes = _xmlDoc->createElement("attributes");
QDomElement xmlDivisions = _xmlDoc->createElement("divisions");
QDomText xmlDivisionsText = _xmlDoc->createTextNode(QString::number(32)); // 32 divisions per quarter gives us 128th - the shortest Canorus length
xmlDivisions.appendChild(xmlDivisionsText);
xmlAttributes.appendChild(xmlDivisions);
for (int i = 0; i < attributeChanges.size(); i++) {
switch (attributeChanges[i]->musElementType()) {
case CAMusElement::Clef: {
QDomElement xmlClef = _xmlDoc->createElement("clef");
exportClef(static_cast<CAClef*>(attributeChanges[i]), xmlClef);
xmlAttributes.appendChild(xmlClef);
break;
}
case CAMusElement::TimeSignature: {
QDomElement xmlTimeSig = _xmlDoc->createElement("time");
exportTimeSig(static_cast<CATimeSignature*>(attributeChanges[i]), xmlTimeSig);
xmlAttributes.appendChild(xmlTimeSig);
break;
}
case CAMusElement::KeySignature: {
QDomElement xmlKeySig = _xmlDoc->createElement("key");
exportKeySig(static_cast<CAKeySignature*>(attributeChanges[i]), xmlKeySig);
xmlAttributes.appendChild(xmlKeySig);
break;
}
default: {
break;
}
}
}
xmlMeasure.appendChild(xmlAttributes);
// TODO: check for dynamics (mf, pp)
// export notes and rests
for (int i = 0; i < voiceList.size(); i++) {
CAVoice* v = voiceList[i];
while (curIndex[i] < v->musElementList().size() && v->musElementList()[curIndex[i]] != targetBarline) {
if (v->musElementList()[curIndex[i]]->isPlayable()) {
CAMusElement* elt = v->musElementList()[curIndex[i]];
QDomElement xmlNote = _xmlDoc->createElement("note");
QDomElement xmlDuration = _xmlDoc->createElement("duration");
// duration=timeLength/8 comes from the hardcoded divisions (set to 32)
int duration = CAPlayableLength::playableLengthToTimeLength(static_cast<CAPlayable*>(elt)->playableLength()) / 8;
QDomText xmlDurationValue = _xmlDoc->createTextNode(QString::number(duration));
xmlDuration.appendChild(xmlDurationValue);
xmlNote.appendChild(xmlDuration);
for (int j = 0; j < static_cast<CAPlayable*>(elt)->playableLength().dotted(); j++) {
QDomElement xmlDot = _xmlDoc->createElement("dot");
xmlNote.appendChild(xmlDot);
}
QDomElement xmlVoice = _xmlDoc->createElement("voice");
QDomText xmlVoiceNr = _xmlDoc->createTextNode(QString::number(v->voiceNumber()));
xmlVoice.appendChild(xmlVoiceNr);
xmlNote.appendChild(xmlVoice);
if (elt->musElementType() == CAMusElement::Note) {
exportNote(static_cast<CANote*>(elt), xmlNote);
} else if (elt->musElementType() == CAMusElement::Rest) {
exportRest(static_cast<CARest*>(elt), xmlNote);
}
xmlMeasure.appendChild(xmlNote);
}
curIndex[i]++;
}
}
}
void CAMusicXmlExport::exportClef(CAClef* clef, QDomElement& xmlClef)
{
QString sign;
int line = 0;
switch (clef->clefType()) {
case CAClef::G:
sign = "G";
line = 2;
break;
case CAClef::F:
sign = "F";
line = 4;
break;
case CAClef::PercussionHigh:
sign = "percussion";
line = 0;
break;
case CAClef::PercussionLow:
sign = "percussion";
line = 0;
break;
case CAClef::Tab:
sign = "TAB";
line = 5;
break;
case CAClef::C:
sign = "C";
line = (clef->c1() + clef->offset()) / 2 + 1;
break;
}
if (sign.size()) {
QDomElement xmlSign = _xmlDoc->createElement("sign");
QDomText xmlSignValue = _xmlDoc->createTextNode(sign);
xmlSign.appendChild(xmlSignValue);
xmlClef.appendChild(xmlSign);
}
if (line) {
QDomElement xmlLine = _xmlDoc->createElement("line");
QDomText xmlLineValue = _xmlDoc->createTextNode(QString::number(line));
xmlLine.appendChild(xmlLineValue);
xmlClef.appendChild(xmlLine);
}
if (clef->offset()) {
QDomElement xmlClefOctaveChange = _xmlDoc->createElement("clef-octave-change");
QDomText xmlClefOctaveChangeValue = _xmlDoc->createTextNode(QString::number(clef->offset() / 8));
xmlClefOctaveChange.appendChild(xmlClefOctaveChangeValue);
xmlClef.appendChild(xmlClefOctaveChange);
}
}
void CAMusicXmlExport::exportTimeSig(CATimeSignature* time, QDomElement& xmlTime)
{
QDomElement xmlBeats = _xmlDoc->createElement("beats");
QDomText xmlBeatsValue = _xmlDoc->createTextNode(QString::number(time->beats()));
xmlBeats.appendChild(xmlBeatsValue);
xmlTime.appendChild(xmlBeats);
QDomElement xmlBeatType = _xmlDoc->createElement("beat-type");
QDomText xmlBeatTypeValue = _xmlDoc->createTextNode(QString::number(time->beat()));
xmlBeatType.appendChild(xmlBeatTypeValue);
xmlTime.appendChild(xmlBeatType);
}
void CAMusicXmlExport::exportKeySig(CAKeySignature* key, QDomElement& xmlKey)
{
QDomElement xmlFifths = _xmlDoc->createElement("fifths");
QDomText xmlFifthsValue = _xmlDoc->createTextNode(QString::number(key->diatonicKey().numberOfAccs()));
xmlFifths.appendChild(xmlFifthsValue);
xmlKey.appendChild(xmlFifths);
QString mode;
if (key->diatonicKey().gender() == CADiatonicKey::Major) {
mode = "major";
} else if (key->diatonicKey().gender() == CADiatonicKey::Minor) {
mode = "minor";
}
if (mode.size()) {
QDomElement xmlMode = _xmlDoc->createElement("mode");
QDomText xmlModeValue = _xmlDoc->createTextNode(mode);
xmlMode.appendChild(xmlModeValue);
xmlKey.appendChild(xmlMode);
}
}
void CAMusicXmlExport::exportNote(CANote* note, QDomElement& xmlNote)
{
if (note->isPartOfChord() && !note->isFirstInChord()) {
QDomElement xmlChord = _xmlDoc->createElement("chord");
xmlNote.appendChild(xmlChord);
}
QString stemDirection;
if (note->stemDirection() == CANote::StemUp || (note->stemDirection() == CANote::StemPreferred && note->voice()->stemDirection() == CANote::StemUp)) {
stemDirection = "up";
} else if (note->stemDirection() == CANote::StemDown || (note->stemDirection() == CANote::StemPreferred && note->voice()->stemDirection() == CANote::StemDown)) {
stemDirection = "down";
}
if (stemDirection.size()) {
QDomElement xmlStemDirection = _xmlDoc->createElement("stem");
QDomText xmlStemDirectionValue = _xmlDoc->createTextNode(stemDirection);
xmlStemDirection.appendChild(xmlStemDirectionValue);
xmlNote.appendChild(xmlStemDirection);
}
QDomElement xmlPitch = _xmlDoc->createElement("pitch");
QDomElement xmlStep = _xmlDoc->createElement("step");
QDomText xmlStepValue = _xmlDoc->createTextNode(QChar(static_cast<char>((note->diatonicPitch().noteName() + 2) % 7 + 'A')));
xmlStep.appendChild(xmlStepValue);
xmlPitch.appendChild(xmlStep);
if (note->diatonicPitch().accs()) {
QDomElement xmlAlter = _xmlDoc->createElement("alter");
QDomText xmlAlterValue = _xmlDoc->createTextNode(QString::number(note->diatonicPitch().accs()));
xmlAlter.appendChild(xmlAlterValue);
xmlPitch.appendChild(xmlAlter);
}
QDomElement xmlOctave = _xmlDoc->createElement("octave");
QDomText xmlOctaveValue = _xmlDoc->createTextNode(QString::number(note->diatonicPitch().noteName() / 7));
xmlOctave.appendChild(xmlOctaveValue);
xmlPitch.appendChild(xmlOctave);
xmlNote.appendChild(xmlPitch);
QString type;
switch (note->playableLength().musicLength()) {
case CAPlayableLength::Breve:
type = "breve";
break;
case CAPlayableLength::Whole:
type = "whole";
break;
case CAPlayableLength::Half:
type = "half";
break;
case CAPlayableLength::Quarter:
type = "quarter";
break;
case CAPlayableLength::Eighth:
type = "eighth";
break;
case CAPlayableLength::Sixteenth:
type = "16th";
break;
case CAPlayableLength::ThirtySecond:
type = "32nd";
break;
case CAPlayableLength::SixtyFourth:
type = "64th";
break;
case CAPlayableLength::HundredTwentyEighth:
type = "128th";
break;
default:
break;
}
if (type.size()) {
QDomElement xmlType = _xmlDoc->createElement("type");
QDomText xmlTypeValue = _xmlDoc->createTextNode(type);
xmlType.appendChild(xmlTypeValue);
xmlNote.appendChild(xmlType);
}
}
void CAMusicXmlExport::exportRest(CARest*, QDomElement& xmlNote)
{
QDomElement xmlRest = _xmlDoc->createElement("rest");
xmlNote.appendChild(xmlRest);
}
| 14,996
|
C++
|
.cpp
| 368
| 33.932065
| 165
| 0.663716
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,424
|
canexport.cpp
|
canorusmusic_canorus/src/export/canexport.cpp
|
/*!
Copyright (c) 2007, Matevž Jekovec, Itay Perl, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include "export/canexport.h"
#include "core/archive.h"
#include "export/canorusmlexport.h"
#include "score/document.h"
#include "score/resource.h"
#include <QFile>
#include <QFileInfo>
#include <QTemporaryFile>
#include <QTextStream>
CACanExport::CACanExport(QTextStream* stream)
: CAExport(stream)
{
}
CACanExport::~CACanExport()
{
}
void CACanExport::exportDocumentImpl(CADocument* doc)
{
// Write the score
QBuffer score;
CACanorusMLExport* content = new CACanorusMLExport();
content->setStreamToDevice(&score);
content->exportDocument(doc);
content->wait();
delete content;
QString fileName = "content.xml";
if (!doc->archive()->addFile(fileName, score)) {
setStatus(-2);
return;
}
for (int i = 0; i < doc->resourceList().size(); i++) {
std::shared_ptr<CAResource> r = doc->resourceList()[i];
if (!r->isLinked()) {
// /tmp/qt_tempXXXXX -> qt_tempXXXXX
QFile target(r->url().toLocalFile());
doc->archive()->addFile(fileName + " files/" + QFileInfo(target).fileName(), target);
}
}
/// \todo fix relative paths
for (int i = 0; i < doc->resourceList().size(); i++) {
std::shared_ptr<CAResource> r = doc->resourceList()[i];
if (r->isLinked()) {
// fix relative paths
continue;
}
}
// Save the archive
doc->archive()->write(*stream()->device());
setStatus(0); // done
}
| 1,705
|
C++
|
.cpp
| 55
| 26.109091
| 97
| 0.645516
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,425
|
export.cpp
|
canorusmusic_canorus/src/export/export.cpp
|
/*!
Copyright (c) 2007-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include "export/export.h"
#include <QTextStream>
/*!
\class CAExport
\brief Base class for export filters
This class inherits CAFile and is the base class for any specific import filter (eg. LilyPond,
CanorusML, MusicXML etc.).
If a developer wants to write a new export filter, he should:
1) Create a new class with the base class CAExport
2) Implement CAExport constructors and at least exportDocumentImpl() function
3) Register the filter (put a new fileformat to CAFileFormats and add the filter to open/save
dialogs in CACanorus)
Optionally:
Developer should change the current status and progress while operations are in progress. He should
also rewrite the readableStatus() function.
The following example illustrates the usage of export class:
\code
CAMyExportFilter export();
export.setStreamToFile("jingle bells.xml");
export.exportDocument( curDocument );
export.wait();
\endcode
*/
CAExport::CAExport(QTextStream* stream)
: CAFile()
{
setStream(stream);
setExportedDocument(nullptr);
setExportedSheet(nullptr);
setExportedStaff(nullptr);
setExportedVoice(nullptr);
setExportedLyricsContext(nullptr);
setExportedFunctionMarkContext(nullptr);
}
CAExport::~CAExport()
{
}
/*!
Executed when a new thread is dispatched.
It looks which part of the document should be exported and starts the procedure.
It emits the appropriate signal when the procedure is finished.
*/
void CAExport::run()
{
if (!stream()) {
setStatus(-1);
} else {
if (exportedDocument()) {
exportDocumentImpl(exportedDocument());
emit documentExported(exportedDocument());
} else if (exportedSheet()) {
exportSheetImpl(exportedSheet());
emit sheetExported(exportedSheet());
} else if (exportedStaff()) {
exportStaffImpl(exportedStaff());
emit staffExported(exportedStaff());
} else if (exportedVoice()) {
exportVoiceImpl(exportedVoice());
emit voiceExported(exportedVoice());
} else if (exportedLyricsContext()) {
exportLyricsContextImpl(exportedLyricsContext());
emit lyricsContextExported(exportedLyricsContext());
} else if (exportedFunctionMarkContext()) {
exportFunctionMarkContextImpl(exportedFunctionMarkContext());
emit functionMarkContextExported(exportedFunctionMarkContext());
}
stream()->flush();
if (stream()->device() && stream()->device()->isOpen()) {
stream()->device()->close();
}
if (status() > 0) { // error - bad implemented filter
// job is finished but status is still marked as working, set to Ready to prevent infinite loops
setStatus(0);
}
}
emit exportDone(status());
}
void CAExport::exportDocument(CADocument* doc, bool bStartThread)
{
setExportedDocument(doc);
setStatus(1); // process started
if (bStartThread)
start();
else {
if (!stream()) {
setStatus(-1);
} else {
if (exportedDocument()) {
exportDocumentImpl(exportedDocument());
emit documentExported(exportedDocument());
}
stream()->flush();
if (status() > 0) { // error - bad implemented filter
// job is finished but status is still marked as working, set to Ready to prevent infinite loops
setStatus(0);
}
}
emit exportDone(status());
}
}
void CAExport::exportSheet(CASheet* sheet)
{
setExportedSheet(sheet);
setStatus(1); // process started
start();
}
void CAExport::exportStaff(CAStaff* staff)
{
setExportedStaff(staff);
setStatus(1); // process started
start();
}
void CAExport::exportVoice(CAVoice* voice)
{
setExportedVoice(voice);
setStatus(1); // process started
start();
}
void CAExport::exportLyricsContext(CALyricsContext* lc)
{
setExportedLyricsContext(lc);
setStatus(1); // process started
start();
}
void CAExport::exportFunctionMarkContext(CAFunctionMarkContext* fmc)
{
setExportedFunctionMarkContext(fmc);
setStatus(1); // process started
start();
}
const QString CAExport::readableStatus()
{
switch (status()) {
case 1:
return tr("Exporting");
case 0:
return tr("Ready");
case -1:
return tr("Unable to open file for writing");
}
return tr("Ready");
}
| 4,740
|
C++
|
.cpp
| 147
| 26.530612
| 112
| 0.676072
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,426
|
midiexport.cpp
|
canorusmusic_canorus/src/export/midiexport.cpp
|
/*!
Copyright (c) 2007-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#include <QFileInfo>
#include <QRegExp>
#include <QTextStream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include "export/midiexport.h"
#include "interface/mididevice.h"
#include "interface/playback.h"
#include "score/document.h"
#include "score/sheet.h"
#include "score/staff.h"
#include "score/voice.h"
class CACanorus;
/*!
\class CAMidiExport
\brief Midi file export filter
This class is used to export the document or parts of the document to a midi file.
The most common use is to simply call one of the constructors
\code
CAMidiExport( myDocument, &textStream );
\endcode
\a textStream is usually the file stream.
\sa CAMidiImport
*/
/*!
Constructor for midi file export. Called when choosing the mid/midi file extension in the export dialog.
Exports all voices to the given text stream.
*/
CAMidiExport::CAMidiExport(QTextStream* out)
: CAExport(out)
, CAMidiDevice()
{
_midiDeviceType = MidiExportDevice;
setRealTime(false);
_trackTime = 0;
}
/*!
Compute the time offset for a new event and update the current track time.
*/
int CAMidiExport::timeIncrement(int time)
{
int offset = 0;
if (time > _trackTime) {
offset = time - _trackTime;
}
_trackTime = time;
return offset;
}
void CAMidiExport::send(QVector<unsigned char> message, int time)
{
if (message.size())
trackChunk.append(writeTime(timeIncrement(time)));
char q;
for (int i = 0; i < message.size(); i++) {
q = static_cast<char>(message[i]);
trackChunk.append(q);
}
for (int i = 0; i < message.size(); i++) {
q = static_cast<char>(message[i]);
}
}
void CAMidiExport::sendMetaEvent(int time, char event, char a, char b, int)
{
// We don't do a time check on time, and we compute
// only the time increment when we really send an event out.
QByteArray tc;
if (event == CAMidiDevice::Meta_Keysig) {
tc.append(writeTime(timeIncrement(time)));
tc.append(static_cast<char>(CAMidiDevice::Midi_Ctl_Event));
tc.append(event);
tc.append(variableLengthValue(2));
tc.append(a);
tc.append(b);
trackChunk.append(tc);
} else if (event == CAMidiDevice::Meta_Timesig) {
char lbBeat = 0;
for (; lbBeat < 5; lbBeat++) { // natural logarithm, smallest is 128th
if (1 << lbBeat >= b)
break;
}
tc.append(writeTime(timeIncrement(time)));
tc.append(static_cast<char>(CAMidiDevice::Midi_Ctl_Event));
tc.append(event);
tc.append(variableLengthValue(4));
tc.append(a);
tc.append(lbBeat);
tc.append(18);
tc.append(8);
trackChunk.append(tc);
} else if (event == CAMidiDevice::Meta_Tempo) {
int usPerQuarter = 60000000 / a;
tc.append(writeTime(timeIncrement(time)));
tc.append(static_cast<char>(CAMidiDevice::Midi_Ctl_Event));
tc.append(event);
tc.append(variableLengthValue(3));
char q;
q = char(usPerQuarter >> 16);
tc.append(q);
q = char(usPerQuarter >> 8);
tc.append(q);
q = char(usPerQuarter >> 0);
tc.append(q);
trackChunk.append(tc);
}
}
/// \todo: replace with enum midiCommands
#define META_TEXT 0x01
#define META_TIMESIG 0x58
#define META_KEYSIG 0x59
#define META_TEMPO 0x51
#define META_TRACK_END 0x2f
#define MIDI_CTL_EVENT 0xff
#define MIDI_CTL_REVERB 0x5b
#define MIDI_CTL_CHORUS 0x5d
#define MIDI_CTL_PAN 0x0a
#define MIDI_CTL_VOLUME 0x07
#define MIDI_CTL_SUSTAIN 0x40
/*!
Converts 16-bit number to big endian byte array.
*/
QByteArray CAMidiExport::word16(short x)
{
QByteArray ba;
ba.append(x >> 8);
ba.append(x);
return ba;
}
QByteArray CAMidiExport::variableLengthValue(int value)
{
QByteArray chunk;
char b;
bool byteswritten = false;
b = (value >> 3 * 7) & 0x7f;
if (b) {
chunk.append(0x80 | b);
byteswritten = true;
}
b = (value >> 2 * 7) & 0x7f;
if (b || byteswritten) {
chunk.append(0x80 | b);
byteswritten = true;
}
b = (value >> 7) & 0x7f;
if (b || byteswritten) {
chunk.append(0x80 | b);
byteswritten = true;
}
b = value & 0x7f;
chunk.append(b);
return chunk;
}
QByteArray CAMidiExport::writeTime(int time)
{
char b;
bool byteswritten = false;
QByteArray ba;
b = (time >> 3 * 7) & 0x7f;
if (b) {
ba.append(0x80 | b);
byteswritten = true;
}
b = (time >> 2 * 7) & 0x7f;
if (b || byteswritten) {
ba.append(0x80 | b);
byteswritten = true;
}
b = (time >> 7) & 0x7f;
if (b || byteswritten) {
ba.append(0x80 | b);
byteswritten = true;
}
b = time & 0x7f;
ba.append(b);
return ba;
}
QByteArray CAMidiExport::trackEnd(void)
{
QByteArray tc;
tc.append(writeTime(0));
/// \todo replace with enum
tc.append(static_cast<char>(MIDI_CTL_EVENT));
tc.append(META_TRACK_END);
tc.append(static_cast<char>(0));
return tc;
}
QByteArray CAMidiExport::textEvent(int time, QString s)
{
QByteArray tc;
tc.append(writeTime(time));
/// \todo replace with enum
tc.append(static_cast<char>(MIDI_CTL_EVENT));
tc.append(META_TEXT);
tc.append(variableLengthValue(s.length()));
tc.append(s);
return tc;
}
/*!
Exports the current document to Lilypond syntax as a complete .ly file.
*/
void CAMidiExport::exportDocumentImpl(CADocument* doc)
{
if (doc->sheetList().size() < 1) {
//TODO: no sheets, raise an error
return;
}
// In the header chunk we need to know the count of tracks.
// We export every non empty voice as separate track.
// For now we export only the first sheet.
CASheet* sheet = doc->sheetList()[0];
setCurSheet(sheet);
trackChunk.clear();
// Let's playback this sheet and dump that into a file,
// and for this we have our own midi driver.
CAPlayback* _playback = new CAPlayback(sheet, this);
_playback->run();
int count = 0;
for (int c = 0; c < doc->sheetList()[0]->contextList().size(); ++c) {
switch (sheet->contextList()[c]->contextType()) {
case CAContext::Staff: {
// exportStaffVoices( static_cast<CAStaff*>(sheet->contextList()[c]) );
CAStaff* staff = static_cast<CAStaff*>(sheet->contextList()[c]);
for (int v = 0; v < staff->voiceList().size(); ++v) {
setCurVoice(staff->voiceList()[v]);
count++;
//std::cout << "Hallo " << c << " " << v << "\n" << std::endl;
}
break;
}
case CAContext::ChordNameContext:
break; // TODO
case CAContext::LyricsContext:
case CAContext::FunctionMarkContext:
case CAContext::FiguredBassContext:
break;
}
}
writeFile();
}
/*!
Exports the current document to Lilypond syntax as a complete .ly file.
*/
void CAMidiExport::exportSheetImpl(CASheet* sheet)
{
/*
if ( doc->sheetList().size() < 1 ) {
//TODO: no sheets, raise an error
return;
}
// In the header chunk we need to know the count of tracks.
// We export every non empty voice as separate track.
// For now we export only the first sheet.
CASheet *sheet = doc->sheetList()[ 0 ];
*/
setCurSheet(sheet);
trackChunk.clear();
// Let's playback this sheet and dump that into a file,
// and for this we have our own midi driver.
CAPlayback* _playback = new CAPlayback(sheet, this);
_playback->run();
int count = 0;
for (int c = 0; c < sheet->contextList().size(); ++c) {
switch (sheet->contextList()[c]->contextType()) {
case CAContext::Staff: {
// exportStaffVoices( static_cast<CAStaff*>(sheet->contextList()[c]) );
CAStaff* staff = static_cast<CAStaff*>(sheet->contextList()[c]);
for (int v = 0; v < staff->voiceList().size(); ++v) {
setCurVoice(staff->voiceList()[v]);
count++;
//std::cout << "Hallo " << c << " " << v << "\n" << std::endl;
}
break;
}
case CAContext::LyricsContext:
case CAContext::FunctionMarkContext:
case CAContext::FiguredBassContext:
case CAContext::ChordNameContext:
break;
}
}
writeFile();
}
void CAMidiExport::writeFile()
{
QByteArray headerChunk;
headerChunk.append("MThd...."); // header and space for length
headerChunk.append(word16(1)); // Midi-Format version
headerChunk.append(word16(2)); // number of tracks, a control track and a music track for a trying out ...
/// \todo QByteArray does not support char values > 0x7f
headerChunk.append(word16(static_cast<short>(CAPlayableLength::playableLengthToTimeLength(CAPlayableLength::Quarter)))); // time division ticks per quarter
setChunkLength(&headerChunk);
streamQByteArray(headerChunk);
QByteArray controlTrackChunk;
controlTrackChunk.append("MTrk....");
controlTrackChunk.append(textEvent(0, QString("Canorus Version ") + CANORUS_VERSION + " generated. "));
controlTrackChunk.append(textEvent(0, "It's still a work in progress."));
controlTrackChunk.append(trackEnd());
setChunkLength(&controlTrackChunk);
streamQByteArray(controlTrackChunk);
// trackChunk is already filled with midi data,
// let's add chunk header, in reverse, ...
trackChunk.prepend("MTrk....");
// ... and add the tail:
trackChunk.append(trackEnd());
setChunkLength(&trackChunk);
streamQByteArray(trackChunk);
}
void CAMidiExport::setChunkLength(QByteArray* x)
{
/// \todo QByteArray does not support char values > 0x7f
qint32 l = (*x).size() - 8; // subtract header length
for (int i = 0; i < 4; i++) {
(*x)[7 - i] = static_cast<char>((l >> (8 * i)));
}
}
void CAMidiExport::streamQByteArray(QByteArray x)
{
for (int i = 0; i < x.size(); i++) // here we pass binary data through QTextStream
out().device()->putChar(x[i]);
#ifdef QT_DEBUG
for (int i = 0; i < x.size(); i++) {
printf(" %02x", 0x0ff & x.at(i));
}
printf("\n");
#endif
return; // when no debugging
}
| 10,522
|
C++
|
.cpp
| 332
| 26.38253
| 159
| 0.63399
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,427
|
svgexport.cpp
|
canorusmusic_canorus/src/export/svgexport.cpp
|
/*!
Copyright (c) 2008-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
// Includes
#include "export/svgexport.h"
#include "control/typesetctl.h"
#include "export/lilypondexport.h"
#ifndef SWIGCPP
#include "canorus.h" // needed for settings()
#endif
#include "core/settings.h"
/*!
\class CASVGExport
\brief SVG export filter
This class is used to export the document or parts of the document to SVG format.
The most common use is to simply call the constructor
\code
CASVGExport( &textStream );
\endcode
\a textStream is usually the file stream or the content of the score source view widget.
*/
/*!
Constructor for SVG export.
Exports a document to LilyPond and create a SVG from it using the given text \a stream.
*/
CASVGExport::CASVGExport(QTextStream* stream)
: CAExport(stream)
{
_poTypesetCtl = nullptr;
}
// Destructor
CASVGExport::~CASVGExport()
{
if (_poTypesetCtl) {
delete _poTypesetCtl->getExporter();
delete _poTypesetCtl;
}
_poTypesetCtl = nullptr;
}
void CASVGExport::startExport()
{
_poTypesetCtl = new CATypesetCtl();
// For now we support only lilypond export
#ifndef SWIGCPP
_poTypesetCtl->setTypesetter((CACanorus::settings()->useSystemDefaultTypesetter()) ? (CASettings::DEFAULT_TYPESETTER_LOCATION) : (CACanorus::settings()->typesetterLocation()));
#else
_poTypesetCtl->setTypesetter(CASettings::DEFAULT_TYPESETTER_LOCATION);
#endif
_poTypesetCtl->setTSetOption("dbackend", "svg", false, false);
_poTypesetCtl->setExporter(new CALilyPondExport());
// Put lilypond output to console, could be shown on a canorus console later
connect(_poTypesetCtl, SIGNAL(nextOutput(const QByteArray&)), this, SLOT(outputTypsetterOutput(const QByteArray&)));
connect(_poTypesetCtl, SIGNAL(typesetterFinished(int)), this, SLOT(svgFinished(int)));
}
void CASVGExport::finishExport()
{
if (_poTypesetCtl) {
// Put lilypond output to console, could be shown on a canorus console later
disconnect(_poTypesetCtl, SIGNAL(nextOutput(const QByteArray&)), this, SLOT(outputTypsetterOutput(const QByteArray&)));
disconnect(_poTypesetCtl, SIGNAL(typesetterFinished(int)), this, SLOT(svgFinished(int)));
delete _poTypesetCtl;
_poTypesetCtl = nullptr; // Destruktor may not delete the same object again
}
}
/*!
Exports the document \a poDoc to LilyPond first and create a SVG from it
using the Typesetter instance.
*/
void CASVGExport::exportDocumentImpl(CADocument* poDoc)
{
if (poDoc->sheetList().size() < 1) {
//TODO: no sheets, raise an error
return;
}
// We cannot create the typesetter instance (a QProcess in the end)
// in the constructor as it's parent would be in a different thread!
startExport();
// The exportDocument method defines the temporary file name and
// directory, so we can only read it after the creation
_poTypesetCtl->exportDocument(poDoc);
// actual PDF creation is done now
runTypesetter();
}
/*!
Exports the sheet \a poSheet to LilyPond first and create a PDF from it
using the Typesetter instance.
*/
void CASVGExport::exportSheetImpl(CASheet* poSheet)
{
// We cannot create the typesetter instance (a QProcess in the end)
// in the constructor as it's parent would be in a different thread!
startExport();
// The exportSheet method defines the temporary file name and
// directory, so we can only read it after the creation
_poTypesetCtl->exportSheet(poSheet);
// actual PDF creation is done now
runTypesetter();
}
/*!
Run creation of PDF file after deleting a potential old one
*/
void CASVGExport::runTypesetter()
{
const QString roTempPath = _poTypesetCtl->getTempFilePath();
_poTypesetCtl->setTSetOption(QString("o"), roTempPath);
_poTypesetCtl->setTSetOption("dbackend", "svg", false, false);
// Remove old svg file first, but ignore error (file might not exist)
if (!file()->remove()) {
qWarning("SVGExport: Could not remove old svg file %s, error %s", qPrintable(file()->fileName()),
qPrintable(file()->errorString()));
file()->unsetError();
}
_poTypesetCtl->runTypesetter(); // create svg
// as we are not in the main thread wait until we are finished
if (_poTypesetCtl->waitForFinished(-1) == false) {
qWarning("SVGExport: Typesetter %s was not finished", "lilypond");
}
}
/*!
Show the output \a roOutput of the typesetter on the console
*/
void CASVGExport::outputTypsetterOutput(const QByteArray& roOutput)
{
// Output to error console
qDebug("%s", roOutput.data());
}
/*!
When the typesetter is finished copy the pdf file to the defined destination
*/
void CASVGExport::svgFinished(int iExitCode)
{
setStatus(iExitCode);
QFile oTempFile(getTempFilePath() + ".svg");
oTempFile.setFileName(getTempFilePath() + ".svg");
qDebug("Exporting SVG file %s", file()->fileName().toLatin1().data());
if (!iExitCode && !oTempFile.copy(file()->fileName())) // Rename it, so we can delete the temporary file
{
qCritical("SVGExport: Could not copy temporary file %s, error %s", qPrintable(oTempFile.fileName()),
qPrintable(oTempFile.errorString()));
return;
}
emit svgIsFinished(iExitCode);
// Remove temporary files.
if (!oTempFile.remove()) {
qWarning("SVGExport: Could not remove temporary file %s, error %s", qPrintable(oTempFile.fileName()),
qPrintable(oTempFile.errorString()));
oTempFile.unsetError();
}
oTempFile.setFileName(getTempFilePath() + ".ps");
// No warning as not every typesetter leaves postscript files behind
oTempFile.remove();
oTempFile.setFileName(getTempFilePath());
if (!oTempFile.remove()) {
qWarning("SVGExport: Could not remove temporary file %s, error %s", qPrintable(oTempFile.fileName()),
qPrintable(oTempFile.errorString()));
oTempFile.unsetError();
}
finishExport();
}
QString CASVGExport::getTempFilePath()
{
return (_poTypesetCtl ? _poTypesetCtl->getTempFilePath() : "");
}
| 6,296
|
C++
|
.cpp
| 165
| 34.078788
| 180
| 0.71571
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,428
|
fetaList.cxx
|
canorusmusic_canorus/src/fonts/fetaList.cxx
|
// To regenerate using linux tools:
// 1. Put the new font in this directory, and load it in fontforge, then save a namelist (Encoding->Save Namelist of Font) to fetaList.nam in this directory.
// 2. Run: ( grep '^//' fetaList.cxx; cat fetaList.nam | while read ln; do echo '_fetaMap["'`echo $ln | cut -d" " -f2`'"]='`echo $ln | cut -d" " -f1`';'; done | grep -v "0x00" ) > fetaListNew.cxx && mv fetaList{New,}.cxx
_fetaMap["rests.0"]=0xE100;
_fetaMap["rests.1"]=0xE101;
_fetaMap["rests.0o"]=0xE102;
_fetaMap["rests.1o"]=0xE103;
_fetaMap["rests.M3"]=0xE104;
_fetaMap["rests.M2"]=0xE105;
_fetaMap["rests.M1"]=0xE106;
_fetaMap["rests.2"]=0xE107;
_fetaMap["rests.2classical"]=0xE108;
_fetaMap["rests.3"]=0xE109;
_fetaMap["rests.4"]=0xE10A;
_fetaMap["rests.5"]=0xE10B;
_fetaMap["rests.6"]=0xE10C;
_fetaMap["rests.7"]=0xE10D;
_fetaMap["accidentals.sharp"]=0xE10E;
_fetaMap["accidentals.sharp.arrowup"]=0xE10F;
_fetaMap["accidentals.sharp.arrowdown"]=0xE110;
_fetaMap["accidentals.sharp.arrowboth"]=0xE111;
_fetaMap["accidentals.sharp.slashslash.stem"]=0xE112;
_fetaMap["accidentals.sharp.slashslashslash.stemstem"]=0xE113;
_fetaMap["accidentals.sharp.slashslashslash.stem"]=0xE114;
_fetaMap["accidentals.sharp.slashslash.stemstemstem"]=0xE115;
_fetaMap["accidentals.natural"]=0xE116;
_fetaMap["accidentals.natural.arrowup"]=0xE117;
_fetaMap["accidentals.natural.arrowdown"]=0xE118;
_fetaMap["accidentals.natural.arrowboth"]=0xE119;
_fetaMap["accidentals.flat"]=0xE11A;
_fetaMap["accidentals.flat.arrowup"]=0xE11B;
_fetaMap["accidentals.flat.arrowdown"]=0xE11C;
_fetaMap["accidentals.flat.arrowboth"]=0xE11D;
_fetaMap["accidentals.flat.slash"]=0xE11E;
_fetaMap["accidentals.flat.slashslash"]=0xE11F;
_fetaMap["accidentals.mirroredflat.flat"]=0xE120;
_fetaMap["accidentals.mirroredflat"]=0xE121;
_fetaMap["accidentals.mirroredflat.backslash"]=0xE122;
_fetaMap["accidentals.flatflat"]=0xE123;
_fetaMap["accidentals.flatflat.slash"]=0xE124;
_fetaMap["accidentals.doublesharp"]=0xE125;
_fetaMap["accidentals.rightparen"]=0xE126;
_fetaMap["accidentals.leftparen"]=0xE127;
_fetaMap["arrowheads.open.01"]=0xE128;
_fetaMap["arrowheads.open.0M1"]=0xE129;
_fetaMap["arrowheads.open.11"]=0xE12A;
_fetaMap["arrowheads.open.1M1"]=0xE12B;
_fetaMap["arrowheads.close.01"]=0xE12C;
_fetaMap["arrowheads.close.0M1"]=0xE12D;
_fetaMap["arrowheads.close.11"]=0xE12E;
_fetaMap["arrowheads.close.1M1"]=0xE12F;
_fetaMap["dots.dot"]=0xE130;
_fetaMap["noteheads.uM2"]=0xE131;
_fetaMap["noteheads.dM2"]=0xE132;
_fetaMap["noteheads.sM1"]=0xE133;
_fetaMap["noteheads.s0"]=0xE134;
_fetaMap["noteheads.s1"]=0xE135;
_fetaMap["noteheads.s2"]=0xE136;
_fetaMap["noteheads.s0diamond"]=0xE137;
_fetaMap["noteheads.s1diamond"]=0xE138;
_fetaMap["noteheads.s2diamond"]=0xE139;
_fetaMap["noteheads.s0triangle"]=0xE13A;
_fetaMap["noteheads.d1triangle"]=0xE13B;
_fetaMap["noteheads.u1triangle"]=0xE13C;
_fetaMap["noteheads.u2triangle"]=0xE13D;
_fetaMap["noteheads.d2triangle"]=0xE13E;
_fetaMap["noteheads.s0slash"]=0xE13F;
_fetaMap["noteheads.s1slash"]=0xE140;
_fetaMap["noteheads.s2slash"]=0xE141;
_fetaMap["noteheads.s0cross"]=0xE142;
_fetaMap["noteheads.s1cross"]=0xE143;
_fetaMap["noteheads.s2cross"]=0xE144;
_fetaMap["noteheads.s2xcircle"]=0xE145;
_fetaMap["noteheads.s0do"]=0xE146;
_fetaMap["noteheads.d1do"]=0xE147;
_fetaMap["noteheads.u1do"]=0xE148;
_fetaMap["noteheads.d2do"]=0xE149;
_fetaMap["noteheads.u2do"]=0xE14A;
_fetaMap["noteheads.s0re"]=0xE14B;
_fetaMap["noteheads.u1re"]=0xE14C;
_fetaMap["noteheads.d1re"]=0xE14D;
_fetaMap["noteheads.u2re"]=0xE14E;
_fetaMap["noteheads.d2re"]=0xE14F;
_fetaMap["noteheads.s0mi"]=0xE150;
_fetaMap["noteheads.s1mi"]=0xE151;
_fetaMap["noteheads.s2mi"]=0xE152;
_fetaMap["noteheads.u0fa"]=0xE153;
_fetaMap["noteheads.d0fa"]=0xE154;
_fetaMap["noteheads.u1fa"]=0xE155;
_fetaMap["noteheads.d1fa"]=0xE156;
_fetaMap["noteheads.u2fa"]=0xE157;
_fetaMap["noteheads.d2fa"]=0xE158;
_fetaMap["noteheads.s0la"]=0xE159;
_fetaMap["noteheads.s1la"]=0xE15A;
_fetaMap["noteheads.s2la"]=0xE15B;
_fetaMap["noteheads.s0ti"]=0xE15C;
_fetaMap["noteheads.u1ti"]=0xE15D;
_fetaMap["noteheads.d1ti"]=0xE15E;
_fetaMap["noteheads.u2ti"]=0xE15F;
_fetaMap["noteheads.d2ti"]=0xE160;
_fetaMap["scripts.ufermata"]=0xE161;
_fetaMap["scripts.dfermata"]=0xE162;
_fetaMap["scripts.ushortfermata"]=0xE163;
_fetaMap["scripts.dshortfermata"]=0xE164;
_fetaMap["scripts.ulongfermata"]=0xE165;
_fetaMap["scripts.dlongfermata"]=0xE166;
_fetaMap["scripts.uverylongfermata"]=0xE167;
_fetaMap["scripts.dverylongfermata"]=0xE168;
_fetaMap["scripts.thumb"]=0xE169;
_fetaMap["scripts.sforzato"]=0xE16A;
_fetaMap["scripts.espr"]=0xE16B;
_fetaMap["scripts.staccato"]=0xE16C;
_fetaMap["scripts.ustaccatissimo"]=0xE16D;
_fetaMap["scripts.dstaccatissimo"]=0xE16E;
_fetaMap["scripts.tenuto"]=0xE16F;
_fetaMap["scripts.uportato"]=0xE170;
_fetaMap["scripts.dportato"]=0xE171;
_fetaMap["scripts.umarcato"]=0xE172;
_fetaMap["scripts.dmarcato"]=0xE173;
_fetaMap["scripts.open"]=0xE174;
_fetaMap["scripts.stopped"]=0xE175;
_fetaMap["scripts.upbow"]=0xE176;
_fetaMap["scripts.downbow"]=0xE177;
_fetaMap["scripts.reverseturn"]=0xE178;
_fetaMap["scripts.turn"]=0xE179;
_fetaMap["scripts.trill"]=0xE17A;
_fetaMap["scripts.upedalheel"]=0xE17B;
_fetaMap["scripts.dpedalheel"]=0xE17C;
_fetaMap["scripts.upedaltoe"]=0xE17D;
_fetaMap["scripts.dpedaltoe"]=0xE17E;
_fetaMap["scripts.flageolet"]=0xE17F;
_fetaMap["scripts.segno"]=0xE180;
_fetaMap["scripts.coda"]=0xE181;
_fetaMap["scripts.varcoda"]=0xE182;
_fetaMap["scripts.rcomma"]=0xE183;
_fetaMap["scripts.lcomma"]=0xE184;
_fetaMap["scripts.rvarcomma"]=0xE185;
_fetaMap["scripts.lvarcomma"]=0xE186;
_fetaMap["scripts.arpeggio"]=0xE187;
_fetaMap["scripts.trill_element"]=0xE188;
_fetaMap["scripts.arpeggio.arrow.M1"]=0xE189;
_fetaMap["scripts.arpeggio.arrow.1"]=0xE18A;
_fetaMap["scripts.trilelement"]=0xE18B;
_fetaMap["scripts.prall"]=0xE18C;
_fetaMap["scripts.mordent"]=0xE18D;
_fetaMap["scripts.prallprall"]=0xE18E;
_fetaMap["scripts.prallmordent"]=0xE18F;
_fetaMap["scripts.upprall"]=0xE190;
_fetaMap["scripts.upmordent"]=0xE191;
_fetaMap["scripts.pralldown"]=0xE192;
_fetaMap["scripts.downprall"]=0xE193;
_fetaMap["scripts.downmordent"]=0xE194;
_fetaMap["scripts.prallup"]=0xE195;
_fetaMap["scripts.lineprall"]=0xE196;
_fetaMap["scripts.caesura.curved"]=0xE197;
_fetaMap["scripts.caesura.straight"]=0xE198;
_fetaMap["flags.u3"]=0xE199;
_fetaMap["flags.u4"]=0xE19A;
_fetaMap["flags.u5"]=0xE19B;
_fetaMap["flags.u6"]=0xE19C;
_fetaMap["flags.u7"]=0xE19D;
_fetaMap["flags.d3"]=0xE19E;
_fetaMap["flags.ugrace"]=0xE19F;
_fetaMap["flags.dgrace"]=0xE1A0;
_fetaMap["flags.d4"]=0xE1A1;
_fetaMap["flags.d5"]=0xE1A2;
_fetaMap["flags.d6"]=0xE1A3;
_fetaMap["flags.d7"]=0xE1A4;
_fetaMap["clefs.C"]=0xE1A5;
_fetaMap["clefs.C_change"]=0xE1A6;
_fetaMap["clefs.F"]=0xE1A7;
_fetaMap["clefs.F_change"]=0xE1A8;
_fetaMap["clefs.G"]=0xE1A9;
_fetaMap["clefs.G_change"]=0xE1AA;
_fetaMap["clefs.percussion"]=0xE1AB;
_fetaMap["clefs.percussion_change"]=0xE1AC;
_fetaMap["clefs.tab"]=0xE1AD;
_fetaMap["clefs.tab_change"]=0xE1AE;
_fetaMap["timesig.C44"]=0xE1AF;
_fetaMap["timesig.C22"]=0xE1B0;
_fetaMap["pedal.*"]=0xE1B1;
_fetaMap["pedal.M"]=0xE1B2;
_fetaMap["pedal.."]=0xE1B3;
_fetaMap["pedal.P"]=0xE1B4;
_fetaMap["pedal.d"]=0xE1B5;
_fetaMap["pedal.e"]=0xE1B6;
_fetaMap["pedal.Ped"]=0xE1B7;
_fetaMap["brackettips.up"]=0xE1B8;
_fetaMap["brackettips.down"]=0xE1B9;
_fetaMap["accordion.accDiscant"]=0xE1BA;
_fetaMap["accordion.accDot"]=0xE1BB;
_fetaMap["accordion.accFreebase"]=0xE1BC;
_fetaMap["accordion.accStdbase"]=0xE1BD;
_fetaMap["accordion.accBayanbase"]=0xE1BE;
_fetaMap["accordion.accOldEE"]=0xE1BF;
_fetaMap["rests.M3neomensural"]=0xE1C0;
_fetaMap["rests.M2neomensural"]=0xE1C1;
_fetaMap["rests.M1neomensural"]=0xE1C2;
_fetaMap["rests.0neomensural"]=0xE1C3;
_fetaMap["rests.1neomensural"]=0xE1C4;
_fetaMap["rests.2neomensural"]=0xE1C5;
_fetaMap["rests.3neomensural"]=0xE1C6;
_fetaMap["rests.4neomensural"]=0xE1C7;
_fetaMap["rests.M3mensural"]=0xE1C8;
_fetaMap["rests.M2mensural"]=0xE1C9;
_fetaMap["rests.M1mensural"]=0xE1CA;
_fetaMap["rests.0mensural"]=0xE1CB;
_fetaMap["rests.1mensural"]=0xE1CC;
_fetaMap["rests.2mensural"]=0xE1CD;
_fetaMap["rests.3mensural"]=0xE1CE;
_fetaMap["rests.4mensural"]=0xE1CF;
_fetaMap["noteheads.slneomensural"]=0xE1D0;
_fetaMap["noteheads.sM3neomensural"]=0xE1D1;
_fetaMap["noteheads.sM2neomensural"]=0xE1D2;
_fetaMap["noteheads.sM1neomensural"]=0xE1D3;
_fetaMap["noteheads.s0harmonic"]=0xE1D4;
_fetaMap["noteheads.s2harmonic"]=0xE1D5;
_fetaMap["noteheads.s0neomensural"]=0xE1D6;
_fetaMap["noteheads.s1neomensural"]=0xE1D7;
_fetaMap["noteheads.s2neomensural"]=0xE1D8;
_fetaMap["noteheads.slmensural"]=0xE1D9;
_fetaMap["noteheads.sM3mensural"]=0xE1DA;
_fetaMap["noteheads.sM2mensural"]=0xE1DB;
_fetaMap["noteheads.sM1mensural"]=0xE1DC;
_fetaMap["noteheads.s0mensural"]=0xE1DD;
_fetaMap["noteheads.s1mensural"]=0xE1DE;
_fetaMap["noteheads.s2mensural"]=0xE1DF;
_fetaMap["noteheads.s0petrucci"]=0xE1E0;
_fetaMap["noteheads.s1petrucci"]=0xE1E1;
_fetaMap["noteheads.s2petrucci"]=0xE1E2;
_fetaMap["noteheads.svaticana.punctum"]=0xE1E3;
_fetaMap["noteheads.svaticana.punctum.cavum"]=0xE1E4;
_fetaMap["noteheads.svaticana.linea.punctum"]=0xE1E5;
_fetaMap["noteheads.svaticana.linea.punctum.cavum"]=0xE1E6;
_fetaMap["noteheads.svaticana.inclinatum"]=0xE1E7;
_fetaMap["noteheads.svaticana.lpes"]=0xE1E8;
_fetaMap["noteheads.svaticana.vlpes"]=0xE1E9;
_fetaMap["noteheads.svaticana.upes"]=0xE1EA;
_fetaMap["noteheads.svaticana.vupes"]=0xE1EB;
_fetaMap["noteheads.svaticana.plica"]=0xE1EC;
_fetaMap["noteheads.svaticana.vplica"]=0xE1ED;
_fetaMap["noteheads.svaticana.epiphonus"]=0xE1EE;
_fetaMap["noteheads.svaticana.vepiphonus"]=0xE1EF;
_fetaMap["noteheads.svaticana.reverse.plica"]=0xE1F0;
_fetaMap["noteheads.svaticana.reverse.vplica"]=0xE1F1;
_fetaMap["noteheads.svaticana.inner.cephalicus"]=0xE1F2;
_fetaMap["noteheads.svaticana.cephalicus"]=0xE1F3;
_fetaMap["noteheads.svaticana.quilisma"]=0xE1F4;
_fetaMap["noteheads.ssolesmes.incl.parvum"]=0xE1F5;
_fetaMap["noteheads.ssolesmes.auct.asc"]=0xE1F6;
_fetaMap["noteheads.ssolesmes.auct.desc"]=0xE1F7;
_fetaMap["noteheads.ssolesmes.incl.auctum"]=0xE1F8;
_fetaMap["noteheads.ssolesmes.stropha"]=0xE1F9;
_fetaMap["noteheads.ssolesmes.stropha.aucta"]=0xE1FA;
_fetaMap["noteheads.ssolesmes.oriscus"]=0xE1FB;
_fetaMap["noteheads.smedicaea.inclinatum"]=0xE1FC;
_fetaMap["noteheads.smedicaea.punctum"]=0xE1FD;
_fetaMap["noteheads.smedicaea.rvirga"]=0xE1FE;
_fetaMap["noteheads.smedicaea.virga"]=0xE1FF;
_fetaMap["noteheads.shufnagel.punctum"]=0xE200;
_fetaMap["noteheads.shufnagel.virga"]=0xE201;
_fetaMap["noteheads.shufnagel.lpes"]=0xE202;
_fetaMap["clefs.vaticana.do"]=0xE203;
_fetaMap["clefs.vaticana.do_change"]=0xE204;
_fetaMap["clefs.vaticana.fa"]=0xE205;
_fetaMap["clefs.vaticana.fa_change"]=0xE206;
_fetaMap["clefs.medicaea.do"]=0xE207;
_fetaMap["clefs.medicaea.do_change"]=0xE208;
_fetaMap["clefs.medicaea.fa"]=0xE209;
_fetaMap["clefs.medicaea.fa_change"]=0xE20A;
_fetaMap["clefs.neomensural.c"]=0xE20B;
_fetaMap["clefs.neomensural.c_change"]=0xE20C;
_fetaMap["clefs.petrucci.c1"]=0xE20D;
_fetaMap["clefs.petrucci.c1_change"]=0xE20E;
_fetaMap["clefs.petrucci.c2"]=0xE20F;
_fetaMap["clefs.petrucci.c2_change"]=0xE210;
_fetaMap["clefs.petrucci.c3"]=0xE211;
_fetaMap["clefs.petrucci.c3_change"]=0xE212;
_fetaMap["clefs.petrucci.c4"]=0xE213;
_fetaMap["clefs.petrucci.c4_change"]=0xE214;
_fetaMap["clefs.petrucci.c5"]=0xE215;
_fetaMap["clefs.petrucci.c5_change"]=0xE216;
_fetaMap["clefs.mensural.c"]=0xE217;
_fetaMap["clefs.mensural.c_change"]=0xE218;
_fetaMap["clefs.petrucci.f"]=0xE219;
_fetaMap["clefs.petrucci.f_change"]=0xE21A;
_fetaMap["clefs.mensural.f"]=0xE21B;
_fetaMap["clefs.mensural.f_change"]=0xE21C;
_fetaMap["clefs.petrucci.g"]=0xE21D;
_fetaMap["clefs.petrucci.g_change"]=0xE21E;
_fetaMap["clefs.mensural.g"]=0xE21F;
_fetaMap["clefs.mensural.g_change"]=0xE220;
_fetaMap["clefs.hufnagel.do"]=0xE221;
_fetaMap["clefs.hufnagel.do_change"]=0xE222;
_fetaMap["clefs.hufnagel.fa"]=0xE223;
_fetaMap["clefs.hufnagel.fa_change"]=0xE224;
_fetaMap["clefs.hufnagel.do.fa"]=0xE225;
_fetaMap["clefs.hufnagel.do.fa_change"]=0xE226;
_fetaMap["custodes.hufnagel.u0"]=0xE227;
_fetaMap["custodes.hufnagel.u1"]=0xE228;
_fetaMap["custodes.hufnagel.u2"]=0xE229;
_fetaMap["custodes.hufnagel.d0"]=0xE22A;
_fetaMap["custodes.hufnagel.d1"]=0xE22B;
_fetaMap["custodes.hufnagel.d2"]=0xE22C;
_fetaMap["custodes.medicaea.u0"]=0xE22D;
_fetaMap["custodes.medicaea.u1"]=0xE22E;
_fetaMap["custodes.medicaea.u2"]=0xE22F;
_fetaMap["custodes.medicaea.d0"]=0xE230;
_fetaMap["custodes.medicaea.d1"]=0xE231;
_fetaMap["custodes.medicaea.d2"]=0xE232;
_fetaMap["custodes.vaticana.u0"]=0xE233;
_fetaMap["custodes.vaticana.u1"]=0xE234;
_fetaMap["custodes.vaticana.u2"]=0xE235;
_fetaMap["custodes.vaticana.d0"]=0xE236;
_fetaMap["custodes.vaticana.d1"]=0xE237;
_fetaMap["custodes.vaticana.d2"]=0xE238;
_fetaMap["custodes.mensural.u0"]=0xE239;
_fetaMap["custodes.mensural.u1"]=0xE23A;
_fetaMap["custodes.mensural.u2"]=0xE23B;
_fetaMap["custodes.mensural.d0"]=0xE23C;
_fetaMap["custodes.mensural.d1"]=0xE23D;
_fetaMap["custodes.mensural.d2"]=0xE23E;
_fetaMap["accidentals.medicaeaM1"]=0xE23F;
_fetaMap["accidentals.vaticanaM1"]=0xE240;
_fetaMap["accidentals.vaticana0"]=0xE241;
_fetaMap["accidentals.mensural1"]=0xE242;
_fetaMap["accidentals.mensuralM1"]=0xE243;
_fetaMap["accidentals.hufnagelM1"]=0xE244;
_fetaMap["flags.mensuralu03"]=0xE245;
_fetaMap["flags.mensuralu13"]=0xE246;
_fetaMap["flags.mensuralu23"]=0xE247;
_fetaMap["flags.mensurald03"]=0xE248;
_fetaMap["flags.mensurald13"]=0xE249;
_fetaMap["flags.mensurald23"]=0xE24A;
_fetaMap["flags.mensuralu04"]=0xE24B;
_fetaMap["flags.mensuralu14"]=0xE24C;
_fetaMap["flags.mensuralu24"]=0xE24D;
_fetaMap["flags.mensurald04"]=0xE24E;
_fetaMap["flags.mensurald14"]=0xE24F;
_fetaMap["flags.mensurald24"]=0xE250;
_fetaMap["flags.mensuralu05"]=0xE251;
_fetaMap["flags.mensuralu15"]=0xE252;
_fetaMap["flags.mensuralu25"]=0xE253;
_fetaMap["flags.mensurald05"]=0xE254;
_fetaMap["flags.mensurald15"]=0xE255;
_fetaMap["flags.mensurald25"]=0xE256;
_fetaMap["flags.mensuralu06"]=0xE257;
_fetaMap["flags.mensuralu16"]=0xE258;
_fetaMap["flags.mensuralu26"]=0xE259;
_fetaMap["flags.mensurald06"]=0xE25A;
_fetaMap["flags.mensurald16"]=0xE25B;
_fetaMap["flags.mensurald26"]=0xE25C;
_fetaMap["timesig.mensural44"]=0xE25D;
_fetaMap["timesig.mensural22"]=0xE25E;
_fetaMap["timesig.mensural32"]=0xE25F;
_fetaMap["timesig.mensural64"]=0xE260;
_fetaMap["timesig.mensural94"]=0xE261;
_fetaMap["timesig.mensural34"]=0xE262;
_fetaMap["timesig.mensural68"]=0xE263;
_fetaMap["timesig.mensural98"]=0xE264;
_fetaMap["timesig.mensural48"]=0xE265;
_fetaMap["timesig.mensural68alt"]=0xE266;
_fetaMap["timesig.mensural24"]=0xE267;
_fetaMap["timesig.neomensural44"]=0xE268;
_fetaMap["timesig.neomensural22"]=0xE269;
_fetaMap["timesig.neomensural32"]=0xE26A;
_fetaMap["timesig.neomensural64"]=0xE26B;
_fetaMap["timesig.neomensural94"]=0xE26C;
_fetaMap["timesig.neomensural34"]=0xE26D;
_fetaMap["timesig.neomensural68"]=0xE26E;
_fetaMap["timesig.neomensural98"]=0xE26F;
_fetaMap["timesig.neomensural48"]=0xE270;
_fetaMap["timesig.neomensural68alt"]=0xE271;
_fetaMap["timesig.neomensural24"]=0xE272;
_fetaMap["scripts.ictus"]=0xE273;
_fetaMap["scripts.uaccentus"]=0xE274;
_fetaMap["scripts.daccentus"]=0xE275;
_fetaMap["scripts.usemicirculus"]=0xE276;
_fetaMap["scripts.dsemicirculus"]=0xE277;
_fetaMap["scripts.circulus"]=0xE278;
_fetaMap["scripts.augmentum"]=0xE279;
_fetaMap["scripts.usignumcongruentiae"]=0xE27A;
_fetaMap["scripts.dsignumcongruentiae"]=0xE27B;
_fetaMap["dots.dotvaticana"]=0xE27C;
| 15,508
|
C++
|
.cxx
| 384
| 39.385417
| 220
| 0.778035
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,430
|
rtmidi_c.h
|
canorusmusic_canorus/lib/rtmidi-4.0.0/rtmidi_c.h
|
/************************************************************************/
/*! \defgroup C-interface
@{
\brief C interface to realtime MIDI input/output C++ classes.
RtMidi offers a C-style interface, principally for use in binding
RtMidi to other programming languages. All structs, enums, and
functions listed here have direct analogs (and simply call to)
items in the C++ RtMidi class and its supporting classes and
types
*/
/************************************************************************/
/*!
\file rtmidi_c.h
*/
#include <stdbool.h>
#include <stddef.h>
#ifndef RTMIDI_C_H
#define RTMIDI_C_H
#if defined(RTMIDI_EXPORT)
#if defined _WIN32 || defined __CYGWIN__
#define RTMIDIAPI __declspec(dllexport)
#else
#define RTMIDIAPI __attribute__((visibility("default")))
#endif
#else
#define RTMIDIAPI //__declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
//! \brief Wraps an RtMidi object for C function return statuses.
struct RtMidiWrapper {
//! The wrapped RtMidi object.
void* ptr;
void* data;
//! True when the last function call was OK.
bool ok;
//! If an error occured (ok != true), set to an error message.
const char* msg;
};
//! \brief Typedef for a generic RtMidi pointer.
typedef struct RtMidiWrapper* RtMidiPtr;
//! \brief Typedef for a generic RtMidiIn pointer.
typedef struct RtMidiWrapper* RtMidiInPtr;
//! \brief Typedef for a generic RtMidiOut pointer.
typedef struct RtMidiWrapper* RtMidiOutPtr;
//! \brief MIDI API specifier arguments. See \ref RtMidi::Api.
enum RtMidiApi {
RTMIDI_API_UNSPECIFIED, /*!< Search for a working compiled API. */
RTMIDI_API_MACOSX_CORE, /*!< Macintosh OS-X CoreMIDI API. */
RTMIDI_API_LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
RTMIDI_API_UNIX_JACK, /*!< The Jack Low-Latency MIDI Server API. */
RTMIDI_API_WINDOWS_MM, /*!< The Microsoft Multimedia MIDI API. */
RTMIDI_API_RTMIDI_DUMMY, /*!< A compilable but non-functional API. */
RTMIDI_API_NUM /*!< Number of values in this enum. */
};
//! \brief Defined RtMidiError types. See \ref RtMidiError::Type.
enum RtMidiErrorType {
RTMIDI_ERROR_WARNING, /*!< A non-critical error. */
RTMIDI_ERROR_DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
RTMIDI_ERROR_UNSPECIFIED, /*!< The default, unspecified error type. */
RTMIDI_ERROR_NO_DEVICES_FOUND, /*!< No devices found on system. */
RTMIDI_ERROR_INVALID_DEVICE, /*!< An invalid device ID was specified. */
RTMIDI_ERROR_MEMORY_ERROR, /*!< An error occured during memory allocation. */
RTMIDI_ERROR_INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
RTMIDI_ERROR_INVALID_USE, /*!< The function was called incorrectly. */
RTMIDI_ERROR_DRIVER_ERROR, /*!< A system driver error occured. */
RTMIDI_ERROR_SYSTEM_ERROR, /*!< A system error occured. */
RTMIDI_ERROR_THREAD_ERROR /*!< A thread error occured. */
};
/*! \brief The type of a RtMidi callback function.
*
* \param timeStamp The time at which the message has been received.
* \param message The midi message.
* \param userData Additional user data for the callback.
*
* See \ref RtMidiIn::RtMidiCallback.
*/
typedef void(* RtMidiCCallback) (double timeStamp, const unsigned char* message,
size_t messageSize, void *userData);
/* RtMidi API */
/*! \brief Determine the available compiled MIDI APIs.
*
* If the given `apis` parameter is null, returns the number of available APIs.
* Otherwise, fill the given apis array with the RtMidi::Api values.
*
* \param apis An array or a null value.
* \param apis_size Number of elements pointed to by apis
* \return number of items needed for apis array if apis==NULL, or
* number of items written to apis array otherwise. A negative
* return value indicates an error.
*
* See \ref RtMidi::getCompiledApi().
*/
RTMIDIAPI int rtmidi_get_compiled_api (enum RtMidiApi *apis, unsigned int apis_size);
//! \brief Return the name of a specified compiled MIDI API.
//! See \ref RtMidi::getApiName().
RTMIDIAPI const char *rtmidi_api_name(enum RtMidiApi api);
//! \brief Return the display name of a specified compiled MIDI API.
//! See \ref RtMidi::getApiDisplayName().
RTMIDIAPI const char *rtmidi_api_display_name(enum RtMidiApi api);
//! \brief Return the compiled MIDI API having the given name.
//! See \ref RtMidi::getCompiledApiByName().
RTMIDIAPI enum RtMidiApi rtmidi_compiled_api_by_name(const char *name);
//! \internal Report an error.
RTMIDIAPI void rtmidi_error (enum RtMidiErrorType type, const char* errorString);
/*! \brief Open a MIDI port.
*
* \param port Must be greater than 0
* \param portName Name for the application port.
*
* See RtMidi::openPort().
*/
RTMIDIAPI void rtmidi_open_port (RtMidiPtr device, unsigned int portNumber, const char *portName);
/*! \brief Creates a virtual MIDI port to which other software applications can
* connect.
*
* \param portName Name for the application port.
*
* See RtMidi::openVirtualPort().
*/
RTMIDIAPI void rtmidi_open_virtual_port (RtMidiPtr device, const char *portName);
/*! \brief Close a MIDI connection.
* See RtMidi::closePort().
*/
RTMIDIAPI void rtmidi_close_port (RtMidiPtr device);
/*! \brief Return the number of available MIDI ports.
* See RtMidi::getPortCount().
*/
RTMIDIAPI unsigned int rtmidi_get_port_count (RtMidiPtr device);
/*! \brief Return a string identifier for the specified MIDI input port number.
* See RtMidi::getPortName().
*/
RTMIDIAPI const char* rtmidi_get_port_name (RtMidiPtr device, unsigned int portNumber);
/* RtMidiIn API */
//! \brief Create a default RtMidiInPtr value, with no initialization.
RTMIDIAPI RtMidiInPtr rtmidi_in_create_default (void);
/*! \brief Create a RtMidiInPtr value, with given api, clientName and queueSizeLimit.
*
* \param api An optional API id can be specified.
* \param clientName An optional client name can be specified. This
* will be used to group the ports that are created
* by the application.
* \param queueSizeLimit An optional size of the MIDI input queue can be
* specified.
*
* See RtMidiIn::RtMidiIn().
*/
RTMIDIAPI RtMidiInPtr rtmidi_in_create (enum RtMidiApi api, const char *clientName, unsigned int queueSizeLimit);
//! \brief Free the given RtMidiInPtr.
RTMIDIAPI void rtmidi_in_free (RtMidiInPtr device);
//! \brief Returns the MIDI API specifier for the given instance of RtMidiIn.
//! See \ref RtMidiIn::getCurrentApi().
RTMIDIAPI enum RtMidiApi rtmidi_in_get_current_api (RtMidiPtr device);
//! \brief Set a callback function to be invoked for incoming MIDI messages.
//! See \ref RtMidiIn::setCallback().
RTMIDIAPI void rtmidi_in_set_callback (RtMidiInPtr device, RtMidiCCallback callback, void *userData);
//! \brief Cancel use of the current callback function (if one exists).
//! See \ref RtMidiIn::cancelCallback().
RTMIDIAPI void rtmidi_in_cancel_callback (RtMidiInPtr device);
//! \brief Specify whether certain MIDI message types should be queued or ignored during input.
//! See \ref RtMidiIn::ignoreTypes().
RTMIDIAPI void rtmidi_in_ignore_types (RtMidiInPtr device, bool midiSysex, bool midiTime, bool midiSense);
/*! Fill the user-provided array with the data bytes for the next available
* MIDI message in the input queue and return the event delta-time in seconds.
*
* \param message Must point to a char* that is already allocated.
* SYSEX messages maximum size being 1024, a statically
* allocated array could
* be sufficient.
* \param size Is used to return the size of the message obtained.
*
* See RtMidiIn::getMessage().
*/
RTMIDIAPI double rtmidi_in_get_message (RtMidiInPtr device, unsigned char *message, size_t *size);
/* RtMidiOut API */
//! \brief Create a default RtMidiInPtr value, with no initialization.
RTMIDIAPI RtMidiOutPtr rtmidi_out_create_default (void);
/*! \brief Create a RtMidiOutPtr value, with given and clientName.
*
* \param api An optional API id can be specified.
* \param clientName An optional client name can be specified. This
* will be used to group the ports that are created
* by the application.
*
* See RtMidiOut::RtMidiOut().
*/
RTMIDIAPI RtMidiOutPtr rtmidi_out_create (enum RtMidiApi api, const char *clientName);
//! \brief Free the given RtMidiOutPtr.
RTMIDIAPI void rtmidi_out_free (RtMidiOutPtr device);
//! \brief Returns the MIDI API specifier for the given instance of RtMidiOut.
//! See \ref RtMidiOut::getCurrentApi().
RTMIDIAPI enum RtMidiApi rtmidi_out_get_current_api (RtMidiPtr device);
//! \brief Immediately send a single message out an open MIDI output port.
//! See \ref RtMidiOut::sendMessage().
RTMIDIAPI int rtmidi_out_send_message (RtMidiOutPtr device, const unsigned char *message, int length);
#ifdef __cplusplus
}
#endif
#endif
/*! }@ */
| 9,194
|
C++
|
.h
| 201
| 43.462687
| 113
| 0.707309
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
1,532,431
|
canorus.h
|
canorusmusic_canorus/src/canorus.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef CANORUS_H_
#define CANORUS_H_
// std::unique_ptr for old Qt LTS 5.9.x
// Do not move below mainwin!
#include <iostream> // verbose stuff
#include <memory>
// Python.h needs to be loaded first!
#include "core/autorecovery.h"
#include "ui/mainwin.h"
#include "ui/settingsdialog.h"
#include <QHash>
#include <QList>
#include <QString>
#include <QUndoStack>
#include <memory>
//Duma leads to a crash on libfontconfig with Ubuntu (10.04/12.04)
//#include "duma.h"
class CASettings;
class CAMidiDevice;
class CADocument;
class CAUndo;
class CAHelpCtl;
class CACanorus {
public:
static void initMain(int argc = 0, char* argv[] = nullptr);
static CASettingsDialog::CASettingsPage initSettings();
static void initTranslations();
static void initCommonGUI(std::unique_ptr<QFileDialog>& uiSaveDialog,
std::unique_ptr<QFileDialog>& uiOpenDialog,
std::unique_ptr<QFileDialog>& uiExportDialog,
std::unique_ptr<QFileDialog>& uiImportDialog);
static void initPlayback();
static bool parseSettingsArguments(int argc, char* argv[]);
static void initScripting();
static void initAutoRecovery();
static void initUndo();
static void initSearchPaths();
static void initFonts();
static void initHelp();
static void parseOpenFileArguments(int argc, char* argv[]);
static void cleanUp();
static int fetaCodepoint(const QString& name);
inline static const QList<CAMainWin*>& mainWinList() { return _mainWinList; }
inline static void addMainWin(CAMainWin* w) { _mainWinList << w; }
inline static void removeMainWin(CAMainWin* w) { _mainWinList.removeAll(w); }
static int mainWinCount(CADocument*);
static QList<CAMainWin*> findMainWin(CADocument* document);
inline static void removeView(CAView* v)
{
for (int i = 0; i < mainWinList().size(); i++)
_mainWinList[i]->removeView(v);
}
inline static void restartTimeEditedTimes(CADocument* doc)
{
for (int i = 0; i < mainWinList().size(); i++)
if (mainWinList()[i]->document() == doc)
mainWinList()[i]->restartTimeEditedTime();
}
inline static CAUndo* undo() { return _undo; }
static void addRecentDocument(QString);
static void insertRecentDocument(QString);
static void removeRecentDocument(QString);
inline static QList<QString>& recentDocumentList() { return _recentDocumentList; }
inline static CASettings* settings() { return _settings; }
inline static CAAutoRecovery* autoRecovery() { return _autoRecovery; }
inline static CAMidiDevice* midiDevice() { return _midiDevice; }
inline static void setMidiDevice(CAMidiDevice* d) { _midiDevice = d; }
inline static CAHelpCtl* help() { return _help; }
static void rebuildUI(CADocument* document, CASheet* sheet);
static void rebuildUI(CADocument* document = nullptr);
static void repaintUI();
// Our own slot connection method
static void connectSlotsByName(QObject* pOS, const QObject* pOR);
// Canorus specific names of const properties for actions
static const char* propCommand() { return "Command"; }
static const char* propContext() { return "Context"; }
static const char* propDescription() { return "Description"; }
static const char* propShortCut() { return "ShortCut"; }
static const char* propMidiCommand() { return "MidiCommand"; }
static const char* propConflicts() { return "Conflicts"; }
private:
static QList<CAMainWin*> _mainWinList;
static CASettings* _settings;
static CAUndo* _undo;
static QList<QString> _recentDocumentList;
static std::unique_ptr<QTranslator> _translator;
static QHash<QString, int> _fetaMap;
// Playback output
static CAMidiDevice* _midiDevice;
// Auto recovery
static CAAutoRecovery* _autoRecovery;
// Help
static CAHelpCtl* _help;
};
#endif /* CANORUS_H_ */
| 4,128
|
C++
|
.h
| 100
| 36.83
| 86
| 0.717424
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,432
|
keysignaturectl.h
|
canorusmusic_canorus/src/scorectl/keysignaturectl.h
|
/*!
Copyright (c) 2006-2010, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef _KEYSIGNATURE_CTL_H_
#define _KEYSIGNATURE_CTL_H_
// Includes
#include <QObject>
// Forward declarations
class CAMainWin;
// Keysignature control is a class for implementing UI controls
// for placing key signatures into a score document
// It is created via the Canorus mainwindow (currently)
class CAKeySignatureCtl : public QObject {
Q_OBJECT
public:
CAKeySignatureCtl(CAMainWin* poMainWin, const QString& oHash);
~CAKeySignatureCtl();
void setupActions();
protected:
CAMainWin* _poMainWin;
public slots:
void on_uiInsertKeySig_toggled(bool);
// Key Signature
void on_uiKeySig_activated(int);
private:
const QString _oHash;
};
#endif // _KEYSIGNATURE_CTL_H
| 976
|
C++
|
.h
| 30
| 28.933333
| 93
| 0.75431
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,433
|
dummyctl.h
|
canorusmusic_canorus/src/scorectl/dummyctl.h
|
/*!
Copyright (c) 2006-2010, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef _DUMMY_CTL_H_
#define _DUMMY_CTL_H_
// Includes
#include <QObject>
// Forward declarations
class CAMainWin;
class CADummy;
// Dummy control is an example class for implementing UI controls
// Such controls are created via the Canorus mainwindow (currently)
class CADummyCtl : public QObject {
Q_OBJECT
public:
CADummyCtl(CAMainWin* poMainWin);
~CADummyCtl();
public slots:
void on_uiDummy_triggered();
protected slots:
void myToggle(int iOn);
protected:
CAMainWin* _poMainWin;
CADummy* _poDummy;
};
#endif // _DUMMY_CTL_H
| 830
|
C++
|
.h
| 28
| 26.142857
| 93
| 0.743622
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,434
|
lilypondimport.h
|
canorusmusic_canorus/src/import/lilypondimport.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef LILYPONDIMPORT_H_
#define LILYPONDIMPORT_H_
#include <QStack>
#include <QString>
#include <QTextStream>
#include "score/barline.h"
#include "score/clef.h"
#include "score/diatonicpitch.h"
#include "score/keysignature.h"
#include "score/lyricscontext.h"
#include "score/playablelength.h"
#include "score/rest.h"
#include "score/syllable.h"
#include "score/timesignature.h"
#include "score/voice.h"
#include "import/import.h"
class QTextStream;
class CALilyPondImport : public CAImport {
#ifndef SWIG
Q_OBJECT
#endif
public:
// Constructors
CALilyPondImport(const QString in);
CALilyPondImport(QTextStream* in = 0);
CALilyPondImport(CADocument* document, QTextStream* in = 0);
inline void setTemplateVoice(CAVoice* voice) { _templateVoice = voice; }
// Destructor
virtual ~CALilyPondImport();
const QString readableStatus();
CASheet* importSheetImpl();
private:
void initLilyPondImport();
static const QRegExp WHITESPACE_DELIMITERS;
static const QRegExp SYNTAX_DELIMITERS;
static const QRegExp DELIMITERS;
// Internal time signature
struct CATime {
int beats;
int beat;
};
enum CALilyPondDepth {
Score,
Layout,
Voice,
Chord
};
// Actual import of the input string
CAVoice* importVoiceImpl();
CALyricsContext* importLyricsContextImpl();
inline CAVoice* curVoice() { return _curVoice; }
inline void setCurVoice(CAVoice* voice) { _curVoice = voice; }
const QString parseNextElement();
const QString peekNextElement();
void addError(QString description, int lineError = 0, int charError = 0);
//////////////////////
// Helper functions //
//////////////////////
CAPlayableLength playableLengthFromLilyPond(QString& playableElt, bool parse = false);
bool isNote(const QString elt);
CADiatonicPitch relativePitchFromLilyPond(QString& note, CADiatonicPitch prevPitch, bool parse = false);
bool isRest(const QString elt);
CARest::CARestType restTypeFromLilyPond(QString& rest, bool parse = false);
CAClef::CAPredefinedClefType predefinedClefTypeFromLilyPond(const QString clef);
int clefOffsetFromLilyPond(const QString clef);
CABarline::CABarlineType barlineTypeFromLilyPond(const QString bar);
CADiatonicKey::CAGender diatonicKeyGenderFromLilyPond(QString gender);
CATime timeSigFromLilyPond(QString time);
CAMusElement* findSharedElement(CAMusElement* elt);
///////////////////////////
// Getter/Setter methods //
///////////////////////////
inline QString& in() { return *stream()->string(); }
inline CALilyPondDepth curDepth() { return _depth.top(); }
inline void pushDepth(CALilyPondDepth depth) { _depth.push(depth); }
inline CALilyPondDepth popDepth() { return _depth.pop(); }
inline int curLine() { return _curLine; }
inline int curChar() { return _curChar; }
// Attributes
CAVoice* _curVoice;
CASlur* _curSlur;
CASlur* _curPhrasingSlur;
QStack<CALilyPondDepth> _depth; // which block is currently processed
int _curLine, _curChar;
QList<QString> _errors;
QList<QString> _warnings;
inline CAVoice* templateVoice() { return _templateVoice; }
CAVoice* _templateVoice; // used when importing voice to set the staff etc.
CADocument* _document;
};
#endif /* LILYPONDIMPORT_H_ */
| 3,610
|
C++
|
.h
| 96
| 33.28125
| 108
| 0.713754
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,435
|
canorusmlimport.h
|
canorusmusic_canorus/src/import/canorusmlimport.h
|
/*!
Copyright (c) 2006-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef CANORUSMLIMPORT_H_
#define CANORUSMLIMPORT_H_
#include <QColor>
#include <QHash>
#include <QStack>
#include <QVersionNumber>
#include <QXmlDefaultHandler>
#include "import/import.h"
#include "score/diatonickey.h"
#include "score/diatonicpitch.h"
#include "score/playablelength.h"
class CAContext;
class CAKeySignature;
class CATimeSignature;
class CAClef;
class CABarline;
class CANote;
class CARest;
class CASlur;
class CASyllable;
class CAMusElement;
class CAMark;
class CATuplet;
class CACanorusMLImport : public CAImport, public QXmlDefaultHandler {
public:
CACanorusMLImport(QTextStream* stream = 0);
CACanorusMLImport(const QString stream);
virtual ~CACanorusMLImport();
void initCanorusMLImport();
CADocument* importDocumentImpl();
bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName,
const QXmlAttributes& attributes);
bool endElement(const QString& namespaceURI, const QString& localName,
const QString& qName);
bool fatalError(const QXmlParseException& exception);
bool characters(const QString& ch);
private:
void importMark(const QXmlAttributes& attributes);
void importResource(const QXmlAttributes& attributes);
inline CADocument* document() { return _document; }
CADocument* _document;
QVersionNumber _version; // version of Canorus the imported file was created with
QString _errorMsg;
QStack<QString> _depth;
// Pointers to the current elements when reading the XML file
CASheet* _curSheet;
CAContext* _curContext;
CAVoice* _curVoice;
CAKeySignature* _curKeySig;
CATimeSignature* _curTimeSig;
CAClef* _curClef;
CABarline* _curBarline;
CANote* _curNote;
CARest* _curRest;
CAMusElement* _curMusElt;
CAMusElement* _prevMusElt; // previous musElt by depth
CAMark* _curMark;
CASlur* _curTie;
CASlur* _curSlur;
CATuplet* _curTuplet;
CASlur* _curPhrasingSlur;
CADiatonicPitch _curDiatonicPitch;
CADiatonicKey _curDiatonicKey;
CAPlayableLength _curPlayableLength;
CAPlayableLength _curTempoPlayableLength;
QHash<CALyricsContext*, int> _lcMap; // lyrics context associated voice indices
QHash<CASyllable*, int> _syllableMap; // syllable associated voice indices
QColor _color; // foreground color of elements
//////////////////////////////////////////////
// Temporary properties for each XML stanza //
//////////////////////////////////////////////
QString _cha;
};
#endif /* CANORUSMLIMPORT_H_ */
| 2,783
|
C++
|
.h
| 79
| 31.556962
| 98
| 0.735119
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,436
|
mxlimport.h
|
canorusmusic_canorus/src/import/mxlimport.h
|
/*!
Copyright (c) 2018, Matevž Jekovec, Reinhard Katzmann, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef MXLIMPORT_H_
#define MXLIMPORT_H_
#include "import/import.h"
#include "import/musicxmlimport.h"
#include "zip/zip.h"
#include <QFileInfo>
#include <QSharedPointer>
class CAMXLImport : public CAMusicXmlImport {
public:
CAMXLImport(QTextStream* stream = nullptr);
CAMXLImport(const QString stream);
virtual ~CAMXLImport();
inline QTextStream* txtStream() { return _txtStream; }
inline void setTxtStream(QTextStream* stream) { _txtStream = stream; }
protected:
CADocument* importDocumentImpl();
private:
bool openContainer(const QFileInfo& containerInfo);
bool readContainerInfo(QString& musicXMLFileName);
QTextStream* _txtStream = nullptr;
QString _zipArchivePath;
};
#endif /* MUSICXMLIMPORT_H_ */
| 988
|
C++
|
.h
| 28
| 32.392857
| 81
| 0.769474
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,437
|
musicxmlimport.h
|
canorusmusic_canorus/src/import/musicxmlimport.h
|
/*!
Copyright (c) 2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef MUSICXMLIMPORT_H_
#define MUSICXMLIMPORT_H_
#include <QHash>
#include <QMultiHash>
#include <QStack>
#include <QString>
#include <QXmlStreamReader>
#include "import/import.h"
#include "score/diatonicpitch.h"
#include "score/playablelength.h"
class CADocument;
class CASheet;
class CAStaff;
class CAClef;
class CAKeySignature;
class CATimeSignature;
class CATempo;
class CAMusicXmlImport : public CAImport, private QXmlStreamReader {
#ifndef SWIG
Q_OBJECT
#endif
public:
CAMusicXmlImport(QTextStream* stream = 0);
CAMusicXmlImport(const QString stream);
virtual ~CAMusicXmlImport();
const QString readableStatus();
protected:
CADocument* importDocumentImpl();
private:
void initMusicXmlImport();
void readHeader();
void readScorePartwise();
void readScoreTimewise();
void readWork();
void readIdentification();
void readDefaults();
void readPartList();
void readPart();
void readMeasure(QString partId);
void readAttributes(QString partId);
void readNote(QString partId, int);
void readForward(QString partId, int);
void readSound(QString partId);
CAVoice* addVoiceIfNeeded(QString partId, int staff, int voice);
void addStavesIfNeeded(QString partId, int staves);
QString _musicXmlVersion;
CADocument* _document;
QHash<QString, QHash<int, CAVoice*>> _partMapVoice; // part name -> map of voice number : voice
QHash<QString, QList<CAStaff*>> _partMapStaff; // part name -> list of staffs
QHash<QString, QHash<int, CAClef*>> _partMapClef; // part name -> map of staff number : last clef
QHash<QString, QHash<int, CAKeySignature*>> _partMapKeySig; // part name -> map of staff number : last keysig
QHash<QString, QHash<int, CATimeSignature*>> _partMapTimeSig; // part name -> map of staff number : last timesig
QHash<QString, int> _midiChannel; // 1-16
QHash<QString, int> _midiProgram; // 1-128
QHash<QString, QString> _partName;
QHash<QString, int> _divisions; // part name -> divisions
int _tempoBpm; // current tempo buffer, append to first found note, set to -1 then
};
#endif /* MUSICXMLIMPORT_H_ */
| 2,373
|
C++
|
.h
| 64
| 33.703125
| 116
| 0.743031
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,438
|
canimport.h
|
canorusmusic_canorus/src/import/canimport.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Itay Perl, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef CANIMPORT_H_
#define CANIMPORT_H_
#include "import/import.h"
class CAArchive;
class CACanImport : public CAImport {
public:
CACanImport(QTextStream* stream = 0);
~CACanImport();
inline CAArchive* archive() { return _archive; }
inline void setArchive(CAArchive* a) { _archive = a; }
protected:
CADocument* importDocumentImpl();
private:
CAArchive* _archive;
};
#endif /* CANIMPORT_H_ */
| 652
|
C++
|
.h
| 21
| 28.285714
| 76
| 0.742351
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,439
|
import.h
|
canorusmusic_canorus/src/import/import.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef IMPORT_H_
#define IMPORT_H_
#include "core/file.h"
class CADocument;
class CASheet;
class CAStaff;
class CAVoice;
class CALyricsContext;
class CAFunctionMarkContext;
class CAImport : public CAFile {
#ifndef SWIG
Q_OBJECT
#endif
public:
CAImport(QTextStream* stream = nullptr);
CAImport(const QString stream);
virtual ~CAImport();
void setStreamFromFile(const QString filename);
QString fileName();
virtual const QString readableStatus();
void importDocument();
void importSheet();
void importStaff();
void importVoice();
void importLyricsContext();
void importFunctionMarkContext();
inline CADocument* importedDocument() { return _importedDocument; }
inline CASheet* importedSheet() { return _importedSheet; }
inline CAStaff* importedStaff() { return _importedStaff; }
inline CAVoice* importedVoice() { return _importedVoice; }
inline CALyricsContext* importedLyricsContext() { return _importedLyricsContext; }
inline CAFunctionMarkContext* importedFunctionMarkContext() { return _importedFunctionMarkContext; }
#ifndef SWIG
signals:
void documentImported(CADocument*);
void sheetImported(CASheet*);
void staffImported(CAStaff*);
void voiceImported(CAVoice*);
void lyricsContextImported(CALyricsContext*);
void functionMarkContextImported(CAFunctionMarkContext*);
void importDone(int status);
#endif
protected:
virtual CADocument* importDocumentImpl()
{
setStatus(0);
return nullptr;
}
virtual CASheet* importSheetImpl()
{
setStatus(0);
return nullptr;
}
virtual CAStaff* importStaffImpl()
{
setStatus(0);
return nullptr;
}
virtual CAVoice* importVoiceImpl()
{
setStatus(0);
return nullptr;
}
virtual CALyricsContext* importLyricsContextImpl()
{
setStatus(0);
return nullptr;
}
virtual CAFunctionMarkContext* importFunctionMarkContextImpl()
{
setStatus(0);
return nullptr;
}
#ifndef SWIG
QTextStream& in()
{
return *stream();
}
#else
QTextStream& _in()
{
return *stream();
}
#endif
protected:
QString _fileName;
private:
inline void setImportedDocument(CADocument* doc) { _importedDocument = doc; }
inline void setImportedSheet(CASheet* sheet) { _importedSheet = sheet; }
inline void setImportedStaff(CAStaff* staff) { _importedStaff = staff; }
inline void setImportedVoice(CAVoice* voice) { _importedVoice = voice; }
inline void setImportedLyricsContext(CALyricsContext* lc) { _importedLyricsContext = lc; }
inline void setImportedFunctionMarkContext(CAFunctionMarkContext* fmc) { _importedFunctionMarkContext = fmc; }
CADocument* _importedDocument;
CASheet* _importedSheet;
CAStaff* _importedStaff;
CAVoice* _importedVoice;
CALyricsContext* _importedLyricsContext;
CAFunctionMarkContext* _importedFunctionMarkContext;
enum CAImportPart {
Undefined,
Document,
Sheet,
Staff,
Voice,
LyricsContext,
FunctionMarkContext
};
void run();
inline void setImportPart(CAImportPart part) { _importPart = part; }
inline CAImportPart importPart() { return _importPart; }
CAImportPart _importPart;
};
#endif /* IMPORT_H_ */
| 3,593
|
C++
|
.h
| 119
| 25.285714
| 114
| 0.715278
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,440
|
midiimport.h
|
canorusmusic_canorus/src/import/midiimport.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef MIDIIMPORT_H_
#define MIDIIMPORT_H_
#include <QStack>
#include <QString>
#include <QTextStream>
//#include "core/muselementfactory.h"
#include "score/barline.h"
#include "score/clef.h"
#include "score/diatonicpitch.h"
#include "score/keysignature.h"
#include "score/lyricscontext.h"
#include "score/playablelength.h"
#include "score/rest.h"
#include "score/syllable.h"
#include "score/timesignature.h"
#include "score/voice.h"
#include "import/import.h"
class QTextStream;
class CAMidiDevice;
class CAMidiImportEvent;
class CAMidiNote;
class CAMidiImport : public CAImport {
#ifndef SWIG
Q_OBJECT
#endif
public:
// Constructor
CAMidiImport(CADocument* document = nullptr, QTextStream* in = nullptr);
// Destructor
virtual ~CAMidiImport();
// close midi in file after import
void closeFile();
// where the real work is done
CADocument* importDocumentImpl();
CASheet* importSheetImpl();
QList<QList<CAMidiNote*>> importMidiNotes();
const QString readableStatus();
QList<int> midiProgramList() { return _midiProgramList; }
private:
// Alternatives during developement
CASheet* importSheetImplPmidiParser(CASheet* sheet);
void importMidiEvents();
void initMidiImport();
static const QRegExp WHITESPACE_DELIMITERS;
static const QRegExp SYNTAX_DELIMITERS;
static const QRegExp DELIMITERS;
// Internal time signature
struct CATime {
int beats;
int beat;
};
private:
enum CALilyPondDepth {
Score,
Layout,
Voice,
Chord
};
inline CAVoice* curVoice() { return _curVoice; }
inline void setCurVoice(CAVoice* voice) { _curVoice = voice; }
void addError(QString description, int lineError = 0, int charError = 0);
// the next four objects should be moved to CADiatonicPitch, doubles are in CAKeybdInput
CADiatonicPitch _actualKeySignature;
signed char _actualKeySignatureAccs[7];
int _actualKeyAccidentalsSum;
CADiatonicPitch matchPitchToKey(CAVoice* voice, int midiPitch);
//////////////////////
// Helper functions //
//////////////////////
///////////////////////////
// Getter/Setter methods //
///////////////////////////
inline QString& in() { return *stream()->string(); }
inline CALilyPondDepth curDepth() { return _depth.top(); }
inline void pushDepth(CALilyPondDepth depth) { _depth.push(depth); }
inline CALilyPondDepth popDepth() { return _depth.pop(); }
inline int curLine() { return _curLine; }
inline int curChar() { return _curChar; }
// Attributes
CAVoice* _curVoice;
CASlur* _curSlur;
CASlur* _curPhrasingSlur;
QStack<CALilyPondDepth> _depth; // which block is currently processed
int _curLine, _curChar;
QList<QString> _errors;
QList<QString> _warnings;
QList<int> _midiProgramList; // list of first instruments in the channel or -1, if not defined
//inline CAVoice *templateVoice() { return _templateVoice; }
//CAVoice *_templateVoice; // used when importing voice to set the staff etc.
//////////////////////
// Helper functions //
//////////////////////
CADocument* _document;
QVector<QList<QList<CAMidiImportEvent*>*>*> _allChannelsEvents;
QList<CAMidiImportEvent*> _eventsX;
void writeMidiFileEventsToScore_New(CASheet* sheet);
void writeMidiChannelEventsToVoice_New(int channel, int voiceIndex, CAStaff* staff, CAVoice* voice);
QVector<int> _allChannelsMediumPitch;
QVector<CAClef*> _allChannelsClef;
QVector<CAKeySignature*> _allChannelsKeySignatures;
QVector<CAMidiImportEvent*> _allChannelsTimeSignatures;
// When voices are built these functions are used to create or determine the current clef/signature
int _actualClefIndex;
CAMusElement* getOrCreateClef(int time, int voiceIndex, CAStaff* staff, CAVoice* voice);
int _actualKeySignatureIndex;
int getNextKeySignatureTime();
CAMusElement* getOrCreateKeySignature(int time, int voiceIndex, CAStaff* staff, CAVoice* voice);
int _actualTimeSignatureIndex;
CAMusElement* getOrCreateTimeSignature(int time, int voiceIndex, CAStaff* staff, CAVoice* voice);
int _numberOfAllVoices;
void fixAccidentals(CASheet* s);
};
#endif /* MIDIIMPORT_H_ */
| 4,513
|
C++
|
.h
| 118
| 33.932203
| 104
| 0.709869
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,441
|
wrapper.h
|
canorusmusic_canorus/src/import/pmidi/wrapper.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Georg Rudolph, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef WRAPPER_H_
#define WRAPPER_H_
#ifdef __cplusplus
extern "C" {
#endif
#define PMIDI_STATUS_END 0
#define PMIDI_STATUS_VERSION 1
#define PMIDI_STATUS_TEXT 2
#define PMIDI_STATUS_KEYSIG 3
#define PMIDI_STATUS_TIMESIG 4
#define PMIDI_STATUS_TEMPO 5
#define PMIDI_STATUS_NOTE 6
#define PMIDI_STATUS_DUMMY 7
#define PMIDI_STATUS_ROOT 8
#define PMIDI_STATUS_CONTROL 9
#define PMIDI_STATUS_PROGRAM 10
#define PMIDI_STATUS_PITCH 11
#define PMIDI_STATUS_PRESSURE 12
#define PMIDI_STATUS_KEYTOUCH 13
#define PMIDI_STATUS_SYSEX 14
#define PMIDI_STATUS_SMPTEOFFS 15
extern struct pmidi_outs {
int format; /* midi 1 or 2 */
int tracks;
int time_base;
int micro_tempo; /* micro secondes per quarter */
int time; /* occurence of element */
int type; /* Type of text (lyric, copyright etc) */
char* name; /* Type as text */
char* text; /* actual text */
int key; /* Key signature */
int minor; /* Is this a minor key or not */
int top; /* 'top' of timesignature */
int bottom; /* 'bottom' of timesignature */
int clocks; /* Can't remember what this is */
int n32pq; /* Thirtysecond notes per quarter */
int program; /* Program number */
int chan; /* Channel number */
int note;
int vel;
int length;
int offvel; /* Note Off velocity */
int control; /* Controller number */
int value; /* Controller value */
int pitch; /* Pitch bending */
int hours; /* SMPTE-Offset */
int minutes;
int seconds;
int frames;
int subframes;
} pmidi_out;
extern int pmidi_wrapper_status;
extern int pmidi_open_midi_file(const char* fileName);
extern int pmidi_parse_midi_file(void);
#ifdef __cplusplus
}
#endif
#endif /* WRAPPER_H_ */
| 1,967
|
C++
|
.h
| 63
| 28.031746
| 79
| 0.705352
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,442
|
except.h
|
canorusmusic_canorus/src/import/pmidi/except.h
|
/*
*
* except.m - XXX
*
* Copyright (C) 1999 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*/
#include <setjmp.h>
struct except {
int set;
#ifdef __MINGW32__
jmp_buf buf;
#else
sigjmp_buf buf;
#endif
};
extern struct except* formatError; /* Bad file format */
extern struct except* ioError; /* Error reading/writing file */
extern struct except* debugError; /* Debugging 'shouldn't happen' errors */
void except(struct except* e, char* message, ...);
| 900
|
C++
|
.h
| 30
| 27.733333
| 75
| 0.726328
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,443
|
intl.h
|
canorusmusic_canorus/src/import/pmidi/intl.h
|
/*
* intl.h - Internationalisation for melys
*
* Copyright (C) 1999 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifdef I18N
#include "libintl.h"
#define _(_STRING) gettext(_STRING)
#define N_(_STRING) _STRING
#else
#define _(_STRING) _STRING
#define N_(_STRING) _STRING
#endif
| 711
|
C++
|
.h
| 22
| 30.318182
| 72
| 0.74817
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,444
|
glib.h
|
canorusmusic_canorus/src/import/pmidi/glib.h
|
/* GLIB - Library of useful routines for C programming
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GLib Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GLib at ftp://ftp.gtk.org/pub/gtk/.
* Modified: Steve Ratcliffe May 1999. File exists so that pmidi
* is not dependant on glib.
*/
#ifndef __G_LIB_H__
#define __G_LIB_H__
#include <stdlib.h>
#include <string.h>
/* system specific config file glibconfig.h provides definitions for
* the extrema of many of the standard types. These are:
*
* G_MINSHORT, G_MAXSHORT
* G_MININT, G_MAXINT
* G_MINLONG, G_MAXLONG
* G_MINFLOAT, G_MAXFLOAT
* G_MINDOUBLE, G_MAXDOUBLE
*
* It also provides the following typedefs:
*
* gint8, guint8
* gint16, guint16
* gint32, guint32
* gint64, guint64
*
* It defines the G_BYTE_ORDER symbol to one of G_*_ENDIAN (see later in
* this file).
*
* And it provides a way to store and retrieve a `gint' in/from a `gpointer'.
* This is useful to pass an integer instead of a pointer to a callback.
*
* GINT_TO_POINTER(i), GUINT_TO_POINTER(i)
* GPOINTER_TO_INT(p), GPOINTER_TO_UINT(p)
*
* Finally, it provide the following wrappers to STDC functions:
*
* g_ATEXIT
* To register hooks which are executed on exit().
* Usually a wrapper for STDC atexit.
*
* void *g_memmove(void *dest, const void *src, guint count);
* A wrapper for STDC memmove, or an implementation, if memmove doesn't
* exist. The prototype looks like the above, give or take a const,
* or size_t.
*/
typedef signed char gint8;
typedef unsigned char guint8;
typedef signed short gint16;
typedef unsigned short guint16;
typedef signed int gint32;
typedef unsigned int guint32;
/* include varargs functions for assertment macros
*/
#include <stdarg.h>
/* optionally feature DMALLOC memory allocation debugger
*/
#ifdef USE_DMALLOC
#include "dmalloc.h"
#endif
#ifdef NATIVE_WIN32
/* On native Win32, directory separator is the backslash, and search path
* separator is the semicolon.
*/
#define G_DIR_SEPARATOR '\\'
#define G_DIR_SEPARATOR_S "\\"
#define G_SEARCHPATH_SEPARATOR ';'
#define G_SEARCHPATH_SEPARATOR_S ";"
#else /* !NATIVE_WIN32 */
/* Unix */
#define G_DIR_SEPARATOR '/'
#define G_DIR_SEPARATOR_S "/"
#define G_SEARCHPATH_SEPARATOR ':'
#define G_SEARCHPATH_SEPARATOR_S ":"
#endif /* !NATIVE_WIN32 */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Provide definitions for some commonly used macros.
* Some of them are only provided if they haven't already
* been defined. It is assumed that if they are already
* defined then the current definition is correct.
*/
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#undef ABS
#define ABS(a) (((a) < 0) ? -(a) : (a))
#undef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
/* Define G_VA_COPY() to do the right thing for copying va_list variables.
* glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.
*/
#if !defined(G_VA_COPY)
#if defined(__GNUC__) && defined(__PPC__) && (defined(_CALL_SYSV) || defined(_WIN32))
#define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
#elif defined(G_VA_COPY_AS_ARRAY)
#define G_VA_COPY(ap1, ap2) g_memmove((ap1), (ap2), sizeof(va_list))
#else /* va_list is a pointer */
#define G_VA_COPY(ap1, ap2) ((ap1) = (ap2))
#endif /* va_list is a pointer */
#endif /* !G_VA_COPY */
/* Provide convenience macros for handling structure
* fields through their offsets.
*/
#define G_STRUCT_OFFSET(struct_type, member) \
((gulong)((gchar*)&((struct_type*)0)->member))
#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
((gpointer)((gchar*)(struct_p) + (gulong)(struct_offset)))
#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
(*(member_type*)G_STRUCT_MEMBER_P((struct_p), (struct_offset)))
/* inlining hassle. for compilers that don't allow the `inline' keyword,
* mostly because of strict ANSI C compliance or dumbness, we try to fall
* back to either `__inline__' or `__inline'.
* we define G_CAN_INLINE, if the compiler seems to be actually
* *capable* to do function inlining, in which case inline function bodys
* do make sense. we also define G_INLINE_FUNC to properly export the
* function prototypes if no inlining can be performed.
* we special case most of the stuff, so inline functions can have a normal
* implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1.
*/
#ifndef G_INLINE_FUNC
#define G_CAN_INLINE 1
#endif
#ifdef G_HAVE_INLINE
#if defined(__GNUC__) && defined(__STRICT_ANSI__)
#undef inline
#define inline __inline__
#endif
#else /* !G_HAVE_INLINE */
#undef inline
#if defined(G_HAVE___INLINE__)
#define inline __inline__
#else /* !inline && !__inline__ */
#if defined(G_HAVE___INLINE)
#define inline __inline
#else /* !inline && !__inline__ && !__inline */
#define inline /* don't inline, then */
#ifndef G_INLINE_FUNC
#undef G_CAN_INLINE
#endif
#endif
#endif
#endif
#ifndef G_INLINE_FUNC
#ifdef __GNUC__
#ifdef __OPTIMIZE__
#define G_INLINE_FUNC extern inline
#else
#undef G_CAN_INLINE
#define G_INLINE_FUNC extern
#endif
#else /* !__GNUC__ */
#ifdef G_CAN_INLINE
#define G_INLINE_FUNC static inline
#else
#define G_INLINE_FUNC extern
#endif
#endif /* !__GNUC__ */
#endif /* !G_INLINE_FUNC */
/* Provide simple macro statement wrappers (adapted from Perl):
* G_STMT_START { statements; } G_STMT_END;
* can be used as a single statement, as in
* if (x) G_STMT_START { ... } G_STMT_END; else ...
*
* For gcc we will wrap the statements within `({' and `})' braces.
* For SunOS they will be wrapped within `if (1)' and `else (void) 0',
* and otherwise within `do' and `while (0)'.
*/
#if !(defined(G_STMT_START) && defined(G_STMT_END))
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(__cplusplus)
#define G_STMT_START (void)(
#define G_STMT_END )
#else
#if (defined(sun) || defined(__sun__))
#define G_STMT_START if (1)
#define G_STMT_END else(void) 0
#else
#define G_STMT_START do
#define G_STMT_END while (0)
#endif
#endif
#endif
/* Provide macros to feature the GCC function attribute.
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define G_GNUC_PRINTF(format_idx, arg_idx) \
__attribute__((format(printf, format_idx, arg_idx)))
#define G_GNUC_SCANF(format_idx, arg_idx) \
__attribute__((format(scanf, format_idx, arg_idx)))
#define G_GNUC_FORMAT(arg_idx) \
__attribute__((format_arg(arg_idx)))
#define G_GNUC_NORETURN \
__attribute__((noreturn))
#define G_GNUC_CONST \
__attribute__((const))
#define G_GNUC_UNUSED \
__attribute__((unused))
#else /* !__GNUC__ */
#define G_GNUC_PRINTF(format_idx, arg_idx)
#define G_GNUC_SCANF(format_idx, arg_idx)
#define G_GNUC_FORMAT(arg_idx)
#define G_GNUC_NORETURN
#define G_GNUC_CONST
#define G_GNUC_UNUSED
#endif /* !__GNUC__ */
/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
* macros, so we can refer to them as strings unconditionally.
*/
#ifdef __GNUC__
#define G_GNUC_FUNCTION __FUNCTION__
#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else /* !__GNUC__ */
#define G_GNUC_FUNCTION ""
#define G_GNUC_PRETTY_FUNCTION ""
#endif /* !__GNUC__ */
/* we try to provide a usefull equivalent for ATEXIT if it is
* not defined, but use is actually abandoned. people should
* use g_atexit() instead.
*/
#ifndef ATEXIT
#define ATEXIT(proc) g_ATEXIT(proc)
#else
#define G_NATIVE_ATEXIT
#endif /* ATEXIT */
/* Hacker macro to place breakpoints for elected machines.
* Actual use is strongly deprecated of course ;)
*/
#if defined(__i386__) && defined(__GNUC__) && __GNUC__ >= 2
#define G_BREAKPOINT() \
G_STMT_START { __asm__ __volatile__("int $03"); } \
G_STMT_END
#elif defined(__alpha__) && defined(__GNUC__) && __GNUC__ >= 2
#define G_BREAKPOINT() \
G_STMT_START { __asm__ __volatile__("bpt"); } \
G_STMT_END
#else /* !__i386__ && !__alpha__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
/* Provide macros for easily allocating memory. The macros
* will cast the allocated memory to the specified type
* in order to avoid compiler warnings. (Makes the code neater).
*/
#define g_new(type, count) \
((type*)malloc((unsigned)sizeof(type) * (count)))
#define g_new0(type, count) \
((type*)calloc((unsigned)sizeof(type) * (count), 1))
#define g_renew(type, mem, count) \
((type*)realloc(mem, (unsigned)sizeof(type) * (count)))
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
g_mem_chunk_new(#type " mem chunks (" #pre_alloc ")", \
sizeof(type), \
sizeof(type) * (pre_alloc), \
(alloc_type)))
#define g_chunk_new(type, chunk) ( \
(type*)g_mem_chunk_alloc(chunk))
#define g_chunk_new0(type, chunk) ( \
(type*)g_mem_chunk_alloc0(chunk))
#define g_chunk_free(mem, mem_chunk) \
G_STMT_START \
{ \
g_mem_chunk_free((mem_chunk), (mem)); \
} \
G_STMT_END
#define g_string(x) #x
/* Provide macros for error handling. The "assert" macros will
* exit on failure. The "return" macros will exit the current
* function. Two different definitions are given for the macros
* if G_DISABLE_ASSERT is not defined, in order to support gcc's
* __PRETTY_FUNCTION__ capability.
*/
#ifdef G_DISABLE_ASSERT
#define g_assert(expr)
#define g_assert_not_reached()
#else /* !G_DISABLE_ASSERT */
#ifdef __GNUC__
#define g_assert(expr) \
G_STMT_START \
{ \
if (!(expr)) \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
} \
G_STMT_END
#define g_assert_not_reached() \
G_STMT_START \
{ \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); \
} \
G_STMT_END
#else /* !__GNUC__ */
#define g_assert(expr) \
G_STMT_START \
{ \
if (!(expr)) \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); \
} \
G_STMT_END
#define g_assert_not_reached() \
G_STMT_START \
{ \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: should not be reached", \
__FILE__, \
__LINE__); \
} \
G_STMT_END
#endif /* __GNUC__ */
#endif /* !G_DISABLE_ASSERT */
#ifdef G_DISABLE_CHECKS
#define g_return_if_fail(expr)
#define g_return_val_if_fail(expr, val)
#else /* !G_DISABLE_CHECKS */
#ifdef __GNUC__
#define g_return_if_fail(expr) \
G_STMT_START \
{ \
if (!(expr)) { \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d (%s): assertion `%s' failed.", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return; \
}; \
} \
G_STMT_END
#define g_return_val_if_fail(expr, val) \
G_STMT_START \
{ \
if (!(expr)) { \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d (%s): assertion `%s' failed.", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return val; \
}; \
} \
G_STMT_END
#else /* !__GNUC__ */
#define g_return_if_fail(expr) \
G_STMT_START \
{ \
if (!(expr)) { \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d: assertion `%s' failed.", \
__FILE__, \
__LINE__, \
#expr); \
return; \
}; \
} \
G_STMT_END
#define g_return_val_if_fail(expr, val) \
G_STMT_START \
{ \
if (!(expr)) { \
g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d: assertion `%s' failed.", \
__FILE__, \
__LINE__, \
#expr); \
return val; \
}; \
} \
G_STMT_END
#endif /* !__GNUC__ */
#endif /* !G_DISABLE_CHECKS */
/* Provide type definitions for commonly used types.
* These are useful because a "gint8" can be adjusted
* to be 1 byte (8 bits) on all platforms. Similarly and
* more importantly, "gint32" can be adjusted to be
* 4 bytes (32 bits) on all platforms.
*/
typedef char gchar;
typedef short gshort;
typedef long glong;
typedef int gint;
typedef gint gboolean;
typedef unsigned char guchar;
typedef unsigned short gushort;
typedef unsigned long gulong;
typedef unsigned int guint;
typedef float gfloat;
typedef double gdouble;
/* HAVE_LONG_DOUBLE doesn't work correctly on all platforms.
* Since gldouble isn't used anywhere, just disable it for now */
#if 0
#ifdef HAVE_LONG_DOUBLE
typedef long double gldouble;
#else /* HAVE_LONG_DOUBLE */
typedef double gldouble;
#endif /* HAVE_LONG_DOUBLE */
#endif /* 0 */
typedef void* gpointer;
typedef const void* gconstpointer;
typedef gint32 gssize;
typedef guint32 gsize;
typedef guint32 GQuark;
typedef gint32 GTime;
/* Portable endian checks and conversions
*
* glibconfig.h defines G_BYTE_ORDER which expands to one of
* the below macros.
*/
#define G_LITTLE_ENDIAN 1234
#define G_BIG_ENDIAN 4321
#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */
/* Basic bit swapping functions
*/
#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16)( \
(((guint16)(val) & (guint16)0x00ffU) << 8) | (((guint16)(val) & (guint16)0xff00U) >> 8)))
#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32)( \
(((guint32)(val) & (guint32)0x000000ffU) << 24) | (((guint32)(val) & (guint32)0x0000ff00U) << 8) | (((guint32)(val) & (guint32)0x00ff0000U) >> 8) | (((guint32)(val) & (guint32)0xff000000U) >> 24)))
/* Intel specific stuff for speed
*/
#if defined(__i386__) && defined(__GNUC__) && __GNUC__ >= 2
#define GUINT16_SWAP_LE_BE_X86(val) \
(__extension__({ register guint16 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT16_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __const__ ("rorw $8, %w0" \
: "=r" (__v) \
: "0" ((guint16) (val))); \
__v; }))
#define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_X86(val))
#if !defined(__i486__) && !defined(__i586__) \
&& !defined(__pentium__) && !defined(__i686__) && !defined(__pentiumpro__)
#define GUINT32_SWAP_LE_BE_X86(val) \
(__extension__({ register guint32 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __const__ ("rorw $8, %w0\n\t" \
"rorl $16, %0\n\t" \
"rorw $8, %w0" \
: "=r" (__v) \
: "0" ((guint32) (val))); \
__v; }))
#else /* 486 and higher has bswap */
#define GUINT32_SWAP_LE_BE_X86(val) \
(__extension__({ register guint32 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __const__ ("bswap %0" \
: "=r" (__v) \
: "0" ((guint32) (val))); \
__v; }))
#endif /* processor specific 32-bit stuff */
#define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86(val))
#else /* !__i386__ */
#define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT(val))
#define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT(val))
#endif /* __i386__ */
#ifdef G_HAVE_GINT64
#define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64)( \
(((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x00000000000000ffU)) << 56) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x000000000000ff00U)) << 40) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x0000000000ff0000U)) << 24) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x00000000ff000000U)) << 8) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x000000ff00000000U)) >> 8) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x0000ff0000000000U)) >> 24) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0x00ff000000000000U)) >> 40) | (((guint64)(val) & (guint64)G_GINT64_CONSTANT(0xff00000000000000U)) >> 56)))
#if defined(__i386__) && defined(__GNUC__) && __GNUC__ >= 2
#define GUINT64_SWAP_LE_BE_X86(val) \
(__extension__({ union { guint64 __ll; \
guint32 __l[2]; } __r; \
if (__builtin_constant_p (val)) \
__r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (val); \
else \
{ \
union { guint64 __ll; \
guint32 __l[2]; } __w; \
__w.__ll = ((guint64) val); \
__r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \
__r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \
} \
__r.__ll; }))
#define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86(val))
#else /* !__i386__ */
#define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT(val))
#endif
#endif
#define GUINT16_SWAP_LE_PDP(val) ((guint16)(val))
#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE(val))
#define GUINT32_SWAP_LE_PDP(val) ((guint32)( \
(((guint32)(val) & (guint32)0x0000ffffU) << 16) | (((guint32)(val) & (guint32)0xffff0000U) >> 16)))
#define GUINT32_SWAP_BE_PDP(val) ((guint32)( \
(((guint32)(val) & (guint32)0x00ff00ffU) << 8) | (((guint32)(val) & (guint32)0xff00ff00U) >> 8)))
/* The G*_TO_?E() macros are defined in glibconfig.h.
* The transformation is symmetric, so the FROM just maps to the TO.
*/
#define GINT16_FROM_LE(val) (GINT16_TO_LE(val))
#define GUINT16_FROM_LE(val) (GUINT16_TO_LE(val))
#define GINT16_FROM_BE(val) (GINT16_TO_BE(val))
#define GUINT16_FROM_BE(val) (GUINT16_TO_BE(val))
#define GINT32_FROM_LE(val) (GINT32_TO_LE(val))
#define GUINT32_FROM_LE(val) (GUINT32_TO_LE(val))
#define GINT32_FROM_BE(val) (GINT32_TO_BE(val))
#define GUINT32_FROM_BE(val) (GUINT32_TO_BE(val))
#ifdef G_HAVE_GINT64
#define GINT64_FROM_LE(val) (GINT64_TO_LE(val))
#define GUINT64_FROM_LE(val) (GUINT64_TO_LE(val))
#define GINT64_FROM_BE(val) (GINT64_TO_BE(val))
#define GUINT64_FROM_BE(val) (GUINT64_TO_BE(val))
#endif
#define GLONG_FROM_LE(val) (GLONG_TO_LE(val))
#define GULONG_FROM_LE(val) (GULONG_TO_LE(val))
#define GLONG_FROM_BE(val) (GLONG_TO_BE(val))
#define GULONG_FROM_BE(val) (GULONG_TO_BE(val))
#define GINT_FROM_LE(val) (GINT_TO_LE(val))
#define GUINT_FROM_LE(val) (GUINT_TO_LE(val))
#define GINT_FROM_BE(val) (GINT_TO_BE(val))
#define GUINT_FROM_BE(val) (GUINT_TO_BE(val))
/* Portable versions of host-network order stuff
*/
#define g_ntohl(val) (GUINT32_FROM_BE(val))
#define g_ntohs(val) (GUINT16_FROM_BE(val))
#define g_htonl(val) (GUINT32_TO_BE(val))
#define g_htons(val) (GUINT16_TO_BE(val))
/* Glib version.
* we prefix variable declarations so they can
* properly get exported in windows dlls.
*/
#ifdef NATIVE_WIN32
#ifdef GLIB_COMPILATION
#define GUTILS_C_VAR __declspec(dllexport)
#else /* !GLIB_COMPILATION */
#define GUTILS_C_VAR extern __declspec(dllimport)
#endif /* !GLIB_COMPILATION */
#else /* !NATIVE_WIN32 */
#define GUTILS_C_VAR extern
#endif /* !NATIVE_WIN32 */
GUTILS_C_VAR const guint glib_major_version;
GUTILS_C_VAR const guint glib_minor_version;
GUTILS_C_VAR const guint glib_micro_version;
GUTILS_C_VAR const guint glib_interface_age;
GUTILS_C_VAR const guint glib_binary_age;
#define GLIB_CHECK_VERSION(major, minor, micro) \
(GLIB_MAJOR_VERSION > (major) || (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && GLIB_MICRO_VERSION >= (micro)))
/* Forward declarations of glib types.
*/
typedef struct _GAllocator GAllocator;
typedef struct _GArray GArray;
typedef struct _GByteArray GByteArray;
typedef struct _GCache GCache;
typedef struct _GCompletion GCompletion;
typedef struct _GData GData;
typedef struct _GDebugKey GDebugKey;
typedef struct _GHashTable GHashTable;
typedef struct _GHook GHook;
typedef struct _GHookList GHookList;
typedef struct _GList GList;
typedef struct _GMemChunk GMemChunk;
typedef struct _GNode GNode;
typedef struct _GPtrArray GPtrArray;
typedef struct _GRelation GRelation;
typedef struct _GScanner GScanner;
typedef struct _GScannerConfig GScannerConfig;
typedef struct _GSList GSList;
typedef struct _GString GString;
typedef struct _GStringChunk GStringChunk;
typedef struct _GTimer GTimer;
typedef struct _GTree GTree;
typedef struct _GTuples GTuples;
typedef union _GTokenValue GTokenValue;
typedef struct _GIOChannel GIOChannel;
typedef enum {
G_TRAVERSE_LEAFS = 1 << 0,
G_TRAVERSE_NON_LEAFS = 1 << 1,
G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS,
G_TRAVERSE_MASK = 0x03
} GTraverseFlags;
typedef enum {
G_IN_ORDER,
G_PRE_ORDER,
G_POST_ORDER,
G_LEVEL_ORDER
} GTraverseType;
/* Log level shift offset for user defined
* log levels (0-7 are used by GLib).
*/
#define G_LOG_LEVEL_USER_SHIFT (8)
/* Glib log levels and flags.
*/
typedef enum {
/* log flags */
G_LOG_FLAG_RECURSION = 1 << 0,
G_LOG_FLAG_FATAL = 1 << 1,
/* GLib log levels */
G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
G_LOG_LEVEL_CRITICAL = 1 << 3,
G_LOG_LEVEL_WARNING = 1 << 4,
G_LOG_LEVEL_MESSAGE = 1 << 5,
G_LOG_LEVEL_INFO = 1 << 6,
G_LOG_LEVEL_DEBUG = 1 << 7,
G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
} GLogLevelFlags;
/* GLib log levels that are considered fatal by default */
#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
typedef gpointer (*GCacheNewFunc)(gpointer key);
typedef gpointer (*GCacheDupFunc)(gpointer value);
typedef void (*GCacheDestroyFunc)(gpointer value);
typedef gint (*GCompareFunc)(gconstpointer a,
gconstpointer b);
typedef gchar* (*GCompletionFunc)(gpointer);
typedef void (*GDestroyNotify)(gpointer data);
typedef void (*GDataForeachFunc)(GQuark key_id,
gpointer data,
gpointer user_data);
typedef void (*GFunc)(gpointer data,
gpointer user_data);
typedef guint (*GHashFunc)(gconstpointer key);
typedef void (*GFreeFunc)(gpointer data);
typedef void (*GHFunc)(gpointer key,
gpointer value,
gpointer user_data);
typedef gboolean (*GHRFunc)(gpointer key,
gpointer value,
gpointer user_data);
typedef gint (*GHookCompareFunc)(GHook* new_hook,
GHook* sibling);
typedef gboolean (*GHookFindFunc)(GHook* hook,
gpointer data);
typedef void (*GHookMarshaller)(GHook* hook,
gpointer data);
typedef gboolean (*GHookCheckMarshaller)(GHook* hook,
gpointer data);
typedef void (*GHookFunc)(gpointer data);
typedef gboolean (*GHookCheckFunc)(gpointer data);
typedef void (*GHookFreeFunc)(GHookList* hook_list,
GHook* hook);
typedef void (*GLogFunc)(const gchar* log_domain,
GLogLevelFlags log_level,
const gchar* message,
gpointer user_data);
typedef gboolean (*GNodeTraverseFunc)(GNode* node,
gpointer data);
typedef void (*GNodeForeachFunc)(GNode* node,
gpointer data);
typedef gint (*GSearchFunc)(gpointer key,
gpointer data);
typedef void (*GScannerMsgFunc)(GScanner* scanner,
gchar* message,
gint error);
typedef gint (*GTraverseFunc)(gpointer key,
gpointer value,
gpointer data);
typedef void (*GVoidFunc)(void);
struct _GList {
gpointer data;
GList* next;
GList* prev;
};
struct _GSList {
gpointer data;
GSList* next;
};
struct _GString {
gchar* str;
gint len;
};
struct _GArray {
gchar* data;
guint len;
};
struct _GByteArray {
guint8* data;
guint len;
};
struct _GPtrArray {
gpointer* pdata;
guint len;
};
struct _GTuples {
guint len;
};
struct _GDebugKey {
gchar* key;
guint value;
};
/* Doubly linked lists
*/
void g_list_push_allocator(GAllocator* allocator);
void g_list_pop_allocator(void);
GList* g_list_alloc(void);
void g_list_free(GList* list);
void g_list_free_1(GList* list);
GList* g_list_append(GList* list,
gpointer data);
GList* g_list_prepend(GList* list,
gpointer data);
GList* g_list_insert(GList* list,
gpointer data,
gint position);
GList* g_list_insert_sorted(GList* list,
gpointer data,
GCompareFunc func);
GList* g_list_concat(GList* list1,
GList* list2);
GList* g_list_remove(GList* list,
gpointer data);
GList* g_list_remove_link(GList* list,
GList* llink);
GList* g_list_reverse(GList* list);
GList* g_list_copy(GList* list);
GList* g_list_nth(GList* list,
guint n);
GList* g_list_find(GList* list,
gpointer data);
GList* g_list_find_custom(GList* list,
gpointer data,
GCompareFunc func);
gint g_list_position(GList* list,
GList* llink);
gint g_list_index(GList* list,
gpointer data);
GList* g_list_last(GList* list);
GList* g_list_first(GList* list);
guint g_list_length(GList* list);
void g_list_foreach(GList* list,
GFunc func,
gpointer user_data);
GList* g_list_sort(GList* list,
GCompareFunc compare_func);
gpointer g_list_nth_data(GList* list,
guint n);
#define g_list_previous(list) ((list) ? (((GList*)(list))->prev) : NULL)
#define g_list_next(list) ((list) ? (((GList*)(list))->next) : NULL)
/* Singly linked lists
*/
void g_slist_push_allocator(GAllocator* allocator);
void g_slist_pop_allocator(void);
GSList* g_slist_alloc(void);
void g_slist_free(GSList* list);
void g_slist_free_1(GSList* list);
GSList* g_slist_append(GSList* list,
gpointer data);
GSList* g_slist_prepend(GSList* list,
gpointer data);
GSList* g_slist_insert(GSList* list,
gpointer data,
gint position);
GSList* g_slist_insert_sorted(GSList* list,
gpointer data,
GCompareFunc func);
GSList* g_slist_concat(GSList* list1,
GSList* list2);
GSList* g_slist_remove(GSList* list,
gpointer data);
GSList* g_slist_remove_link(GSList* list,
GSList* llink);
GSList* g_slist_reverse(GSList* list);
GSList* g_slist_copy(GSList* list);
GSList* g_slist_nth(GSList* list,
guint n);
GSList* g_slist_find(GSList* list,
gpointer data);
GSList* g_slist_find_custom(GSList* list,
gpointer data,
GCompareFunc func);
gint g_slist_position(GSList* list,
GSList* llink);
gint g_slist_index(GSList* list,
gpointer data);
GSList* g_slist_last(GSList* list);
guint g_slist_length(GSList* list);
void g_slist_foreach(GSList* list,
GFunc func,
gpointer user_data);
GSList* g_slist_sort(GSList* list,
GCompareFunc compare_func);
gpointer g_slist_nth_data(GSList* list,
guint n);
#define g_slist_next(slist) ((slist) ? (((GSList*)(slist))->next) : NULL)
/* Hash tables
*/
GHashTable* g_hash_table_new(GHashFunc hash_func,
GCompareFunc key_compare_func);
void g_hash_table_destroy(GHashTable* hash_table);
void g_hash_table_insert(GHashTable* hash_table,
gpointer key,
gpointer value);
void g_hash_table_remove(GHashTable* hash_table,
gconstpointer key);
gpointer g_hash_table_lookup(GHashTable* hash_table,
gconstpointer key);
gboolean g_hash_table_lookup_extended(GHashTable* hash_table,
gconstpointer lookup_key,
gpointer* orig_key,
gpointer* value);
void g_hash_table_freeze(GHashTable* hash_table);
void g_hash_table_thaw(GHashTable* hash_table);
void g_hash_table_foreach(GHashTable* hash_table,
GHFunc func,
gpointer user_data);
guint g_hash_table_foreach_remove(GHashTable* hash_table,
GHRFunc func,
gpointer user_data);
guint g_hash_table_size(GHashTable* hash_table);
/* Caches
*/
GCache* g_cache_new(GCacheNewFunc value_new_func,
GCacheDestroyFunc value_destroy_func,
GCacheDupFunc key_dup_func,
GCacheDestroyFunc key_destroy_func,
GHashFunc hash_key_func,
GHashFunc hash_value_func,
GCompareFunc key_compare_func);
void g_cache_destroy(GCache* cache);
gpointer g_cache_insert(GCache* cache,
gpointer key);
void g_cache_remove(GCache* cache,
gpointer value);
void g_cache_key_foreach(GCache* cache,
GHFunc func,
gpointer user_data);
void g_cache_value_foreach(GCache* cache,
GHFunc func,
gpointer user_data);
/* Balanced binary trees
*/
GTree* g_tree_new(GCompareFunc key_compare_func);
void g_tree_destroy(GTree* tree);
void g_tree_insert(GTree* tree,
gpointer key,
gpointer value);
void g_tree_remove(GTree* tree,
gpointer key);
gpointer g_tree_lookup(GTree* tree,
gpointer key);
void g_tree_traverse(GTree* tree,
GTraverseFunc traverse_func,
GTraverseType traverse_type,
gpointer data);
gpointer g_tree_search(GTree* tree,
GSearchFunc search_func,
gpointer data);
gint g_tree_height(GTree* tree);
gint g_tree_nnodes(GTree* tree);
/* N-way tree implementation
*/
struct _GNode {
gpointer data;
GNode* next;
GNode* prev;
GNode* parent;
GNode* children;
};
#define G_NODE_IS_ROOT(node) (((GNode*)(node))->parent == NULL && ((GNode*)(node))->prev == NULL && ((GNode*)(node))->next == NULL)
#define G_NODE_IS_LEAF(node) (((GNode*)(node))->children == NULL)
void g_node_push_allocator(GAllocator* allocator);
void g_node_pop_allocator(void);
GNode* g_node_new(gpointer data);
void g_node_destroy(GNode* root);
void g_node_unlink(GNode* node);
GNode* g_node_insert(GNode* parent,
gint position,
GNode* node);
GNode* g_node_insert_before(GNode* parent,
GNode* sibling,
GNode* node);
GNode* g_node_prepend(GNode* parent,
GNode* node);
guint g_node_n_nodes(GNode* root,
GTraverseFlags flags);
GNode* g_node_get_root(GNode* node);
gboolean g_node_is_ancestor(GNode* node,
GNode* descendant);
guint g_node_depth(GNode* node);
GNode* g_node_find(GNode* root,
GTraverseType order,
GTraverseFlags flags,
gpointer data);
/* convenience macros */
#define g_node_append(parent, node) \
g_node_insert_before((parent), NULL, (node))
#define g_node_insert_data(parent, position, data) \
g_node_insert((parent), (position), g_node_new(data))
#define g_node_insert_data_before(parent, sibling, data) \
g_node_insert_before((parent), (sibling), g_node_new(data))
#define g_node_prepend_data(parent, data) \
g_node_prepend((parent), g_node_new(data))
#define g_node_append_data(parent, data) \
g_node_insert_before((parent), NULL, g_node_new(data))
/* traversal function, assumes that `node' is root
* (only traverses `node' and its subtree).
* this function is just a high level interface to
* low level traversal functions, optimized for speed.
*/
void g_node_traverse(GNode* root,
GTraverseType order,
GTraverseFlags flags,
gint max_depth,
GNodeTraverseFunc func,
gpointer data);
/* return the maximum tree height starting with `node', this is an expensive
* operation, since we need to visit all nodes. this could be shortened by
* adding `guint height' to struct _GNode, but then again, this is not very
* often needed, and would make g_node_insert() more time consuming.
*/
guint g_node_max_height(GNode* root);
void g_node_children_foreach(GNode* node,
GTraverseFlags flags,
GNodeForeachFunc func,
gpointer data);
void g_node_reverse_children(GNode* node);
guint g_node_n_children(GNode* node);
GNode* g_node_nth_child(GNode* node,
guint n);
GNode* g_node_last_child(GNode* node);
GNode* g_node_find_child(GNode* node,
GTraverseFlags flags,
gpointer data);
gint g_node_child_position(GNode* node,
GNode* child);
gint g_node_child_index(GNode* node,
gpointer data);
GNode* g_node_first_sibling(GNode* node);
GNode* g_node_last_sibling(GNode* node);
#define g_node_prev_sibling(node) ((node) ? ((GNode*)(node))->prev : NULL)
#define g_node_next_sibling(node) ((node) ? ((GNode*)(node))->next : NULL)
#define g_node_first_child(node) ((node) ? ((GNode*)(node))->children : NULL)
/* Callback maintenance functions
*/
#define G_HOOK_FLAG_USER_SHIFT (4)
typedef enum {
G_HOOK_FLAG_ACTIVE = 1 << 0,
G_HOOK_FLAG_IN_CALL = 1 << 1,
G_HOOK_FLAG_MASK = 0x0f
} GHookFlagMask;
#define G_HOOK_DEFERRED_DESTROY ((GHookFreeFunc)0x01)
struct _GHookList {
guint seq_id;
guint hook_size;
guint is_setup : 1;
GHook* hooks;
GMemChunk* hook_memchunk;
GHookFreeFunc hook_free; /* virtual function */
GHookFreeFunc hook_destroy; /* virtual function */
};
struct _GHook {
gpointer data;
GHook* next;
GHook* prev;
guint ref_count;
guint hook_id;
guint flags;
gpointer func;
GDestroyNotify destroy;
};
#define G_HOOK_ACTIVE(hook) ((((GHook*)hook)->flags & G_HOOK_FLAG_ACTIVE) != 0)
#define G_HOOK_IN_CALL(hook) ((((GHook*)hook)->flags & G_HOOK_FLAG_IN_CALL) != 0)
#define G_HOOK_IS_VALID(hook) (((GHook*)hook)->hook_id != 0 && G_HOOK_ACTIVE(hook))
#define G_HOOK_IS_UNLINKED(hook) (((GHook*)hook)->next == NULL && ((GHook*)hook)->prev == NULL && ((GHook*)hook)->hook_id == 0 && ((GHook*)hook)->ref_count == 0)
void g_hook_list_init(GHookList* hook_list,
guint hook_size);
void g_hook_list_clear(GHookList* hook_list);
GHook* g_hook_alloc(GHookList* hook_list);
void g_hook_free(GHookList* hook_list,
GHook* hook);
void g_hook_ref(GHookList* hook_list,
GHook* hook);
void g_hook_unref(GHookList* hook_list,
GHook* hook);
gboolean g_hook_destroy(GHookList* hook_list,
guint hook_id);
void g_hook_destroy_link(GHookList* hook_list,
GHook* hook);
void g_hook_prepend(GHookList* hook_list,
GHook* hook);
void g_hook_insert_before(GHookList* hook_list,
GHook* sibling,
GHook* hook);
void g_hook_insert_sorted(GHookList* hook_list,
GHook* hook,
GHookCompareFunc func);
GHook* g_hook_get(GHookList* hook_list,
guint hook_id);
GHook* g_hook_find(GHookList* hook_list,
gboolean need_valids,
GHookFindFunc func,
gpointer data);
GHook* g_hook_find_data(GHookList* hook_list,
gboolean need_valids,
gpointer data);
GHook* g_hook_find_func(GHookList* hook_list,
gboolean need_valids,
gpointer func);
GHook* g_hook_find_func_data(GHookList* hook_list,
gboolean need_valids,
gpointer func,
gpointer data);
/* return the first valid hook, and increment its reference count */
GHook* g_hook_first_valid(GHookList* hook_list,
gboolean may_be_in_call);
/* return the next valid hook with incremented reference count, and
* decrement the reference count of the original hook
*/
GHook* g_hook_next_valid(GHookList* hook_list,
GHook* hook,
gboolean may_be_in_call);
/* GHookCompareFunc implementation to insert hooks sorted by their id */
gint g_hook_compare_ids(GHook* new_hook,
GHook* sibling);
/* convenience macros */
#define g_hook_append(hook_list, hook) \
g_hook_insert_before((hook_list), NULL, (hook))
/* invoke all valid hooks with the (*GHookFunc) signature.
*/
void g_hook_list_invoke(GHookList* hook_list,
gboolean may_recurse);
/* invoke all valid hooks with the (*GHookCheckFunc) signature,
* and destroy the hook if FALSE is returned.
*/
void g_hook_list_invoke_check(GHookList* hook_list,
gboolean may_recurse);
/* invoke a marshaller on all valid hooks.
*/
void g_hook_list_marshal(GHookList* hook_list,
gboolean may_recurse,
GHookMarshaller marshaller,
gpointer data);
void g_hook_list_marshal_check(GHookList* hook_list,
gboolean may_recurse,
GHookCheckMarshaller marshaller,
gpointer data);
/* Fatal error handlers.
* g_on_error_query() will prompt the user to either
* [E]xit, [H]alt, [P]roceed or show [S]tack trace.
* g_on_error_stack_trace() invokes gdb, which attaches to the current
* process and shows a stack trace.
* These function may cause different actions on non-unix platforms.
* The prg_name arg is required by gdb to find the executable, if it is
* passed as NULL, g_on_error_query() will try g_get_prgname().
*/
void g_on_error_query(const gchar* prg_name);
void g_on_error_stack_trace(const gchar* prg_name);
/* Logging mechanism
*/
extern const gchar* g_log_domain_glib;
guint g_log_set_handler(const gchar* log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data);
void g_log_remove_handler(const gchar* log_domain,
guint handler_id);
void g_log_default_handler(const gchar* log_domain,
GLogLevelFlags log_level,
const gchar* message,
gpointer unused_data);
void g_log(const gchar* log_domain,
GLogLevelFlags log_level,
const gchar* format,
...) G_GNUC_PRINTF(3, 4);
void g_logv(const gchar* log_domain,
GLogLevelFlags log_level,
const gchar* format,
va_list args);
GLogLevelFlags g_log_set_fatal_mask(const gchar* log_domain,
GLogLevelFlags fatal_mask);
GLogLevelFlags g_log_set_always_fatal(GLogLevelFlags fatal_mask);
#ifndef G_LOG_DOMAIN
#define G_LOG_DOMAIN ((gchar*)0)
#endif /* G_LOG_DOMAIN */
#define g_error(format, args...) g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
format, ##args)
#define g_message(format, args...) g_log(G_LOG_DOMAIN, \
G_LOG_LEVEL_MESSAGE, \
format, ##args)
#define g_warning printf
/* Memory allocation and debugging
*/
#define g_malloc(size) ((gpointer)malloc(size))
#define g_malloc0(size) ((gpointer)calloc(size, 1))
#define g_realloc(mem, size) ((gpointer)realloc(mem, size))
#define g_free(mem) free(mem)
void g_mem_profile(void);
void g_mem_check(gpointer mem);
/* String utility functions that modify a string argument or
* return a constant string that must not be freed.
*/
#define G_STR_DELIMITERS "_-|> <."
gchar* g_strdelimit(gchar* string,
const gchar* delimiters,
gchar new_delimiter);
gdouble g_strtod(const gchar* nptr,
gchar** endptr);
gchar* g_strerror(gint errnum);
gchar* g_strsignal(gint signum);
gint g_strcasecmp(const gchar* s1,
const gchar* s2);
gint g_strncasecmp(const gchar* s1,
const gchar* s2,
guint n);
void g_strdown(gchar* string);
void g_strup(gchar* string);
void g_strreverse(gchar* string);
/* removes leading spaces */
gchar* g_strchug(gchar* string);
/* removes trailing spaces */
gchar* g_strchomp(gchar* string);
/* removes leading & trailing spaces */
#define g_strstrip(string) g_strchomp(g_strchug(string))
/* String utility functions that return a newly allocated string which
* ought to be freed from the caller at some point.
*/
gchar* g_strdup(const gchar* str);
gchar* g_strdup_printf(const gchar* format,
...) G_GNUC_PRINTF(1, 2);
gchar* g_strdup_vprintf(const gchar* format,
va_list args);
gchar* g_strndup(const gchar* str,
guint n);
gchar* g_strnfill(guint length,
gchar fill_char);
gchar* g_strconcat(const gchar* string1,
...); /* NULL terminated */
gchar* g_strjoin(const gchar* separator,
...); /* NULL terminated */
gchar* g_strescape(gchar* string);
gpointer g_memdup(gconstpointer mem,
guint byte_size);
/* NULL terminated string arrays.
* g_strsplit() splits up string into max_tokens tokens at delim and
* returns a newly allocated string array.
* g_strjoinv() concatenates all of str_array's strings, sliding in an
* optional separator, the returned string is newly allocated.
* g_strfreev() frees the array itself and all of its strings.
*/
gchar** g_strsplit(const gchar* string,
const gchar* delimiter,
gint max_tokens);
gchar* g_strjoinv(const gchar* separator,
gchar** str_array);
void g_strfreev(gchar** str_array);
/* calculate a string size, guarranteed to fit format + args.
*/
guint g_printf_string_upper_bound(const gchar* format,
va_list args);
/* Retrive static string info
*/
gchar* g_get_user_name(void);
gchar* g_get_real_name(void);
gchar* g_get_home_dir(void);
gchar* g_get_tmp_dir(void);
gchar* g_get_prgname(void);
void g_set_prgname(const gchar* prgname);
/* Miscellaneous utility functions
*/
guint g_parse_debug_string(const gchar* string,
GDebugKey* keys,
guint nkeys);
gint g_snprintf(gchar* string,
gulong n,
gchar const* format,
...) G_GNUC_PRINTF(3, 4);
gint g_vsnprintf(gchar* string,
gulong n,
gchar const* format,
va_list args);
gchar* g_basename(const gchar* file_name);
/* Check if a file name is an absolute path */
gboolean g_path_is_absolute(const gchar* file_name);
/* In case of absolute paths, skip the root part */
gchar* g_path_skip_root(gchar* file_name);
/* strings are newly allocated with g_malloc() */
gchar* g_dirname(const gchar* file_name);
gchar* g_get_current_dir(void);
gchar* g_getenv(const gchar* variable);
/* we use a GLib function as a replacement for ATEXIT, so
* the programmer is not required to check the return value
* (if there is any in the implementation) and doesn't encounter
* missing include files.
*/
void g_atexit(GVoidFunc func);
/* Bit tests
*/
G_INLINE_FUNC gint g_bit_nth_lsf(guint32 mask,
gint nth_bit);
#ifdef G_CAN_INLINE
G_INLINE_FUNC gint
g_bit_nth_lsf(guint32 mask,
gint nth_bit)
{
do {
nth_bit++;
if (mask & (1 << (guint)nth_bit))
return nth_bit;
} while (nth_bit < 32);
return -1;
}
#endif /* G_CAN_INLINE */
G_INLINE_FUNC gint g_bit_nth_msf(guint32 mask,
gint nth_bit);
#ifdef G_CAN_INLINE
G_INLINE_FUNC gint
g_bit_nth_msf(guint32 mask,
gint nth_bit)
{
if (nth_bit < 0)
nth_bit = 32;
do {
nth_bit--;
if (mask & (1 << (guint)nth_bit))
return nth_bit;
} while (nth_bit > 0);
return -1;
}
#endif /* G_CAN_INLINE */
G_INLINE_FUNC guint g_bit_storage(guint number);
#ifdef G_CAN_INLINE
G_INLINE_FUNC guint
g_bit_storage(guint number)
{
register guint n_bits = 0;
do {
n_bits++;
number >>= 1;
} while (number);
return n_bits;
}
#endif /* G_CAN_INLINE */
/* String Chunks
*/
GStringChunk* g_string_chunk_new(gint size);
void g_string_chunk_free(GStringChunk* chunk);
gchar* g_string_chunk_insert(GStringChunk* chunk,
const gchar* string);
gchar* g_string_chunk_insert_const(GStringChunk* chunk,
const gchar* string);
/* Strings
*/
GString* g_string_new(const gchar* init);
GString* g_string_sized_new(guint dfl_size);
void g_string_free(GString* string,
gint free_segment);
GString* g_string_assign(GString* lval,
const gchar* rval);
GString* g_string_truncate(GString* string,
gint len);
GString* g_string_append(GString* string,
const gchar* val);
GString* g_string_append_c(GString* string,
gchar c);
GString* g_string_prepend(GString* string,
const gchar* val);
GString* g_string_prepend_c(GString* string,
gchar c);
GString* g_string_insert(GString* string,
gint pos,
const gchar* val);
GString* g_string_insert_c(GString* string,
gint pos,
gchar c);
GString* g_string_erase(GString* string,
gint pos,
gint len);
GString* g_string_down(GString* string);
GString* g_string_up(GString* string);
void g_string_sprintf(GString* string,
const gchar* format,
...) G_GNUC_PRINTF(2, 3);
void g_string_sprintfa(GString* string,
const gchar* format,
...) G_GNUC_PRINTF(2, 3);
/* Resizable arrays, remove fills any cleared spot and shortens the
* array, while preserving the order. remove_fast will distort the
* order by moving the last element to the position of the removed
*/
#define g_array_append_val(a, v) pmidi_array_append_vals(a, &v, 1)
#define g_array_prepend_val(a, v) g_array_prepend_vals(a, &v, 1)
#define g_array_insert_val(a, i, v) g_array_insert_vals(a, i, &v, 1)
#define g_array_index(a, t, i) (((t*)(a)->data)[(i)])
GArray* pmidi_array_new(gboolean zero_terminated,
gboolean clear,
guint element_size);
void pmidi_array_free(GArray* array,
gboolean free_segment);
GArray* pmidi_array_append_vals(GArray* array,
gconstpointer data,
guint len);
GArray* g_array_prepend_vals(GArray* array,
gconstpointer data,
guint len);
GArray* g_array_insert_vals(GArray* array,
guint index,
gconstpointer data,
guint len);
GArray* g_array_set_size(GArray* array,
guint length);
GArray* g_array_remove_index(GArray* array,
guint index);
GArray* g_array_remove_index_fast(GArray* array,
guint index);
/* Resizable pointer array. This interface is much less complicated
* than the above. Add appends appends a pointer. Remove fills any
* cleared spot and shortens the array. remove_fast will again distort
* order.
*/
#define g_ptr_array_index(array, index) (array->pdata)[index]
GPtrArray* pmidi_ptr_array_new(void);
void pmidi_ptr_array_free(GPtrArray* array,
gboolean free_seg);
void g_ptr_array_set_size(GPtrArray* array,
gint length);
gpointer g_ptr_array_remove_index(GPtrArray* array,
guint index);
gpointer pmidi_ptr_array_remove_index_fast(GPtrArray* array,
guint index);
gboolean g_ptr_array_remove(GPtrArray* array,
gpointer data);
gboolean g_ptr_array_remove_fast(GPtrArray* array,
gpointer data);
void pmidi_ptr_array_add(GPtrArray* array,
gpointer data);
/* Byte arrays, an array of guint8. Implemented as a GArray,
* but type-safe.
*/
GByteArray* g_byte_array_new(void);
void g_byte_array_free(GByteArray* array,
gboolean free_segment);
GByteArray* g_byte_array_append(GByteArray* array,
const guint8* data,
guint len);
GByteArray* g_byte_array_prepend(GByteArray* array,
const guint8* data,
guint len);
GByteArray* g_byte_array_set_size(GByteArray* array,
guint length);
GByteArray* g_byte_array_remove_index(GByteArray* array,
guint index);
GByteArray* g_byte_array_remove_index_fast(GByteArray* array,
guint index);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __G_LIB_H__ */
| 50,055
|
C++
|
.h
| 1,387
| 32.906273
| 617
| 0.629833
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,445
|
seqlib.h
|
canorusmusic_canorus/src/import/pmidi/seqlib.h
|
/*
* File: seqlib.h
*
* Copyright (C) 1999-2003 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* ---------
* This file is a set of interfaces to provide a little
* higher level view of the sequencer. It is mainly experimental
* to investigate new approaches. If successful they will be proposed
* as additions/replacements to the existing seq lib.
*
*
*
*/
#if HAVE_ALSA_ASOUNDLIB_H
#include <alsa/asoundlib.h>
#else
#include <sys/asoundlib.h>
#endif
typedef struct seq_context seq_context_t;
seq_context_t* seq_create_context();
seq_context_t* seq_new_client(seq_context_t* ctxp);
void seq_free_context(seq_context_t* cxtp);
int seq_new_port(seq_context_t* ctxp);
void seq_destroy_port(seq_context_t* cxtp, int port);
int seq_connect_add(seq_context_t* ctxp, int client, int port);
int seq_init_tempo(seq_context_t* ctxp, int resolution, int tempo,
int realtime);
void seq_set_queue(seq_context_t* ctxp, int q);
int seq_sendto(seq_context_t* ctxp, snd_seq_event_t* ev, int client, int port);
snd_seq_addr_t* seq_dev_addr(seq_context_t* ctxp, int dev);
void seq_start_timer(seq_context_t* ctxp);
void seq_stop_timer(seq_context_t* ctxp);
void seq_control_timer(seq_context_t* ctxp, int onoff);
int seq_write(seq_context_t* ctxp, snd_seq_event_t* ep);
void* seq_handle(seq_context_t* ctxp);
void seq_midi_event_init(seq_context_t* ctxp, snd_seq_event_t* ep,
unsigned long time, int devchan);
void seq_midi_note(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int note,
int vel, int length);
void seq_midi_note_on(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int note,
int vel, int length);
void seq_midi_note_off(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int note,
int vel, int length);
void seq_midi_keypress(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int note,
int value);
void seq_midi_control(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int control,
int value);
void seq_midi_program(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int program);
void seq_midi_chanpress(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan,
int pressure);
void seq_midi_pitchbend(seq_context_t* ctxp, snd_seq_event_t* ep, int devchan, int bend);
void seq_midi_tempo(seq_context_t* ctxp, snd_seq_event_t* ep, int tempo);
void seq_midi_sysex(seq_context_t* ctxp, snd_seq_event_t* ep, int status,
unsigned char* data, int length);
void seq_midi_echo(seq_context_t* ctxp, unsigned long time);
| 2,918
|
C++
|
.h
| 66
| 42.151515
| 90
| 0.734293
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,446
|
midi.h
|
canorusmusic_canorus/src/import/pmidi/midi.h
|
/*
*
* File: midi.h
*
* Copyright (C) 1999 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*/
/*
* Midi status byte values.
*/
#define MIDI_NOTE_OFF 0x80
#define MIDI_NOTE_ON 0x90
#define MIDI_KEY_AFTERTOUCH 0xa0
#define MIDI_CONTROLER 0xb0
#define MIDI_PATCH 0xc0
#define MIDI_CHANNEL_AFTERTOUCH 0xd0
#define MIDI_PITCH_WHEEL 0xe0
#define MIDI_SYSEX 0xf0
#define MIDI_META 0xff
/* Meta event defines */
#define MIDI_META_SEQUENCE 0
/* The text type meta events */
#define MIDI_META_TEXT 1
#define MIDI_META_COPYRIGHT 2
#define MIDI_META_TRACKNAME 3
#define MIDI_META_INSTRUMENT 4
#define MIDI_META_LYRIC 5
#define MIDI_META_MARKER 6
#define MIDI_META_CUE 7
/* More meta events */
#define MIDI_META_CHANNEL 0x20
#define MIDI_META_PORT 0x21
#define MIDI_META_EOT 0x2f
#define MIDI_META_TEMPO 0x51
#define MIDI_META_SMPTE_OFFSET 0x54
#define MIDI_META_TIME 0x58
#define MIDI_META_KEY 0x59
#define MIDI_META_PROP 0x7f
/** The maximum of the midi defined text types */
#define MIDI_MAX_TEXT_TYPE 7
#define MIDI_HEAD_MAGIC 0x4d546864
#define MIDI_TRACK_MAGIC 0x4d54726b
struct rootElement* midi_read(FILE* fp);
struct rootElement* midi_read_file(char* name);
| 1,591
|
C++
|
.h
| 54
| 27.944444
| 72
| 0.775603
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,447
|
seqpriv.h
|
canorusmusic_canorus/src/import/pmidi/seqpriv.h
|
/*
* File: seqpriv.h
*
* Copyright (C) 1999-2003 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* ---------
* This file is a set of interfaces to provide a little
* higher level view of the sequencer. It is mainly experimental
* to investigate new approaches. If successful they will be proposed
* as additions/replacements to the existing seq lib.
*
*
*
*/
struct seq_context {
snd_seq_t* handle; /* The snd_seq handle to /dev/snd/seq */
int client; /* The client associated with this context */
int queue; /* The queue to use for all operations */
snd_seq_addr_t source; /* Source for events */
GArray* destlist; /* Destination list */
#define ctxndest destlist->len
#define ctxdest destlist->data
char timer_started; /* True if timer is running */
int port_count; /* Ports allocated */
struct seq_context* main; /* Pointer to the main context */
GSList* ctlist; /* Context list if a main context */
};
| 1,387
|
C++
|
.h
| 37
| 34.594595
| 72
| 0.711952
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,448
|
elements.h
|
canorusmusic_canorus/src/import/pmidi/elements.h
|
/*
*
* File: elements.h
*
* Copyright (C) 1999 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*
*
*
*/
#define MD_CONTAINER_BEGIN 50 /* Begining of container types */
/*
* The basic element type. All elements have a time associated with
* them and most use the device and channel field.
*/
struct element {
short type; /* Element type */
guint32 element_time; /* Time for this element */
short device_channel; /* Device/channel for this element */
};
#define MD_ELEMENT(e) \
((struct element*)md_check_cast((struct element*)(e), MD_TYPE_ELEMENT))
struct containerElement {
struct element parent;
GPtrArray* elements; /* List of elements */
};
#define MD_CONTAINER(e) \
((struct containerElement*)md_check_cast((struct element*)(e), MD_TYPE_CONTAINER))
struct rootElement {
struct containerElement parent;
short format; /* Midi format */
short tracks; /* Number of tracks */
short time_base; /* Time base value */
};
#define MD_ROOT(e) \
((struct rootElement*)md_check_cast((struct element*)(e), MD_TYPE_ROOT))
struct trackElement {
struct containerElement parent;
guint32 final_time;
};
#define MD_TRACK(e) \
((struct trackElement*)md_check_cast((struct element*)(e), MD_TYPE_TRACK))
struct tempomapElement {
struct containerElement parent;
};
#define MD_TEMPOMAP(e) \
((struct tempomapElement*)md_check_cast((struct element*)(e), MD_TYPE_TEMPOMAP))
struct noteElement {
struct element parent;
short note;
short vel;
int length;
short offvel; /* Note Off velocity */
};
#define MD_NOTE(e) \
((struct noteElement*)md_check_cast((struct element*)(e), MD_TYPE_NOTE))
struct partElement {
struct containerElement parent;
guint32 final_time;
};
#define MD_PART(e) \
((struct partElement*)md_check_cast((struct element*)(e), MD_TYPE_PART))
struct controlElement {
struct element parent;
short control; /* Controller number */
short value; /* Controller value */
};
#define MD_CONTROL(e) \
((struct controlElement*)md_check_cast((struct element*)(e), MD_TYPE_CONTROL))
struct programElement {
struct element parent;
int program; /* Program number */
};
#define MD_PROGRAM(e) \
((struct programElement*)md_check_cast((struct element*)(e), MD_TYPE_PROGRAM))
struct keytouchElement {
struct element parent;
int note;
int velocity;
};
#define MD_KEYTOUCH(e) \
((struct keytouchElement*)md_check_cast((struct element*)(e), MD_TYPE_KEYTOUCH))
struct pressureElement {
struct element parent;
int velocity;
};
#define MD_PRESSURE(e) \
((struct pressureElement*)md_check_cast((struct element*)(e), MD_TYPE_PRESSURE))
struct pitchElement {
struct element parent;
int pitch;
};
#define MD_PITCH(e) \
((struct pitchElement*)md_check_cast((struct element*)(e), MD_TYPE_PITCH))
struct sysexElement {
struct element parent;
int status;
unsigned char* data;
int length;
};
#define MD_SYSEX(e) \
((struct sysexElement*)md_check_cast((struct element*)(e), MD_TYPE_SYSEX))
struct metaElement {
struct element parent;
};
#define MD_META(e) \
((struct metaElement*)md_check_cast((struct element*)(e), MD_TYPE_META))
struct mapElement {
struct metaElement parent;
};
#define MD_MAP(e) \
((struct mapElement*)md_check_cast((struct element*)(e), MD_TYPE_MAP))
struct keysigElement {
struct mapElement parent;
char key; /* Key signature */
char minor; /* Is this a minor key or not */
};
#define MD_KEYSIG(e) \
((struct keysigElement*)md_check_cast((struct element*)(e), MD_TYPE_KEYSIG))
struct timesigElement {
struct mapElement parent;
short top; /* 'top' of timesignature */
short bottom; /* 'bottom' of timesignature */
short clocks; /* Can't remember what this is */
short n32pq; /* Thirtysecond notes per quarter */
};
#define MD_TIMESIG(e) \
((struct timesigElement*)md_check_cast((struct element*)(e), MD_TYPE_TIMESIG))
struct tempoElement {
struct mapElement parent;
int micro_tempo; /* The tempo in microsec per quarter note */
};
#define MD_TEMPO(e) \
((struct tempoElement*)md_check_cast((struct element*)(e), MD_TYPE_TEMPO))
struct textElement {
struct element parent;
int type; /* Type of text (lyric, copyright etc) */
char* name; /* Type as text */
char* text; /* actual text */
int length; /* length of the text (including a null?) */
};
#define MD_TEXT(e) \
((struct textElement*)md_check_cast((struct element*)(e), MD_TYPE_TEXT))
struct smpteoffsetElement {
struct element parent;
short hours;
short minutes;
short seconds;
short frames;
short subframes;
};
#define MD_SMPTEOFFSET(e) \
((struct smpteoffsetElement*)md_check_cast((struct element*)(e), MD_TYPE_SMPTEOFFSET))
struct element* md_element_new();
struct containerElement* md_container_new();
struct rootElement* md_root_new(void);
struct trackElement* md_track_new(void);
struct tempomapElement* md_tempomap_new();
struct noteElement* md_note_new(short note, short vel, int length);
struct partElement* md_part_new(void);
struct controlElement* md_control_new(short control, short value);
struct programElement* md_program_new(int program);
struct keytouchElement* md_keytouch_new(int note, int vel);
struct pressureElement* md_pressure_new(int vel);
struct pitchElement* md_pitch_new(int val);
struct sysexElement* md_sysex_new(int status, unsigned char* data, int len);
struct metaElement* md_meta_new();
struct mapElement* md_map_new();
struct keysigElement* md_keysig_new(short key, short minor);
struct timesigElement* md_timesig_new(short top, short bottom, short clocks,
short n32pq);
struct tempoElement* md_tempo_new(int m);
struct textElement* md_text_new(int type, char* text);
struct smpteoffsetElement* md_smpteoffset_new(short hours, short minutes,
short seconds, short frames, short subframes);
void md_add(struct containerElement* c, struct element* e);
void md_free(struct element* el);
struct element* md_check_cast(struct element* el, int type);
/* Defines for types */
#define MD_TYPE_PART (0 + MD_CONTAINER_BEGIN)
#define MD_TYPE_ROOT (1 + MD_CONTAINER_BEGIN)
#define MD_TYPE_KEYTOUCH 2
#define MD_TYPE_TEXT 3
#define MD_TYPE_PITCH 4
#define MD_TYPE_PROGRAM 5
#define MD_TYPE_META 6
#define MD_TYPE_PRESSURE 7
#define MD_TYPE_NOTE 8
#define MD_TYPE_ELEMENT 9
#define MD_TYPE_SMPTEOFFSET 10
#define MD_TYPE_TEMPO 11
#define MD_TYPE_TEMPOMAP (12 + MD_CONTAINER_BEGIN)
#define MD_TYPE_SYSEX 13
#define MD_TYPE_TRACK (14 + MD_CONTAINER_BEGIN)
#define MD_TYPE_KEYSIG 15
#define MD_TYPE_TIMESIG 16
#define MD_TYPE_CONTAINER 17
#define MD_TYPE_MAP 18
#define MD_TYPE_CONTROL 19
| 7,124
|
C++
|
.h
| 209
| 31.296651
| 90
| 0.723012
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,449
|
md.h
|
canorusmusic_canorus/src/import/pmidi/md.h
|
/*
* File: md.h
*
* Copyright (C) 1999 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*
*/
/* Defines for md_walk() */
#define MD_WALK_ALL 1 /* Include all elements including deleted, hidden*/
/* Defines for walk callback flags */
#define MD_WALK_START 0x001 /* This is a start element */
#define MD_WALK_END 0x002 /* This is the end of an element */
#define MD_WALK_EMPTY (MD_WALK_START | MD_WALK_END) /* Empty element */
/* Typedef for md_walk callback function */
typedef void (*walkFunc)(struct element*, void*, int);
/*
* Structure to keep track of the position on each track that
* is being merged.
*/
struct sequenceState {
int nmerge; /* Number of tracks in trackPos to merge */
struct trackPos* track_ptrs; /* Position pointers */
struct rootElement* root; /* Root to be returned first */
unsigned long endtime; /* End time */
};
struct trackPos {
int len; /* Total length of this container element */
int count; /* Current position count */
struct element** currel; /* Pointer to current position */
};
void md_walk(struct containerElement* c, walkFunc fn, void* arg, int flags);
int iscontainer(struct element* el);
struct sequenceState* md_sequence_init(struct rootElement* root);
struct element* md_sequence_next(struct sequenceState* seq);
void md_sequence_end(struct sequenceState* seq);
unsigned long md_sequence_end_time(struct sequenceState* seq);
| 1,834
|
C++
|
.h
| 46
| 37.608696
| 76
| 0.731913
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,450
|
fileformats.h
|
canorusmusic_canorus/src/core/fileformats.h
|
/*!
Copyright (c) 2006-2019, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef FILEFORMATS_H_
#define FILEFORMATS_H_
#include <QString>
class CAFileFormats {
public:
enum CAFileFormatType {
CanorusML = 1,
Can = 2,
LilyPond = 3,
MusicXML = 4,
MXL = 16,
ABCMusic = 5,
NoteEdit = 6,
MUP = 7,
Finale = 8,
Sibelius = 9,
Noteworthy = 10,
Igor = 11,
Capella = 12,
Midi = 13,
PDF = 14,
SVG = 15
};
static const QString LILYPOND_FILTER;
static const QString CANORUSML_FILTER;
static const QString CAN_FILTER;
static const QString MUSICXML_FILTER;
static const QString MXL_FILTER;
static const QString NOTEEDIT_FILTER;
static const QString ABCMUSIC_FILTER;
static const QString FINALE_FILTER;
static const QString SIBELIUS_FILTER;
static const QString CAPELLA_FILTER;
static const QString MIDI_FILTER;
static const QString PDF_FILTER;
static const QString SVG_FILTER;
static const QString getFilter(const CAFileFormatType);
static CAFileFormatType getType(const QString);
};
#endif /*FILEFORMATS_H_*/
| 1,356
|
C++
|
.h
| 45
| 24.555556
| 86
| 0.680982
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,451
|
undo.h
|
canorusmusic_canorus/src/core/undo.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef UNDO_H_
#define UNDO_H_
class CAUndoCommand;
class CADocument;
#include <QHash>
#include <QList>
class CAUndo {
public:
CAUndo();
virtual ~CAUndo();
bool canUndo(CADocument*);
bool canRedo(CADocument*);
void undo(CADocument*);
void redo(CADocument*);
inline bool containsUndoStack(CADocument* d) { return _undoStack.contains(d); }
void createUndoStack(CADocument* d);
inline QList<CAUndoCommand*>* undoStack(CADocument* d) { return _undoStack[d]; }
inline int& undoIndex(CADocument* d) { return _undoIndex[undoStack(d)]; }
inline void removeUndoStack(CADocument* d) { _undoStack.remove(d); }
void deleteUndoStack(CADocument* doc);
void createUndoCommand(CADocument* d, QString text);
void pushUndoCommand();
CAUndoCommand* undoCommand(CADocument* d);
CAUndoCommand* redoCommand(CADocument* d);
void updateLastUndoCommand(CAUndoCommand* c);
void replaceDocument(CADocument*, CADocument*);
QList<CADocument*> getAllDocuments(CADocument* d);
private:
void clearUndoCommand();
CAUndoCommand* _undoCommand; // current undo command created to be put on the undo stack
QHash<CADocument*, QList<CAUndoCommand*>*> _undoStack;
QHash<QList<CAUndoCommand*>*, int> _undoIndex;
};
#endif /* UNDO_H_ */
| 1,506
|
C++
|
.h
| 39
| 34.948718
| 92
| 0.739369
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,452
|
typesetter.h
|
canorusmusic_canorus/src/core/typesetter.h
|
/*!
Copyright (c) 2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef TYPESETTER_H_
#define TYPESETTER_H_
class CATypesetter {
public:
enum CATypesetterType { // used for storing the default typesetter in settings
LilyPond = 1
};
CATypesetter();
virtual ~CATypesetter();
};
#endif /* TYPESETTER_H_ */
| 477
|
C++
|
.h
| 16
| 26.8125
| 82
| 0.739035
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,453
|
file.h
|
canorusmusic_canorus/src/core/file.h
|
/*!
Copyright (c) 2007-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef FILE_H_
#define FILE_H_
#include <QFile>
#include <QThread>
class QTextStream;
class CAFile : public QThread {
public:
CAFile();
virtual ~CAFile();
inline int status() { return _status; }
inline int progress() { return _progress; }
virtual const QString readableStatus() = 0;
void setStreamFromFile(const QString filename);
void setStreamToFile(const QString filename);
void setStreamFromDevice(QIODevice* device);
void setStreamToDevice(QIODevice* device);
void setStreamToString();
QString getStreamAsString();
protected:
inline void setStatus(const int status) { _status = status; }
inline void setProgress(const int progress) { _progress = progress; }
inline QTextStream* stream() { return _stream; }
virtual void setStream(QTextStream* stream) { _stream = stream; }
inline QFile* file() { return _file; }
inline void setFile(QFile* file) { _file = file; }
private:
int _status; // status number
int _progress; // percentage of the work already done
QTextStream* _stream;
QFile* _file;
bool _deleteStream; // whether to delete stream when destroyed.
};
#endif /* FILE_H_ */
| 1,404
|
C++
|
.h
| 38
| 33.236842
| 76
| 0.720827
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,454
|
tar.h
|
canorusmusic_canorus/src/core/tar.h
|
/*!
Copyright (c) 2007-2019, Itay Perl, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef TAR_H_
#define TAR_H_
#include <QByteArray>
#include <QFile>
#include <QHash>
#include <QString>
#include <memory>
using std::unique_ptr;
class QIODevice;
typedef unique_ptr<QIODevice> CAIOPtr;
class CATar {
public:
CATar();
CATar(QIODevice&);
virtual ~CATar();
bool addFile(const QString& filename, QIODevice& data, bool replace = true);
bool addFile(const QString& filename, QByteArray data, bool replace = true);
void removeFile(const QString& filename);
inline bool contains(const QString& filename);
CAIOPtr file(const QString& filename);
qint64 write(QIODevice& dest, qint64 chunk);
qint64 write(QIODevice& dest);
inline bool open(QIODevice& dest)
{
if (_pos.contains(&dest)) {
return false;
}
_pos[&dest].pos = _pos[&dest].file = _pos[&dest].eof = 0;
return true;
}
inline void close(QIODevice& dest) { _pos.remove(&dest); }
bool eof(QIODevice& dest);
inline bool error() { return !_ok; }
protected:
static const int CHUNK;
typedef struct { /* size in bytes (ASCII) */
char name[101]; /* 100 */
quint32 mode; /* 8 */
quint32 uid; /* 8 */
quint32 gid; /* 8 */
quint64 size; /* 12 */
quint64 mtime; /* 12 */
quint32 chksum; /* 8 */
char typeflag; /* 1 */
char linkname[101]; /* 100 */
/* magic "ustar\0" */ /* 6 */
/* version "00" */ /* 2 */
char uname[33]; /* 32 */
char gname[33]; /* 32 */
// NULs /* 16 */
char prefix[156]; /* 155 */
// NULs /* 12 */
} CATarHeader;
typedef struct {
CATarHeader hdr;
QFile* data;
} CATarFile;
QList<CATarFile*> _files;
void parse(QIODevice& data);
bool _ok;
typedef struct {
qint64 pos;
qint32 file;
bool close;
bool eof;
} CATarBufInfo;
QHash<QIODevice*, CATarBufInfo> _pos;
// helper functions
char* bufncpy(char*, const char*, size_t, size_t bufsize = 0);
char* bufncpyi(char*&, const char*, size_t, size_t bufsize = 0);
char* numToOct(char*, quint64, size_t);
char* numToOcti(char*&, quint64, size_t);
void writeHeader(QIODevice& dest, int file);
};
#endif /* TAR_H_ */
| 2,525
|
C++
|
.h
| 80
| 26
| 80
| 0.602627
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,455
|
muselementfactory.h
|
canorusmusic_canorus/src/core/muselementfactory.h
|
/*!
Copyright (c) 2006, Reinhard Katzmann, Canorus development team
2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef MUSELEMENTFACTORY_H_
#define MUSELEMENTFACTORY_H_
#include "score/barline.h"
#include "score/articulation.h"
#include "score/clef.h"
#include "score/crescendo.h"
#include "score/diatonickey.h"
#include "score/fermata.h"
#include "score/figuredbassmark.h"
#include "score/fingering.h"
#include "score/functionmark.h"
#include "score/keysignature.h"
#include "score/lyricscontext.h"
#include "score/mark.h"
#include "score/muselement.h"
#include "score/playablelength.h"
#include "score/repeatmark.h"
#include "score/rest.h"
#include "score/ritardando.h"
#include "score/slur.h"
#include "score/staff.h"
#include "score/syllable.h"
#include "score/tempo.h"
#include "score/timesignature.h"
#include "score/voice.h"
class CAMusElement;
class CAMusElementFactory {
public:
CAMusElementFactory();
~CAMusElementFactory();
CAMusElement* createMusElem();
void removeMusElem(bool bReallyRemove = false);
void configureMusElem(CAMusElement& roMusElement);
inline CAMusElement* musElement() { return mpoMusElement; };
inline void setMusElement(CAMusElement* elt) { mpoMusElement = elt; }
inline void cloneMusElem() { mpoMusElement = mpoMusElement->clone(); }
inline void emptyMusElem() { mpoMusElement = mpoEmpty; }
bool configureClef(CAStaff* staff,
CAMusElement* right);
bool configureKeySignature(CAStaff* staff,
CAMusElement* right);
bool configureTimeSignature(CAStaff* staff,
CAMusElement* right);
bool configureBarline(CAStaff* staff,
CAMusElement* right);
bool configureRest(CAVoice* voice,
CAMusElement* right);
bool configureNote(int pitch,
CAVoice* voice,
CAMusElement* right,
bool addToChord);
bool configureTuplet(QList<CAPlayable*> listOfNotes);
bool configureSlur(CAStaff* staff,
CANote* noteStart, CANote* noteEnd);
bool configureMark(CAMusElement* elt);
bool configureFiguredBassNumber(CAFiguredBassMark* fbm);
bool configureFunctionMark(CAFunctionMarkContext* fmc,
int timeStart, int timeLength);
inline CAMusElement::CAMusElementType musElementType() { return _musElementType; }
void setMusElementType(CAMusElement::CAMusElementType eMEType) { _musElementType = eMEType; }
inline CAPlayableLength& playableLength() { return _playableLength; }
inline void setPlayableLength(CAPlayableLength& playableLength)
{
_playableLength = playableLength;
};
void addPlayableDotted(int add, CAPlayableLength curLength);
inline CANote::CAStemDirection noteStemDirection() { return _eNoteStemDirection; }
inline void setNoteStemDirection(CANote::CAStemDirection eDir)
{
_eNoteStemDirection = eDir;
}
inline int noteAccs() { return _iNoteAccs; };
inline void setNoteAccs(int iNoteAccs)
{
_iNoteAccs = iNoteAccs;
};
inline void addNoteAccs(int iAdd)
{
if (_iNoteAccs + iAdd < 3)
_iNoteAccs += iAdd;
};
inline void subNoteAccs(int iSub)
{
if (_iNoteAccs - iSub > -3)
_iNoteAccs -= iSub;
};
inline int diatonicKeyNumberOfAccs() { return _diatonicKeyNumberOfAccs; }
inline void setDiatonicKeyNumberOfAccs(int accs) { _diatonicKeyNumberOfAccs = accs; }
inline CADiatonicKey::CAGender diatonicKeyGender() { return _diatonicKeyGender; }
inline void setDiatonicKeyGender(CADiatonicKey::CAGender g) { _diatonicKeyGender = g; }
inline int noteExtraAccs() { return _iNoteExtraAccs; };
inline void setNoteExtraAccs(int iNoteExtraAccs)
{
_iNoteExtraAccs = iNoteExtraAccs;
};
inline void addNoteExtraAccs(int iAdd)
{
_iNoteExtraAccs += iAdd;
};
inline void subNoteExtraAccs(int iSub)
{
_iNoteExtraAccs -= iSub;
};
inline CARest::CARestType restType() { return _eRestType; }
inline void setRestType(CARest::CARestType eType)
{
_eRestType = eType;
}
inline int timeSigBeats() { return _iTimeSigBeats; }
inline void setTimeSigBeats(int iTimeSigBeats)
{
_iTimeSigBeats = iTimeSigBeats;
};
inline int timeSigBeat() { return _iTimeSigBeat; }
inline void setTimeSigBeat(int iTimeSigBeat)
{
_iTimeSigBeat = iTimeSigBeat;
};
inline CAClef::CAPredefinedClefType clef() { return _eClef; }
inline void setClef(CAClef::CAPredefinedClefType eClefType)
{
_eClef = eClefType;
};
inline int clefOffset() { return _iClefOffset; } // readable offset interval, not internal offset
inline void setClefOffset(int offset)
{
_iClefOffset = offset;
};
inline CABarline::CABarlineType barlineType() { return _eBarlineType; }
inline void setBarlineType(CABarline::CABarlineType type)
{
_eBarlineType = type;
}
inline int tupletNumber() { return _tupletNumber; }
inline void setTupletNumber(int number) { _tupletNumber = number; }
inline int tupletActualNumber() { return _tupletActualNumber; }
inline void setTupletActualNumber(int actualNumber) { _tupletActualNumber = actualNumber; }
inline CASlur::CASlurType slurType() { return _eSlurType; }
inline void setSlurType(CASlur::CASlurType type) { _eSlurType = type; }
inline CASlur::CASlurStyle slurStyle() { return _slurStyle; }
inline void setSlurStyle(CASlur::CASlurStyle style) { _slurStyle = style; }
inline CAMark::CAMarkType markType() { return _markType; }
inline void setMarkType(CAMark::CAMarkType t) { _markType = t; }
inline CAArticulation::CAArticulationType articulationType() { return _articulationType; }
inline void setArticulationType(CAArticulation::CAArticulationType t) { _articulationType = t; }
inline int fbmNumber() { return _fbmNumber; }
inline void setFBMNumber(int n) { _fbmNumber = n; }
inline int fbmAccs() { return _fbmAccs; }
inline void setFBMAccs(int n) { _fbmAccs = n; }
inline bool fbmAccsVisible() { return _fbmAccsVisible; }
inline void setFBMAccsVisible(int n) { _fbmAccsVisible = n; }
inline CAFunctionMark::CAFunctionType fmFunction() { return _fmFunction; }
inline void setFMFunction(CAFunctionMark::CAFunctionType f) { _fmFunction = f; }
inline CAFunctionMark::CAFunctionType fmChordArea() { return _fmChordArea; }
inline void setFMChordArea(CAFunctionMark::CAFunctionType c) { _fmChordArea = c; }
inline CAFunctionMark::CAFunctionType fmTonicDegree() { return _fmTonicDegree; }
inline void setFMTonicDegree(CAFunctionMark::CAFunctionType td) { _fmTonicDegree = td; }
inline bool isFMFunctionMinor() { return _fmFunctionMinor; }
inline void setFMFunctionMinor(bool m) { _fmFunctionMinor = m; }
inline bool isFMTonicDegreeMinor() { return _fmTonicDegreeMinor; }
inline void setFMTonicDegreeMinor(bool m) { _fmTonicDegreeMinor = m; }
inline bool isFMChordAreaMinor() { return _fmChordAreaMinor; }
inline void setFMChordAreaMinor(bool m) { _fmChordAreaMinor = m; }
inline bool isFMEllipse() { return _fmEllipse; }
inline void setFMEllipse(bool e) { _fmEllipse = e; }
inline const QString dynamicText() { return _dynamicText; }
inline void setDynamicText(const QString t) { _dynamicText = t; }
inline const int dynamicVolume() { return _dynamicVolume; }
inline void setDynamicVolume(const int vol) { _dynamicVolume = vol; }
inline const int instrument() { return _instrument; }
inline void setInstrument(const int instrument) { _instrument = instrument; }
inline const CAFermata::CAFermataType fermataType() { return _fermataType; }
inline void setFermataType(const CAFermata::CAFermataType type) { _fermataType = type; }
inline const int tempoBpm() { return _tempoBpm; }
inline void setTempoBpm(const int tempoBpm) { _tempoBpm = tempoBpm; }
inline CAPlayableLength& tempoBeat() { return _tempoBeat; }
inline void setTempoBeat(CAPlayableLength& length) { _tempoBeat = length; }
inline const CARitardando::CARitardandoType ritardandoType() { return _ritardandoType; }
inline void setRitardandoType(CARitardando::CARitardandoType t) { _ritardandoType = t; }
inline const int crescendoFinalVolume() { return _crescendoFinalVolume; }
inline void setCrescendoFinalVolume(const int v) { _crescendoFinalVolume = v; }
inline const CACrescendo::CACrescendoType crescendoType() { return _crescendoType; }
inline void setCrescendoType(const CACrescendo::CACrescendoType t) { _crescendoType = t; }
inline const CARepeatMark::CARepeatMarkType repeatMarkType() { return _repeatMarkType; }
inline void setRepeatMarkType(const CARepeatMark::CARepeatMarkType t) { _repeatMarkType = t; }
inline const int repeatMarkVoltaNumber() { return _repeatMarkVoltaNumber; }
inline void setRepeatMarkVoltaNumber(const int n) { _repeatMarkVoltaNumber = n; }
inline const CAFingering::CAFingerNumber fingeringFinger() { return _fingeringFinger; }
inline void setFingeringFinger(const CAFingering::CAFingerNumber f) { _fingeringFinger = f; }
inline const bool isFingeringOriginal() { return _fingeringOriginal; }
inline void setFingeringOriginal(const int o) { _fingeringOriginal = o; }
private:
CAMusElement* mpoMusElement; // Newly created music element itself
CAMusElement* mpoEmpty; // An empty (dummy) element.
/////////////////////////////////
// Element creation parameters //
/////////////////////////////////
CAMusElement::CAMusElementType _musElementType; // Music element type
// Staff music elements
CAPlayableLength _playableLength; // Length of note/rest to be added
CANote::CAStemDirection _eNoteStemDirection; // Note stem direction to be inserted
CASlur::CASlurType _eSlurType; // Slur type to be placed
int _tupletNumber; // Tuplet number of notes
int _tupletActualNumber; // Tuplet actual number of notes
int _iPlayableDotted; // Number of dots to be inserted for the note/rest
int _iNoteExtraAccs; // Extra note accidentals for new notes which user adds/removes with +/- keys
int _iNoteAccs; // Note accidentals at specific coordinates updated regularily when in insert mode
CARest::CARestType _eRestType; // Hidden/Normal rest
int _diatonicKeyNumberOfAccs; // Key signature number of accidentals
CADiatonicKey::CAGender _diatonicKeyGender; // Major/Minor gender of the key signature
int _iTimeSigBeats; // Time signature number of beats to be inserted
int _iTimeSigBeat; // Time signature beat to be inserted
CAClef::CAPredefinedClefType _eClef; // Type of the clef to be inserted
int _iClefOffset; // Interval offset for the clef
CABarline::CABarlineType _eBarlineType; // Type of the barline
CAMark::CAMarkType _markType; // Type of the mark
CAArticulation::CAArticulationType _articulationType; // Type of the articulation mark
CASlur::CASlurStyle _slurStyle; // Style of the slur (solid, dotted)
// Figured bass
int _fbmNumber; // Figured bass number
int _fbmAccs; // Figured bass accidentals
bool _fbmAccsVisible; // Are accidentals visible
// Function Mark
CAFunctionMark::CAFunctionType _fmFunction; // Name of the function
CAFunctionMark::CAFunctionType _fmChordArea; // Chord area of the function
CAFunctionMark::CAFunctionType _fmTonicDegree; // Tonic degree of the function
bool _fmFunctionMinor;
bool _fmChordAreaMinor;
bool _fmTonicDegreeMinor;
bool _fmEllipse;
// Marks
QString _dynamicText;
int _dynamicVolume;
int _instrument;
CAFermata::CAFermataType _fermataType;
CAPlayableLength _tempoBeat;
int _tempoBpm;
CARitardando::CARitardandoType _ritardandoType;
int _crescendoFinalVolume;
CACrescendo::CACrescendoType _crescendoType;
CARepeatMark::CARepeatMarkType _repeatMarkType;
int _repeatMarkVoltaNumber;
CAFingering::CAFingerNumber _fingeringFinger;
int _fingeringOriginal;
};
#endif // MUSELEMENTFACTORY_H_
| 12,286
|
C++
|
.h
| 252
| 43.519841
| 102
| 0.732291
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,456
|
midirecorder.h
|
canorusmusic_canorus/src/core/midirecorder.h
|
/*!
Copyright (c) 2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef MIDIRECORDER_H_
#define MIDIRECORDER_H_
#include <QTimer>
#include <QVector>
#include <memory>
class CAMidiExport;
class CAResource;
class CAMidiDevice;
class CAMidiRecorder : public QObject {
#ifndef SWIG
Q_OBJECT
#endif
public:
CAMidiRecorder(std::shared_ptr<CAResource> r, CAMidiDevice* d);
virtual ~CAMidiRecorder();
void startRecording(int time = 0);
void pauseRecording();
void stopRecording();
const unsigned int& curTime() const { return _curTime; }
#ifndef SWIG
private slots:
void timerTimeout();
void onMidiInEvent(QVector<unsigned char> messages);
#endif
private:
std::shared_ptr<CAResource> _resource;
CAMidiExport* _midiExport;
QTimer* _timer;
unsigned int _curTime;
bool _paused;
};
#endif /* MIDIRECORDER_H_ */
| 1,016
|
C++
|
.h
| 37
| 24.540541
| 76
| 0.750776
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,457
|
autorecovery.h
|
canorusmusic_canorus/src/core/autorecovery.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef AUTOSAVE_H_
#define AUTOSAVE_H_
#include <QObject>
class QTimer;
class CAAutoRecovery : public QObject {
Q_OBJECT
public:
CAAutoRecovery();
~CAAutoRecovery();
void updateTimer();
void openRecovery();
public slots:
void cleanupRecovery();
void saveRecovery();
private:
QTimer* _autoRecoveryTimer;
QTimer* _saveAfterRecoveryTimer;
const int _recoveryTimeout = 120000;
};
#endif /* AUTOSAVE_H_ */
| 661
|
C++
|
.h
| 25
| 23.32
| 72
| 0.744409
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,458
|
archive.h
|
canorusmusic_canorus/src/core/archive.h
|
/*!
Copyright (c) 2007, Itay Perl, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef ARCHIVE_H_
#define ARCHIVE_H_
#include "core/tar.h"
#include <QBuffer>
#include <iostream>
class QByteArray;
class QString;
class CAArchive {
public:
CAArchive();
CAArchive(QIODevice& arch);
qint64 write(QIODevice& dest);
virtual ~CAArchive();
// interface to CATar
inline bool addFile(const QString& filename, QIODevice& data)
{
if (!error())
return _tar->addFile(filename, data);
else
return false;
}
inline bool addFile(const QString& filename, QByteArray data)
{
if (!error())
return _tar->addFile(filename, data);
else
return false;
}
inline void removeFile(const QString& filename)
{
if (!error())
_tar->removeFile(filename);
}
inline CAIOPtr file(const QString& filename)
{
if (!error())
return _tar->file(filename);
else
return CAIOPtr(new QBuffer());
}
inline bool error() { return _err || _tar->error(); }
inline const QString& version() { return _version; }
protected:
static const int CHUNK;
static const QString COMMENT;
QString _version;
bool _err;
void parse(QIODevice&);
int getOS();
CATar* _tar;
};
#endif /* ARCHIVE_H_ */
| 1,511
|
C++
|
.h
| 57
| 20.964912
| 76
| 0.634789
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,459
|
undocommand.h
|
canorusmusic_canorus/src/core/undocommand.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef UNDOCOMMAND_H_
#define UNDOCOMMAND_H_
#include <QUndoCommand>
class CASheet;
class CADocument;
class CAUndoCommand : public QUndoCommand {
public:
CAUndoCommand(CADocument* document, QString text);
virtual ~CAUndoCommand();
virtual void undo();
virtual void redo();
static void undoDocument(CADocument* current, CADocument* newDocument);
inline CADocument* getUndoDocument() { return _undoDocument; }
inline void setUndoDocument(CADocument* doc) { _undoDocument = doc; }
inline CADocument* getRedoDocument() { return _redoDocument; }
inline void setRedoDocument(CADocument* doc) { _redoDocument = doc; }
private:
CADocument* _undoDocument;
CADocument* _redoDocument;
};
#endif /* UNDOCOMMAND_H_ */
| 973
|
C++
|
.h
| 26
| 34.230769
| 76
| 0.758805
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,460
|
settings.h
|
canorusmusic_canorus/src/core/settings.h
|
/*!
Copyright (c) 2007-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <QSettings>
#ifndef SWIG
#include "ui/singleaction.h"
#include <QColor>
//#include <QAction>
#endif
#include "core/fileformats.h"
#include "core/typesetter.h"
#include <QDir>
class CASettings : public QSettings {
#ifndef SWIG
Q_OBJECT
#endif
public:
CASettings(QObject* parent = nullptr);
CASettings(const QString& fileName, QObject* parent = nullptr);
void initSettings();
virtual ~CASettings();
int readSettings();
void writeSettings();
static const QString defaultSettingsPath();
/////////////////////
// Editor settings //
/////////////////////
inline bool finaleLyricsBehaviour() { return _finaleLyricsBehaviour; }
inline void setFinaleLyricsBehaviour(bool b) { _finaleLyricsBehaviour = b; }
static const bool DEFAULT_FINALE_LYRICS_BEHAVIOUR;
inline bool shadowNotesInOtherStaffs() { return _shadowNotesInOtherStaffs; }
inline void setShadowNotesInOtherStaffs(bool b) { _shadowNotesInOtherStaffs = b; }
static const bool DEFAULT_SHADOW_NOTES_IN_OTHER_STAFFS;
inline bool playInsertedNotes() { return _playInsertedNotes; }
inline void setPlayInsertedNotes(bool b) { _playInsertedNotes = b; }
static const bool DEFAULT_PLAY_INSERTED_NOTES;
inline bool autoBar() { return _autoBar; }
inline void setAutoBar(bool b) { _autoBar = b; }
static const bool DEFAULT_AUTO_BAR;
inline bool useNoteChecker() { return _useNoteChecker; }
inline void setUseNoteChecker(bool b) { _useNoteChecker = b; }
static const bool DEFAULT_USE_NOTE_CHECKER;
/////////////////////////////
// Loading/Saving settings //
/////////////////////////////
inline QDir documentsDirectory() { return _documentsDirectory; }
inline void setDocumentsDirectory(QDir d) { _documentsDirectory = d; }
static const QDir DEFAULT_DOCUMENTS_DIRECTORY;
inline CAFileFormats::CAFileFormatType defaultSaveFormat() { return _defaultSaveFormat; }
inline void setDefaultSaveFormat(CAFileFormats::CAFileFormatType t) { _defaultSaveFormat = t; }
static const CAFileFormats::CAFileFormatType DEFAULT_SAVE_FORMAT;
inline int autoRecoveryInterval() { return _autoRecoveryInterval; }
inline void setAutoRecoveryInterval(int interval) { _autoRecoveryInterval = interval; };
static const int DEFAULT_AUTO_RECOVERY_INTERVAL;
inline int maxRecentDocuments() { return _maxRecentDocuments; }
inline void setMaxRecentDocuments(int r) { _maxRecentDocuments = r; }
static const int DEFAULT_MAX_RECENT_DOCUMENTS;
/////////////////////////
// Appearance settings //
/////////////////////////
#ifndef SWIG
inline bool lockScrollPlayback()
{
return _lockScrollPlayback;
}
inline void setLockScrollPlayback(bool l) { _lockScrollPlayback = l; }
static const bool DEFAULT_LOCK_SCROLL_PLAYBACK;
inline bool animatedScroll() { return _animatedScroll; }
inline void setAnimatedScroll(bool a) { _animatedScroll = a; }
static const bool DEFAULT_ANIMATED_SCROLL;
inline bool antiAliasing() { return _antiAliasing; }
inline void setAntiAliasing(bool a) { _antiAliasing = a; }
static const bool DEFAULT_ANTIALIASING;
inline bool showRuler() { return _showRuler; }
inline void setShowRuler(bool b) { _showRuler = b; }
static const bool DEFAULT_SHOW_RULER;
inline QColor backgroundColor() { return _backgroundColor; }
inline void setBackgroundColor(QColor backgroundColor) { _backgroundColor = backgroundColor; }
static const QColor DEFAULT_BACKGROUND_COLOR;
inline QColor foregroundColor() { return _foregroundColor; }
inline void setForegroundColor(QColor foregroundColor) { _foregroundColor = foregroundColor; }
static const QColor DEFAULT_FOREGROUND_COLOR;
inline QColor selectionColor() { return _selectionColor; }
inline void setSelectionColor(QColor selectionColor) { _selectionColor = selectionColor; }
static const QColor DEFAULT_SELECTION_COLOR;
inline QColor selectionAreaColor() { return _selectionAreaColor; }
inline void setSelectionAreaColor(QColor selectionAreaColor) { _selectionAreaColor = selectionAreaColor; }
static const QColor DEFAULT_SELECTION_AREA_COLOR;
inline QColor selectedContextColor() { return _selectedContextColor; }
inline void setSelectedContextColor(QColor selectedContextColor) { _selectedContextColor = selectedContextColor; }
static const QColor DEFAULT_SELECTED_CONTEXT_COLOR;
inline QColor hiddenElementsColor() { return _hiddenElementsColor; }
inline void setDisabledElementsColor(QColor disabledElementsColor) { _disabledElementsColor = disabledElementsColor; }
static const QColor DEFAULT_HIDDEN_ELEMENTS_COLOR;
inline QColor disabledElementsColor() { return _disabledElementsColor; }
inline void setHiddenElementsColor(QColor hiddenElementsColor) { _hiddenElementsColor = hiddenElementsColor; }
static const QColor DEFAULT_DISABLED_ELEMENTS_COLOR;
#endif
///////////////////////
// Playback settings //
///////////////////////
inline int midiInPort() { return _midiInPort; }
void setMidiInPort(int in);
static const int DEFAULT_MIDI_IN_PORT;
inline int midiInNumDevices() { return _midiInNumDevices; }
void setMidiInNumDevices(int inNum) { _midiInNumDevices = inNum; }
static const int DEFAULT_MIDI_IN_NUM_DEVICES;
inline int midiOutPort() { return _midiOutPort; }
inline void setMidiOutPort(int out) { _midiOutPort = out; }
static const int DEFAULT_MIDI_OUT_PORT;
inline int midiOutNumDevices() { return _midiOutNumDevices; }
void setMidiOutNumDevices(int outNum) { _midiOutNumDevices = outNum; }
static const int DEFAULT_MIDI_OUT_NUM_DEVICES;
///////////////////////
// Printing settings //
///////////////////////
inline CATypesetter::CATypesetterType typesetter() { return _typesetter; }
void setTypesetter(CATypesetter::CATypesetterType t) { _typesetter = t; }
static const CATypesetter::CATypesetterType DEFAULT_TYPESETTER;
inline QString typesetterLocation() { return _typesetterLocation; }
void setTypesetterLocation(QString tl) { _typesetterLocation = tl; }
static const QString DEFAULT_TYPESETTER_LOCATION;
inline bool useSystemDefaultTypesetter() { return _useSystemDefaultTypesetter; }
void setUseSystemDefaultTypesetter(bool s) { _useSystemDefaultTypesetter = s; }
static const bool DEFAULT_USE_SYSTEM_TYPESETTER;
inline QString pdfViewerLocation() { return _pdfViewerLocation; }
void setPdfViewerLocation(QString pl) { _pdfViewerLocation = pl; }
static const QString DEFAULT_PDF_VIEWER_LOCATION;
inline bool useSystemDefaultPdfViewer() { return _useSystemDefaultPdfViewer; }
void setUseSystemDefaultPdfViewer(bool s) { _useSystemDefaultPdfViewer = s; }
static const bool DEFAULT_USE_SYSTEM_PDF_VIEWER;
///////////////////////////////
// Action / Command settings //
///////////////////////////////
inline QDir latestShortcutsDirectory() { return _latestShortcutsDirectory; }
inline void setLatestShortcutsDirectory(QDir d) { _latestShortcutsDirectory = d; }
static const QDir DEFAULT_SHORTCUTS_DIRECTORY;
#ifndef SWIG
int getSingleAction(const QString& oCommandName, QAction*& poResAction);
int getSingleAction(const QString& oCommandName, CASingleAction*& poResAction);
/*!
Re one single action in the list of actions
Does not check for the correct position in the list to be fast!
*/
inline CASingleAction& getSingleAction(int iPos, QList<CASingleAction*>& oActionList)
{
CASingleAction* poResAction = static_cast<CASingleAction*>(oActionList[iPos]);
return *poResAction;
}
bool setSingleAction(QAction oSingleAction, int iPos);
inline const QList<CASingleAction*>& getActionList() { return _oActionList; }
void setActionList(QList<CASingleAction*>& oActionList);
void addSingleAction(CASingleAction& oAction);
bool deleteSingleAction(QString oCommandName, CASingleAction*& poResAction);
#endif
private:
#ifndef SWIG
void writeRecentDocuments();
void readRecentDocuments();
#endif
/////////////////////
// Editor settings //
/////////////////////
bool _finaleLyricsBehaviour;
bool _shadowNotesInOtherStaffs;
bool _playInsertedNotes;
bool _autoBar;
bool _useNoteChecker;
/////////////////////////////
// Loading/Saving settings //
/////////////////////////////
QDir _documentsDirectory; // location of directory automatically opened when File->Open is selected
CAFileFormats::CAFileFormatType _defaultSaveFormat;
int _autoRecoveryInterval; // auto recovery interval in minutes
int _maxRecentDocuments; // number of stored recently opened files
/////////////////////////
// Appearance settings //
/////////////////////////
#ifndef SWIG
bool _lockScrollPlayback;
bool _animatedScroll;
bool _antiAliasing;
bool _showRuler;
QColor _backgroundColor;
QColor _foregroundColor;
QColor _selectionColor;
QColor _selectionAreaColor;
QColor _selectedContextColor;
QColor _hiddenElementsColor;
QColor _disabledElementsColor;
#endif
///////////////////////
// Playback settings //
///////////////////////
int _midiOutPort; // -1 disabled, 0+ port number
int _midiInPort; // -1 disabled, 0+ port number
int _midiOutNumDevices; // last number of MIDI out ports
int _midiInNumDevices; // last number of MIDI in ports
///////////////////////
// Printing settings //
///////////////////////
CATypesetter::CATypesetterType _typesetter;
QString _typesetterLocation;
bool _useSystemDefaultTypesetter;
QString _pdfViewerLocation;
bool _useSystemDefaultPdfViewer;
/*
% To adjust the size of notes and fonts in points, it can be done like this:
% #(set-global-staff-size 16.0)
% Some examples to adjust the page size:
% \paper { #(set-paper-size "a3") } letter legal
% \paper { #(set-paper-size "a4" 'landscape) }
% For special size, like the screen, adjustments can be done like this:
% \paper{
% paper-width = 16\cm
% line-width = 12\cm
% left-margin = 2\cm
% top-margin = 3\cm
% bottom-margin = 3\cm
% ragged-last-bottom = ##t
% }
*/
/////////////////////////////
// Action/Command settings //
/////////////////////////////
QDir _latestShortcutsDirectory; // save location of shortcuts/midi commands
// @ToDo: QAction can be exported to SWIG ? Abstract interface but requires QObject
#ifndef SWIG
QList<CASingleAction*> _oActionList;
CASingleAction* _poEmptyEntry; // Entry is unused for search function
#endif
};
#endif /* SETTINGS_H_ */
| 10,957
|
C++
|
.h
| 237
| 41.902954
| 122
| 0.705926
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,461
|
notechecker.h
|
canorusmusic_canorus/src/core/notechecker.h
|
/*!
Copyright (c) 2015, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef NOTECHECKER_H_
#define NOTECHECKER_H_
class CASheet;
class CANoteChecker {
public:
CANoteChecker();
virtual ~CANoteChecker();
void checkSheet(CASheet*);
};
#endif /* NOTECHECKER_H_ */
| 425
|
C++
|
.h
| 15
| 25.8
| 76
| 0.759305
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,462
|
mimedata.h
|
canorusmusic_canorus/src/core/mimedata.h
|
/*!
Copyright (c) 2007-2020, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef MIMETYPE_H_
#define MIMETYPE_H_
#include <QList>
#include <QMimeData>
#include <QStringList>
class CAContext;
class CAMimeData : public QMimeData {
public:
CAMimeData();
CAMimeData(QList<CAContext*> list);
virtual ~CAMimeData();
using QMimeData::hasFormat;
bool hasFormat(const QString) const;
QStringList formats() const;
inline void setContexts(QList<CAContext*> list) { _contexts = list; }
inline const QList<CAContext*>& contexts() const { return _contexts; }
inline bool hasContexts() const { return _contexts.size(); }
static const QString CANORUS_MIME_TYPE;
private:
QList<CAContext*> _contexts;
};
#endif /* MIMEDATA_H_ */
| 911
|
C++
|
.h
| 27
| 30.62963
| 76
| 0.740275
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,463
|
transpose.h
|
canorusmusic_canorus/src/core/transpose.h
|
/*!
Copyright (c) 2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef TRANSPOSE_H_
#define TRANSPOSE_H_
#include <QList>
#include <QSet>
#include "score/diatonickey.h"
#include "score/interval.h"
class CAMusElement;
class CASheet;
class CAContext;
class CATranspose {
public:
CATranspose();
CATranspose(CASheet* sheet);
#ifndef SWIG
CATranspose(QList<CAContext*> contexts);
#endif
CATranspose(QList<CAMusElement*> selection);
~CATranspose();
void transposeBySemitones(int semitones);
void transposeByInterval(CAInterval);
void transposeByKeySig(CADiatonicKey from, CADiatonicKey to, int direction);
void reinterpretAccidentals(int type);
void addSheet(CASheet* s);
void addContext(CAContext* context);
void addMusElement(CAMusElement* musElt) { _elements << musElt; }
private:
QSet<CAMusElement*> _elements;
};
#endif /* TRANSPOSE_H_ */
| 1,046
|
C++
|
.h
| 34
| 27.852941
| 80
| 0.765469
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,464
|
actiondelegate.h
|
canorusmusic_canorus/src/core/actiondelegate.h
|
/*!
Copyright (c) 2015, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef ACTIONDELEGATE_H_
#define ACTIONDELEGATE_H_
#include <QAction>
#include <QString>
// Helper methods to reduce code ballast in mainwin class
// Keyboard (Midi) Shortcuts that can be changed dynamically
class CAMainWin;
class CASingleAction;
class CAActionDelegate {
public:
CAActionDelegate(CAMainWin* mainWin);
void addWinActions(QWidget& widget);
void removeMainWinActions();
void updateMainWinActions();
protected:
void addSingleAction(const QString& oCommandName, const QString& oDescription, const QAction& oAction);
void updateSingleAction(CASingleAction& oSource, QAction& oAction);
private:
CAMainWin* _mainWin;
};
#endif // ACTIONDELEGATE_H_
| 924
|
C++
|
.h
| 26
| 32.961538
| 107
| 0.793919
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,465
|
keysignatureui.h
|
canorusmusic_canorus/src/scoreui/keysignatureui.h
|
/*!
Copyright (c) 2006-2010, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef _KEYSIGNATURE_UI_H_
#define _KEYSIGNATURE_UI_H_
// Includes
#include <QComboBox>
#include <QObject>
// Forward declarations
class CAMainWin;
class QToolBar;
class CAKeySignatureCtl;
// Dummy ui is an example class for creating UI parts of the mainwindow
// Such ui objects are created via the Canorus mainwindow (currently)
// To find the widget children the parent must be a widget too!
class CAKeySignatureUI : public QWidget {
Q_OBJECT
public:
CAKeySignatureUI(CAMainWin* poMainWin, const QString& oHash);
~CAKeySignatureUI();
void updateKeySigToolBar();
inline CAKeySignatureCtl& ctl() { return *_poKeySignatureCtl; }
static void populateComboBox(QComboBox* c);
static void populateComboBoxDirection(QComboBox* c);
protected:
CAMainWin* _poMainWin;
CAKeySignatureCtl* _poKeySignatureCtl;
QToolBar* uiKeySigToolBar;
// CAKeySigPSP *uiKeySigPSP; // Key signature perspective. \todo Reimplement it.
QComboBox* uiKeySig;
// QComboBox *uiKeySigGender;
};
#endif // _KEYSIGNATURE_UI_H
| 1,320
|
C++
|
.h
| 35
| 34.057143
| 93
| 0.757098
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,466
|
dummyui.h
|
canorusmusic_canorus/src/scoreui/dummyui.h
|
/*!
Copyright (c) 2006-2010, Reinhard Katzmann, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef _DUMMY_UI_H_
#define _DUMMY_UI_H_
// Includes
#include <QObject>
// Forward declarations
class CAMainWin;
class CADummyUIObj;
class CADummyCtl;
// Dummy ui is an example class for creating UI parts of the mainwindow
// Such ui objects are created via the Canorus mainwindow (currently)
class CADummyUI : public QObject {
Q_OBJECT
public:
CADummyUI(CAMainWin* poMainWin);
~CADummyUI();
protected:
updateDummyUIObjs();
CAMainWin* _poMainWin;
CADummyCtl* _poDummyCtl;
CADummyUIObj* _poDummyUIObj;
};
#endif // _DUMMY_UI_H
| 826
|
C++
|
.h
| 27
| 27.037037
| 93
| 0.745524
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,467
|
drawablenotecheckererror.h
|
canorusmusic_canorus/src/layout/drawablenotecheckererror.h
|
/*!
Copyright (c) 2015, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLENOTECHECKERERROR_H_
#define DRAWABLENOTECHECKERERROR_H_
#include "layout/drawable.h"
class CANoteCheckerError;
class CADrawableNoteCheckerError : public CADrawable {
public:
CADrawableNoteCheckerError(CANoteCheckerError* nce, CADrawable* dTarget);
void draw(QPainter* p, const CADrawSettings s);
CADrawable* clone();
};
#endif /* DRAWABLECONTEXT_H_ */
| 595
|
C++
|
.h
| 16
| 34.875
| 77
| 0.797557
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,468
|
drawablekeysignature.h
|
canorusmusic_canorus/src/layout/drawablekeysignature.h
|
/*!
Copyright (c) 2006-2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLEKEYSIGNATURE_H_
#define DRAWABLEKEYSIGNATURE_H_
#include "layout/drawablemuselement.h"
#include "score/diatonickey.h"
class CADrawableStaff;
class CAKeySignature;
class CADrawableAccidental;
class QComboBox;
class CADrawableKeySignature : public CADrawableMusElement {
public:
CADrawableKeySignature(CAKeySignature* keySig, CADrawableStaff* staff, double x, double y);
~CADrawableKeySignature();
void draw(QPainter* p, CADrawSettings s);
CADrawableKeySignature* clone(CADrawableContext* newContext = 0);
inline CAKeySignature* keySignature() { return (CAKeySignature*)_musElement; }
private:
QList<CADrawableAccidental*> _drawableAccidentalList; ///List of actual drawable accidentals
};
#endif /*DRAWABLEKEYSIGNATURE_H_*/
| 990
|
C++
|
.h
| 24
| 38.75
| 96
| 0.806688
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,469
|
drawablestaff.h
|
canorusmusic_canorus/src/layout/drawablestaff.h
|
/*!
Copyright (c) 2006-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLESTAFF_H_
#define DRAWABLESTAFF_H_
#include "layout/drawablecontext.h"
#include "score/staff.h"
class CANote;
class CAClef;
class CAKeySignature;
class CATimeSignature;
class CABarline;
class CADrawableClef;
class CADrawableKeySignature;
class CADrawableTimeSignature;
class CADrawableBarline;
class CADrawableStaff : public CADrawableContext {
public:
CADrawableStaff(CAStaff* staff, double x, double y);
void draw(QPainter*, const CADrawSettings s);
CADrawableStaff* clone();
inline CAStaff* staff() { return static_cast<CAStaff*>(_context); }
inline double lineSpace() { return (staff()->numberOfLines() ? height() / (staff()->numberOfLines() - 1) : 0); }
double calculateCenterYCoord(int pitch, CAClef* clef);
double calculateCenterYCoord(CANote* note, CAClef* clef);
double calculateCenterYCoord(CANote* note, double x);
double calculateCenterYCoord(int pitch, double x);
double calculateCenterYCoord(double y);
int calculatePitch(double x, double y);
void addClef(CADrawableClef* clef);
void addKeySignature(CADrawableKeySignature* keySig);
void addTimeSignature(CADrawableTimeSignature* keySig);
void addBarline(CADrawableBarline* barline);
bool removeClef(CADrawableClef* clef);
bool removeKeySignature(CADrawableKeySignature* keySig);
bool removeTimeSignature(CADrawableTimeSignature* keySig);
bool removeBarline(CADrawableBarline* barline);
CAClef* getClef(double x);
CAKeySignature* getKeySignature(double x);
QList<CADrawableTimeSignature*>& drawableTimeSignatureList() { return _drawableTimeSignatureList; }
CATimeSignature* getTimeSignature(double x);
QList<CADrawableBarline*>& drawableBarlineList() { return _drawableBarlineList; }
CABarline* getBarline(double x);
static bool xDrawableBarlineLessThan(const CADrawableBarline* a, const double x);
int getAccs(double x, int pitch);
void addMElement(CADrawableMusElement* elt);
int removeMElement(CADrawableMusElement* elt);
private:
QList<CADrawableClef*> _drawableClefList; // List of all the drawable clefs. Used for fast look-up with the given key - X-coordinate usually.
QList<CADrawableKeySignature*> _drawableKeySignatureList; // List of all the drawable key signatures. Used for fast look-up with the given key - X-coordinate usually.
QList<CADrawableTimeSignature*> _drawableTimeSignatureList; // List of all the drawable time signatures. Used for fast look-up with the given key - X-coordinate usually.
QList<CADrawableBarline*> _drawableBarlineList; // List of all the barlines. Used for fast look-up with the given key - X-coordinate usually.
static const double STAFFLINE_WIDTH; // Width of the staffs' lines. Defined in drawablestaff.cpp
};
#endif /* DRAWABLESTAFF_H_ */
| 3,028
|
C++
|
.h
| 57
| 49.438596
| 173
| 0.779506
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,470
|
drawablechordname.h
|
canorusmusic_canorus/src/layout/drawablechordname.h
|
/*!
Copyright (c) 2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLECHORDNAME_H_
#define DRAWABLECHORDNAME_H_
#include "layout/drawablemuselement.h"
#include "score/chordname.h"
class CADrawableChordNameContext;
class CADrawableChordName : public CADrawableMusElement {
public:
CADrawableChordName(CAChordName*, CADrawableChordNameContext*, double x, double y);
~CADrawableChordName();
void draw(QPainter* p, const CADrawSettings s);
CADrawableChordName* clone(CADrawableContext* c = 0);
CAChordName* chordName() { return static_cast<CAChordName*>(musElement()); }
static const double DEFAULT_TEXT_SIZE;
private:
QString drawableDiatonicPitch();
};
#endif /* DRAWABLECHORDNAME_H_ */
| 881
|
C++
|
.h
| 22
| 37.227273
| 87
| 0.785882
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,471
|
drawablerest.h
|
canorusmusic_canorus/src/layout/drawablerest.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEREST_H_
#define DRAWABLEREST_H_
#include "layout/drawablemuselement.h"
#include "score/rest.h"
class CADrawableRest : public CADrawableMusElement {
public:
CADrawableRest(CARest* rest, CADrawableContext* drawableContext, double x, double y);
CADrawableRest* clone(CADrawableContext* newContext = nullptr);
~CADrawableRest();
void draw(QPainter* p, CADrawSettings s);
inline CARest* rest() { return static_cast<CARest*>(_musElement); }
private:
double _restWidth; ///Width of the rest itself without dots, ledger lines etc.
};
#endif /*DRAWABLEREST_H_*/
| 815
|
C++
|
.h
| 20
| 38
| 89
| 0.767471
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,472
|
drawablechordnamecontext.h
|
canorusmusic_canorus/src/layout/drawablechordnamecontext.h
|
/*!
Copyright (c) 2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLECHORDNAMECONTEXT_H_
#define DRAWABLECHORDNAMECONTEXT_H_
#include "layout/drawablecontext.h"
#include "score/chordnamecontext.h"
class CAChordNameContext;
class CADrawableChordNameContext : public CADrawableContext {
public:
CADrawableChordNameContext(CAChordNameContext* c, double x, double y);
~CADrawableChordNameContext();
CADrawableChordNameContext* clone();
void draw(QPainter* p, const CADrawSettings s);
CAChordNameContext* chordNameContext() { return static_cast<CAChordNameContext*>(context()); }
static const double DEFAULT_CHORDNAME_VERTICAL_SPACING;
};
#endif /* DRAWABLECHORDNAMECONTEXT_H_ */
| 868
|
C++
|
.h
| 20
| 40.6
| 98
| 0.800954
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,473
|
drawablebarline.h
|
canorusmusic_canorus/src/layout/drawablebarline.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEBARLINE_H_
#define DRAWABLEBARLINE_H_
#include "layout/drawablemuselement.h"
#include "score/barline.h"
class CADrawableStaff;
class CADrawableBarline : public CADrawableMusElement {
public:
CADrawableBarline(CABarline* m, CADrawableStaff* staff, double x, double y);
~CADrawableBarline();
void draw(QPainter* p, CADrawSettings s);
CADrawableBarline* clone(CADrawableContext* newContext = nullptr);
inline CABarline* barline() { return static_cast<CABarline*>(_musElement); }
private:
static const double SPACE_BETWEEN_BARLINES;
static const double BARLINE_WIDTH;
static const double BOLD_BARLINE_WIDTH;
static const double REPEAT_DOTS_WIDTH;
static const double DOTTED_BARLINE_WIDTH;
};
#endif /*DRAWABLEBARLINE_H_*/
| 997
|
C++
|
.h
| 25
| 36.8
| 80
| 0.779855
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,474
|
drawablesyllable.h
|
canorusmusic_canorus/src/layout/drawablesyllable.h
|
/*!
Copyright (c) 2007-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLESYLLABLE_H_
#define DRAWABLESYLLABLE_H_
#include "layout/drawablemuselement.h"
#include "score/syllable.h"
class CASyllable;
class CADrawableLyricsContext;
class CADrawableSyllable : public CADrawableMusElement {
public:
CADrawableSyllable(CASyllable*, CADrawableLyricsContext*, double x, double y);
~CADrawableSyllable();
void draw(QPainter* p, const CADrawSettings s);
CADrawableSyllable* clone(CADrawableContext* c = nullptr);
CASyllable* syllable() { return static_cast<CASyllable*>(musElement()); }
static const double DEFAULT_TEXT_SIZE;
static const double DEFAULT_DASH_LENGTH;
private:
inline const QString textToDrawableText(QString in) { return in.replace("_", " "); }
};
#endif /* DRAWABLESYLLABLE_H_ */
| 989
|
C++
|
.h
| 24
| 38.375
| 88
| 0.775105
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,475
|
drawablemidinote.h
|
canorusmusic_canorus/src/layout/drawablemidinote.h
|
/*!
Copyright (c) 2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEMIDINOTE_H_
#define DRAWABLEMIDINOTE_H_
#include "layout/drawablemuselement.h"
class CAMidiNote;
class CADrawableStaff;
class CADrawableMidiNote : public CADrawableMusElement {
public:
CADrawableMidiNote(CAMidiNote* midiNote, CADrawableStaff* c, double x, double y);
virtual ~CADrawableMidiNote();
void draw(QPainter* p, CADrawSettings s);
CADrawableMidiNote* clone(CADrawableContext* newContext);
};
#endif /* DRAWABLEMIDINOTE_H_ */
| 681
|
C++
|
.h
| 18
| 35.444444
| 85
| 0.796043
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,476
|
drawablenote.h
|
canorusmusic_canorus/src/layout/drawablenote.h
|
/*!
Copyright (c) 2006-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLENOTE_H_
#define DRAWABLENOTE_H_
#include "layout/drawablemuselement.h"
#include "score/note.h"
class CANote;
class CADrawableAccidental;
class CADrawableNote : public CADrawableMusElement {
public:
CADrawableNote(CANote* note, CADrawableContext* drawableContext, double x, double y, bool shadowNote = false, CADrawableAccidental* acc = 0);
~CADrawableNote();
void draw(QPainter* p, CADrawSettings s);
inline CANote* note() { return static_cast<CANote*>(_musElement); }
CADrawableNote* clone(CADrawableContext* newContext = 0);
void setDrawLedgerLines(bool ledgerLines) { _drawLedgerLines = ledgerLines; }
bool drawLedgerLines() { return _drawLedgerLines; }
void setDrawableAccidental(CADrawableAccidental* acc) { _drawableAcc = acc; }
CADrawableAccidental* drawableAccidental() { return _drawableAcc; }
private:
bool _drawLedgerLines; ///Are the ledger lines drawn or not. True when ledger lines needed, False when the note is inside the staff
bool _shadowNote; ///Is the current note shadow note?
CADrawableAccidental* _drawableAcc;
CANote::CAStemDirection _stemDirection; /// This value is StemUp or StemDown only, no StemPreferred or StemNeutral present. We generate this on CADrawableNote constructor.
double _stemLength;
double _noteHeadWidth;
double _penWidth; // pen width for stem
QString _noteHeadGlyphName; // Feta glyph name for the notehead symbol.
QString _flagUpGlyphName; // likewise for stem flags
QString _flagDownGlyphName;
static const double HUNDREDTWENTYEIGHTH_STEM_LENGTH;
static const double SIXTYFOURTH_STEM_LENGTH;
static const double THIRTYSECOND_STEM_LENGTH;
static const double SIXTEENTH_STEM_LENGTH;
static const double EIGHTH_STEM_LENGTH;
static const double QUARTER_STEM_LENGTH;
static const double HALF_STEM_LENGTH;
static const double QUARTER_YPOS_DELTA;
static const double HALF_YPOS_DELTA;
};
#endif /* DRAWABLENOTE_H_ */
| 2,212
|
C++
|
.h
| 44
| 46.363636
| 175
| 0.769838
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,477
|
drawablemark.h
|
canorusmusic_canorus/src/layout/drawablemark.h
|
/*!
Copyright (c) 2007-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#include "layout/drawablemuselement.h"
#include "score/fingering.h"
#include "score/mark.h"
#ifndef DRAWABLEMARK_H_
#define DRAWABLEMARK_H_
class CADrawableStaff;
class CANote;
class CADrawableNote;
class CADrawableMark : public CADrawableMusElement {
public:
CADrawableMark(CAMark* mark, CADrawableContext* drawableContext, double x, double y);
virtual ~CADrawableMark();
void draw(QPainter* p, CADrawSettings s);
CADrawableMark* clone(CADrawableContext* newContext = nullptr);
inline CAMark* mark() { return static_cast<CAMark*>(musElement()); }
inline void setRehersalMarkNumber(int n) { _rehersalMarkNumber = n; }
inline int rehersalMarkNumber() { return _rehersalMarkNumber; }
static QString fingerListToString(const QList<CAFingering::CAFingerNumber> list);
private:
static const double DEFAULT_TEXT_SIZE;
static const double DEFAULT_PIXMAP_SIZE;
CANote* _tempoNote;
CADrawableNote* _tempoDNote;
QPixmap* _pixmap;
int _rehersalMarkNumber;
};
#endif /* DRAWABLEMARK_H_ */
| 1,257
|
C++
|
.h
| 32
| 36.125
| 89
| 0.771193
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,478
|
drawable.h
|
canorusmusic_canorus/src/layout/drawable.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLE_H_
#define DRAWABLE_H_
#include <QColor>
#include <QRectF>
class QPainter;
struct CADrawSettings {
double z; // zoom level
int x; // painter x pos in pixels
int y; // painter y pos in pixels
int w; // canvas width in pixels
int h; // canvas height in pixels
QColor color; // pen color
double worldX; // x coordinate of the view
double worldY; // y coordinate of the view
};
class CADrawable {
public:
enum CADrawableType {
DrawableMusElement,
DrawableContext
};
enum CADirection {
Undefined,
Top,
Bottom,
Left,
Right,
TopLeft,
TopRight,
BottomLeft,
BottomRight
};
CADrawable(double x, double y); // x and y position of an element in absolute world units
virtual ~CADrawable() {}
virtual void draw(QPainter* p, const CADrawSettings s) = 0;
virtual CADrawable* clone() = 0;
void drawHScaleHandles(QPainter* p, const CADrawSettings s);
void drawVScaleHandles(QPainter* p, const CADrawSettings s);
inline CADrawableType drawableType() { return _drawableType; }
inline double xPos() const { return _xPos; }
inline double yPos() const { return _yPos; }
inline double width() const { return _width; }
inline double height() const { return _height; }
inline double neededSpaceWidth() const { return _neededSpaceWidth; }
inline double neededSpaceHeight() const { return _neededSpaceHeight; }
inline double neededWidth() const { return _width + _neededSpaceWidth; }
inline double neededHeight() const { return _height + _neededSpaceHeight; }
inline double xCenter() const { return _xPos + (_width) / 2; }
inline double yCenter() const { return _yPos + (_height) / 2; }
inline const QRectF bBox() const { return QRectF(_xPos, _yPos, _width, _height); }
inline bool isVisible() const { return _visible; }
inline bool isSelectable() const { return _selectable; }
inline bool isHScalable() const { return _hScalable; }
inline bool isVScalable() const { return _vScalable; }
inline void setXPos(double xPos) { _xPos = xPos; }
inline void setYPos(double yPos) { _yPos = yPos; }
inline void setWidth(double width) { _width = width; }
inline void setHeight(double height) { _height = height; }
inline void setNeededSpaceWidth(double width) { _neededSpaceWidth = width; }
inline void setNeededSpaceHeight(double height) { _neededSpaceHeight = height; }
inline void setVisible(bool v) { _visible = v; }
inline void setSelectable(bool s) { _selectable = s; }
inline void setHScalable(bool s) { _hScalable = s; }
inline void setVScalable(bool s) { _vScalable = s; }
protected:
void setDrawableType(CADrawableType t) { _drawableType = t; }
CADrawableType _drawableType; // DrawableMusElement or DrawableContext.
double _xPos;
double _yPos;
double _width; // Element's width as it appears on the screen
double _height; // Element's height as it appears on the screen
double _neededSpaceWidth; // Minimum width the next element should be placed next to it by engraver
double _neededSpaceHeight; // Minimum height the next element should be placed next to it by engraver
bool _visible;
bool _selectable; // Can the element be clicked on and is then selected
bool _hScalable; // Can the element be streched horizontally
bool _vScalable; // Can the element be streched vertically
static const int SCALE_HANDLES_SIZE; // Width and Height of the scale handles squares in pixels
};
#endif /* DRAWABLE_H_ */
| 3,838
|
C++
|
.h
| 85
| 40.223529
| 105
| 0.70091
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,479
|
drawablefiguredbassnumber.h
|
canorusmusic_canorus/src/layout/drawablefiguredbassnumber.h
|
/*!
Copyright (c) 2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLEFIGUREDBASSMARK_H_
#define DRAWABLEFIGUREDBASSMARK_H_
#include "layout/drawablemuselement.h"
#include "score/figuredbassmark.h"
class CADrawableFiguredBassContext;
class CADrawableFiguredBassNumber : public CADrawableMusElement {
public:
CADrawableFiguredBassNumber(CAFiguredBassMark* m, int number, CADrawableFiguredBassContext*, double x, double y);
virtual ~CADrawableFiguredBassNumber();
CADrawableFiguredBassNumber* clone(CADrawableContext* c);
void draw(QPainter* p, const CADrawSettings s);
CAFiguredBassMark* figuredBassMark() { return static_cast<CAFiguredBassMark*>(musElement()); }
int number() { return _number; }
static const double DEFAULT_NUMBER_SIZE;
private:
int _number;
};
#endif /* DRAWABLEFIGUREDBASSMARK_H_ */
| 1,003
|
C++
|
.h
| 23
| 40.652174
| 117
| 0.795876
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,480
|
drawablefiguredbasscontext.h
|
canorusmusic_canorus/src/layout/drawablefiguredbasscontext.h
|
/*!
Copyright (c) 2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLEFIGUREDBASSCONTEXT_H_
#define DRAWABLEFIGUREDBASSCONTEXT_H_
#include "layout/drawablecontext.h"
#include "score/figuredbasscontext.h"
class CAFiguredBassContext;
class CADrawableFiguredBassContext : public CADrawableContext {
public:
CADrawableFiguredBassContext(CAFiguredBassContext* c, double x, double y);
virtual ~CADrawableFiguredBassContext();
CADrawableFiguredBassContext* clone();
void draw(QPainter* p, const CADrawSettings s);
CAFiguredBassContext* figuredBassContext() { return static_cast<CAFiguredBassContext*>(context()); }
};
#endif /* DRAWABLEFIGUREDBASSCONTEXT_H_ */
| 840
|
C++
|
.h
| 19
| 41.631579
| 104
| 0.807125
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,481
|
layoutengine.h
|
canorusmusic_canorus/src/layout/layoutengine.h
|
/*!
Copyright (c) 2006-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef LAYOUTENGINE_
#define LAYOUTENGINE_
#include <QList>
class CAScoreView;
class CADrawableMusElement;
class CALayoutEngine {
public:
static void reposit(CAScoreView* v);
private:
static void placeMarks(CADrawableMusElement*, CAScoreView*, int);
static void placeNoteCheckerErrors(CADrawableMusElement*, CAScoreView*);
static int* streamsRehersalMarks;
static QList<CADrawableMusElement*> scalableElts;
};
#endif /* LAYOUTENGINE_ */
| 679
|
C++
|
.h
| 20
| 31.45
| 76
| 0.797546
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,482
|
drawablefunctionmarkcontext.h
|
canorusmusic_canorus/src/layout/drawablefunctionmarkcontext.h
|
/*!
Copyright (c) 2006, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEFUNCTIONMARKCONTEXT_H_
#define DRAWABLEFUNCTIONMARKCONTEXT_H_
#include "layout/drawablecontext.h"
class CAFunctionMarkContext;
class CADrawableFunctionMarkContext : public CADrawableContext {
public:
CADrawableFunctionMarkContext(CAFunctionMarkContext* c, double x, double y, int numberOfLines = 2);
~CADrawableFunctionMarkContext();
void draw(QPainter* p, const CADrawSettings s);
CADrawableFunctionMarkContext* clone();
void setNumberOfLines(int number) { _numberOfLines = number; }
int numberOfLines() { return _numberOfLines; }
enum CAFunctionMarkLine {
Upper, // used for function name in tonicization
Middle, // used for general function names
Lower // used for chord areas, ellipse sign etc.
};
double yPosLine(CAFunctionMarkLine part); // Returns the Y coordinate of the top of the given line
void nextLine();
int currentLineIdx() { return _currentLineIdx; }
private:
CADrawableFunctionMarkContext()
: CADrawableContext(NULL, 0, 0)
, _numberOfLines(0)
, _currentLineIdx(0)
{
}
int _numberOfLines; // Number of lines the context can consist. Usually, this number is 2. But when doing research on scores, this could be expanded
int _currentLineIdx;
};
#endif /* DRAWABLEFUNCTIONMARKCONTEXT_H_ */
| 1,550
|
C++
|
.h
| 36
| 38.555556
| 152
| 0.746507
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,483
|
drawablelyricscontext.h
|
canorusmusic_canorus/src/layout/drawablelyricscontext.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLELYRICSCONTEXT_H_
#define DRAWABLELYRICSCONTEXT_H_
#include "layout/drawablecontext.h"
#include "score/lyricscontext.h"
class CALyricsContext;
class CADrawableLyricsContext : public CADrawableContext {
public:
CADrawableLyricsContext(CALyricsContext* c, double x, double y);
~CADrawableLyricsContext();
CADrawableLyricsContext* clone();
void draw(QPainter* p, const CADrawSettings s);
CALyricsContext* lyricsContext() { return static_cast<CALyricsContext*>(context()); }
static const double DEFAULT_TEXT_VERTICAL_SPACING;
};
#endif /* DRAWABLELYRICSCONTEXT_H_ */
| 824
|
C++
|
.h
| 20
| 38.4
| 89
| 0.789937
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,484
|
kdtree.h
|
canorusmusic_canorus/src/layout/kdtree.h
|
/*!
Copyright (c) 2006-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef KDTREE_H
#define KDTREE_H
#include <QMultiMap>
#include <QRect>
#include <iostream> // debugging
#include <limits> // max double for managing staffs with unlimited width
#include "layout/drawable.h"
#include "layout/drawablecontext.h"
#include "layout/drawablemuselement.h"
#include "layout/drawablenotecheckererror.h"
#include "score/muselement.h"
#include "score/playable.h"
#include "score/voice.h"
/*!
\class CAKDTree
\brief Space partitioning structure for fast access to drawable elements on canvas
This class is a data structure focused on efficient access to the drawable
instances of the music elements. It is based on an interval tree and employs
multiple QMap instances to enable efficient query of elements in the given
interval, finding the next element in the same staff and mapping a music
element to one or more drawable instances.
\sa CAScoreView, CADrawable
*/
template <typename T>
class CAKDTree {
public:
CAKDTree();
void addElement(T elt);
T removeElement(double x, double y);
QList<T> findInRange(double x, double y, double w = 0, double h = 0);
QList<T> findInRange(QRect& area);
T findNearestLeft(double x, bool timeBased = false, CADrawableContext* context = 0, CAVoice* voice = 0);
T findNearestRight(double x, bool timeBased = false, CADrawableContext* context = 0, CAVoice* voice = 0);
T findNearestUp(double y);
T findNearestDown(double y);
double getMaxX();
double getMaxY();
void clear(bool autoDelete = true);
inline int size() { return _mapX.size(); }
QList<T> list() { return _mapX.values(); }
private:
//////////////////////
// Basic properties //
//////////////////////
QMultiMap<double, T> _mapX; // List of all the drawable elements sorted by xPos()
QMultiMap<double, T> _mapXW; // List of all the drawable elements sorted by xPos()+width()
double _maxY; // The largest Ypos()+height() value of any element
void calculateMaxY();
};
/*!
The default constructor.
*/
template <typename T>
CAKDTree<T>::CAKDTree()
{
_maxY = 0;
}
/*!
Adds a drawable element \a elt to the tree.
*/
template <typename T>
void CAKDTree<T>::addElement(T elt)
{
_mapX.insertMulti(elt->xPos(), elt);
if (elt->width()) {
// regular music element
_mapXW.insertMulti(elt->xPos() + elt->width(), elt);
} else {
// music element with unlimited width (e.g. staffs)
_mapXW.insertMulti(std::numeric_limits<double>::max(), elt);
}
if (elt->yPos() + elt->height() > _maxY) {
_maxY = elt->yPos() + elt->height();
}
}
/*!
Removes all elements from the tree.
Also destroys the elements if \a autoDelete is true.
*/
template <typename T>
void CAKDTree<T>::clear(bool autoDelete)
{
if (autoDelete) {
for (typename QMultiMap<double, T>::const_iterator it = _mapX.constBegin(); it != _mapX.constEnd(); it++) {
delete it.value();
}
}
_mapX.clear();
_mapXW.clear();
_maxY = 0;
}
/*!
Returns the list of elements present in the given rectangular area or an empty list if none found.
Element is in the list, if the region only touches it - not neccessarily fits the whole in the region.
*/
template <typename T>
QList<T> CAKDTree<T>::findInRange(double x, double y, double w, double h)
{
QList<T> l;
T rightMostElt = _mapX.lowerBound(x + w).value();
for (typename QMultiMap<double, T>::const_iterator it = _mapXW.upperBound(x); (it != _mapXW.end()) && (it.value() != rightMostElt); it++) {
if (( // The object is normal and fits into the area
(it.value()->yPos() <= y + h) && (it.value()->yPos() + it.value()->height() >= y))
|| ( // The object is unlimited in width (eg. contexts)
(it.value()->width() == 0) && (it.value()->yPos() <= y + h) && (it.value()->yPos() + it.value()->height() >= y))
|| ( // The object is unlimited in height (eg. helper lines)
(it.value()->height() == 0))) {
l << it.value();
}
}
return l;
}
/*!
This function is provided for convenience.
Returns the list of elements present in the given rectangular area or an empty list if none found.
Element is in the list, if the region only touches it - not neccessarily fits the whole in the region.
*/
template <typename T>
QList<T> CAKDTree<T>::findInRange(QRect& rect)
{
return findInRange(rect.x(), rect.y(), rect.width(), rect.height());
}
/*!
Finds the nearest left element to the given coordinate and returns a pointer to it or 0 if none
found. Left elements borders are taken into account.
If \a timeBased is false (default), the lookup should be view-based - the nearest element is
selected as it appears on the screen. If \a timeBased if true, the nearest element is selected
according to the nearest start/end time.
*/
template <typename T>
T CAKDTree<T>::findNearestLeft(double x, bool timeBased, CADrawableContext* context, CAVoice* voice)
{
if (_mapX.size() == 0) {
return 0;
}
typename QMultiMap<double, T>::const_iterator it = _mapX.lowerBound(x); // returns constEnd, if not found
while (it != _mapX.constBegin() && (it == _mapX.constEnd() || it.value()->xPos() >= x)) {
it--;
}
if (it.value()->xPos() >= x) {
// no elements to the left at all
return 0;
}
do {
if (
// compare contexts
(!context || it.value()->drawableContext() == context) &&
// compare voices
(!voice || (
// if the element isn't playable, see if it has the same context as the voice
(!it.value()->musElement()->isPlayable() && it.value()->musElement()->context() == voice->staff()) ||
// if the element is playable, see if it has the exactly same voice
(it.value()->musElement()->isPlayable() && static_cast<CAPlayable*>(it.value()->musElement())->voice() == voice)))) {
return static_cast<T>(it.value());
}
} while ((it--) != _mapX.constBegin());
// no regular elements to the left exists
return 0;
}
/*!
Finds the nearest right element to the given coordinate and returns a pointer to it or 0 if none
found. Left elements borders are taken into account.
If \a timeBased is false (default), the lookup should be view-based - the nearest element is
selected as it appears on the screen. If \a timeBased if true, the nearest element is selected
according to the nearest start/end time.
*/
template <typename T>
T CAKDTree<T>::findNearestRight(double x, bool timeBased, CADrawableContext* context, CAVoice* voice)
{
typename QMultiMap<double, T>::const_iterator it = _mapX.upperBound(x);
for (; it != _mapX.constEnd(); it++) {
if (
// compare contexts
(!context || it.value()->drawableContext() == context) &&
// compare voices
(!voice || (
// if the element isn't playable, see if it has the same context as the voice
(!it.value()->musElement()->isPlayable() && it.value()->musElement()->context() == voice->staff()) ||
// if the element is playable, see if it has the exactly same voice
(it.value()->musElement()->isPlayable() && static_cast<CAPlayable*>(it.value()->musElement())->voice() == voice)))) {
return static_cast<T>(it.value());
}
}
// no elements to the right exists
return 0;
}
/*!
Finds the nearest upper element to the given coordinate and returns a pointer to it or 0 if none
found. Top element border is taken into account.
If \a timeBased is false (default), the lookup should be view-based - the nearest element is
selected as it appears on the screen. If \a timeBased if true, the nearest element is selected
according to the nearest start/end time.
*/
template <typename T>
T CAKDTree<T>::findNearestUp(double y)
{
if (_mapX.isEmpty())
return 0;
T elt = 0;
for (typename QMultiMap<double, T>::const_iterator it = _mapX.constBegin(); it != _mapX.constEnd(); it++) {
if (((!elt) || ((it.value()->yPos() + it.value()->height()) > (elt->yPos() + elt->height())))
&& ((it.value()->yPos() + it.value()->height()) < y)) {
elt = it.value();
}
}
return elt;
}
/*!
Finds the nearest lower element to the given coordinate and returns a pointer to it or 0 if none
found. Top element border is taken into account.
If \a timeBased is false (default), the lookup should be view-based - the nearest element is
selected as it appears on the screen. If \a timeBased if true, the nearest element is selected
according to the nearest start/end time.
*/
template <typename T>
T CAKDTree<T>::findNearestDown(double y)
{
if (_mapX.isEmpty())
return 0;
T elt = 0;
for (typename QMultiMap<double, T>::const_iterator it = _mapX.constBegin(); it != _mapX.constEnd(); it++) {
if (((!elt) || (it.value()->yPos() < elt->yPos())) && (it.value()->yPos() > y)) {
elt = it.value();
}
}
return elt;
}
/*!
Returns the max X coordinate of the end of the most-right element.
This value is read from buffer, so the calculation time is constant.
*/
template <typename T>
double CAKDTree<T>::getMaxX()
{
if (_mapXW.constEnd() == _mapXW.constBegin())
return 0.0;
for (typename QMultiMap<double, T>::const_iterator it = (--_mapXW.constEnd());
it != _mapXW.constBegin();
it--) {
if (it.key() != std::numeric_limits<double>::max()) {
// don't take contexts unlimited length into account
return it.key();
}
}
return 0;
}
/*!
Returns the max Y coordinate of the end of the most-bottom element.
This value is read from buffer, so the calculation time is constant.
*/
template <typename T>
double CAKDTree<T>::getMaxY()
{
return _maxY;
}
/*!
Used internally for the maxX and maxY properties to update.
Calculates the largest X and Y coordinates among all ends of elements and store it locally.
This operation takes O(n) time complexity where n is number of elements in the tree.
*/
template <typename T>
void CAKDTree<T>::calculateMaxY()
{
_maxY = 0;
for (typename QMultiMap<double, T>::iterator it = _mapX.begin(); it != _mapX.end(); it++) {
if (it.value()->yPos() + it.value()->height() > _maxY) {
_maxY = it.value()->yPos() + it.value()->height();
}
}
}
#endif
/*!
\fn int CAKDTree<T>::size()
Returns the number of elements currently in the tree.
*/
/*!
\fn CADrawable *CAKDTree<T>:at(int i)
Returns the element with index \a i in the tree.
If the element doesn't exist (eg. index out of bounds), returns 0.
*/
/*!
\fn QList<T>& CAKDTree<T>:list()
Returns the pointer to the list of all the elements.
*/
| 11,198
|
C++
|
.h
| 289
| 33.775087
| 144
| 0.644811
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,485
|
drawableaccidental.h
|
canorusmusic_canorus/src/layout/drawableaccidental.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEACCIDENTAL_H_
#define DRAWABLEACCIDENTAL_H_
#include "layout/drawablemuselement.h"
class CADrawableAccidental : public CADrawableMusElement {
public:
CADrawableAccidental(signed char accs, CAMusElement* musElement, CADrawableContext* drawableContext, double x, double y);
~CADrawableAccidental();
void draw(QPainter* p, CADrawSettings s);
CADrawableAccidental* clone(CADrawableContext* newContext = nullptr);
private:
signed char _accs;
double _centerX, _centerY; // easier to do clone(), otherwise not needed
};
#endif /* DRAWABLEACCIDENTAL_H_ */
| 808
|
C++
|
.h
| 19
| 39.789474
| 125
| 0.784163
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,486
|
drawablefunctionmark.h
|
canorusmusic_canorus/src/layout/drawablefunctionmark.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEFUNCTIONMARK_H_
#define DRAWABLEFUNCTIONMARK_H_
#include "layout/drawablemuselement.h"
#include "score/functionmark.h"
class CAFunctionMark;
class CADrawableFunctionMarkContext;
class CADrawableFunctionMark : public CADrawableMusElement {
public:
CADrawableFunctionMark(CAFunctionMark* function, CADrawableFunctionMarkContext* context, double x, double y);
~CADrawableFunctionMark();
void draw(QPainter* p, const CADrawSettings s);
CADrawableFunctionMark* clone(CADrawableContext* newContext = 0);
inline CAFunctionMark* functionMark() { return (CAFunctionMark*)_musElement; };
inline CADrawableFunctionMarkContext* drawableFunctionMarkContext() { return (CADrawableFunctionMarkContext*)_drawableContext; };
bool isExtenderLineVisible() { return _extenderLineVisible; }
void setExtenderLineVisible(bool visible) { _extenderLineVisible = visible; }
bool isExtenderLineOnly() { return _extenderLineOnly; }
void setExtenderLineOnly(bool line) { _extenderLineOnly = line; }
private:
bool _extenderLineVisible; // Should the function draw a horizontal line until the end of the function
QString _text; // Function transformed to String which is rendered then
bool _extenderLineOnly; // Only extender line should be rendered over the whole width of the function
};
class CADrawableFunctionMarkSupport : public CADrawableMusElement {
public:
enum CADrawableFunctionMarkSupportType {
Key,
Rectangle,
ChordArea,
Tonicization,
Ellipse,
Alterations
};
// Key constructor
CADrawableFunctionMarkSupport(CADrawableFunctionMarkSupportType, const QString key, CADrawableContext* c, double x, double y);
// Rectangle, ChordArea, Tonicization, Ellipse constructor
CADrawableFunctionMarkSupport(CADrawableFunctionMarkSupportType, CADrawableFunctionMark* function, CADrawableContext* c, double x, double y, CADrawableFunctionMark* function2 = 0);
// Alterations consructor
CADrawableFunctionMarkSupport(CADrawableFunctionMarkSupportType, CAFunctionMark* function, CADrawableContext* c, double x, double y);
~CADrawableFunctionMarkSupport();
void draw(QPainter* p, const CADrawSettings s);
CADrawableFunctionMarkSupport* clone(CADrawableContext* newContext = 0);
CADrawableFunctionMarkSupportType drawableFunctionMarkSupportType() { return _drawableFunctionMarkSupportType; }
bool isExtenderLineVisible() { return _extenderLineVisible; }
void setExtenderLineVisible(bool visible) { _extenderLineVisible = visible; }
bool rectWider() { return _rectWider; }
void setRectWider(bool wider)
{
if (!_rectWider) {
_rectWider = wider;
_yPos -= 3;
_height += 6;
}
}
private:
CADrawableFunctionMarkSupportType _drawableFunctionMarkSupportType;
QString _key;
CADrawableFunctionMark *_function1, *_function2; // Tonicization's start/end functions
bool _extenderLineVisible; // Extender line when tonicization used after
bool _rectWider; // Is rectangle wider in height. Default: false. Useful when doing a series of modulations where you don't know which rectangle belongs to which function. Every 2nd rectangle is then a bit higher than the others.
};
#endif /* DRAWABLEFUNCTIONMARK_H_ */
| 3,546
|
C++
|
.h
| 67
| 48.014925
| 233
| 0.772229
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,487
|
drawabletuplet.h
|
canorusmusic_canorus/src/layout/drawabletuplet.h
|
/*!
Copyright (c) 2008-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLETUPLET_H_
#define DRAWABLETUPLET_H_
#include "layout/drawablemuselement.h"
#include "score/tuplet.h"
class CADrawableTuplet : public CADrawableMusElement {
public:
CADrawableTuplet(CATuplet* tuplet, CADrawableContext* c, double x1, double y1, double x2, double y2);
virtual ~CADrawableTuplet();
CATuplet* tuplet() { return static_cast<CATuplet*>(_musElement); }
void draw(QPainter* p, const CADrawSettings s);
CADrawableTuplet* clone(CADrawableContext* newContext = 0);
inline double x1() { return _x1; }
inline double y1() { return _y1; }
inline double x2() { return _x2; }
inline double y2() { return _y2; }
inline void setX1(double x1) { _x1 = x1; }
inline void setY1(double y1) { _y1 = y1; }
inline void setX2(double x2) { _x2 = x2; }
inline void setY2(double y2) { _y2 = y2; }
private:
double _x1;
double _x2;
double _y1;
double _y2;
};
#endif /* DRAWABLETUPLET_H_ */
| 1,184
|
C++
|
.h
| 31
| 34.612903
| 105
| 0.703671
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,488
|
drawablecontext.h
|
canorusmusic_canorus/src/layout/drawablecontext.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLECONTEXT_H_
#define DRAWABLECONTEXT_H_
#include <QList>
#include "layout/drawable.h"
#include "layout/drawablemuselement.h"
class CAContext;
class CADrawableContext : public CADrawable {
public:
enum CADrawableContextType {
DrawableStaff,
DrawableLyricsContext,
DrawableFiguredBassContext,
DrawableFunctionMarkContext,
DrawableChordNameContext,
};
CADrawableContext(CAContext* c, double x, double y);
inline CAContext* context() { return _context; }
CADrawableContextType drawableContextType() { return _drawableContextType; }
inline virtual void addMElement(CADrawableMusElement* elt)
{
int i;
for (i = _drawableMusElementList.size() - 1; (i >= 0) && _drawableMusElementList[i]->xPos() > elt->xPos(); i--)
;
_drawableMusElementList.insert(++i, elt);
}
virtual int removeMElement(CADrawableMusElement* elt) { return _drawableMusElementList.removeAll(elt); }
CADrawableMusElement* lastDrawableMusElement()
{
if (_drawableMusElementList.size())
return _drawableMusElementList.last();
else
return 0;
}
virtual CADrawableContext* clone() = 0;
QList<CADrawableMusElement*>& drawableMusElementList() { return _drawableMusElementList; }
inline CADrawableMusElement* findMElement(CAMusElement* elt)
{
for (int i = 0; i < _drawableMusElementList.size(); i++)
if (_drawableMusElementList[i]->musElement() == elt)
return _drawableMusElementList[i];
return 0;
}
QList<CADrawableMusElement*> findInRange(double x1, double x2);
protected:
void setDrawableContextType(CADrawableContextType type) { _drawableContextType = type; }
CADrawableContextType _drawableContextType;
CAContext* _context;
QList<CADrawableMusElement*> _drawableMusElementList; // List of all the drawable musElements in this context sorted by their left borders
};
#endif /* DRAWABLECONTEXT_H_ */
| 2,242
|
C++
|
.h
| 55
| 34.981818
| 142
| 0.716782
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,489
|
drawabletimesignature.h
|
canorusmusic_canorus/src/layout/drawabletimesignature.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DRAWABLETIMESIGNATURE_H_
#define DRAWABLETIMESIGNATURE_H_
#include "canorus.h"
#include "layout/drawablemuselement.h"
#include "score/timesignature.h"
class CADrawableStaff;
class CADrawableTimeSignature : public CADrawableMusElement {
public:
CADrawableTimeSignature(CATimeSignature* timeSig, CADrawableStaff* drawableStaff, double x, double y); /// y coordinate is a top of the staff
~CADrawableTimeSignature();
void draw(QPainter* p, CADrawSettings s);
CADrawableTimeSignature* clone(CADrawableContext* newContext = nullptr);
inline CATimeSignature* timeSignature() { return static_cast<CATimeSignature*>(_musElement); }
};
#endif /*DRAWABLETIMESIGNATURE_H_*/
| 915
|
C++
|
.h
| 20
| 43.3
| 145
| 0.797525
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,490
|
drawablemuselement.h
|
canorusmusic_canorus/src/layout/drawablemuselement.h
|
/*!
Copyright (c) 2006-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLEMUSELEMENT_H_
#define DRAWABLEMUSELEMENT_H_
#include "layout/drawable.h"
class CAMusElement;
class CADrawableContext;
class CADrawableMusElement : public CADrawable {
public:
enum CADrawableMusElementType {
DrawableNote,
DrawableRest,
DrawableMidiNote,
DrawableClef,
DrawableKeySignature,
DrawableTimeSignature,
DrawableBarline,
DrawableAccidental,
DrawableSlur,
DrawableTuplet,
DrawableSyllable,
DrawableFunctionMark,
DrawableFunctionMarkSupport,
DrawableFiguredBassNumber,
DrawableMark,
DrawableChordName,
};
CADrawableMusElement(CAMusElement* musElement, CADrawableContext* drawableContext, double x, double y);
CADrawableMusElementType drawableMusElementType() { return _drawableMusElementType; }
inline CAMusElement* musElement() { return _musElement; }
CADrawableContext* drawableContext() { return _drawableContext; }
void setDrawableContext(CADrawableContext* context) { _drawableContext = context; }
virtual CADrawable* clone() { return clone(nullptr); }
virtual CADrawableMusElement* clone(CADrawableContext* newContext = nullptr) = 0;
static const QString EMPTY_PLACEHOLDER;
protected:
void setDrawableMusElementType(CADrawableMusElementType t) { _drawableMusElementType = t; }
CADrawableMusElementType _drawableMusElementType; // CADrawableMusElement type
CADrawableContext* _drawableContext;
CAMusElement* _musElement;
bool _selectable;
};
#endif /* DRAWABLEMUSELEMENT_H_ */
| 1,817
|
C++
|
.h
| 46
| 34.108696
| 107
| 0.758523
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,491
|
drawableslur.h
|
canorusmusic_canorus/src/layout/drawableslur.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#ifndef DRAWABLESLUR_H_
#define DRAWABLESLUR_H_
#include "layout/drawablemuselement.h"
#include "score/slur.h"
class CASlur;
class CADrawableSlur : public CADrawableMusElement {
public:
CADrawableSlur(CASlur* slur, CADrawableContext* c, double x1, double y1, double xMid, double yMid, double x2, double y2);
virtual ~CADrawableSlur();
CASlur* slur() { return static_cast<CASlur*>(_musElement); }
void draw(QPainter* p, const CADrawSettings s);
CADrawableSlur* clone(CADrawableContext* newContext = nullptr);
inline double x1() { return _x1; }
inline double y1() { return _y1; }
inline double xMid() { return _xMid; }
inline double yMid() { return _yMid; }
inline double x2() { return _x2; }
inline double y2() { return _y2; }
inline void setX1(double x1)
{
_x1 = x1;
updateGeometry();
}
inline void setY1(double y1)
{
_y1 = y1;
updateGeometry();
}
inline void setXMid(double xMid)
{
_xMid = xMid;
updateGeometry();
}
inline void setYMid(double yMid)
{
_yMid = yMid;
updateGeometry();
}
inline void setX2(double x2)
{
_x2 = x2;
updateGeometry();
}
inline void setY2(double y2)
{
_y2 = y2;
updateGeometry();
}
private:
void updateGeometry();
double min(double, double, double);
double max(double, double, double);
double _x1;
double _y1;
double _xMid;
double _yMid;
double _x2;
double _y2;
};
#endif /* DRAWABLESLUR_H_ */
| 1,793
|
C++
|
.h
| 65
| 22.553846
| 125
| 0.647059
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,492
|
drawableclef.h
|
canorusmusic_canorus/src/layout/drawableclef.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.
*/
#include "layout/drawablemuselement.h"
#ifndef DRAWABLECLEF_H_
#define DRAWABLECLEF_H_
class CAClef;
class CADrawableStaff;
class CADrawableClef : public CADrawableMusElement {
public:
CADrawableClef(CAClef* clef, CADrawableStaff* drawableStaff, double x, double y);
void draw(QPainter* p, CADrawSettings s);
CADrawableClef* clone(CADrawableContext* newContext = 0);
inline CAClef* clef() { return (CAClef*)_musElement; }
static const int CLEF_EIGHT_SIZE;
};
#endif /* DRAWABLECLEF_H_ */
| 730
|
C++
|
.h
| 19
| 35.789474
| 85
| 0.773826
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,493
|
timesignature.h
|
canorusmusic_canorus/src/score/timesignature.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef TIMESIGNATURE_H_
#define TIMESIGNATURE_H_
#include <QString>
#include "score/muselement.h"
#include "score/staff.h"
class CAContext;
class CATimeSignature : public CAMusElement {
public:
enum CATimeSignatureType {
Classical, // Ordinary numbers, C for 4/4, C| for 2/2
Number, // Force to always show numbers!
Mensural,
Neomensural,
Baroque
};
CATimeSignature(int beats, int beat, CAStaff* staff, int startTime, CATimeSignatureType type = Classical);
CATimeSignature* clone(CAContext* context = nullptr);
~CATimeSignature();
CAStaff* staff() { return static_cast<CAStaff*>(context()); }
int beats() { return _beats; }
void setBeats(int beats) { _beats = beats; }
int beat() { return _beat; }
void setBeat(int beat) { _beat = beat; }
int barDuration();
CATimeSignatureType timeSignatureType() { return _timeSignatureType; }
const QString timeSignatureML(); // Deprecated
const QString timeSignatureTypeML(); // Deprecated
static const QString timeSignatureTypeToString(CATimeSignatureType);
static CATimeSignatureType timeSignatureTypeFromString(const QString);
int compare(CAMusElement* elt);
private:
int _beats;
int _beat;
CATimeSignatureType _timeSignatureType;
};
#endif /*TIMESIGNATURE_H_*/
| 1,557
|
C++
|
.h
| 41
| 33.585366
| 110
| 0.728
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,494
|
fingering.h
|
canorusmusic_canorus/src/score/fingering.h
|
/*!
Copyright (c) 2007-2009, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef FINGERING_H_
#define FINGERING_H_
#include "score/mark.h"
#include <QList>
class CANote;
class CAFingering : public CAMark {
public:
enum CAFingerNumber {
First = 1,
Second = 2,
Third = 3,
Fourth = 4,
Fifth = 5,
Thumb,
LHeel,
RHeel,
LToe,
RToe,
Undefined
};
CAFingering(CAFingerNumber finger, CANote* m, bool italic = false);
CAFingering(QList<CAFingerNumber> fingers, CANote* m, bool italic = false);
virtual ~CAFingering();
CAFingering* clone(CAMusElement* elt = nullptr);
int compare(CAMusElement* elt);
inline CAFingerNumber finger() { return (_fingerList.size() ? _fingerList[0] : Undefined); }
inline void setFinger(CAFingerNumber f)
{
_fingerList.clear();
_fingerList << f;
}
inline const QList<CAFingerNumber>& fingerList() { return _fingerList; }
inline void addFinger(CAFingerNumber f) { _fingerList << f; }
inline void removeFinger(CAFingerNumber n) { _fingerList.removeAll(n); }
inline bool isOriginal() { return _original; }
inline void setOriginal(bool original) { _original = original; }
static const QString fingerNumberToString(CAFingerNumber n);
static CAFingerNumber fingerNumberFromString(const QString s);
private:
QList<CAFingerNumber> _fingerList;
bool _original;
};
#endif /* FINGERING_H_ */
| 1,638
|
C++
|
.h
| 48
| 28.979167
| 96
| 0.688213
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,495
|
syllable.h
|
canorusmusic_canorus/src/score/syllable.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef SYLLABLE_H_
#define SYLLABLE_H_
#include "score/lyricscontext.h"
#include "score/muselement.h"
#include <QString>
class CAVoice;
class CAContext;
class CASyllable : public CAMusElement {
public:
CASyllable(QString text, bool hyphen, bool melisma, CALyricsContext* context, int timeStart, int timeLength, CAVoice* voice = nullptr);
~CASyllable();
void clear();
inline bool hyphenStart() { return _hyphenStart; }
inline void setHyphenStart(bool h) { _hyphenStart = h; }
inline bool melismaStart() { return _melismaStart; }
inline void setMelismaStart(bool m) { _melismaStart = m; }
inline QString text() { return _text; }
inline void setText(QString text) { _text = text; }
inline CAVoice* associatedVoice() { return _associatedVoice; }
inline void setAssociatedVoice(CAVoice* v) { _associatedVoice = v; }
inline CALyricsContext* lyricsContext() { return static_cast<CALyricsContext*>(_context); }
CASyllable* clone(CAContext* context);
int compare(CAMusElement*);
private:
bool _hyphenStart, _melismaStart;
QString _text;
CAVoice* _associatedVoice; // per-syllable associated voice, 0 if preferred (parent's voice)
};
#endif /* SYLLABLE_H_ */
| 1,442
|
C++
|
.h
| 34
| 39
| 139
| 0.737294
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,496
|
slur.h
|
canorusmusic_canorus/src/score/slur.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef SLUR_H_
#define SLUR_H_
#include <QString>
#include "score/muselement.h"
class CAContext;
class CANote;
class CASlur : public CAMusElement {
public:
enum CASlurDirection {
SlurUp,
SlurDown,
SlurNeutral,
SlurPreferred
};
enum CASlurStyle {
Undefined = 0,
SlurSolid,
SlurDotted
};
enum CASlurType {
TieType,
SlurType,
PhrasingSlurType
};
CASlur(CASlurType, CASlurDirection, CAContext* c, CANote* noteStart, CANote* noteEnd = nullptr, CASlurStyle style = SlurSolid);
virtual ~CASlur();
CASlur* clone(CAContext* context = nullptr);
CASlur* clone(CAContext* context, CANote* noteStart, CANote* noteEnd);
int compare(CAMusElement* elt);
inline CASlurDirection slurDirection() { return _slurDirection; }
inline void setSlurDirection(CASlurDirection dir) { _slurDirection = dir; }
inline CASlurType slurType() { return _slurType; }
inline CANote* noteStart() { return _noteStart; }
inline CANote* noteEnd() { return _noteEnd; }
inline CASlurStyle slurStyle() { return _slurStyle; }
inline void setNoteStart(CANote* noteStart) { _noteStart = noteStart; }
inline void setNoteEnd(CANote* noteEnd) { _noteEnd = noteEnd; }
inline void setSlurStyle(CASlurStyle slurStyle) { _slurStyle = slurStyle; }
static const QString slurStyleToString(CASlurStyle style);
static CASlurStyle slurStyleFromString(const QString style);
static const QString slurDirectionToString(CASlurDirection dir);
static CASlurDirection slurDirectionFromString(const QString dir);
private:
inline void setSlurType(CASlurType type) { _slurType = type; }
CASlurDirection _slurDirection;
CASlurStyle _slurStyle;
CASlurType _slurType;
CANote* _noteStart;
CANote* _noteEnd;
};
#endif /*SLUR_H_*/
| 2,092
|
C++
|
.h
| 56
| 32.410714
| 131
| 0.723489
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,497
|
document.h
|
canorusmusic_canorus/src/score/document.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DOCUMENT_H_
#define DOCUMENT_H_
#include <QDateTime>
#include <QList>
#include <QString>
#include <memory>
class CASheet;
class CAArchive;
class CAResource;
class CADocument {
public:
CADocument();
virtual ~CADocument();
CADocument* clone();
void clear();
const QList<CASheet*>& sheetList() { return _sheetList; }
CASheet* addSheetByName(const QString name);
inline void addSheet(CASheet* sheet) { _sheetList << sheet; }
CASheet* addSheet();
inline void removeSheet(CASheet* sheet) { _sheetList.removeAll(sheet); }
CASheet* findSheet(const QString name);
const QList<std::shared_ptr<CAResource> >& resourceList() { return _resourceList; }
inline void addResource(std::shared_ptr<CAResource> r) { _resourceList << r; }
inline void removeResource(std::shared_ptr<CAResource> r) { _resourceList.removeAll(r); }
const QString title() { return _title; }
const QString subtitle() { return _subtitle; }
const QString composer() { return _composer; }
const QString arranger() { return _arranger; }
const QString poet() { return _poet; }
const QString textTranslator() { return _textTranslator; }
const QString dedication() { return _dedication; }
const QString copyright() { return _copyright; }
const QDateTime dateCreated() { return _dateCreated; }
const QDateTime dateLastModified() { return _dateLastModified; }
const unsigned int timeEdited() { return _timeEdited; }
const QString comments() { return _comments; }
void setTitle(const QString title) { _title = title; }
void setSubtitle(const QString subtitle) { _subtitle = subtitle; }
void setComposer(const QString composer) { _composer = composer; }
void setArranger(const QString arranger) { _arranger = arranger; }
void setPoet(const QString poet) { _poet = poet; }
void setTextTranslator(const QString textTranslator) { _textTranslator = textTranslator; }
void setDedication(const QString dedication) { _dedication = dedication; }
void setCopyright(const QString copyright) { _copyright = copyright; }
void setDateCreated(const QDateTime dateCreated) { _dateCreated = dateCreated; }
void setDateLastModified(const QDateTime dateLastModified) { _dateLastModified = dateLastModified; }
void setTimeEdited(const unsigned int timeEdited) { _timeEdited = timeEdited; }
void setComments(const QString comments) { _comments = comments; }
///////////////////////////////////////////////////////
// Temporary properties (not stored inside the file) //
///////////////////////////////////////////////////////
const QString fileName() { return _fileName; }
bool isModified() { return _modified; }
CAArchive* archive() { return _archive; }
void setFileName(const QString fileName) { _fileName = fileName; } // not saved!
void setModified(bool m) { _modified = m; }
void setArchive(CAArchive* a) { _archive = a; }
private:
QList<CASheet*> _sheetList;
QList<std::shared_ptr<CAResource> > _resourceList;
QString _title;
QString _subtitle;
QString _composer;
QString _arranger;
QString _poet;
QString _textTranslator;
QString _dedication;
QString _copyright;
QDateTime _dateLastModified;
QDateTime _dateCreated;
unsigned int _timeEdited; // time the document has been edited in seconds
QString _comments;
////////////////////////////////////////////////////
// Temporary properties stored during the session //
////////////////////////////////////////////////////
QString _fileName; // absolute filename of the document
bool _modified; // unsaved changes
CAArchive* _archive; // pointer to existing archive, if it exists
};
#endif /* DOCUMENT_H_ */
| 3,991
|
C++
|
.h
| 85
| 42.635294
| 104
| 0.677975
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,498
|
playable.h
|
canorusmusic_canorus/src/score/playable.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef PLAYABLE_H_
#define PLAYABLE_H_
#include "score/muselement.h"
#include "score/playablelength.h"
#include "score/staff.h"
#include "score/tuplet.h"
class CAVoice;
class CAPlayable : public CAMusElement {
public:
CAPlayable(CAPlayableLength length, CAVoice* voice, int timeStart, int timeLength = -1);
virtual ~CAPlayable();
inline CAPlayableLength& playableLength() { return _playableLength; }
inline void setPlayableLength(CAPlayableLength& l) { _playableLength = l; }
virtual CAPlayable* clone(CAContext* context)
{
CAPlayable* pl = clone();
pl->setContext(context);
return pl;
}
virtual CAPlayable* clone(CAVoice* voice = nullptr) = 0;
CATuplet* tuplet() { return _tuplet; }
void setTuplet(CATuplet* t) { _tuplet = t; }
inline CAVoice* voice() { return _voice; }
void setVoice(CAVoice* v);
inline CAStaff* staff() { return static_cast<CAStaff*>(_context); }
inline bool isFirstInTuplet() { return (_tuplet && _tuplet->firstNote() == this); }
inline bool isLastInTuplet() { return (_tuplet && _tuplet->lastNote() == this); }
void resetTime();
void calculateTimeLength();
protected:
CAPlayableLength _playableLength;
CAVoice* _voice;
CATuplet* _tuplet;
};
#endif /* PLAYABLE_H_ */
| 1,522
|
C++
|
.h
| 40
| 34.1
| 92
| 0.706322
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,499
|
diatonickey.h
|
canorusmusic_canorus/src/score/diatonickey.h
|
/*!
Copyright (c) 2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DIATONICKEY_H_
#define DIATONICKEY_H_
#include "score/diatonicpitch.h"
#include <QList>
#include <QString>
class CADiatonicKey {
public:
enum CAGender {
Major,
Minor
};
enum CAShape {
Natural,
Harmonic,
Melodic
};
CADiatonicKey();
CADiatonicKey(const QString& key);
CADiatonicKey(const int& numberOfAccs, const CAGender& gender);
CADiatonicKey(const CADiatonicPitch& pitch, const CAGender& gender);
CADiatonicKey(const CADiatonicPitch& pitch, const CAGender& gender, const CAShape& shape);
bool operator==(CADiatonicKey);
inline bool operator!=(CADiatonicKey p) { return !operator==(p); }
#ifndef SWIG
void operator=(const QString& key);
#endif
CADiatonicKey operator+(CAInterval);
inline CADiatonicPitch diatonicPitch() { return _diatonicPitch; }
inline const CAGender gender() { return _gender; }
inline const CAShape shape() { return _shape; }
inline void setDiatonicPitch(const CADiatonicPitch p) { _diatonicPitch = p; }
inline void setGender(const CAGender g) { _gender = g; }
inline void setShape(const CAShape s) { _shape = s; }
static const QString shapeToString(CAShape);
static CAShape shapeFromString(const QString);
static const QString genderToString(CAGender);
static CAGender genderFromString(const QString);
static const QString diatonicKeyToString(CADiatonicKey k);
static CADiatonicKey diatonicKeyFromString(const QString);
int numberOfAccs();
QList<int> accsMatrix();
int noteAccs(int noteName);
bool containsPitch(const CADiatonicPitch& p);
private:
CADiatonicPitch _diatonicPitch; // pitch of the key
CAGender _gender; // major, minor
CAShape _shape; // natural, harmonic, melodic
};
#endif /* DIATONICKEY_H_ */
| 2,036
|
C++
|
.h
| 54
| 33.277778
| 94
| 0.731707
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,500
|
muselement.h
|
canorusmusic_canorus/src/score/muselement.h
|
/*!
Copyright (c) 2006-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef MUSELEMENT_H_
#define MUSELEMENT_H_
#include <QColor>
#include <QList>
#include <QString>
class CAContext;
class CAMusElement;
class CAPlayable;
class CAMark;
class CANoteCheckerError;
class CAMusElement {
public:
enum CAMusElementType {
Undefined = 0,
Note,
Rest,
MidiNote,
Barline,
Clef,
TimeSignature,
KeySignature,
Slur,
Tuplet,
Syllable,
FunctionMark,
FiguredBassMark,
Mark,
ChordName
};
CAMusElement(CAContext* context, int timeStart, int timeLength = 0);
virtual ~CAMusElement();
virtual CAMusElement* clone(CAContext* context = nullptr) = 0;
virtual int compare(CAMusElement* elt) = 0;
CAMusElementType musElementType() { return _musElementType; }
inline CAContext* context() { return _context; }
inline void setContext(CAContext* context) { _context = context; }
inline virtual int timeStart() const { return _timeStart; }
inline void setTimeStart(int time) { _timeStart = time; }
inline virtual int timeLength() const { return _timeLength; }
inline void setTimeLength(int length) { _timeLength = length; }
inline int timeEnd() { return timeStart() + timeLength(); }
inline virtual int realTimeStart() { return _timeStart; } // TODO: calculates and returns time in miliseconds
inline virtual int realTimeLength() { return _timeLength; } // TODO: calculates and returns time in miliseconds
inline int realTimeEnd() { return realTimeStart() + realTimeLength(); } // TODO: calculates and returns time in miliseconds
inline const QString name() { return _name; }
inline void setName(const QString name) { _name = name; }
inline bool isVisible() { return _visible; }
inline void setVisible(const bool v) { _visible = v; }
inline const QColor color() { return _color; }
inline void setColor(const QColor c) { _color = c; }
inline const QList<CAMark*> markList() { return _markList; }
void addMark(CAMark* mark);
void addMarks(QList<CAMark*> marks);
inline void removeMark(CAMark* mark) { _markList.removeAll(mark); }
inline const QList<CANoteCheckerError*>& noteCheckerErrorList() { return _noteCheckerErrorList; }
inline void addNoteCheckerError(CANoteCheckerError* nce) { _noteCheckerErrorList << nce; }
inline void removeNoteCheckerError(CANoteCheckerError* nce) { _noteCheckerErrorList.removeAll(nce); }
bool isPlayable();
static const QString musElementTypeToString(CAMusElementType);
static CAMusElementType musElementTypeFromString(const QString);
protected:
inline void setMusElementType(CAMusElementType type) { _musElementType = type; }
CAMusElementType _musElementType;
QList<CAMark*> _markList;
QList<CANoteCheckerError*> _noteCheckerErrorList;
CAContext* _context;
int _timeStart;
int _timeLength;
bool _visible;
QColor _color;
QString _name;
};
#endif /* MUSELEMENT_H_ */
| 3,227
|
C++
|
.h
| 78
| 36.333333
| 127
| 0.715564
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,501
|
note.h
|
canorusmusic_canorus/src/score/note.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef NOTE_H_
#define NOTE_H_
#include "score/diatonicpitch.h"
#include "score/muselement.h"
#include "score/playable.h"
#include "score/slur.h"
class CAVoice;
class CANote : public CAPlayable {
public:
enum CAStemDirection {
StemUndefined = -1,
StemNeutral,
StemUp,
StemDown,
StemPreferred // voice's direction
};
CANote(CADiatonicPitch pitch, CAPlayableLength length, CAVoice* voice, int timeStart, int timeLength = -1);
CANote* clone(CAVoice* voice = 0);
virtual ~CANote();
CAPlayableLength noteLength() { return _playableLength; }
inline CADiatonicPitch& diatonicPitch() { return _diatonicPitch; }
inline void setDiatonicPitch(CADiatonicPitch pitch)
{
_diatonicPitch = pitch;
updateTies();
}
inline int midiPitch() { return _diatonicPitch.midiPitch(); }
CAStemDirection stemDirection() { return _stemDirection; }
void setStemDirection(CAStemDirection direction);
int notePosition();
inline CASlur* tieStart() { return _tieStart; }
inline CASlur* tieEnd() { return _tieEnd; }
inline CASlur* slurStart() { return _slurStart; }
inline CASlur* slurEnd() { return _slurEnd; }
inline CASlur* phrasingSlurStart() { return _phrasingSlurStart; }
inline CASlur* phrasingSlurEnd() { return _phrasingSlurEnd; }
CAStemDirection actualStemDirection();
CASlur::CASlurDirection actualSlurDirection();
inline void setTieStart(CASlur* tieStart) { _tieStart = tieStart; }
inline void setTieEnd(CASlur* tieEnd) { _tieEnd = tieEnd; }
inline void setSlurStart(CASlur* slurStart) { _slurStart = slurStart; }
inline void setSlurEnd(CASlur* slurEnd) { _slurEnd = slurEnd; }
inline void setPhrasingSlurStart(CASlur* pSlurStart) { _phrasingSlurStart = pSlurStart; }
inline void setPhrasingSlurEnd(CASlur* pSlurEnd) { _phrasingSlurEnd = pSlurEnd; }
void updateTies();
bool isPartOfChord();
bool isLastInChord();
bool isFirstInChord();
QList<CANote*> getChord();
bool forceAccidentals() { return _forceAccidentals; }
void setForceAccidentals(bool force) { _forceAccidentals = force; }
static const QString generateNoteName(int pitch, int accs);
static const QString stemDirectionToString(CAStemDirection);
static CAStemDirection stemDirectionFromString(const QString);
int compare(CAMusElement* elt);
private:
CADiatonicPitch _diatonicPitch;
CAStemDirection _stemDirection;
bool _forceAccidentals; // Always draw notes accidentals.
////////////////////
// Slurs and ties //
////////////////////
CASlur* _tieStart;
CASlur* _tieEnd;
CASlur* _slurStart;
CASlur* _slurEnd;
CASlur* _phrasingSlurStart;
CASlur* _phrasingSlurEnd;
};
#endif /* NOTE_H_*/
| 3,023
|
C++
|
.h
| 75
| 35.506667
| 111
| 0.713602
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,502
|
dynamic.h
|
canorusmusic_canorus/src/score/dynamic.h
|
/*!
Copyright (c) 2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DYNAMIC_H_
#define DYNAMIC_H_
#include "score/mark.h"
#include <QString>
class CANote;
class CADynamic : public CAMark {
public:
enum CADynamicText {
ppppp,
pppp,
ppp,
pp,
p,
fffff,
ffff,
fff,
ff,
f,
fp,
mf,
mp,
rfz,
sff,
sf,
sfz,
spp,
sp,
Custom
};
CADynamic(QString text, int volume, CANote* note);
virtual ~CADynamic();
CADynamic* clone(CAMusElement* elt = nullptr);
int compare(CAMusElement*);
inline const QString text() { return _text; }
inline void setText(const QString t) { _text = t; }
inline int volume() { return _volume; }
inline void setVolume(const int v) { _volume = v; }
static const QString dynamicTextToString(CADynamicText t);
static CADynamicText dynamicTextFromString(const QString t);
private:
QString _text;
int _volume; // volume percantage - from 0% to 100%
};
#endif /* DYNAMIC_H_ */
| 1,259
|
C++
|
.h
| 49
| 20
| 76
| 0.627189
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,503
|
chordname.h
|
canorusmusic_canorus/src/score/chordname.h
|
/*!
Copyright (c) 2019-2022, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef CHORDNAME_H_
#define CHORDNAME_H_
#include "score/diatonicpitch.h"
#include "score/muselement.h"
#include <QString>
class CAChordNameContext;
class CAChordName : public CAMusElement {
public:
CAChordName(CADiatonicPitch pitch, QString qualityModifier, CAChordNameContext* parent, int timeStart, int timeLength);
virtual ~CAChordName();
void clear();
CAChordName& operator+=(CAInterval);
CADiatonicPitch diatonicPitch() { return _diatonicPitch; }
void setDiatonicPitch(CADiatonicPitch dp) { _diatonicPitch = dp; }
QString qualityModifier() { return _qualityModifier; }
void setQualityModifier(QString qm) { _qualityModifier = qm; }
CAChordName* clone(CAContext* c);
int compare(CAMusElement* elt);
bool importFromString(const QString& text);
private:
CADiatonicPitch _diatonicPitch;
QString _qualityModifier;
};
#endif /* CHORDNAME_H_ */
| 1,127
|
C++
|
.h
| 29
| 35.551724
| 123
| 0.766114
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,504
|
rest.h
|
canorusmusic_canorus/src/score/rest.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef REST_H_
#define REST_H_
#include "score/playable.h"
class CAStaff;
class CARest : public CAPlayable {
public:
enum CARestType {
Undefined = -1,
Normal,
Hidden
};
CARest(CARestType type, CAPlayableLength length, CAVoice* voice, int timeStart, int timeLength = -1);
~CARest();
CARest* clone(CAVoice* voice = nullptr);
CARestType restType() { return _restType; }
void setRestType(CARestType type) { _restType = type; }
int compare(CAMusElement* elt);
static const QString restTypeToString(CARestType);
static CARestType restTypeFromString(const QString);
static QList<CARest*> composeRests(int timeLength, int timeStart, CAVoice* voice = nullptr, CARestType = Hidden);
private:
CARestType _restType;
};
#endif /* REST_H_ */
| 1,030
|
C++
|
.h
| 29
| 31.551724
| 117
| 0.726263
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,505
|
voice.h
|
canorusmusic_canorus/src/score/voice.h
|
/*!
Copyright (c) 2006-2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICNESE.GPL for details.
*/
#ifndef VOICE_H_
#define VOICE_H_
#include <QList> // music elements container
#include "score/muselement.h"
#include "score/note.h"
class CAKeySignature;
class CATimeSignature;
class CAClef;
class CALyricsContext;
class CARest;
class CATempo;
class CAVoice {
friend class CAStaff; // used for insertion of music elements and updateTimes() when inserting elements and synchronizing voices
public:
CAVoice(const QString name, CAStaff* staff, CANote::CAStemDirection stemDirection = CANote::StemNeutral);
~CAVoice();
inline CAStaff* staff() { return _staff; }
inline void setStaff(CAStaff* staff) { _staff = staff; }
void clear();
CAVoice* clone(CAStaff* newStaff = nullptr);
void cloneVoiceProperties(CAVoice* v);
/////////////////////////////////////////
// Notes, rests and signs manipulation //
/////////////////////////////////////////
void append(CAMusElement* elt, bool addToChord = false);
bool insert(CAMusElement* eltAfter, CAMusElement* elt, bool addToChord = false);
bool remove(CAMusElement* elt, bool updateSignsTimes = true);
CAPlayable* insertInTupletAndVoiceAt(CAPlayable* p, CAPlayable* n);
bool synchronizeMusElements();
//////////////////////////////
// Voice analysis and query //
//////////////////////////////
inline const QList<CAMusElement*>& musElementList() { return _musElementList; }
QList<CAMusElement*> getSignList();
QList<CANote*> getNoteList();
bool containsPitch(int noteName, int timeStart);
bool containsPitch(CADiatonicPitch p, int timeStart);
CAMusElement* next(CAMusElement* elt);
CAMusElement* previous(CAMusElement* elt);
CAMusElement* nextByType(CAMusElement::CAMusElementType type, CAMusElement* elt);
CAMusElement* previousByType(CAMusElement::CAMusElementType type, CAMusElement* elt);
CANote* nextNote(int timeStart);
CANote* previousNote(int timeStart);
CARest* nextRest(int timeStart);
CARest* previousRest(int timeStart);
CAPlayable* nextPlayable(int timeStart);
CAPlayable* previousPlayable(int timeStart);
bool binarySearch_startTime(int time, int& position);
CAMusElement* getOneEltByType(CAMusElement::CAMusElementType type, int startTime);
QList<CAMusElement*> getEltByType(CAMusElement::CAMusElementType type, int startTime);
CAMusElement* getOnePreviousByType(CAMusElement::CAMusElementType type, int startTime);
QList<CAMusElement*> getPreviousByType(CAMusElement::CAMusElementType type, int startTime);
inline int lastTimeEnd() { return (musElementList().size() ? musElementList().back()->timeEnd() : 0); }
inline int lastTimeStart() { return (musElementList().size() ? musElementList().back()->timeStart() : 0); }
inline CAMusElement* lastMusElement() { return musElementList().size() ? musElementList().back() : nullptr; }
CADiatonicPitch lastNotePitch(bool inChord = false);
CAPlayable* lastPlayableElt();
CANote* lastNote();
CATimeSignature* getTimeSig(CAMusElement* elt);
CAKeySignature* getKeySig(CAMusElement* elt);
CAClef* getClef(CAMusElement* elt);
QList<CAPlayable*> getChord(int time);
QList<CAMusElement*> getBar(int time);
CATempo* getTempo(int time);
QList<CAMusElement*> getKeySignature(int startTime);
QList<CAMusElement*> getTimeSignature(int startTime);
QList<CAMusElement*> getClef(int startTime);
QList<CAMusElement*> getPreviousKeySignature(int startTime);
QList<CAMusElement*> getPreviousTimeSignature(int startTime);
QList<CAMusElement*> getPreviousClef(int startTime);
////////////////
// Properties //
////////////////
inline int voiceNumber() { return (staff() ? (staff()->voiceList().indexOf(this) + 1) : 1); }
inline bool isFirstVoice() { return (voiceNumber() == 1); }
inline CANote::CAStemDirection stemDirection() { return _stemDirection; }
inline void setStemDirection(CANote::CAStemDirection direction) { _stemDirection = direction; }
inline const QString name() { return _name; }
inline void setName(const QString name) { _name = name; }
inline unsigned char midiChannel() { return _midiChannel; }
inline void setMidiChannel(const unsigned char ch) { _midiChannel = ch; }
inline unsigned char midiProgram() { return _midiProgram; }
inline void setMidiProgram(const unsigned char program) { _midiProgram = program; }
inline char midiPitchOffset() { return _midiPitchOffset; }
inline void setMidiPitchOffset(const char midiPitchOffset) { _midiPitchOffset = midiPitchOffset; }
inline const QList<CALyricsContext*>& lyricsContextList() { return _lyricsContextList; }
inline void addLyricsContext(CALyricsContext* lc) { _lyricsContextList << lc; }
inline void setLyricsContexts(QList<CALyricsContext*> list) { _lyricsContextList = list; }
inline void addLyricsContexts(QList<CALyricsContext*> list) { _lyricsContextList += list; }
inline bool removeLyricsContext(CALyricsContext* lc) { return _lyricsContextList.removeAll(lc); }
private:
bool addNoteToChord(CANote* note, CANote* referenceNote);
bool insertMusElement(CAMusElement* before, CAMusElement* elt);
bool updateTimes(int idx, int length, bool signsToo = false);
// list of all the music elements
QList<CAMusElement*> _musElementList;
CAStaff* _staff; // parent staff
CANote::CAStemDirection _stemDirection;
QList<CALyricsContext*> _lyricsContextList;
QString _name;
/////////////////////
// MIDI properties //
/////////////////////
unsigned char _midiChannel;
unsigned char _midiProgram;
char _midiPitchOffset;
};
#endif /* VOICE_H_ */
| 5,896
|
C++
|
.h
| 113
| 47.654867
| 132
| 0.717686
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,506
|
diatonicpitch.h
|
canorusmusic_canorus/src/score/diatonicpitch.h
|
/*!
Copyright (c) 2008-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef DIATONICPITCH_H_
#define DIATONICPITCH_H_
#include "score/interval.h"
#include <QString>
class CADiatonicKey;
class CADiatonicPitch {
public:
enum CANoteName {
Undefined = -1,
C = 0,
D = 1,
E = 2,
F = 3,
G = 4,
A = 5,
B = 6
};
enum CAMidiPitchMode {
PreferAuto = 0,
PreferSharps = 1,
PreferFlats = -1
};
CADiatonicPitch();
CADiatonicPitch(const QString& pitch);
CADiatonicPitch(const int& noteName, const int& accs = 0);
bool operator==(CADiatonicPitch);
inline bool operator!=(CADiatonicPitch p) { return !operator==(p); }
bool operator==(int noteName);
inline bool operator!=(int p) { return !operator==(p); }
CADiatonicPitch operator+(CAInterval);
CADiatonicPitch operator-(CAInterval i)
{
return operator+(CAInterval(i.quality(), i.quantity() * (-1)));
}
inline int noteName() const { return _noteName; }
inline signed char accs() const { return _accs; }
inline void setNoteName(const int noteName) { _noteName = noteName; }
inline void setAccs(const signed char accs) { _accs = accs; }
inline int midiPitch() { return CADiatonicPitch::diatonicPitchToMidiPitch(*this); }
static const QString diatonicPitchToString(CADiatonicPitch p);
static CADiatonicPitch diatonicPitchFromString(const QString s);
static CADiatonicPitch diatonicPitchFromMidiPitch(int midiPitch, CAMidiPitchMode m = PreferAuto);
static CADiatonicPitch diatonicPitchFromMidiPitchKey(int midiPitch, CADiatonicKey k, CAMidiPitchMode m = PreferAuto);
static int diatonicPitchToMidiPitch(const CADiatonicPitch& dp);
private:
int _noteName; // 0-sub-contra C, 1-D, 2-E etc.
signed char _accs; // 0-neutral, 1-sharp, -1-flat etc.
};
#endif /* DIATONICPITCH_H_ */
| 2,073
|
C++
|
.h
| 54
| 33.277778
| 121
| 0.696108
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,507
|
functionmarkcontext.h
|
canorusmusic_canorus/src/score/functionmarkcontext.h
|
/*!
Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef FUNCTIONMARKCONTEXT_H_
#define FUNCTIONMARKCONTEXT_H_
#include <QList>
#include <QString>
#include "score/context.h"
class CASheet;
class CAFunctionMark;
class CAFunctionMarkContext : public CAContext {
public:
CAFunctionMarkContext(const QString name, CASheet* sheet);
~CAFunctionMarkContext();
CAFunctionMarkContext* clone(CASheet* s);
inline const QList<CAFunctionMark*>& functionMarkList() { return _functionMarkList; }
QList<CAFunctionMark*> functionMarkAt(int timeStart);
void addFunctionMark(CAFunctionMark* mark, bool replace = true);
void clear();
CAMusElement* next(CAMusElement* elt);
CAMusElement* previous(CAMusElement* elt);
bool remove(CAMusElement* elt);
CAMusElement *insertEmptyElement(int timeStart);
void repositionElements();
private:
QList<CAFunctionMark*> _functionMarkList;
};
#endif /* FUNCTIONMARKCONTEXT_H_*/
| 1,123
|
C++
|
.h
| 30
| 34.3
| 89
| 0.777675
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,508
|
tempo.h
|
canorusmusic_canorus/src/score/tempo.h
|
/*!
Copyright (c) 2007-2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef TEMPO_H_
#define TEMPO_H_
#include "score/mark.h"
#include "score/playable.h"
class CATempo : public CAMark {
public:
CATempo(CAPlayableLength l, unsigned char bpm, CAMusElement* m);
virtual ~CATempo();
CATempo* clone(CAMusElement* elt = nullptr);
int compare(CAMusElement* elt);
inline unsigned char bpm() { return _bpm; }
inline void setBpm(unsigned char bpm) { _bpm = bpm; }
inline CAPlayableLength beat() { return _beat; }
inline void setBeat(CAPlayableLength l) { _beat = l; }
private:
CAPlayableLength _beat;
unsigned char _bpm; // beats per minute
};
#endif /* TEMPO_H_ */
| 854
|
C++
|
.h
| 24
| 32.458333
| 76
| 0.721411
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,509
|
interval.h
|
canorusmusic_canorus/src/score/interval.h
|
/*!
Copyright (c) 2008, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef INTERVAL_H_
#define INTERVAL_H_
#include <QString>
class CADiatonicPitch;
class CAInterval {
public:
enum CAQuality {
Major = 1,
Minor = -1,
Perfect = 0,
Augmented = 2,
Diminished = -2
};
enum CAQuantity {
Undefined = 0,
Prime = 1,
Second = 2,
Third = 3,
Fourth = 4,
Fifth = 5,
Sixth = 6,
Seventh = 7,
Octave = 8
};
CAInterval();
CAInterval(int qlt, int qnt);
CAInterval(CADiatonicPitch note1, CADiatonicPitch note2, bool absolute = true);
CAInterval operator~();
CAInterval operator+(CAInterval);
CAInterval operator-(CAInterval i)
{
return operator+(CAInterval(i.quality(), i.quantity() * (-1)));
}
CAInterval operator*(int numerator)
{
CAInterval interval = *this;
while (--numerator) {
interval = interval + (*this);
}
return interval;
}
bool operator==(CAInterval i)
{
return i.quality() == _qlt && i.quantity() == _qnt;
}
bool operator!=(CAInterval i)
{
return !(operator==(i));
}
inline int quality() { return _qlt; }
inline int quantity() { return _qnt; }
inline void setQuality(const int qlt) { _qlt = qlt; }
inline void setQuantity(const int qnt) { _qnt = qnt; }
int semitones();
static CAInterval fromSemitones(int semitones);
static const QString qualityToReadable(int k);
static const QString quantityToReadable(int k);
private:
int _qlt;
int _qnt;
};
#endif /* INTERVAL_H_ */
| 1,831
|
C++
|
.h
| 67
| 21.507463
| 83
| 0.614989
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,532,510
|
chordnamecontext.h
|
canorusmusic_canorus/src/score/chordnamecontext.h
|
/*!
Copyright (c) 2019, Matevž Jekovec, Canorus development team
All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
*/
#ifndef CHORDNAMECONTEXT_H_
#define CHORDNAMECONTEXT_H_
#include "score/context.h"
#include <QList>
class CAChordName;
class CAChordNameContext : public CAContext {
public:
CAChordNameContext(QString name, CASheet* sheet);
~CAChordNameContext();
CAContext* clone(CASheet*);
void clear();
CAMusElement* next(CAMusElement* elt);
CAMusElement* previous(CAMusElement* elt);
bool remove(CAMusElement* elt);
CAMusElement *insertEmptyElement(int timeStart);
void repositionElements();
QList<CAChordName*>& chordNameList() { return _chordNameList; }
CAChordName* chordNameAtTimeStart(int timeStart);
void addChordName(CAChordName*, bool replace = true);
private:
QList<CAChordName*> _chordNameList;
};
#endif /* CHORDNAMECONTEXT_H_ */
| 1,002
|
C++
|
.h
| 28
| 32.464286
| 76
| 0.763485
|
canorusmusic/canorus
| 34
| 14
| 92
|
GPL-3.0
|
9/20/2024, 10:43:45 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.