Commits

Anonymous committed a883860

Added USB gain functionality

  • Participants
  • Parent commits e902494

Comments (0)

Files changed (10)

File plug/amp_advanced.cpp

     connect(ui->dial_5, SIGNAL(valueChanged(int)), parent, SLOT(set_threshold(int)));
     connect(ui->dial_6, SIGNAL(valueChanged(int)), parent, SLOT(set_bias(int)));
     connect(ui->dial_7, SIGNAL(valueChanged(int)), parent, SLOT(set_sag(int)));
+    connect(ui->dial_8, SIGNAL(valueChanged(int)), parent, SLOT(set_usb_gain(int)));
     connect(ui->checkBox, SIGNAL(toggled(bool)), parent, SLOT(set_brightness(bool)));
 }
 
     ui->dial_7->setValue(value);
 }
 
+void Amp_Advanced::set_usb_gain(int value)
+{
+    ui->dial_8->setValue(value);
+}
+
 void Amp_Advanced::set_brightness(bool value)
 {
     ui->checkBox->setChecked(value);

File plug/amp_advanced.h

     void set_bias(int);
     void set_sag(int);
     void set_brightness(bool);
+    void set_usb_gain(int);
 
 private slots:
     void activate_custom_ng(int);

File plug/amp_advanced.ui

        </item>
       </layout>
      </item>
-    </layout>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_8">
        <item>
        </item>
       </layout>
      </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
       <layout class="QVBoxLayout" name="verticalLayout_9">
        <item>
        </item>
       </layout>
      </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_10">
+       <item>
+        <widget class="QDial" name="dial_8">
+         <property name="accessibleName">
+          <string>Bias dial</string>
+         </property>
+         <property name="accessibleDescription">
+          <string>Allows you to choose bias level</string>
+         </property>
+         <property name="maximum">
+          <number>255</number>
+         </property>
+         <property name="value">
+          <number>0</number>
+         </property>
+         <property name="notchTarget">
+          <double>12.750000000000000</double>
+         </property>
+         <property name="notchesVisible">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSpinBox" name="spinBox_8">
+         <property name="accessibleName">
+          <string>Bias box</string>
+         </property>
+         <property name="accessibleDescription">
+          <string>Allows you to precisely enter the level of bias</string>
+         </property>
+         <property name="maximum">
+          <number>255</number>
+         </property>
+         <property name="value">
+          <number>0</number>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="label_10">
+         <property name="text">
+          <string>&amp;USB Gain</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+         <property name="buddy">
+          <cstring>spinBox_8</cstring>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
     </layout>
    </item>
    <item>
    </item>
   </layout>
  </widget>
+ <tabstops>
+  <tabstop>comboBox</tabstop>
+  <tabstop>comboBox_2</tabstop>
+  <tabstop>checkBox</tabstop>
+  <tabstop>dial</tabstop>
+  <tabstop>spinBox</tabstop>
+  <tabstop>dial_2</tabstop>
+  <tabstop>spinBox_2</tabstop>
+  <tabstop>dial_3</tabstop>
+  <tabstop>spinBox_3</tabstop>
+  <tabstop>dial_6</tabstop>
+  <tabstop>spinBox_6</tabstop>
+  <tabstop>dial_7</tabstop>
+  <tabstop>spinBox_7</tabstop>
+  <tabstop>dial_5</tabstop>
+  <tabstop>spinBox_5</tabstop>
+  <tabstop>dial_4</tabstop>
+  <tabstop>spinBox_4</tabstop>
+  <tabstop>dial_8</tabstop>
+  <tabstop>spinBox_8</tabstop>
+  <tabstop>pushButton</tabstop>
+ </tabstops>
  <resources/>
  <connections>
   <connection>
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>488</x>
-     <y>414</y>
+     <x>407</x>
+     <y>297</y>
     </hint>
     <hint type="destinationlabel">
      <x>329</x>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>47</x>
-     <y>154</y>
+     <x>53</x>
+     <y>102</y>
     </hint>
     <hint type="destinationlabel">
-     <x>46</x>
-     <y>206</y>
+     <x>52</x>
+     <y>128</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>72</x>
-     <y>208</y>
+     <x>78</x>
+     <y>128</y>
     </hint>
     <hint type="destinationlabel">
-     <x>73</x>
-     <y>157</y>
+     <x>79</x>
+     <y>102</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>170</x>
-     <y>156</y>
+     <x>202</x>
+     <y>102</y>
     </hint>
     <hint type="destinationlabel">
-     <x>170</x>
-     <y>208</y>
+     <x>202</x>
+     <y>128</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>141</x>
-     <y>207</y>
+     <x>202</x>
+     <y>128</y>
     </hint>
     <hint type="destinationlabel">
-     <x>141</x>
-     <y>161</y>
+     <x>202</x>
+     <y>102</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>243</x>
-     <y>134</y>
+     <x>304</x>
+     <y>102</y>
     </hint>
     <hint type="destinationlabel">
-     <x>246</x>
-     <y>208</y>
+     <x>304</x>
+     <y>128</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>268</x>
-     <y>203</y>
+     <x>304</x>
+     <y>128</y>
     </hint>
     <hint type="destinationlabel">
-     <x>270</x>
-     <y>155</y>
+     <x>304</x>
+     <y>102</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>53</x>
-     <y>331</y>
+     <x>262</x>
+     <y>223</y>
     </hint>
     <hint type="destinationlabel">
-     <x>55</x>
-     <y>366</y>
+     <x>264</x>
+     <y>249</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>66</x>
-     <y>363</y>
+     <x>275</x>
+     <y>249</y>
     </hint>
     <hint type="destinationlabel">
-     <x>67</x>
-     <y>335</y>
+     <x>276</x>
+     <y>223</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>412</x>
-     <y>314</y>
+     <x>202</x>
+     <y>223</y>
     </hint>
     <hint type="destinationlabel">
-     <x>410</x>
-     <y>355</y>
+     <x>202</x>
+     <y>249</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>425</x>
-     <y>349</y>
+     <x>202</x>
+     <y>249</y>
     </hint>
     <hint type="destinationlabel">
-     <x>425</x>
-     <y>312</y>
+     <x>202</x>
+     <y>223</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>184</x>
-     <y>311</y>
+     <x>406</x>
+     <y>102</y>
     </hint>
     <hint type="destinationlabel">
-     <x>186</x>
-     <y>367</y>
+     <x>406</x>
+     <y>128</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>211</x>
-     <y>363</y>
+     <x>406</x>
+     <y>128</y>
     </hint>
     <hint type="destinationlabel">
-     <x>207</x>
-     <y>321</y>
+     <x>406</x>
+     <y>102</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>297</x>
-     <y>317</y>
+     <x>101</x>
+     <y>223</y>
     </hint>
     <hint type="destinationlabel">
-     <x>297</x>
-     <y>373</y>
+     <x>101</x>
+     <y>249</y>
     </hint>
    </hints>
   </connection>
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>322</x>
-     <y>363</y>
+     <x>101</x>
+     <y>249</y>
     </hint>
     <hint type="destinationlabel">
-     <x>325</x>
-     <y>321</y>
+     <x>101</x>
+     <y>223</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>dial_8</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>spinBox_8</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>361</x>
+     <y>196</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>365</x>
+     <y>245</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>spinBox_8</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>dial_8</receiver>
+   <slot>setValue(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>344</x>
+     <y>239</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>346</x>
+     <y>196</y>
     </hint>
    </hints>
   </connection>

File plug/amplifier.cpp

     bias = 128;
     sag = 1;
     brightness = 0;
+    usb_gain = 0;
 
     changed = false;
 
     changed = true;
 }
 
+void Amplifier::set_usb_gain(int value)
+{
+    usb_gain = value;
+    changed = true;
+}
+
 void Amplifier::choose_amp(int value)
 {
     amp_num = value;
     settings.bias = bias;
     settings.sag = sag;
     settings.brightness = brightness;
+    settings.usb_gain = usb_gain;
 
     ((MainWindow*)parent())->set_amplifier(settings);
 }
     advanced->set_bias(settings.bias);
     advanced->set_sag(settings.sag);
     advanced->set_brightness(settings.brightness);
+    advanced->set_usb_gain(settings.usb_gain);
 }
 
 void Amplifier::get_settings(struct amp_settings *settings)
     settings->bias = bias;
     settings->sag = sag;
     settings->brightness = brightness;
