-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRefaceDXPatch.cpp
51 lines (40 loc) · 1.28 KB
/
RefaceDXPatch.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Copyright (c) 2020 Christof Ruch. All rights reserved.
Dual licensed: Distributed under Affero GPL license by default, an MIT license is available for purchase
*/
#include "RefaceDXPatch.h"
#include <algorithm>
#include <boost/format.hpp>
namespace midikraft {
const int kRefaceDXPatchType = 0;
RefaceDXPatch::RefaceDXPatch(Synth::PatchData const &voiceData, MidiProgramNumber place) : Patch(kRefaceDXPatchType, voiceData), originalProgramNumber_(place)
{
}
std::string RefaceDXPatch::name() const
{
std::string result;
// Extract the first 10 bytes of the common block, that's the ascii name
for (int i = 0; i < std::min((size_t)10, data().size()); i++) {
result.push_back(data()[i]);
}
return result;
}
void RefaceDXPatch::setName(std::string const &name)
{
// Poke this into the first 10 bytes of the common block, which is the ASCII name. Ignore UTF 8 complexity for now.
for (int i = 0; i < std::min((size_t)10, name.size()); i++) {
setAt(i, name[i]);
}
for (int i = std::min(10, (int) name.size()); i < 10; i++) {
setAt(i, ' ');
}
}
bool RefaceDXPatch::isDefaultName(std::string const &patchName) const
{
return patchName == "Init Voice";
}
MidiProgramNumber RefaceDXPatch::patchNumber() const
{
return originalProgramNumber_;
}
}