Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.9KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla patchbay widget code
  4. # Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Config)
  19. from carla_config import *
  20. # ------------------------------------------------------------------------------------------------------------
  21. # Imports (Global)
  22. if config_UseQt5:
  23. from PyQt5.QtCore import QPointF, QTimer
  24. from PyQt5.QtGui import QImage
  25. from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
  26. from PyQt5.QtWidgets import QFrame, QGraphicsView, QGridLayout
  27. else:
  28. from PyQt4.QtCore import QPointF, QTimer
  29. from PyQt4.QtGui import QFrame, QGraphicsView, QGridLayout, QImage, QPrinter, QPrintDialog
  30. # ------------------------------------------------------------------------------------------------------------
  31. # Imports (Custom Stuff)
  32. import patchcanvas
  33. from carla_host import *
  34. from digitalpeakmeter import DigitalPeakMeter
  35. from pixmapkeyboard import PixmapKeyboardHArea
  36. # ------------------------------------------------------------------------------------------------
  37. # Patchbay widget
  38. class CarlaPatchbayW(QFrame, PluginEditParentMeta):
  39. #class CarlaPatchbayW(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
  40. def __init__(self, parent, host, doSetup = True, onlyPatchbay = True, is3D = False):
  41. QFrame.__init__(self, parent)
  42. self.host = host
  43. # -------------------------------------------------------------
  44. # Connect actions to functions
  45. #self.fKeys.keyboard.noteOn.connect(self.slot_noteOn)
  46. #self.fKeys.keyboard.noteOff.connect(self.slot_noteOff)
  47. # -------------------------------------------------------------
  48. # Connect actions to functions (part 2)
  49. #host.NoteOnCallback.connect(self.slot_handleNoteOnCallback)
  50. #host.NoteOffCallback.connect(self.slot_handleNoteOffCallback)
  51. # -----------------------------------------------------------------
  52. @pyqtSlot(int, int, int, int)
  53. def slot_handleNoteOnCallback(self, pluginId, channel, note, velocity):
  54. if pluginId in self.fSelectedPlugins:
  55. self.fKeys.keyboard.sendNoteOn(note, False)
  56. @pyqtSlot(int, int, int)
  57. def slot_handleNoteOffCallback(self, pluginId, channel, note):
  58. if pluginId in self.fSelectedPlugins:
  59. self.fKeys.keyboard.sendNoteOff(note, False)
  60. # -----------------------------------------------------------------
  61. # PluginEdit callbacks
  62. def editDialogNotePressed(self, pluginId, note):
  63. if pluginId in self.fSelectedPlugins:
  64. self.fKeys.keyboard.sendNoteOn(note, False)
  65. def editDialogNoteReleased(self, pluginId, note):
  66. if pluginId in self.fSelectedPlugins:
  67. self.fKeys.keyboard.sendNoteOff(note, False)
  68. # -----------------------------------------------------------------
  69. @pyqtSlot(int)
  70. def slot_noteOn(self, note):
  71. for pluginId in self.fSelectedPlugins:
  72. self.host.send_midi_note(pluginId, 0, note, 100)
  73. pedit = self.getPluginEditDialog(pluginId)
  74. pedit.noteOn(0, note, 100)
  75. @pyqtSlot(int)
  76. def slot_noteOff(self, note):
  77. for pluginId in self.fSelectedPlugins:
  78. self.host.send_midi_note(pluginId, 0, note, 0)
  79. pedit = self.getPluginEditDialog(pluginId)
  80. pedit.noteOff(0, note)