+    settings->usb_gain = usb_gain;
 }
 
 void Amplifier::enable_set_button(bool value)

File plug/amplifier.h

     Ui::Amplifier *ui;
     Amp_Advanced *advanced;
     unsigned char amp_num, gain, volume, treble, middle, bass;
-    unsigned char cabinet, noise_gate, presence, gain2, master_vol, threshold, depth, bias, sag;
+    unsigned char cabinet, noise_gate, presence, gain2, master_vol, threshold, depth, bias, sag, usb_gain;
     bool changed, brightness;
 
 public slots:
     void set_bias(int);
     void set_sag(int);
     void set_brightness(bool);
+    void set_usb_gain(int);
 
     // send settings to the amplifier
     void send_amp(void);

File plug/data_structs.h

     unsigned char bias;
     unsigned char sag;
     bool brightness;
+    unsigned char usb_gain;
 };
 
 struct fx_pedal_settings

File plug/loadfromfile.cpp

                 parseFX();
             else if(xml->name().toString() == "FUSE")
                 parseFUSE();
+            else if(xml->name().toString() == "UsbGain")
+            {
+                amplifier_settings->usb_gain = xml->readElementText().toInt();
+            }
         }
         xml->readNextStartElement();
     }

File plug/mustang.cpp

 {
     int ret, recieved;
     unsigned char array[LENGTH];
-    unsigned char recieved_data[296][LENGTH], data[6][LENGTH];
+    unsigned char recieved_data[296][LENGTH], data[7][LENGTH];
     memset(recieved_data, 0x00, 296*LENGTH);
 
     if(amp_hand == NULL)
 
         if(name != NULL || amp_set != NULL || effects_set != NULL)
         {
-            for(j = 0; j < 6; i++, j++)
+            for(j = 0; j < 7; i++, j++)
                 memcpy(data[j], recieved_data[i], LENGTH);
             decode_data(data, name, amp_set, effects_set);
         }
     ret = libusb_interrupt_transfer(amp_hand, 0x01, execute, LENGTH, &recieved, TMOUT);
     libusb_interrupt_transfer(amp_hand, 0x81, array, LENGTH, &recieved, TMOUT);
 
+    memset(array, 0x00, LENGTH);
+    array[0] = 0x1c;
+    array[1] = 0x03;
+    array[2] = 0x0d;
+    array[6] = 0x01;
+    array[7] = 0x01;
+    array[16] = value.usb_gain;
+
+    ret = libusb_interrupt_transfer(amp_hand, 0x01, array, LENGTH, &recieved, TMOUT);
+    libusb_interrupt_transfer(amp_hand, 0x81, array, LENGTH, &recieved, TMOUT);
+    ret = libusb_interrupt_transfer(amp_hand, 0x01, execute, LENGTH, &recieved, TMOUT);
+    libusb_interrupt_transfer(amp_hand, 0x81, array, LENGTH, &recieved, TMOUT);
+
     return ret;
 }
 
 int Mustang::load_memory_bank(int slot, char *name, struct amp_settings *amp_set, struct fx_pedal_settings *effects_set)
 {
     int ret, recieved;
-    unsigned char array[LENGTH], data[6][LENGTH];
+    unsigned char array[LENGTH], data[7][LENGTH];
 
     memset(array, 0x00, LENGTH);
     array[0] = 0x1c;
     for(int i = 0; recieved; i++)
     {
         libusb_interrupt_transfer(amp_hand, 0x81, array, LENGTH, &recieved, TMOUT);
-        if(i < 6)
+        if(i < 7)
             memcpy(data[i], array, LENGTH);
     }
 
         amp_set->bias = data[1][BIAS];
         amp_set->sag = data[1][SAG];
         amp_set->brightness = data[1][BRIGHTNESS]?true:false;
+        amp_set->usb_gain = data[6][16];
     }
 
 

File plug/savetofile.cpp

     writeAmp(amplifier_settings);
     manageWriteFX(fx_settings);
     writeFUSE();
+    writeUSBGain(amplifier_settings.usb_gain);
 
     xml->writeEndElement();
     xml->writeEndDocument();
     xml->writeEndElement();  // end Info
     xml->writeEndElement();  // end FUSE
 }
+
+void SaveToFile::writeUSBGain(int value)
+{
+    xml->writeStartElement("UsbGain");
+    xml->writeCharacters(QString("%1").arg(value));
+    xml->writeEndElement();
+}

File plug/savetofile.h

     void manageWriteFX(struct fx_pedal_settings[4]);
     void writeFX(struct fx_pedal_settings);
     void writeFUSE();
+    void writeUSBGain(int);
 
 private slots:
     QString choose_destination();