Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "interpreter/exceptions.h" | ||
2 | #include "line6pod2_program_changes.h" | ||
3 | #include <QString> | ||
4 | #include <QObject> | ||
5 | |||
6 | using namespace interpreter; | ||
7 | |||
8 | |||
9 | 46 | Line6Pod2ProgramChange::Line6Pod2ProgramChange(const QByteArray &message) | |
10 | 46 | : MidiMessage(message) | |
11 | { | ||
12 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 43 times.
|
45 | if (m_length != 2) |
13 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
|
6 | UnexpectedMessage("Program change MIDI with invalid size").raise(); |
14 | |||
15 | 43 | uint8_t code = message.at(1); | |
16 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 39 times.
|
43 | if (code == 0) { |
17 | 4 | m_bank = -1; | |
18 | 4 | m_channel = 'T'; | |
19 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 38 times.
|
39 | } else if (code == 37) { |
20 | 1 | m_bank = -1; | |
21 | 1 | m_channel = 'M'; | |
22 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 36 times.
|
38 | } else if (code > 37) { |
23 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
|
6 | UnexpectedMessage("MIDI program out of range").raise(); |
24 | } else { | ||
25 | 36 | m_bank = ((code - 1) / 4) + 1; | |
26 |
4/5✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
|
36 | switch (((code - 1) % 4) + 1) { |
27 | 9 | case 1: | |
28 | 9 | m_channel = 'A'; | |
29 | 9 | break; | |
30 | 9 | case 2: | |
31 | 9 | m_channel = 'B'; | |
32 | 9 | break; | |
33 | 9 | case 3: | |
34 | 9 | m_channel = 'C'; | |
35 | 9 | break; | |
36 | 9 | case 4: | |
37 | 9 | m_channel = 'D'; | |
38 | 9 | break; | |
39 | } | ||
40 | } | ||
41 | 45 | } | |
42 | |||
43 | 88 | Line6Pod2ProgramChange::~Line6Pod2ProgramChange() | |
44 | { | ||
45 | 88 | } | |
46 | |||
47 | 38 | int Line6Pod2ProgramChange::getBank() const | |
48 | { | ||
49 | 38 | return m_bank; | |
50 | } | ||
51 | |||
52 | 38 | char Line6Pod2ProgramChange::getChannel() const | |
53 | { | ||
54 | 38 | return m_channel; | |
55 | } | ||
56 | |||
57 | 38 | QString Line6Pod2ProgramChange::toString() const | |
58 | { | ||
59 |
3/3✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 36 times.
|
38 | switch (m_channel) { |
60 | 1 | case 'T': | |
61 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | return tr("Select Tuner"); |
62 | 1 | case 'M': | |
63 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | return tr("Select Manual Mode"); |
64 | 36 | default: | |
65 |
1/2✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
|
36 | QString human_readable(tr("Select Bank %1 Channel %2")); |
66 | |||
67 |
2/4✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 | return human_readable.arg(m_bank).arg(m_channel); |
68 | } | ||
69 | } | ||
70 |