| 32 | SaffirePro24::Switch::Switch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue ) |
---|
| 33 | : Control::Boolean(eap, name) |
---|
| 34 | , m_eap(eap) |
---|
| 35 | , m_selected(0) |
---|
| 36 | , m_offset(offset) |
---|
| 37 | , m_activevalue(activevalue) |
---|
| 38 | { |
---|
| 39 | m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); |
---|
| 40 | printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); |
---|
| 41 | debugOutput(DEBUG_LEVEL_VERBOSE, "Probably the initialization is the other way round.\n"); |
---|
| 42 | m_selected = (m_state_tmp&m_activevalue)?true:false; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | bool SaffirePro24::Switch::selected() { |
---|
| 46 | return m_selected; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | bool SaffirePro24::Switch::select(bool n) { |
---|
| 50 | if ( n != m_selected ) { |
---|
| 51 | m_selected = n; |
---|
| 52 | m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); |
---|
| 53 | m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue); |
---|
| 54 | int msg = 0; |
---|
| 55 | if (m_offset<0x14) msg = 2; |
---|
| 56 | if (m_offset<0x3C && m_offset>=0x14) msg = 1; |
---|
| 57 | if (m_offset<0x40 && m_offset>=0x3C) msg = 3; |
---|
| 58 | if (m_offset<0x60 && m_offset>=0x58) msg = 4; |
---|
| 59 | debugOutput(DEBUG_LEVEL_VERBOSE, "Switch will write the msg %i.\n", msg); |
---|
| 60 | m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, msg); |
---|
| 61 | } |
---|
| 62 | return true; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | class SaffirePro24::LineInstSwitch : public Switch |
---|
| 66 | { |
---|
| 67 | public: |
---|
| 68 | LineInstSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) |
---|
| 69 | : Switch(eap, name, offset, activevalue) {} |
---|
| 70 | std::string getBooleanLabel(bool n) { |
---|
| 71 | if ( n ) return "Instrument"; |
---|
| 72 | return "Line"; |
---|
| 73 | } |
---|
| 74 | }; |
---|
| 75 | class SaffirePro24::LevelSwitch : public Switch |
---|
| 76 | { |
---|
| 77 | public: |
---|
| 78 | LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) |
---|
| 79 | : Switch(eap, name, offset, activevalue) {} |
---|
| 80 | std::string getBooleanLabel(bool n) { |
---|
| 81 | if ( n ) return "High"; |
---|
| 82 | return "Low"; |
---|
| 83 | } |
---|
| 84 | }; |
---|
| 85 | |
---|
53 | | getEAP()->readRegBlock(Dice::Device::EAP::eRT_Application, 0x58, tmp, 2*sizeof(fb_quadlet_t)); |
---|
54 | | hexDumpQuadlets(tmp, 2); |
---|
| 112 | getEAP()->readRegBlock(Dice::Device::EAP::eRT_Application, 0x00, tmp, 1*sizeof(fb_quadlet_t)); |
---|
| 113 | //hexDumpQuadlets(tmp, 2); // DEBUG |
---|
| 114 | if (tmp[0] != 0x00010004 ) { |
---|
| 115 | debugError("This is a Focusrite Saffire Pro24 but not the right firmware. Better stop here before something goes wrong.\n"); |
---|
| 116 | debugError("This device has firmware 0x%x while we only know about version 0x%x.\n", tmp[0], 0x10004); |
---|
| 117 | return false; |
---|
| 118 | } |
---|
| 119 | //getEAP()->readRegBlock(Dice::Device::EAP::eRT_Command, 0x00, tmp, 2*sizeof(fb_quadlet_t)); // DEBUG |
---|
| 120 | //hexDumpQuadlets(tmp, 2); // DEBUG |
---|
92 | | m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); |
---|
93 | | printf("%s: Active?%i\n", name.c_str(), m_state_tmp&m_activevalue); |
---|
94 | | m_selected = (m_state_tmp&m_activevalue)?1:0; |
---|
95 | | } |
---|
96 | | |
---|
97 | | int SaffirePro24::LineInstSwitch::selected() { |
---|
98 | | return m_selected; |
---|
99 | | } |
---|
100 | | |
---|
101 | | bool SaffirePro24::LineInstSwitch::select(int n) { |
---|
102 | | if ( n != m_selected ) { |
---|
103 | | m_selected = n; |
---|
104 | | m_eap->readReg(Dice::Device::EAP::eRT_Application, m_offset, &m_state_tmp); |
---|
105 | | m_eap->writeReg(Dice::Device::EAP::eRT_Application, m_offset, m_state_tmp^m_activevalue); |
---|
106 | | m_eap->writeReg(Dice::Device::EAP::eRT_Application, msgSet, 4); |
---|
| 159 | m_mute = new Switch(m_eap, "Mute", 0x0C, 1); |
---|
| 160 | addElement(m_mute); |
---|
| 161 | m_dim = new Switch(m_eap, "Dim", 0x10, 1); |
---|
| 162 | addElement(m_dim); |
---|
| 163 | for (int i=0; i<10; ++i) { |
---|
| 164 | std::stringstream stream; |
---|
| 165 | stream << "MuteAffectsCh" << i; |
---|
| 166 | Switch* s = new Switch(m_eap, stream.str(), 0x3C, 1<<i); |
---|
| 167 | addElement(s); |
---|
| 168 | m_mute_affected.push_back(s); |
---|
| 169 | stream.str(std::string()); |
---|
| 170 | stream << "DimAffectsCh" << i; |
---|
| 171 | s = new Switch(m_eap, stream.str(), 0x3C, 1<<(10+i)); |
---|
| 172 | addElement(s); |
---|
| 173 | m_dim_affected.push_back(s); |
---|
108 | | return true; |
---|
109 | | } |
---|
110 | | std::string SaffirePro24::LineInstSwitch::getEnumLabel(int n) { |
---|
111 | | if ( n == 1 ) { |
---|
112 | | return "Instrument"; |
---|
113 | | } |
---|
114 | | return "Line"; |
---|
115 | | } |
---|
116 | | |
---|
117 | | SaffirePro24::LevelSwitch::LevelSwitch(Dice::Device::EAP* eap, std::string name, size_t offset, int activevalue) |
---|
118 | | : LineInstSwitch(eap, name, offset, activevalue) |
---|
119 | | { |
---|
120 | | } |
---|
121 | | std::string SaffirePro24::LevelSwitch::getEnumLabel(int n) { |
---|
122 | | switch (n) { |
---|
123 | | case 0: |
---|
124 | | return "Low"; |
---|
125 | | case 1: |
---|
126 | | return "High"; |
---|
127 | | default: |
---|
128 | | return ""; |
---|
| 175 | for (int i=0; i<5; ++i) { |
---|
| 176 | std::stringstream stream; |
---|
| 177 | stream << "Mono_" << i*2 << "_" << i*2+1; |
---|
| 178 | Switch* s = new Switch(m_eap, stream.str(), 0x3C, 1<<(20+i)); |
---|
| 179 | addElement(s); |
---|
| 180 | m_mono.push_back(s); |
---|