Advertisement
Guest User

one to many mapping features_controllerAbstraction

a guest
Mar 30th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.95 KB | None | 0 0
  1. === modified file 'mixxx/src/SConscript'
  2. --- mixxx/src/SConscript    2012-03-14 03:30:52 +0000
  3. +++ mixxx/src/SConscript    2012-03-26 16:12:57 +0000
  4. @@ -34,7 +34,7 @@
  5.                              [sources, env.RES('#src/mixxx.rc')],
  6.                              LINKCOM = [env['LINKCOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1'])
  7.  else:
  8. -   mixxx_bin = env.Program('mixxx', sources)
  9. +   mixxx_bin = env.Program('mixxx', sources, CCFLAGS='-msse -mmmx -msse2')
  10.  
  11.  def build_tests():
  12.          test_files = Glob('test/*.cpp', strings=True)
  13. @@ -53,7 +53,7 @@
  14.          env.Append(LIBPATH="#lib/gmock-1.5.0/lib")
  15.          env.Append(LIBS = 'gmock')
  16.  
  17. -   env.Program(target='mixxx-test', source=test_sources)
  18. +   env.Program(target='mixxx-test', source=test_sources, CCFLAGS='-msse -mmmx -msse2')
  19.  
  20.     Command("../mixxx-test", "./mixxx-test", Copy("$TARGET", "$SOURCE"))
  21.  
  22.  
  23. === modified file 'mixxx/src/controllers/midi/midicontroller.cpp'
  24. --- mixxx/src/controllers/midi/midicontroller.cpp   2012-03-18 09:17:24 +0000
  25. +++ mixxx/src/controllers/midi/midicontroller.cpp   2012-03-26 16:20:25 +0000
  26. @@ -193,7 +193,6 @@
  27.  
  28.  //     if (m_bReceiveInhibit) return;
  29.  
  30. -    QPair<ConfigKey, MidiOptions> controlOptions;
  31.  
  32.      MidiKey mappingKey;
  33.      mappingKey.status = status;
  34. @@ -211,57 +210,63 @@
  35.      }
  36.      // If no control is bound to this MIDI message, return
  37.      if (!m_mappings.contains(mappingKey.key)) return;
  38. -    controlOptions = m_mappings.value(mappingKey.key);
  39. -
  40. -    ConfigKey ckey = controlOptions.first;
  41. -    MidiOptions options = controlOptions.second;
  42. -
  43. -    if (options.script) {
  44. -        if (m_pEngine == NULL) return;
  45. -        
  46. -        QScriptValueList args;
  47. -        args << QScriptValue(status & 0x0F);
  48. -        args << QScriptValue(control);
  49. -        args << QScriptValue(value);
  50. -        args << QScriptValue(status);
  51. -        args << QScriptValue(ckey.group);
  52. -        
  53. -        m_pEngine->execute(ckey.item, args);
  54. -        return;
  55. -    }
  56. -
  57. -    ControlObject * p = ControlObject::getControl(ckey);
  58. -
  59. -    if (p) //Only pass values on to valid ControlObjects.
  60. -    {
  61. -        double currMixxxControlValue = p->GetMidiValue();
  62. -
  63. -        double newValue = value;
  64. -
  65. +  
  66. +   //Since multiple controls can be mapped to a single MIDI message use iterator
  67. +   QMultiHash<uint16_t,QPair<ConfigKey, MidiOptions> >::iterator m_controlOptions = m_mappings.find(mappingKey.key);
  68. +   while(m_controlOptions != m_mappings.end() and m_controlOptions.key() == mappingKey.key) {
  69. +       QPair<ConfigKey, MidiOptions> controlOptions = m_mappings.value(mappingKey.key);
  70. +  
  71. +       ConfigKey ckey = controlOptions.first;
  72. +       MidiOptions options = controlOptions.second;
  73. +  
  74. +       if (options.script) {
  75. +           if (m_pEngine == NULL) return;
  76. +          
  77. +           QScriptValueList args;
  78. +           args << QScriptValue(status & 0x0F);
  79. +           args << QScriptValue(control);
  80. +           args << QScriptValue(value);
  81. +           args << QScriptValue(status);
  82. +           args << QScriptValue(ckey.group);
  83. +          
  84. +           m_pEngine->execute(ckey.item, args);
  85. +           return;
  86. +       }
  87. +  
  88. +       ControlObject * p = ControlObject::getControl(ckey);
  89. +  
  90. +       if (p) //Only pass values on to valid ControlObjects.
  91. +       {
  92. +           double currMixxxControlValue = p->GetMidiValue();
  93. +  
  94. +           double newValue = value;
  95. +          
  96.  //         qDebug() << "MIDI Options" << QString::number(options.all, 2).rightJustified(16,'0');
  97.  
  98.          // compute 14-bit number for pitch bend messages
  99. -        if (opCode == MIDI_PITCH_BEND) {
  100. -            unsigned int ivalue;
  101. -            ivalue = (value << 7) | control;
  102. -
  103. -            currMixxxControlValue = p->get();
  104. -
  105. -            // Range is 0x0000..0x3FFF center @ 0x2000, i.e. 0..16383 center @ 8192
  106. -            newValue = (ivalue-8192)/8191;
  107. -            // computeValue not done on pitch messages because it all assumes 7-bit numbers
  108. -        }
  109. -        else newValue = computeValue(options, currMixxxControlValue, value);
  110. -
  111. -        if (options.soft_takeover) {
  112. -            m_st.enable(ckey.group,ckey.item);  // This is the only place to enable it if it isn't already.
  113. -            if (m_st.ignore(ckey.group,ckey.item,newValue,true)) return;
  114. -        }
  115. -
  116. -        ControlObject::sync();
  117. -        
  118. -        p->queueFromMidi(static_cast<MidiOpCode>(opCode), newValue);
  119. -    }
  120. +           if (opCode == MIDI_PITCH_BEND) {
  121. +               unsigned int ivalue;
  122. +               ivalue = (value << 7) | control;
  123. +          
  124. +               currMixxxControlValue = p->get();
  125. +  
  126. +               // Range is 0x0000..0x3FFF center @ 0x2000, i.e. 0..16383 center @ 8192
  127. +               newValue = (ivalue-8192)/8191;
  128. +               // computeValue not done on pitch messages because it all assumes 7-bit numbers
  129. +           }
  130. +           else newValue = computeValue(options, currMixxxControlValue, value);
  131. +          
  132. +           if (options.soft_takeover) {
  133. +               m_st.enable(ckey.group,ckey.item);  // This is the only place to enable it if it isn't already.
  134. +               if (m_st.ignore(ckey.group,ckey.item,newValue,true)) return;
  135. +           }
  136. +      
  137. +           ControlObject::sync();
  138. +          
  139. +           p->queueFromMidi(static_cast<MidiOpCode>(opCode), newValue);
  140. +       }
  141. +       m_controlOptions++; //next mapped control
  142. +   }
  143.      return;
  144.  }
  145.  
  146. @@ -854,4 +859,4 @@
  147.          tagNode.appendChild(text);
  148.          parentNode.appendChild(tagNode);
  149.      }
  150. -}
  151. \ No newline at end of file
  152. +}
  153.  
  154. === modified file 'mixxx/src/controllers/midi/midicontroller.h'
  155. --- mixxx/src/controllers/midi/midicontroller.h 2012-03-18 09:17:24 +0000
  156. +++ mixxx/src/controllers/midi/midicontroller.h 2012-03-26 16:21:44 +0000
  157. @@ -77,7 +77,7 @@
  158.          QDomElement m_bindings;
  159.          QList<MidiOutputHandler*> m_outputs;
  160.  
  161. -        QHash<uint16_t, QPair<ConfigKey, MidiOptions> > m_mappings;
  162. +        QMultiHash<uint16_t, QPair<ConfigKey, MidiOptions> > m_mappings;
  163.          QHash<ConfigKey, MidiOutput> m_outputMappings;
  164.  
  165.          SoftTakeover m_st;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement