2008-12-08 04:50:19 -05:00
|
|
|
/*
|
2012-10-08 00:32:12 -04:00
|
|
|
Copyright (C) 2012 Paul Davis
|
|
|
|
Author: Hans Baier
|
2008-12-08 04:50:19 -05:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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 General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#ifndef MIDNAM_PATCH_H_
|
|
|
|
#define MIDNAM_PATCH_H_
|
|
|
|
|
2012-06-12 00:05:10 -04:00
|
|
|
#include <algorithm>
|
2014-12-17 19:43:09 -05:00
|
|
|
#include <cassert>
|
2012-06-02 10:50:09 -04:00
|
|
|
#include <iostream>
|
2008-06-02 17:41:35 -04:00
|
|
|
#include <string>
|
2008-12-05 23:43:11 -05:00
|
|
|
#include <list>
|
2008-06-02 17:41:35 -04:00
|
|
|
#include <set>
|
2008-12-09 02:42:19 -05:00
|
|
|
#include <map>
|
2013-01-19 19:46:55 -05:00
|
|
|
#include <vector>
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-06-12 00:05:10 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
#include "midi++/libmidi_visibility.h"
|
2008-12-08 04:50:19 -05:00
|
|
|
#include "midi++/event.h"
|
|
|
|
#include "pbd/xml++.h"
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
namespace MIDI
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace Name
|
|
|
|
{
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
struct LIBMIDIPP_API PatchPrimaryKey
|
2008-12-10 05:54:45 -05:00
|
|
|
{
|
|
|
|
public:
|
2014-12-17 19:43:09 -05:00
|
|
|
PatchPrimaryKey (int program_num = 0, int bank_num = 0)
|
|
|
|
: _bank(std::max(0, std::min(bank_num, 16383)))
|
|
|
|
, _program(std::max(0, std::min(program_num, 127)))
|
|
|
|
{}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-12-12 00:17:53 -05:00
|
|
|
inline PatchPrimaryKey& operator=(const PatchPrimaryKey& id) {
|
2014-12-17 19:43:09 -05:00
|
|
|
_bank = id._bank;
|
|
|
|
_program = id._program;
|
2008-12-12 00:17:53 -05:00
|
|
|
return *this;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-12-10 05:54:45 -05:00
|
|
|
inline bool operator==(const PatchPrimaryKey& id) const {
|
2014-12-17 19:43:09 -05:00
|
|
|
return (_bank == id._bank &&
|
|
|
|
_program == id._program);
|
2008-12-10 05:54:45 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-12-17 19:43:09 -05:00
|
|
|
/** Strict weak ordering. */
|
2008-12-10 05:54:45 -05:00
|
|
|
inline bool operator<(const PatchPrimaryKey& id) const {
|
2014-12-17 19:43:09 -05:00
|
|
|
if (_bank < id._bank) {
|
2008-12-10 05:54:45 -05:00
|
|
|
return true;
|
2014-12-17 19:43:09 -05:00
|
|
|
} else if (_bank == id._bank && _program < id._program) {
|
2008-12-10 05:54:45 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-12-17 19:43:09 -05:00
|
|
|
|
|
|
|
void set_bank(int bank) { _bank = std::max(0, std::min(bank, 16383)); }
|
|
|
|
void set_program(int program) { _program = std::max(0, std::min(program, 127)); }
|
|
|
|
|
|
|
|
inline uint16_t bank() const { return _bank; }
|
|
|
|
inline uint8_t program() const { return _program; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint16_t _bank;
|
|
|
|
uint8_t _program;
|
2008-12-10 05:54:45 -05:00
|
|
|
};
|
|
|
|
|
2009-01-14 22:13:24 -05:00
|
|
|
class PatchBank;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
class LIBMIDIPP_API Patch
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2012-10-08 23:09:54 -04:00
|
|
|
Patch (std::string a_name = std::string(), uint8_t a_number = 0, uint16_t bank_number = 0);
|
2009-01-14 22:13:24 -05:00
|
|
|
virtual ~Patch() {};
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
const std::string& note_list_name() const { return _note_list_name; }
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2014-12-17 19:43:09 -05:00
|
|
|
uint8_t program_number() const { return _id.program(); }
|
|
|
|
void set_program_number(uint8_t n) { _id.set_program(n); }
|
2012-06-12 00:05:10 -04:00
|
|
|
|
2014-12-17 19:43:09 -05:00
|
|
|
uint16_t bank_number() const { return _id.bank(); }
|
|
|
|
void set_bank_number (uint16_t n) { _id.set_bank(n); }
|
2012-06-12 00:05:10 -04:00
|
|
|
|
2008-12-10 05:54:45 -05:00
|
|
|
const PatchPrimaryKey& patch_primary_key() const { return _id; }
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2012-10-08 23:09:54 -04:00
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
2012-06-12 00:05:10 -04:00
|
|
|
std::string _name;
|
|
|
|
PatchPrimaryKey _id;
|
2013-01-19 19:46:55 -05:00
|
|
|
std::string _note_list_name;
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
typedef std::list<boost::shared_ptr<Patch> > PatchNameList;
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
class LIBMIDIPP_API PatchBank
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
public:
|
2018-07-24 15:30:23 -04:00
|
|
|
PatchBank (uint16_t n = UINT16_MAX, std::string a_name = std::string()) : _name(a_name), _number (n) {};
|
2012-10-08 23:09:54 -04:00
|
|
|
virtual ~PatchBank() { }
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
void set_name(const std::string& a_name) { _name = a_name; }
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2012-10-08 23:09:54 -04:00
|
|
|
int number() const { return _number; }
|
2012-06-12 00:05:10 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
const PatchNameList& patch_name_list() const { return _patch_name_list; }
|
2012-03-20 14:01:59 -04:00
|
|
|
const std::string& patch_list_name() const { return _patch_list_name; }
|
|
|
|
|
|
|
|
int set_patch_name_list (const PatchNameList&);
|
|
|
|
|
2012-10-08 23:09:54 -04:00
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
2009-05-12 13:03:42 -04:00
|
|
|
std::string _name;
|
2012-10-08 23:09:54 -04:00
|
|
|
uint16_t _number;
|
2009-01-14 22:13:24 -05:00
|
|
|
PatchNameList _patch_name_list;
|
2012-03-20 14:01:59 -04:00
|
|
|
std::string _patch_list_name;
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
class LIBMIDIPP_API ChannelNameSet
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-12-12 00:17:53 -05:00
|
|
|
typedef std::set<uint8_t> AvailableForChannels;
|
|
|
|
typedef std::list<boost::shared_ptr<PatchBank> > PatchBanks;
|
|
|
|
typedef std::map<PatchPrimaryKey, boost::shared_ptr<Patch> > PatchMap;
|
2008-12-15 06:05:41 -05:00
|
|
|
typedef std::list<PatchPrimaryKey> PatchList;
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
ChannelNameSet() {};
|
|
|
|
virtual ~ChannelNameSet() {};
|
2013-01-20 03:56:00 -05:00
|
|
|
ChannelNameSet(std::string& name) : _name(name) {};
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-12-23 01:03:45 -05:00
|
|
|
const PatchBanks& patch_banks() const { return _patch_banks; }
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
bool available_for_channel(uint8_t channel) const {
|
|
|
|
return _available_for_channels.find(channel) != _available_for_channels.end();
|
2008-12-10 05:54:45 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
boost::shared_ptr<Patch> find_patch(const PatchPrimaryKey& key) {
|
2008-12-10 05:54:45 -05:00
|
|
|
return _patch_map[key];
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
boost::shared_ptr<Patch> previous_patch(const PatchPrimaryKey& key) {
|
2008-12-15 06:05:41 -05:00
|
|
|
for (PatchList::const_iterator i = _patch_list.begin();
|
|
|
|
i != _patch_list.end();
|
|
|
|
++i) {
|
|
|
|
if ((*i) == key) {
|
|
|
|
if (i != _patch_list.begin()) {
|
|
|
|
--i;
|
|
|
|
return _patch_map[*i];
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2008-12-15 06:05:41 -05:00
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-12-15 06:05:41 -05:00
|
|
|
return boost::shared_ptr<Patch>();
|
2008-12-14 17:56:44 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
boost::shared_ptr<Patch> next_patch(const PatchPrimaryKey& key) {
|
2008-12-15 06:05:41 -05:00
|
|
|
for (PatchList::const_iterator i = _patch_list.begin();
|
|
|
|
i != _patch_list.end();
|
|
|
|
++i) {
|
|
|
|
if ((*i) == key) {
|
|
|
|
if (++i != _patch_list.end()) {
|
|
|
|
return _patch_map[*i];
|
|
|
|
} else {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-12-15 06:05:41 -05:00
|
|
|
return boost::shared_ptr<Patch>();
|
2008-12-14 17:56:44 -05:00
|
|
|
}
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
const std::string& note_list_name() const { return _note_list_name; }
|
|
|
|
const std::string& control_list_name() const { return _control_list_name; }
|
2013-01-19 21:41:27 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2008-08-04 18:37:24 -04:00
|
|
|
|
2012-10-08 23:09:54 -04:00
|
|
|
void set_patch_banks (const PatchBanks&);
|
2013-01-20 03:56:00 -05:00
|
|
|
void use_patch_name_list (const PatchNameList&);
|
2012-06-11 18:59:35 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
private:
|
2012-10-08 23:09:54 -04:00
|
|
|
friend std::ostream& operator<< (std::ostream&, const ChannelNameSet&);
|
2013-01-20 03:56:00 -05:00
|
|
|
|
|
|
|
std::string _name;
|
2008-06-02 17:41:35 -04:00
|
|
|
AvailableForChannels _available_for_channels;
|
|
|
|
PatchBanks _patch_banks;
|
2008-12-10 05:54:45 -05:00
|
|
|
PatchMap _patch_map;
|
2008-12-15 06:05:41 -05:00
|
|
|
PatchList _patch_list;
|
2012-03-20 14:01:59 -04:00
|
|
|
std::string _patch_list_name;
|
2013-01-19 21:41:27 -05:00
|
|
|
std::string _note_list_name;
|
2013-01-20 03:56:00 -05:00
|
|
|
std::string _control_list_name;
|
2008-06-02 17:41:35 -04:00
|
|
|
};
|
|
|
|
|
2012-06-12 12:32:06 -04:00
|
|
|
std::ostream& operator<< (std::ostream&, const ChannelNameSet&);
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
class LIBMIDIPP_API Note
|
2008-12-05 19:07:07 -05:00
|
|
|
{
|
|
|
|
public:
|
2013-01-19 19:46:55 -05:00
|
|
|
Note() {}
|
|
|
|
Note(uint8_t number, const std::string& name) : _number(number), _name(name) {}
|
2008-12-05 19:07:07 -05:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
2008-12-05 19:07:07 -05:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
uint8_t number() const { return _number; }
|
|
|
|
void set_number(uint8_t number) { _number = number; }
|
2008-12-05 19:07:07 -05:00
|
|
|
|
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2008-12-05 19:07:07 -05:00
|
|
|
|
|
|
|
private:
|
2013-01-19 19:46:55 -05:00
|
|
|
uint8_t _number;
|
2009-05-12 13:03:42 -04:00
|
|
|
std::string _name;
|
2008-12-05 19:07:07 -05:00
|
|
|
};
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
class LIBMIDIPP_API NoteNameList
|
2008-12-05 23:38:44 -05:00
|
|
|
{
|
|
|
|
public:
|
2013-01-19 19:46:55 -05:00
|
|
|
typedef std::vector< boost::shared_ptr<Note> > Notes;
|
2008-12-05 23:38:44 -05:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
NoteNameList() { _notes.resize(128); }
|
|
|
|
NoteNameList (const std::string& name) : _name(name) { _notes.resize(128); }
|
|
|
|
|
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
const Notes& notes() const { return _notes; }
|
2008-12-05 23:38:44 -05:00
|
|
|
|
2013-01-19 19:46:55 -05:00
|
|
|
void set_name(const std::string& name) { _name = name; }
|
2008-12-05 23:38:44 -05:00
|
|
|
|
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2008-12-05 23:38:44 -05:00
|
|
|
|
|
|
|
private:
|
2009-05-12 13:03:42 -04:00
|
|
|
std::string _name;
|
2013-01-19 19:46:55 -05:00
|
|
|
Notes _notes;
|
2008-12-05 23:38:44 -05:00
|
|
|
};
|
|
|
|
|
2014-01-11 15:19:18 -05:00
|
|
|
class LIBMIDIPP_API Value
|
2014-01-06 17:02:55 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Value() {}
|
|
|
|
Value(const uint16_t number,
|
|
|
|
const std::string& name)
|
|
|
|
: _number(number)
|
|
|
|
, _name(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
uint16_t number() const { return _number; }
|
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
|
|
|
|
void set_number(uint16_t number) { _number = number; }
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
|
|
|
|
|
|
|
XMLNode& get_state(void);
|
|
|
|
int set_state(const XMLTree&, const XMLNode&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint16_t _number;
|
|
|
|
std::string _name;
|
|
|
|
};
|
|
|
|
|
2014-01-11 15:19:18 -05:00
|
|
|
class LIBMIDIPP_API ValueNameList
|
2014-01-06 17:02:55 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::map<uint16_t, boost::shared_ptr<Value> > Values;
|
|
|
|
|
|
|
|
ValueNameList() {}
|
|
|
|
ValueNameList(const std::string& name) : _name(name) {}
|
|
|
|
|
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
|
|
|
|
|
|
|
boost::shared_ptr<const Value> value(uint16_t num) const;
|
|
|
|
boost::shared_ptr<const Value> max_value_below(uint16_t num) const;
|
|
|
|
|
|
|
|
const Values& values() const { return _values; }
|
|
|
|
|
|
|
|
XMLNode& get_state(void);
|
|
|
|
int set_state(const XMLTree&, const XMLNode&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _name;
|
|
|
|
Values _values;
|
|
|
|
};
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
class LIBMIDIPP_API Control
|
2013-01-16 03:24:31 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Control() {}
|
|
|
|
Control(const std::string& type,
|
2013-01-20 03:56:00 -05:00
|
|
|
const uint16_t number,
|
2013-01-16 03:24:31 -05:00
|
|
|
const std::string& name)
|
|
|
|
: _type(type)
|
|
|
|
, _number(number)
|
|
|
|
, _name(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
const std::string& type() const { return _type; }
|
2013-01-20 03:56:00 -05:00
|
|
|
uint16_t number() const { return _number; }
|
2013-01-16 03:24:31 -05:00
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
|
2014-01-06 17:02:55 -05:00
|
|
|
const std::string& value_name_list_name() const { return _value_name_list_name; }
|
|
|
|
boost::shared_ptr<const ValueNameList> value_name_list() const { return _value_name_list; }
|
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
void set_type(const std::string& type) { _type = type; }
|
|
|
|
void set_number(uint16_t number) { _number = number; }
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
2013-01-16 03:24:31 -05:00
|
|
|
|
|
|
|
XMLNode& get_state(void);
|
|
|
|
int set_state(const XMLTree&, const XMLNode&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _type;
|
2013-01-20 03:56:00 -05:00
|
|
|
uint16_t _number;
|
2013-01-16 03:24:31 -05:00
|
|
|
std::string _name;
|
2014-01-06 17:02:55 -05:00
|
|
|
|
|
|
|
std::string _value_name_list_name; ///< Global, UsesValueNameList
|
|
|
|
boost::shared_ptr<ValueNameList> _value_name_list; ///< Local, ValueNameList
|
2013-01-16 03:24:31 -05:00
|
|
|
};
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
class LIBMIDIPP_API ControlNameList
|
2013-01-16 03:24:31 -05:00
|
|
|
{
|
|
|
|
public:
|
2013-01-20 03:56:00 -05:00
|
|
|
typedef std::map<uint16_t, boost::shared_ptr<Control> > Controls;
|
2013-01-16 03:24:31 -05:00
|
|
|
|
|
|
|
ControlNameList() {}
|
|
|
|
ControlNameList(const std::string& name) : _name(name) {}
|
|
|
|
|
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
void set_name(const std::string& name) { _name = name; }
|
|
|
|
|
|
|
|
boost::shared_ptr<const Control> control(uint16_t num) const;
|
2013-01-16 03:24:31 -05:00
|
|
|
|
|
|
|
const Controls& controls() const { return _controls; }
|
|
|
|
|
|
|
|
XMLNode& get_state(void);
|
|
|
|
int set_state(const XMLTree&, const XMLNode&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _name;
|
|
|
|
Controls _controls;
|
|
|
|
};
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
class LIBMIDIPP_API CustomDeviceMode
|
2008-11-23 14:42:09 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CustomDeviceMode() {};
|
|
|
|
virtual ~CustomDeviceMode() {};
|
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
const std::string& name() const { return _name; }
|
|
|
|
void set_name(const std::string& name) { _name = name; }
|
2008-11-23 14:42:09 -05:00
|
|
|
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-11-23 14:42:09 -05:00
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-10-08 00:32:12 -04:00
|
|
|
/// Note: channel here is 0-based while in the MIDNAM-file it's 1-based
|
2013-01-20 03:56:00 -05:00
|
|
|
const std::string& channel_name_set_name_by_channel(uint8_t channel) {
|
2008-12-10 05:54:45 -05:00
|
|
|
assert(channel <= 15);
|
2015-10-04 14:51:05 -04:00
|
|
|
return _channel_name_set_assignments[channel];
|
2008-12-10 05:54:45 -05:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-11-23 14:42:09 -05:00
|
|
|
private:
|
|
|
|
/// array index = channel number
|
2015-10-04 14:51:05 -04:00
|
|
|
/// string contents = name of channel name set
|
2009-05-12 13:03:42 -04:00
|
|
|
std::string _name;
|
|
|
|
std::string _channel_name_set_assignments[16];
|
2008-11-23 14:42:09 -05:00
|
|
|
};
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
class LIBMIDIPP_API MasterDeviceNames
|
2008-11-23 14:42:09 -05:00
|
|
|
{
|
|
|
|
public:
|
2013-01-20 03:56:00 -05:00
|
|
|
typedef std::set<std::string> Models;
|
2008-12-10 05:54:45 -05:00
|
|
|
/// maps name to CustomDeviceMode
|
2013-01-20 03:56:00 -05:00
|
|
|
typedef std::map<std::string, boost::shared_ptr<CustomDeviceMode> > CustomDeviceModes;
|
|
|
|
typedef std::list<std::string> CustomDeviceModeNames;
|
2008-12-10 05:54:45 -05:00
|
|
|
/// maps name to ChannelNameSet
|
2013-01-20 03:56:00 -05:00
|
|
|
typedef std::map<std::string, boost::shared_ptr<ChannelNameSet> > ChannelNameSets;
|
|
|
|
typedef std::map<std::string, boost::shared_ptr<NoteNameList> > NoteNameLists;
|
|
|
|
typedef std::map<std::string, boost::shared_ptr<ControlNameList> > ControlNameLists;
|
2014-01-06 17:02:55 -05:00
|
|
|
typedef std::map<std::string, boost::shared_ptr<ValueNameList> > ValueNameLists;
|
2013-01-20 03:56:00 -05:00
|
|
|
typedef std::map<std::string, PatchNameList> PatchNameLists;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-11-23 14:42:09 -05:00
|
|
|
MasterDeviceNames() {};
|
|
|
|
virtual ~MasterDeviceNames() {};
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
const std::string& manufacturer() const { return _manufacturer; }
|
2013-01-20 03:56:00 -05:00
|
|
|
void set_manufacturer(const std::string& manufacturer) { _manufacturer = manufacturer; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-11-23 14:42:09 -05:00
|
|
|
const Models& models() const { return _models; }
|
|
|
|
void set_models(const Models some_models) { _models = some_models; }
|
2013-01-16 03:24:31 -05:00
|
|
|
|
|
|
|
const ControlNameLists& controls() const { return _control_name_lists; }
|
2014-01-06 17:02:55 -05:00
|
|
|
const ValueNameLists& values() const { return _value_name_lists; }
|
|
|
|
|
|
|
|
boost::shared_ptr<const ValueNameList> value_name_list_by_control(
|
|
|
|
const std::string& mode,
|
|
|
|
uint8_t channel,
|
|
|
|
uint8_t number);
|
2013-01-16 03:24:31 -05:00
|
|
|
|
2008-12-10 05:54:45 -05:00
|
|
|
const CustomDeviceModeNames& custom_device_mode_names() const { return _custom_device_mode_names; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-20 02:33:27 -05:00
|
|
|
boost::shared_ptr<CustomDeviceMode> custom_device_mode_by_name(const std::string& mode_name);
|
2014-01-06 17:02:55 -05:00
|
|
|
boost::shared_ptr<ChannelNameSet> channel_name_set_by_channel(const std::string& mode, uint8_t channel);
|
2013-01-20 02:33:27 -05:00
|
|
|
boost::shared_ptr<Patch> find_patch(const std::string& mode, uint8_t channel, const PatchPrimaryKey& key);
|
2013-01-19 19:46:55 -05:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
boost::shared_ptr<ControlNameList> control_name_list(const std::string& name);
|
2014-01-06 17:02:55 -05:00
|
|
|
boost::shared_ptr<ValueNameList> value_name_list(const std::string& name);
|
2013-01-20 03:56:00 -05:00
|
|
|
boost::shared_ptr<NoteNameList> note_name_list(const std::string& name);
|
|
|
|
boost::shared_ptr<ChannelNameSet> channel_name_set(const std::string& name);
|
2013-01-19 19:46:55 -05:00
|
|
|
|
|
|
|
std::string note_name(const std::string& mode_name,
|
|
|
|
uint8_t channel,
|
|
|
|
uint16_t bank,
|
|
|
|
uint8_t program,
|
|
|
|
uint8_t number);
|
|
|
|
|
2008-11-23 14:42:09 -05:00
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-11-23 14:42:09 -05:00
|
|
|
private:
|
2009-05-12 13:03:42 -04:00
|
|
|
std::string _manufacturer;
|
2008-12-10 05:54:45 -05:00
|
|
|
Models _models;
|
|
|
|
CustomDeviceModes _custom_device_modes;
|
|
|
|
CustomDeviceModeNames _custom_device_mode_names;
|
|
|
|
ChannelNameSets _channel_name_sets;
|
|
|
|
NoteNameLists _note_name_lists;
|
2012-03-20 14:01:59 -04:00
|
|
|
PatchNameLists _patch_name_lists;
|
2013-01-16 03:24:31 -05:00
|
|
|
ControlNameLists _control_name_lists;
|
2014-01-06 17:02:55 -05:00
|
|
|
ValueNameLists _value_name_lists;
|
2008-11-23 14:42:09 -05:00
|
|
|
};
|
|
|
|
|
2013-10-17 10:27:04 -04:00
|
|
|
class LIBMIDIPP_API MIDINameDocument
|
2008-08-04 18:37:24 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-12-09 02:42:19 -05:00
|
|
|
// Maps Model names to MasterDeviceNames
|
|
|
|
typedef std::map<std::string, boost::shared_ptr<MasterDeviceNames> > MasterDeviceNamesList;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-10-15 14:56:11 -04:00
|
|
|
MIDINameDocument() {}
|
2015-10-19 06:18:16 -04:00
|
|
|
MIDINameDocument(const std::string& file_path);
|
2008-08-04 18:37:24 -04:00
|
|
|
virtual ~MIDINameDocument() {};
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2015-10-19 06:18:16 -04:00
|
|
|
const std::string& file_path () const { return _file_path; }
|
2009-05-12 13:03:42 -04:00
|
|
|
const std::string& author() const { return _author; }
|
2016-10-29 13:01:16 -04:00
|
|
|
|
2013-01-20 03:56:00 -05:00
|
|
|
void set_author(const std::string& author) { _author = author; }
|
2016-10-29 13:01:16 -04:00
|
|
|
void set_file_path(const std::string& file_path) { _file_path = file_path; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-01-19 05:02:00 -05:00
|
|
|
boost::shared_ptr<MasterDeviceNames> master_device_names(const std::string& model);
|
|
|
|
|
2008-12-09 02:42:19 -05:00
|
|
|
const MasterDeviceNamesList& master_device_names_by_model() const { return _master_device_names_list; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-12-09 02:42:19 -05:00
|
|
|
const MasterDeviceNames::Models& all_models() const { return _all_models; }
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-08-04 18:37:24 -04:00
|
|
|
XMLNode& get_state (void);
|
2012-03-20 14:01:59 -04:00
|
|
|
int set_state (const XMLTree&, const XMLNode&);
|
2008-08-04 18:37:24 -04:00
|
|
|
|
|
|
|
private:
|
2016-10-29 13:01:16 -04:00
|
|
|
std::string _file_path;
|
2009-05-12 13:03:42 -04:00
|
|
|
std::string _author;
|
2008-12-09 02:42:19 -05:00
|
|
|
MasterDeviceNamesList _master_device_names_list;
|
|
|
|
MasterDeviceNames::Models _all_models;
|
2008-08-04 18:37:24 -04:00
|
|
|
};
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2013-10-17 15:07:18 -04:00
|
|
|
LIBMIDIPP_API extern const char* general_midi_program_names[128]; /* 0 .. 127 */
|
2012-06-11 18:59:35 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2008-08-04 18:37:24 -04:00
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
#endif /*MIDNAM_PATCH_H_*/
|