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.

carla_skin.py 76KB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
Rack enhancements 2 (#770) Squashed commit of the following: commit 0449cd63f7c356684903f784be434191df9c4392 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit 84a7b527a7eb79de1da215d6350ba5c639a46477 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit 30681d1523d088a728ba702c3af42ef97da2ddd2 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit 63d2ab2e2189efdfa1c5e57b1519706184aa14bc Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit 2137b781093177891d43bcf84cbcca9f7a398ba6 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit 13fa4f2c34f789c43fa54c6657bb3dd018fcac80 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit 9964af199453ce45ae8a8c10828a79d11870e011 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commit d212577057c5a914f52fd38a9d35645517e09d46 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit 9a7e06098899ea5ac7e510b4374e3f88aeae8282 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
6 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Rack enhancements 2 (#770) Squashed commit of the following: commit 0449cd63f7c356684903f784be434191df9c4392 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit 84a7b527a7eb79de1da215d6350ba5c639a46477 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit 30681d1523d088a728ba702c3af42ef97da2ddd2 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit 63d2ab2e2189efdfa1c5e57b1519706184aa14bc Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit 2137b781093177891d43bcf84cbcca9f7a398ba6 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit 13fa4f2c34f789c43fa54c6657bb3dd018fcac80 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit 9964af199453ce45ae8a8c10828a79d11870e011 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commit d212577057c5a914f52fd38a9d35645517e09d46 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit 9a7e06098899ea5ac7e510b4374e3f88aeae8282 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
6 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
Rack enhancements 2 (#770) Squashed commit of the following: commit 0449cd63f7c356684903f784be434191df9c4392 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit 84a7b527a7eb79de1da215d6350ba5c639a46477 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit 30681d1523d088a728ba702c3af42ef97da2ddd2 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit 63d2ab2e2189efdfa1c5e57b1519706184aa14bc Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit 2137b781093177891d43bcf84cbcca9f7a398ba6 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit 13fa4f2c34f789c43fa54c6657bb3dd018fcac80 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit 9964af199453ce45ae8a8c10828a79d11870e011 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commit d212577057c5a914f52fd38a9d35645517e09d46 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit 9a7e06098899ea5ac7e510b4374e3f88aeae8282 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
6 years ago
Rack enhancements 2 (#770) Squashed commit of the following: commit 0449cd63f7c356684903f784be434191df9c4392 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit 84a7b527a7eb79de1da215d6350ba5c639a46477 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit 30681d1523d088a728ba702c3af42ef97da2ddd2 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit 63d2ab2e2189efdfa1c5e57b1519706184aa14bc Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit 2137b781093177891d43bcf84cbcca9f7a398ba6 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit 13fa4f2c34f789c43fa54c6657bb3dd018fcac80 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit 9964af199453ce45ae8a8c10828a79d11870e011 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commit d212577057c5a914f52fd38a9d35645517e09d46 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit 9a7e06098899ea5ac7e510b4374e3f88aeae8282 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
6 years ago
Rack enhancements 2 (#770) Squashed commit of the following: commit 0449cd63f7c356684903f784be434191df9c4392 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit 84a7b527a7eb79de1da215d6350ba5c639a46477 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit 30681d1523d088a728ba702c3af42ef97da2ddd2 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit 63d2ab2e2189efdfa1c5e57b1519706184aa14bc Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit 2137b781093177891d43bcf84cbcca9f7a398ba6 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit 13fa4f2c34f789c43fa54c6657bb3dd018fcac80 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit 9964af199453ce45ae8a8c10828a79d11870e011 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commit d212577057c5a914f52fd38a9d35645517e09d46 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit 9a7e06098899ea5ac7e510b4374e3f88aeae8282 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
6 years ago
Rack enhancements 2 (#770) Squashed commit of the following: commit 0449cd63f7c356684903f784be434191df9c4392 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit 84a7b527a7eb79de1da215d6350ba5c639a46477 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit 30681d1523d088a728ba702c3af42ef97da2ddd2 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit 63d2ab2e2189efdfa1c5e57b1519706184aa14bc Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit 2137b781093177891d43bcf84cbcca9f7a398ba6 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit 13fa4f2c34f789c43fa54c6657bb3dd018fcac80 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit 9964af199453ce45ae8a8c10828a79d11870e011 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commit d212577057c5a914f52fd38a9d35645517e09d46 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit 9a7e06098899ea5ac7e510b4374e3f88aeae8282 Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
6 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin/slot skin code
  4. # Copyright (C) 2013-2019 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 (Global)
  19. from PyQt5.QtCore import Qt, QRectF, QLineF
  20. from PyQt5.QtGui import QFont, QFontDatabase, QPen, QPixmap
  21. from PyQt5.QtWidgets import QColorDialog, QFrame, QPushButton
  22. # ------------------------------------------------------------------------------------------------------------
  23. # Imports (Custom)
  24. import ui_carla_plugin_calf
  25. import ui_carla_plugin_classic
  26. import ui_carla_plugin_compact
  27. import ui_carla_plugin_default
  28. import ui_carla_plugin_presets
  29. from carla_widgets import *
  30. from widgets.digitalpeakmeter import DigitalPeakMeter
  31. from widgets.pixmapdial import PixmapDial
  32. # ------------------------------------------------------------------------------------------------------------
  33. # Plugin Skin Rules (WORK IN PROGRESS)
  34. # Base is a QFrame (NoFrame, Plain, 0-size lines), with "PluginWidget" as object name.
  35. # Spacing of the top-most layout must be 1px.
  36. # Top and bottom margins must be 3px (can be splitted between different qt layouts).
  37. # Left and right margins must be 6px (can be splitted between different qt layouts).
  38. # If the left or right side has built-in margins, say a transparent png border,
  39. # those margins must be taken into consideration.
  40. #
  41. # There's a top and bottom layout, separated by a horizontal line.
  42. # Compacted skins do not have the bottom layout and separating line.
  43. # T O P A R E A
  44. #
  45. # -----------------------------------------------------------------
  46. # | <> | <> [ WIDGETS ] [ LEDS ] |
  47. # | BUTTONS <> | <> PLUGIN NAME < spacer > [ WIDGETS ] [ LEDS ] |
  48. # | <> | <> [ WIDGETS ] [ LEDS ] |
  49. # -----------------------------------------------------------------
  50. #
  51. # Buttons area has size fixed. (TBA)
  52. # Spacers at the left of the plugin name must be 8x1 in size (fixed).
  53. # The line before the plugin name must be height-10px (fixed).
  54. # WIDGETS area can be extended to the left, if using meters they should have 80px.
  55. # WIDGETS margins are 4px for left+right and 2px for top+bottom, with 4px spacing.
  56. # ------------------------------------------------------------------------------------------------------------
  57. # Try to "shortify" a parameter name
  58. def getParameterShortName(paramName):
  59. paramName = paramName.split("/",1)[0].split(" (",1)[0].split(" [",1)[0].strip()
  60. paramLow = paramName.lower()
  61. # Cut useless prefix
  62. if paramLow.startswith("compressor "):
  63. paramName = paramName.replace("ompressor ", ".", 1)
  64. paramLow = paramName.lower()
  65. elif paramLow.startswith("room "):
  66. paramName = paramName.split(" ",1)[1]
  67. paramLow = paramName.lower()
  68. # Cut useless suffix
  69. if paramLow.endswith(" level"):
  70. paramName = paramName.rsplit(" ",1)[0]
  71. paramLow = paramName.lower()
  72. elif paramLow.endswith(" time"):
  73. paramName = paramName.rsplit(" ",1)[0]
  74. paramLow = paramName.lower()
  75. # Cut generic names
  76. if "attack" in paramLow:
  77. paramName = paramName.replace("ttack", "tk")
  78. elif "bandwidth" in paramLow:
  79. paramName = paramName.replace("andwidth", "w")
  80. elif "damping" in paramLow:
  81. paramName = paramName.replace("amping", "amp")
  82. elif "distortion" in paramLow:
  83. paramName = paramName.replace("istortion", "ist")
  84. elif "feedback" in paramLow:
  85. paramName = paramName.replace("eedback", "b")
  86. elif "frequency" in paramLow:
  87. paramName = paramName.replace("requency", "req")
  88. elif "input" in paramLow:
  89. paramName = paramName.replace("nput", "n")
  90. elif "makeup" in paramLow:
  91. paramName = paramName.replace("akeup", "kUp" if "Make" in paramName else "kup")
  92. elif "output" in paramLow:
  93. paramName = paramName.replace("utput", "ut")
  94. elif "random" in paramLow:
  95. paramName = paramName.replace("andom", "nd")
  96. elif "threshold" in paramLow:
  97. paramName = paramName.replace("hreshold", "hres")
  98. # remove space if last char from 1st word is lowercase and the first char from the 2nd is uppercase,
  99. # or if 2nd is a number
  100. if " " in paramName:
  101. name1, name2 = paramName.split(" ", 1)
  102. if (name1[-1].islower() and name2[0].isupper()) or name2.isdigit():
  103. paramName = paramName.replace(" ", "", 1)
  104. # cut stuff if too big
  105. if len(paramName) > 7:
  106. paramName = paramName.replace("a","").replace("e","").replace("i","").replace("o","").replace("u","")
  107. if len(paramName) > 7:
  108. paramName = paramName[:7]
  109. return paramName.strip()
  110. # ------------------------------------------------------------------------------------------------------------
  111. # Get RGB colors for a plugin category
  112. def getColorFromCategory(category):
  113. r = 40
  114. g = 40
  115. b = 40
  116. if category == PLUGIN_CATEGORY_MODULATOR:
  117. r += 10
  118. elif category == PLUGIN_CATEGORY_EQ:
  119. g += 10
  120. elif category == PLUGIN_CATEGORY_FILTER:
  121. b += 10
  122. elif category == PLUGIN_CATEGORY_DELAY:
  123. r += 15
  124. b -= 15
  125. elif category == PLUGIN_CATEGORY_DISTORTION:
  126. g += 10
  127. b += 10
  128. elif category == PLUGIN_CATEGORY_DYNAMICS:
  129. r += 10
  130. b += 10
  131. elif category == PLUGIN_CATEGORY_UTILITY:
  132. r += 10
  133. g += 10
  134. return (r, g, b)
  135. # ------------------------------------------------------------------------------------------------------------
  136. #
  137. def setPixmapDialStyle(widget, parameterId, parameterCount, whiteLabels, skinStyle):
  138. if skinStyle.startswith("calf"):
  139. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  140. widget.setPixmap(7)
  141. elif skinStyle.startswith("openav"):
  142. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT)
  143. if parameterId == PARAMETER_DRYWET:
  144. widget.setPixmap(13)
  145. elif parameterId == PARAMETER_VOLUME:
  146. widget.setPixmap(12)
  147. else:
  148. widget.setPixmap(11)
  149. else:
  150. if parameterId == PARAMETER_DRYWET:
  151. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  152. elif parameterId == PARAMETER_VOLUME:
  153. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  154. else:
  155. _r = 255 - int((float(parameterId)/float(parameterCount))*200.0)
  156. _g = 55 + int((float(parameterId)/float(parameterCount))*200.0)
  157. _b = 0 #(r-40)*4
  158. widget.setCustomPaintColor(QColor(_r, _g, _b))
  159. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  160. if whiteLabels:
  161. colorEnabled = QColor("#BBB")
  162. colorDisabled = QColor("#555")
  163. else:
  164. colorEnabled = QColor("#111")
  165. colorDisabled = QColor("#AAA")
  166. widget.setLabelColor(colorEnabled, colorDisabled)
  167. widget.setPixmap(3)
  168. # ------------------------------------------------------------------------------------------------------------
  169. # Abstract plugin slot
  170. class AbstractPluginSlot(QFrame, PluginEditParentMeta):
  171. def __init__(self, parent, host, pluginId, skinColor, skinStyle):
  172. QFrame.__init__(self, parent)
  173. self.host = host
  174. self.fParent = parent
  175. if False:
  176. # kdevelop likes this :)
  177. host = CarlaHostNull()
  178. self.host = host
  179. # -------------------------------------------------------------
  180. # Get plugin info
  181. self.fPluginId = pluginId
  182. self.fPluginInfo = host.get_plugin_info(self.fPluginId)
  183. self.fSkinColor = skinColor
  184. self.fSkinStyle = skinStyle
  185. self.fDarkStyle = QColor(skinColor[0], skinColor[1], skinColor[2]).blackF() > 0.4
  186. # -------------------------------------------------------------
  187. # Internal stuff
  188. self.fIsActive = False
  189. self.fIsSelected = False
  190. self.fLastGreenLedState = False
  191. self.fLastBlueLedState = False
  192. self.fParameterIconTimer = ICON_STATE_NULL
  193. self.fParameterList = [] # index, widget
  194. audioCountInfo = host.get_audio_port_count_info(self.fPluginId)
  195. self.fPeaksInputCount = audioCountInfo['ins']
  196. self.fPeaksOutputCount = audioCountInfo['outs']
  197. if self.fPeaksInputCount > 2:
  198. self.fPeaksInputCount = 2
  199. if self.fPeaksOutputCount > 2:
  200. self.fPeaksOutputCount = 2
  201. self.fAdjustViewableKnobCountScheduled = False
  202. # used during testing
  203. self.fIdleTimerId = 0
  204. # -------------------------------------------------------------
  205. # Set-up GUI
  206. self.fEditDialog = PluginEdit(self, host, self.fPluginId)
  207. # -------------------------------------------------------------
  208. # Set-up common widgets (as none)
  209. self.b_enable = None
  210. self.b_gui = None
  211. self.b_edit = None
  212. self.b_remove = None
  213. self.cb_presets = None
  214. self.label_name = None
  215. self.label_presets = None
  216. self.label_type = None
  217. self.led_control = None
  218. self.led_midi = None
  219. self.led_audio_in = None
  220. self.led_audio_out = None
  221. self.peak_in = None
  222. self.peak_out = None
  223. self.w_knobs_left = None
  224. self.w_knobs_right = None
  225. self.spacer_knobs = None
  226. # -------------------------------------------------------------
  227. # Set-up connections
  228. self.customContextMenuRequested.connect(self.slot_showCustomMenu)
  229. host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback)
  230. host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback)
  231. host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback)
  232. host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback)
  233. host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback)
  234. host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback)
  235. host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback)
  236. host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback)
  237. host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback)
  238. host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback)
  239. # Prepare resources
  240. self.sel_pen = QPen(Qt.cyan, 1, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin)
  241. self.sel_pen.setDashPattern([2.0, 4.0])
  242. self.sel_side_pen = QPen(Qt.cyan, 2, Qt.SolidLine, Qt.FlatCap)
  243. self.shadow_pen = QPen(Qt.black, 1)
  244. # -----------------------------------------------------------------
  245. @pyqtSlot(int, str)
  246. def slot_handlePluginRenamedCallback(self, pluginId, newName):
  247. if self.fPluginId == pluginId:
  248. self.setName(newName)
  249. @pyqtSlot(int, str)
  250. def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg):
  251. if self.fPluginId == pluginId:
  252. pass
  253. @pyqtSlot(int, int, float)
  254. def slot_handleParameterValueChangedCallback(self, pluginId, index, value):
  255. if self.fPluginId == pluginId:
  256. self.setParameterValue(index, value, True)
  257. @pyqtSlot(int, int, float)
  258. def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value):
  259. if self.fPluginId == pluginId:
  260. self.setParameterDefault(index, value)
  261. @pyqtSlot(int, int, int)
  262. def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc):
  263. if self.fPluginId == pluginId:
  264. self.setParameterMidiControl(index, cc)
  265. @pyqtSlot(int, int, int)
  266. def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel):
  267. if self.fPluginId == pluginId:
  268. self.setParameterMidiChannel(index, channel)
  269. @pyqtSlot(int, int)
  270. def slot_handleProgramChangedCallback(self, pluginId, index):
  271. if self.fPluginId == pluginId:
  272. self.setProgram(index, True)
  273. @pyqtSlot(int, int)
  274. def slot_handleMidiProgramChangedCallback(self, pluginId, index):
  275. if self.fPluginId == pluginId:
  276. self.setMidiProgram(index, True)
  277. @pyqtSlot(int, int, bool)
  278. def slot_handleOptionChangedCallback(self, pluginId, option, yesNo):
  279. if self.fPluginId == pluginId:
  280. self.setOption(option, yesNo)
  281. @pyqtSlot(int, int)
  282. def slot_handleUiStateChangedCallback(self, pluginId, state):
  283. if self.fPluginId == pluginId:
  284. self.customUiStateChanged(state)
  285. #------------------------------------------------------------------
  286. def ready(self):
  287. self.fIsActive = bool(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5)
  288. isCalfSkin = self.fSkinStyle.startswith("calf") and not isinstance(self, PluginSlot_Compact)
  289. imageSuffix = "white" if self.fDarkStyle else "black"
  290. whiteLabels = self.fDarkStyle
  291. if self.fSkinStyle.startswith("calf") or self.fSkinStyle.startswith("openav") or self.fSkinStyle in (
  292. "3bandeq", "3bandsplitter", "pingpongpan", "nekobi", "calf_black", "zynfx"):
  293. imageSuffix = "white"
  294. whiteLabels = True
  295. if self.b_enable is not None:
  296. self.b_enable.setChecked(self.fIsActive)
  297. self.b_enable.clicked.connect(self.slot_enableClicked)
  298. if isCalfSkin:
  299. self.b_enable.setPixmaps(":/bitmaps/button_calf3.png",
  300. ":/bitmaps/button_calf3_down.png",
  301. ":/bitmaps/button_calf3.png")
  302. else:
  303. self.b_enable.setPixmaps(":/bitmaps/button_off.png",
  304. ":/bitmaps/button_on.png",
  305. ":/bitmaps/button_off.png")
  306. if self.b_gui is not None:
  307. self.b_gui.clicked.connect(self.slot_showCustomUi)
  308. self.b_gui.setEnabled(bool(self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI))
  309. if isCalfSkin:
  310. self.b_gui.setPixmaps(":/bitmaps/button_calf2.png",
  311. ":/bitmaps/button_calf2_down.png",
  312. ":/bitmaps/button_calf2_hover.png")
  313. elif self.fPluginInfo['iconName'] == "distrho" or self.fSkinStyle in ("3bandeq","3bandsplitter","pingpongpan", "nekobi"):
  314. self.b_gui.setPixmaps(":/bitmaps/button_distrho-{}.png".format(imageSuffix),
  315. ":/bitmaps/button_distrho_down-{}.png".format(imageSuffix),
  316. ":/bitmaps/button_distrho_hover-{}.png".format(imageSuffix))
  317. elif self.fPluginInfo['iconName'] == "file":
  318. self.b_gui.setPixmaps(":/bitmaps/button_file-{}.png".format(imageSuffix),
  319. ":/bitmaps/button_file_down-{}.png".format(imageSuffix),
  320. ":/bitmaps/button_file_hover-{}.png".format(imageSuffix))
  321. else:
  322. self.b_gui.setPixmaps(":/bitmaps/button_gui-{}.png".format(imageSuffix),
  323. ":/bitmaps/button_gui_down-{}.png".format(imageSuffix),
  324. ":/bitmaps/button_gui_hover-{}.png".format(imageSuffix))
  325. if self.b_edit is not None:
  326. self.b_edit.clicked.connect(self.slot_showEditDialog)
  327. if isCalfSkin:
  328. self.b_edit.setPixmaps(":/bitmaps/button_calf2.png".format(imageSuffix),
  329. ":/bitmaps/button_calf2_down.png".format(imageSuffix),
  330. ":/bitmaps/button_calf2_hover.png".format(imageSuffix))
  331. else:
  332. self.b_edit.setPixmaps(":/bitmaps/button_edit-{}.png".format(imageSuffix),
  333. ":/bitmaps/button_edit_down-{}.png".format(imageSuffix),
  334. ":/bitmaps/button_edit_hover-{}.png".format(imageSuffix))
  335. else:
  336. # Edit button *must* be available
  337. self.b_edit = QPushButton(self)
  338. self.b_edit.setCheckable(True)
  339. self.b_edit.hide()
  340. if self.b_remove is not None:
  341. self.b_remove.clicked.connect(self.slot_removePlugin)
  342. if self.label_name is not None:
  343. self.label_name.setEnabled(self.fIsActive)
  344. self.label_name.setText(self.fPluginInfo['name'])
  345. nameFont = self.label_name.font()
  346. if self.fSkinStyle.startswith("calf"):
  347. nameFont.setBold(True)
  348. nameFont.setPixelSize(12)
  349. elif self.fSkinStyle.startswith("openav"):
  350. QFontDatabase.addApplicationFont(":/fonts/uranium.ttf")
  351. nameFont.setFamily("Uranium")
  352. nameFont.setPixelSize(15)
  353. nameFont.setCapitalization(QFont.AllUppercase)
  354. else:
  355. nameFont.setBold(True)
  356. nameFont.setPixelSize(11)
  357. self.label_name.setFont(nameFont)
  358. if self.label_presets is not None:
  359. presetFont = self.label_presets.font()
  360. presetFont.setBold(True)
  361. presetFont.setPixelSize(10)
  362. self.label_presets.setFont(presetFont)
  363. if self.label_type is not None:
  364. self.label_type.setText(getPluginTypeAsString(self.fPluginInfo['type']))
  365. if self.led_control is not None:
  366. self.led_control.setColor(self.led_control.YELLOW)
  367. self.led_control.setEnabled(False)
  368. if self.led_midi is not None:
  369. self.led_midi.setColor(self.led_midi.RED)
  370. self.led_midi.setEnabled(False)
  371. if self.led_audio_in is not None:
  372. self.led_audio_in.setColor(self.led_audio_in.GREEN)
  373. self.led_audio_in.setEnabled(False)
  374. if self.led_audio_out is not None:
  375. self.led_audio_out.setColor(self.led_audio_out.BLUE)
  376. self.led_audio_out.setEnabled(False)
  377. if self.peak_in is not None:
  378. self.peak_in.setChannelCount(self.fPeaksInputCount)
  379. self.peak_in.setMeterColor(DigitalPeakMeter.COLOR_GREEN)
  380. self.peak_in.setMeterOrientation(DigitalPeakMeter.HORIZONTAL)
  381. if self.fSkinStyle.startswith("calf"):
  382. self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_CALF)
  383. elif self.fSkinStyle == "rncbc":
  384. self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_RNCBC)
  385. elif self.fSkinStyle.startswith("openav") or self.fSkinStyle == "zynfx":
  386. self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  387. if self.fPeaksInputCount == 0 and not isinstance(self, PluginSlot_Classic):
  388. self.peak_in.hide()
  389. if self.peak_out is not None:
  390. self.peak_out.setChannelCount(self.fPeaksOutputCount)
  391. self.peak_out.setMeterColor(DigitalPeakMeter.COLOR_BLUE)
  392. self.peak_out.setMeterOrientation(DigitalPeakMeter.HORIZONTAL)
  393. if self.fSkinStyle.startswith("calf"):
  394. self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_CALF)
  395. elif self.fSkinStyle == "rncbc":
  396. self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_RNCBC)
  397. elif self.fSkinStyle.startswith("openav") or self.fSkinStyle == "zynfx":
  398. self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV)
  399. if self.fPeaksOutputCount == 0 and not isinstance(self, PluginSlot_Classic):
  400. self.peak_out.hide()
  401. # -------------------------------------------------------------
  402. if self.fSkinStyle == "openav":
  403. styleSheet = """
  404. QFrame#PluginWidget {
  405. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  406. stop: 0 #383838, stop: %f #111111, stop: 1.0 #111111);
  407. }
  408. QLabel#label_name { color: #FFFFFF; }
  409. QLabel#label_name:disabled { color: #505050; }
  410. """ % (0.95 if isinstance(self, PluginSlot_Compact) else 0.35)
  411. elif self.fSkinStyle == "openav-old":
  412. styleSheet = """
  413. QFrame#PluginWidget {
  414. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
  415. stop: 0 #303030, stop: %f #111111, stop: 1.0 #111111);
  416. }
  417. QLabel#label_name { color: #FF5100; }
  418. QLabel#label_name:disabled { color: #505050; }
  419. """ % (0.95 if isinstance(self, PluginSlot_Compact) else 0.35)
  420. else:
  421. colorEnabled = "#BBB"
  422. colorDisabled = "#555"
  423. if self.fSkinStyle in ("3bandeq", "calf_black", "calf_blue", "nekobi", "zynfx"):
  424. styleSheet2 = "background-image: url(:/bitmaps/background_%s.png);" % self.fSkinStyle
  425. else:
  426. styleSheet2 = "background-color: rgb(200, 200, 200);"
  427. styleSheet2 += "background-image: url(:/bitmaps/background_noise1.png);"
  428. if not self.fDarkStyle:
  429. colorEnabled = "#111"
  430. colorDisabled = "#AAA"
  431. styleSheet = """
  432. QFrame#PluginWidget {
  433. %s
  434. background-repeat: repeat-xy;
  435. }
  436. QLabel#label_name,
  437. QLabel#label_audio_in,
  438. QLabel#label_audio_out,
  439. QLabel#label_midi,
  440. QLabel#label_presets { color: %s; }
  441. QLabel#label_name:disabled { color: %s; }
  442. """ % (styleSheet2, colorEnabled, colorDisabled)
  443. styleSheet += """
  444. QComboBox#cb_presets,
  445. QLabel#label_audio_in,
  446. QLabel#label_audio_out,
  447. QLabel#label_midi { font-size: 10px; }
  448. """
  449. self.setStyleSheet(styleSheet)
  450. # -------------------------------------------------------------
  451. # Set-up parameters
  452. if self.w_knobs_left is not None:
  453. parameterCount = self.host.get_parameter_count(self.fPluginId)
  454. index = 0
  455. layout = self.w_knobs_left.layout()
  456. for i in range(parameterCount):
  457. # 50 should be enough for everybody, right?
  458. if index >= 50:
  459. break
  460. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  461. paramData = self.host.get_parameter_data(self.fPluginId, i)
  462. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  463. isInteger = (paramData['hints'] & PARAMETER_IS_INTEGER) != 0
  464. if paramData['type'] != PARAMETER_INPUT:
  465. continue
  466. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  467. continue
  468. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  469. continue
  470. if (paramData['hints'] & PARAMETER_USES_SCALEPOINTS) != 0 and not isInteger:
  471. # NOTE: we assume integer scalepoints are continuous
  472. continue
  473. if isInteger and paramRanges['max']-paramRanges['min'] <= 3:
  474. continue
  475. if paramInfo['name'].startswith("unused"):
  476. continue
  477. paramName = getParameterShortName(paramInfo['name'])
  478. widget = PixmapDial(self, i)
  479. widget.setLabel(paramName)
  480. widget.setMinimum(paramRanges['min'])
  481. widget.setMaximum(paramRanges['max'])
  482. widget.hide()
  483. if isInteger:
  484. widget.setPrecision(paramRanges['max']-paramRanges['min'], True)
  485. setPixmapDialStyle(widget, i, parameterCount, whiteLabels, self.fSkinStyle)
  486. index += 1
  487. self.fParameterList.append([i, widget])
  488. layout.addWidget(widget)
  489. if self.w_knobs_right is not None and (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) != 0:
  490. widget = PixmapDial(self, PARAMETER_DRYWET)
  491. widget.setLabel("Dry/Wet")
  492. widget.setMinimum(0.0)
  493. widget.setMaximum(1.0)
  494. setPixmapDialStyle(widget, PARAMETER_DRYWET, 0, whiteLabels, self.fSkinStyle)
  495. self.fParameterList.append([PARAMETER_DRYWET, widget])
  496. self.w_knobs_right.layout().addWidget(widget)
  497. if self.w_knobs_right is not None and (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) != 0:
  498. widget = PixmapDial(self, PARAMETER_VOLUME)
  499. widget.setLabel("Volume")
  500. widget.setMinimum(0.0)
  501. widget.setMaximum(1.27)
  502. setPixmapDialStyle(widget, PARAMETER_VOLUME, 0, whiteLabels, self.fSkinStyle)
  503. self.fParameterList.append([PARAMETER_VOLUME, widget])
  504. self.w_knobs_right.layout().addWidget(widget)
  505. for paramIndex, paramWidget in self.fParameterList:
  506. paramWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  507. paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu)
  508. paramWidget.dragStateChanged.connect(self.slot_parameterDragStateChanged)
  509. paramWidget.realValueChanged.connect(self.slot_parameterValueChanged)
  510. paramWidget.blockSignals(True)
  511. paramWidget.setValue(self.host.get_internal_parameter_value(self.fPluginId, paramIndex))
  512. paramWidget.blockSignals(False)
  513. # -------------------------------------------------------------
  514. self.setWindowTitle(self.fPluginInfo['name'])
  515. if not self.fAdjustViewableKnobCountScheduled:
  516. self.fAdjustViewableKnobCountScheduled = True
  517. QTimer.singleShot(5, self.adjustViewableKnobCount)
  518. #------------------------------------------------------------------
  519. def getFixedHeight(self):
  520. return 32
  521. def getHints(self):
  522. return self.fPluginInfo['hints']
  523. def getPluginId(self):
  524. return self.fPluginId
  525. #------------------------------------------------------------------
  526. def setPluginId(self, idx):
  527. self.fPluginId = idx
  528. self.fEditDialog.setPluginId(idx)
  529. def setName(self, name):
  530. self.fPluginInfo['name'] = name
  531. self.fEditDialog.setName(name)
  532. if self.label_name is not None:
  533. self.label_name.setText(name)
  534. def setSelected(self, yesNo):
  535. if self.fIsSelected == yesNo:
  536. return
  537. self.fIsSelected = yesNo
  538. self.update()
  539. #------------------------------------------------------------------
  540. def setActive(self, active, sendCallback=False, sendHost=True):
  541. self.fIsActive = active
  542. if sendCallback:
  543. self.fParameterIconTimer = ICON_STATE_ON
  544. self.activeChanged(active)
  545. if sendHost:
  546. self.host.set_active(self.fPluginId, active)
  547. if active:
  548. self.fEditDialog.clearNotes()
  549. self.midiActivityChanged(False)
  550. if self.label_name is not None:
  551. self.label_name.setEnabled(self.fIsActive)
  552. # called from rack, checks if param is possible first
  553. def setInternalParameter(self, parameterId, value):
  554. if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
  555. return
  556. elif parameterId == PARAMETER_ACTIVE:
  557. return self.setActive(bool(value), True, True)
  558. elif parameterId == PARAMETER_DRYWET:
  559. if (self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) == 0: return
  560. self.host.set_drywet(self.fPluginId, value)
  561. elif parameterId == PARAMETER_VOLUME:
  562. if (self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) == 0: return
  563. self.host.set_volume(self.fPluginId, value)
  564. elif parameterId == PARAMETER_BALANCE_LEFT:
  565. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  566. self.host.set_balance_left(self.fPluginId, value)
  567. elif parameterId == PARAMETER_BALANCE_RIGHT:
  568. if (self.fPluginInfo['hints'] & PLUGIN_CAN_BALANCE) == 0: return
  569. self.host.set_balance_right(self.fPluginId, value)
  570. elif parameterId == PARAMETER_PANNING:
  571. if (self.fPluginInfo['hints'] & PLUGIN_CAN_PANNING) == 0: return
  572. self.host.set_panning(self.fPluginId, value)
  573. elif parameterId == PARAMETER_CTRL_CHANNEL:
  574. self.host.set_ctrl_channel(self.fPluginId, value)
  575. self.fEditDialog.setParameterValue(parameterId, value)
  576. #------------------------------------------------------------------
  577. def setParameterValue(self, parameterId, value, sendCallback):
  578. if parameterId == PARAMETER_ACTIVE:
  579. return self.setActive(bool(value), True, False)
  580. self.fEditDialog.setParameterValue(parameterId, value)
  581. if sendCallback:
  582. self.fParameterIconTimer = ICON_STATE_ON
  583. self.editDialogParameterValueChanged(self.fPluginId, parameterId, value)
  584. def setParameterDefault(self, parameterId, value):
  585. self.fEditDialog.setParameterDefault(parameterId, value)
  586. def setParameterMidiControl(self, parameterId, control):
  587. self.fEditDialog.setParameterMidiControl(parameterId, control)
  588. def setParameterMidiChannel(self, parameterId, channel):
  589. self.fEditDialog.setParameterMidiChannel(parameterId, channel)
  590. #------------------------------------------------------------------
  591. def setProgram(self, index, sendCallback):
  592. self.fEditDialog.setProgram(index)
  593. if sendCallback:
  594. self.fParameterIconTimer = ICON_STATE_ON
  595. self.editDialogProgramChanged(self.fPluginId, index)
  596. self.updateParameterValues()
  597. def setMidiProgram(self, index, sendCallback):
  598. self.fEditDialog.setMidiProgram(index)
  599. if sendCallback:
  600. self.fParameterIconTimer = ICON_STATE_ON
  601. self.editDialogMidiProgramChanged(self.fPluginId, index)
  602. self.updateParameterValues()
  603. #------------------------------------------------------------------
  604. def setOption(self, option, yesNo):
  605. self.fEditDialog.setOption(option, yesNo)
  606. #------------------------------------------------------------------
  607. def showCustomUI(self):
  608. self.host.show_custom_ui(self.fPluginId, True)
  609. if self.b_gui is not None:
  610. self.b_gui.setChecked(True)
  611. def showEditDialog(self):
  612. self.fEditDialog.show()
  613. self.fEditDialog.activateWindow()
  614. if self.b_edit is not None:
  615. self.b_edit.setChecked(True)
  616. def showRenameDialog(self):
  617. oldName = self.fPluginInfo['name']
  618. newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName)
  619. if not (newNameTry[1] and newNameTry[0] and oldName != newNameTry[0]):
  620. return
  621. newName = newNameTry[0]
  622. if not self.host.rename_plugin(self.fPluginId, newName):
  623. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  624. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  625. return
  626. def showReplaceDialog(self):
  627. data = gCarla.gui.showAddPluginDialog()
  628. if data is None:
  629. return
  630. btype, ptype, filename, label, uniqueId, extraPtr = data
  631. if not self.host.replace_plugin(self.fPluginId):
  632. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to replace plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  633. return
  634. ok = self.host.add_plugin(btype, ptype, filename, None, label, uniqueId, extraPtr, 0x0)
  635. self.host.replace_plugin(self.host.get_max_plugin_number())
  636. if not ok:
  637. CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), self.tr("Failed to load plugin"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  638. #------------------------------------------------------------------
  639. def activeChanged(self, onOff):
  640. self.fIsActive = onOff
  641. if self.b_enable is None:
  642. return
  643. self.b_enable.blockSignals(True)
  644. self.b_enable.setChecked(onOff)
  645. self.b_enable.blockSignals(False)
  646. def customUiStateChanged(self, state):
  647. if self.b_gui is None:
  648. return
  649. self.b_gui.blockSignals(True)
  650. if state == 0:
  651. self.b_gui.setChecked(False)
  652. self.b_gui.setEnabled(True)
  653. elif state == 1:
  654. self.b_gui.setChecked(True)
  655. self.b_gui.setEnabled(True)
  656. elif state == -1:
  657. self.b_gui.setChecked(False)
  658. self.b_gui.setEnabled(False)
  659. self.b_gui.blockSignals(False)
  660. def parameterActivityChanged(self, onOff):
  661. if self.led_control is None:
  662. return
  663. self.led_control.setChecked(onOff)
  664. def midiActivityChanged(self, onOff):
  665. if self.led_midi is None:
  666. return
  667. self.led_midi.setChecked(onOff)
  668. def optionChanged(self, option, yesNo):
  669. pass
  670. # -----------------------------------------------------------------
  671. # PluginEdit callbacks
  672. def editDialogVisibilityChanged(self, pluginId, visible):
  673. if self.b_edit is None:
  674. return
  675. self.b_edit.blockSignals(True)
  676. self.b_edit.setChecked(visible)
  677. self.b_edit.blockSignals(False)
  678. def editDialogPluginHintsChanged(self, pluginId, hints):
  679. self.fPluginInfo['hints'] = hints
  680. for paramIndex, paramWidget in self.fParameterList:
  681. if paramIndex == PARAMETER_DRYWET:
  682. paramWidget.setVisible(hints & PLUGIN_CAN_DRYWET)
  683. elif paramIndex == PARAMETER_VOLUME:
  684. paramWidget.setVisible(hints & PLUGIN_CAN_VOLUME)
  685. if self.b_gui is not None:
  686. self.b_gui.setEnabled(bool(hints & PLUGIN_HAS_CUSTOM_UI))
  687. def editDialogParameterValueChanged(self, pluginId, parameterId, value):
  688. for paramIndex, paramWidget in self.fParameterList:
  689. if paramIndex != parameterId:
  690. continue
  691. paramWidget.blockSignals(True)
  692. paramWidget.setValue(value)
  693. paramWidget.blockSignals(False)
  694. break
  695. def editDialogProgramChanged(self, pluginId, index):
  696. if self.cb_presets is None:
  697. return
  698. self.cb_presets.blockSignals(True)
  699. self.cb_presets.setCurrentIndex(index)
  700. self.cb_presets.blockSignals(False)
  701. # FIXME
  702. self.updateParameterValues()
  703. def editDialogMidiProgramChanged(self, pluginId, index):
  704. if self.cb_presets is None:
  705. return
  706. self.cb_presets.blockSignals(True)
  707. self.cb_presets.setCurrentIndex(index)
  708. self.cb_presets.blockSignals(False)
  709. # FIXME
  710. self.updateParameterValues()
  711. def editDialogNotePressed(self, pluginId, note):
  712. pass
  713. def editDialogNoteReleased(self, pluginId, note):
  714. pass
  715. def editDialogMidiActivityChanged(self, pluginId, onOff):
  716. self.midiActivityChanged(onOff)
  717. #------------------------------------------------------------------
  718. def idleFast(self):
  719. # Input peaks
  720. if self.fPeaksInputCount > 0:
  721. if self.fPeaksInputCount > 1:
  722. peak1 = self.host.get_input_peak_value(self.fPluginId, True)
  723. peak2 = self.host.get_input_peak_value(self.fPluginId, False)
  724. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  725. if self.peak_in is not None:
  726. self.peak_in.displayMeter(1, peak1)
  727. self.peak_in.displayMeter(2, peak2)
  728. else:
  729. peak = self.host.get_input_peak_value(self.fPluginId, True)
  730. ledState = bool(peak != 0.0)
  731. if self.peak_in is not None:
  732. self.peak_in.displayMeter(1, peak)
  733. if self.fLastGreenLedState != ledState and self.led_audio_in is not None:
  734. self.fLastGreenLedState = ledState
  735. self.led_audio_in.setChecked(ledState)
  736. # Output peaks
  737. if self.fPeaksOutputCount > 0:
  738. if self.fPeaksOutputCount > 1:
  739. peak1 = self.host.get_output_peak_value(self.fPluginId, True)
  740. peak2 = self.host.get_output_peak_value(self.fPluginId, False)
  741. ledState = bool(peak1 != 0.0 or peak2 != 0.0)
  742. if self.peak_out is not None:
  743. self.peak_out.displayMeter(1, peak1)
  744. self.peak_out.displayMeter(2, peak2)
  745. else:
  746. peak = self.host.get_output_peak_value(self.fPluginId, True)
  747. ledState = bool(peak != 0.0)
  748. if self.peak_out is not None:
  749. self.peak_out.displayMeter(1, peak)
  750. if self.fLastBlueLedState != ledState and self.led_audio_out is not None:
  751. self.fLastBlueLedState = ledState
  752. self.led_audio_out.setChecked(ledState)
  753. def idleSlow(self):
  754. if self.fParameterIconTimer == ICON_STATE_ON:
  755. self.parameterActivityChanged(True)
  756. self.fParameterIconTimer = ICON_STATE_WAIT
  757. elif self.fParameterIconTimer == ICON_STATE_WAIT:
  758. self.fParameterIconTimer = ICON_STATE_OFF
  759. elif self.fParameterIconTimer == ICON_STATE_OFF:
  760. self.parameterActivityChanged(False)
  761. self.fParameterIconTimer = ICON_STATE_NULL
  762. self.fEditDialog.idleSlow()
  763. #------------------------------------------------------------------
  764. def drawOutline(self, painter):
  765. painter.save()
  766. painter.setBrush(Qt.transparent)
  767. w = float(self.width())
  768. h = float(self.height())
  769. painter.setPen(self.shadow_pen)
  770. painter.drawLine(QLineF(0.5, h-1, w-1, h-1))
  771. if self.fIsSelected:
  772. painter.setCompositionMode(QPainter.CompositionMode_Plus)
  773. painter.setPen(self.sel_pen)
  774. painter.drawRect(QRectF(0.5, 0.5, w-1, h-1))
  775. sidelines = [QLineF(1, 1, 1, h-1), QLineF(w-1, 1, w-1, h-1)]
  776. painter.setPen(self.sel_side_pen)
  777. painter.drawLines(sidelines)
  778. painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
  779. painter.restore()
  780. def updateParameterValues(self):
  781. for paramIndex, paramWidget in self.fParameterList:
  782. if paramIndex < 0:
  783. continue
  784. paramWidget.blockSignals(True)
  785. paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex))
  786. paramWidget.blockSignals(False)
  787. #------------------------------------------------------------------
  788. @pyqtSlot(bool)
  789. def slot_enableClicked(self, yesNo):
  790. self.setActive(yesNo, False, True)
  791. @pyqtSlot()
  792. def slot_showCustomMenu(self):
  793. menu = QMenu(self)
  794. # -------------------------------------------------------------
  795. # Expand/Minimize
  796. actCompact = menu.addAction(self.tr("Expand") if isinstance(self, PluginSlot_Compact) else self.tr("Minimize"))
  797. actColor = menu.addAction(self.tr("Change Color..."))
  798. actSkin = menu.addAction(self.tr("Change Skin..."))
  799. menu.addSeparator()
  800. # -------------------------------------------------------------
  801. # Move up and down
  802. actMoveUp = menu.addAction(self.tr("Move Up"))
  803. actMoveDown = menu.addAction(self.tr("Move Down"))
  804. if self.fPluginId == 0:
  805. actMoveUp.setEnabled(False)
  806. if self.fPluginId >= self.fParent.getPluginCount():
  807. actMoveDown.setEnabled(False)
  808. # -------------------------------------------------------------
  809. # Bypass and Enable/Disable
  810. actBypass = menu.addAction(self.tr("Bypass"))
  811. actEnable = menu.addAction(self.tr("Disable") if self.fIsActive else self.tr("Enable"))
  812. menu.addSeparator()
  813. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  814. actBypass.setCheckable(True)
  815. actBypass.setChecked(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET) == 0.0)
  816. else:
  817. actBypass.setVisible(False)
  818. # -------------------------------------------------------------
  819. # Reset and Randomize parameters
  820. actReset = menu.addAction(self.tr("Reset parameters"))
  821. actRandom = menu.addAction(self.tr("Randomize parameters"))
  822. menu.addSeparator()
  823. # -------------------------------------------------------------
  824. # Edit and Show Custom UI
  825. actEdit = menu.addAction(self.tr("Edit"))
  826. actGui = menu.addAction(self.tr("Show Custom UI"))
  827. menu.addSeparator()
  828. if self.b_edit is not None:
  829. actEdit.setCheckable(True)
  830. actEdit.setChecked(self.b_edit.isChecked())
  831. else:
  832. actEdit.setVisible(False)
  833. if self.b_gui is not None:
  834. actGui.setCheckable(True)
  835. actGui.setChecked(self.b_gui.isChecked())
  836. actGui.setEnabled(self.b_gui.isEnabled())
  837. else:
  838. actGui.setVisible(False)
  839. # -------------------------------------------------------------
  840. # Other stuff
  841. actClone = menu.addAction(self.tr("Clone"))
  842. actRename = menu.addAction(self.tr("Rename..."))
  843. actReplace = menu.addAction(self.tr("Replace..."))
  844. actRemove = menu.addAction(self.tr("Remove"))
  845. if self.fIdleTimerId != 0:
  846. actRemove.setVisible(False)
  847. if self.host.exportLV2:
  848. menu.addSeparator()
  849. actExportLV2 = menu.addAction(self.tr("Export LV2..."))
  850. else:
  851. actExportLV2 = None
  852. # -------------------------------------------------------------
  853. # exec
  854. actSel = menu.exec_(QCursor.pos())
  855. if not actSel:
  856. return
  857. # -------------------------------------------------------------
  858. # Expand/Minimize
  859. elif actSel == actCompact:
  860. # FIXME
  861. gCarla.gui.compactPlugin(self.fPluginId)
  862. # -------------------------------------------------------------
  863. # Tweaks
  864. elif actSel == actColor:
  865. initial = QColor(self.fSkinColor[0], self.fSkinColor[1], self.fSkinColor[2])
  866. color = QColorDialog.getColor(initial, self, self.tr("Change Color"), QColorDialog.DontUseNativeDialog)
  867. if not color.isValid():
  868. return
  869. color = color.getRgb()[0:3]
  870. colorStr = "%i;%i;%i" % color
  871. gCarla.gui.changePluginColor(self.fPluginId, color, colorStr)
  872. elif actSel == actSkin:
  873. skinList = [
  874. "default",
  875. "3bandeq",
  876. "rncbc",
  877. "calf_black",
  878. "calf_blue",
  879. "classic",
  880. "openav-old",
  881. "openav",
  882. "zynfx",
  883. "presets",
  884. "mpresets",
  885. ]
  886. try:
  887. index = skinList.index(self.fSkinStyle)
  888. except:
  889. index = 0
  890. skin = QInputDialog.getItem(self, self.tr("Change Skin"),
  891. self.tr("Change Skin to:"),
  892. skinList, index, False)
  893. if not all(skin):
  894. return
  895. gCarla.gui.changePluginSkin(self.fPluginId, skin[0])
  896. # -------------------------------------------------------------
  897. # Move up and down
  898. elif actSel == actMoveUp:
  899. gCarla.gui.switchPlugins(self.fPluginId, self.fPluginId-1)
  900. elif actSel == actMoveDown:
  901. gCarla.gui.switchPlugins(self.fPluginId, self.fPluginId+1)
  902. # -------------------------------------------------------------
  903. # Bypass and Enable/Disable
  904. elif actSel == actBypass:
  905. value = 0.0 if actBypass.isChecked() else 1.0
  906. self.host.set_drywet(self.fPluginId, value)
  907. self.setParameterValue(PARAMETER_DRYWET, value, True)
  908. elif actSel == actEnable:
  909. self.setActive(not self.fIsActive, True, True)
  910. # -------------------------------------------------------------
  911. # Reset and Randomize parameters
  912. elif actSel == actReset:
  913. self.host.reset_parameters(self.fPluginId)
  914. elif actSel == actRandom:
  915. self.host.randomize_parameters(self.fPluginId)
  916. # -------------------------------------------------------------
  917. # Edit and Show Custom UI
  918. elif actSel == actEdit:
  919. self.b_edit.click()
  920. elif actSel == actGui:
  921. self.b_gui.click()
  922. # -------------------------------------------------------------
  923. # Clone
  924. elif actSel == actClone:
  925. if not self.host.clone_plugin(self.fPluginId):
  926. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  927. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  928. # -------------------------------------------------------------
  929. # Rename
  930. elif actSel == actRename:
  931. self.showRenameDialog()
  932. # -------------------------------------------------------------
  933. # Replace
  934. elif actSel == actReplace:
  935. self.showReplaceDialog()
  936. # -------------------------------------------------------------
  937. # Remove
  938. elif actSel == actRemove:
  939. if not self.host.remove_plugin(self.fPluginId):
  940. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  941. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  942. # -------------------------------------------------------------
  943. # Export LV2
  944. elif actSel == actExportLV2:
  945. filepath = QInputDialog.getItem(self, self.tr("Export LV2 Plugin"),
  946. self.tr("Select LV2 Path where plugin will be exported to:"),
  947. CARLA_DEFAULT_LV2_PATH, editable=False)
  948. if not all(filepath):
  949. return
  950. plugname = self.fPluginInfo['name']
  951. filepath = os.path.join(filepath[0], plugname.replace(" ","_"))
  952. if not filepath.endswith(".lv2"):
  953. filepath += ".lv2"
  954. if os.path.exists(filepath):
  955. if QMessageBox.question(self, self.tr("Export to LV2"),
  956. self.tr("Plugin bundle already exists, overwrite?")) == QMessageBox.Ok:
  957. return
  958. if not self.host.export_plugin_lv2(self.fPluginId, filepath):
  959. return CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  960. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  961. QMessageBox.information(self, self.tr("Plugin exported"),
  962. self.tr("Plugin exported successfully, saved in folder:\n%s" % filepath))
  963. # -------------------------------------------------------------
  964. @pyqtSlot()
  965. def slot_knobCustomMenu(self):
  966. sender = self.sender()
  967. index = sender.fIndex
  968. minimum = sender.fMinimum
  969. maximum = sender.fMaximum
  970. current = sender.fRealValue
  971. label = sender.fLabel
  972. if index in (PARAMETER_NULL, PARAMETER_CTRL_CHANNEL) or index <= PARAMETER_MAX:
  973. return
  974. elif index in (PARAMETER_DRYWET, PARAMETER_VOLUME):
  975. default = 1.0
  976. elif index == PARAMETER_BALANCE_LEFT:
  977. default = -1.0
  978. elif index == PARAMETER_BALANCE_RIGHT:
  979. default = 1.0
  980. elif index == PARAMETER_PANNING:
  981. default = 0.0
  982. else:
  983. default = self.host.get_default_parameter_value(self.fPluginId, index)
  984. if index < PARAMETER_NULL:
  985. # show in integer percentage
  986. textReset = self.tr("Reset (%i%%)" % round(default*100.0))
  987. textMinim = self.tr("Set to Minimum (%i%%)" % round(minimum*100.0))
  988. textMaxim = self.tr("Set to Maximum (%i%%)" % round(maximum*100.0))
  989. else:
  990. # show in full float value
  991. textReset = self.tr("Reset (%f)" % default)
  992. textMinim = self.tr("Set to Minimum (%f)" % minimum)
  993. textMaxim = self.tr("Set to Maximum (%f)" % maximum)
  994. menu = QMenu(self)
  995. actReset = menu.addAction(textReset)
  996. menu.addSeparator()
  997. actMinimum = menu.addAction(textMinim)
  998. actCenter = menu.addAction(self.tr("Set to Center"))
  999. actMaximum = menu.addAction(textMaxim)
  1000. menu.addSeparator()
  1001. actSet = menu.addAction(self.tr("Set value..."))
  1002. if index > PARAMETER_NULL or index not in (PARAMETER_BALANCE_LEFT, PARAMETER_BALANCE_RIGHT, PARAMETER_PANNING):
  1003. menu.removeAction(actCenter)
  1004. actSelected = menu.exec_(QCursor.pos())
  1005. if actSelected == actSet:
  1006. if index < PARAMETER_NULL:
  1007. value, ok = QInputDialog.getInt(self, self.tr("Set value"), label, round(current*100), round(minimum*100), round(maximum*100), 1)
  1008. if not ok:
  1009. return
  1010. value = float(value)/100.0
  1011. else:
  1012. paramInfo = self.host.get_parameter_info(self.fPluginId, index)
  1013. paramRanges = self.host.get_parameter_ranges(self.fPluginId, index)
  1014. scalePoints = []
  1015. for i in range(paramInfo['scalePointCount']):
  1016. scalePoints.append(self.host.get_parameter_scalepoint_info(self.fPluginId, index, i))
  1017. dialog = CustomInputDialog(self, label, current, minimum, maximum,
  1018. paramRanges['step'], paramRanges['stepSmall'], scalePoints)
  1019. if not dialog.exec_():
  1020. return
  1021. value = dialog.returnValue()
  1022. elif actSelected == actMinimum:
  1023. value = minimum
  1024. elif actSelected == actMaximum:
  1025. value = maximum
  1026. elif actSelected == actReset:
  1027. value = default
  1028. elif actSelected == actCenter:
  1029. value = 0.0
  1030. else:
  1031. return
  1032. sender.setValue(value, True)
  1033. #------------------------------------------------------------------
  1034. @pyqtSlot(bool)
  1035. def slot_showCustomUi(self, show):
  1036. self.host.show_custom_ui(self.fPluginId, show)
  1037. @pyqtSlot(bool)
  1038. def slot_showEditDialog(self, show):
  1039. self.fEditDialog.setVisible(show)
  1040. @pyqtSlot()
  1041. def slot_removePlugin(self):
  1042. if not self.host.remove_plugin(self.fPluginId):
  1043. CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"),
  1044. self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok)
  1045. #------------------------------------------------------------------
  1046. @pyqtSlot(bool)
  1047. def slot_parameterDragStateChanged(self, touch):
  1048. index = self.sender().getIndex()
  1049. if index >= 0:
  1050. self.host.set_parameter_touch(self.fPluginId, index, touch)
  1051. @pyqtSlot(float)
  1052. def slot_parameterValueChanged(self, value):
  1053. index = self.sender().getIndex()
  1054. if index < 0:
  1055. self.setInternalParameter(index, value)
  1056. else:
  1057. self.host.set_parameter_value(self.fPluginId, index, value)
  1058. self.setParameterValue(index, value, False)
  1059. @pyqtSlot(int)
  1060. def slot_programChanged(self, index):
  1061. self.host.set_program(self.fPluginId, index)
  1062. self.setProgram(index, False)
  1063. @pyqtSlot(int)
  1064. def slot_midiProgramChanged(self, index):
  1065. self.host.set_midi_program(self.fPluginId, index)
  1066. self.setMidiProgram(index, False)
  1067. #------------------------------------------------------------------
  1068. def adjustViewableKnobCount(self):
  1069. if self.w_knobs_left is None or self.spacer_knobs is None:
  1070. return
  1071. curWidth = 2
  1072. maxWidth = self.w_knobs_left.width() + self.spacer_knobs.geometry().width() + 2
  1073. plen = len(self.fParameterList)
  1074. for i in range(plen):
  1075. index, widget = self.fParameterList[i]
  1076. if index < 0:
  1077. break
  1078. curWidth += widget.width() + 4
  1079. if curWidth + widget.width() * 2 + 8 < maxWidth:
  1080. #if not widget.isVisible():
  1081. widget.show()
  1082. continue
  1083. for i2 in range(i, plen):
  1084. index2, widget2 = self.fParameterList[i2]
  1085. if index2 < 0:
  1086. break
  1087. #if widget2.isVisible():
  1088. widget2.hide()
  1089. break
  1090. self.fAdjustViewableKnobCountScheduled = False
  1091. def testTimer(self):
  1092. self.fIdleTimerId = self.startTimer(25)
  1093. #------------------------------------------------------------------
  1094. def mouseDoubleClickEvent(self, event):
  1095. QFrame.mouseDoubleClickEvent(self, event)
  1096. # FIXME
  1097. gCarla.gui.compactPlugin(self.fPluginId)
  1098. def closeEvent(self, event):
  1099. if self.fIdleTimerId != 0:
  1100. self.killTimer(self.fIdleTimerId)
  1101. self.fIdleTimerId = 0
  1102. self.host.engine_close()
  1103. QFrame.closeEvent(self, event)
  1104. def resizeEvent(self, event):
  1105. if not self.fAdjustViewableKnobCountScheduled:
  1106. self.fAdjustViewableKnobCountScheduled = True
  1107. QTimer.singleShot(100, self.adjustViewableKnobCount)
  1108. QFrame.resizeEvent(self, event)
  1109. def timerEvent(self, event):
  1110. if event.timerId() == self.fIdleTimerId:
  1111. self.host.engine_idle()
  1112. self.idleFast()
  1113. self.idleSlow()
  1114. QFrame.timerEvent(self, event)
  1115. def paintEvent(self, event):
  1116. painter = QPainter(self)
  1117. # Colorization
  1118. if self.fSkinColor != (0,0,0):
  1119. painter.setCompositionMode(QPainter.CompositionMode_Multiply)
  1120. r,g,b = self.fSkinColor
  1121. painter.setBrush(QColor(r,g,b))
  1122. painter.setPen(Qt.NoPen)
  1123. painter.drawRect(QRectF(0,0,self.width(),self.height()))
  1124. painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
  1125. self.drawOutline(painter)
  1126. QFrame.paintEvent(self, event)
  1127. # ------------------------------------------------------------------------------------------------------------
  1128. class PluginSlot_Calf(AbstractPluginSlot):
  1129. def __init__(self, parent, host, pluginId, skinColor, skinStyle):
  1130. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinColor, skinStyle)
  1131. self.ui = ui_carla_plugin_calf.Ui_PluginWidget()
  1132. self.ui.setupUi(self)
  1133. audioCount = self.host.get_audio_port_count_info(self.fPluginId)
  1134. midiCount = self.host.get_midi_port_count_info(self.fPluginId)
  1135. # -------------------------------------------------------------
  1136. # Internal stuff
  1137. self.fButtonFont = self.ui.b_gui.font()
  1138. self.fButtonFont.setBold(False)
  1139. self.fButtonFont.setPixelSize(10)
  1140. self.fButtonColorOn = QColor( 18, 41, 87)
  1141. self.fButtonColorOff = QColor(150, 150, 150)
  1142. # -------------------------------------------------------------
  1143. # Set-up GUI
  1144. self.ui.label_active.setFont(self.fButtonFont)
  1145. self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png")
  1146. self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont)
  1147. self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont)
  1148. if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI:
  1149. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  1150. else:
  1151. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  1152. if audioCount['ins'] == 0:
  1153. self.ui.label_audio_in.hide()
  1154. if audioCount['outs'] == 0:
  1155. self.ui.label_audio_out.hide()
  1156. if midiCount['ins'] == 0:
  1157. self.ui.label_midi.hide()
  1158. self.ui.led_midi.hide()
  1159. if self.fIdleTimerId != 0:
  1160. self.ui.b_remove.setEnabled(False)
  1161. self.ui.b_remove.setVisible(False)
  1162. # -------------------------------------------------------------
  1163. self.b_enable = self.ui.b_enable
  1164. self.b_gui = self.ui.b_gui
  1165. self.b_edit = self.ui.b_edit
  1166. self.b_remove = self.ui.b_remove
  1167. self.label_name = self.ui.label_name
  1168. self.led_midi = self.ui.led_midi
  1169. self.peak_in = self.ui.peak_in
  1170. self.peak_out = self.ui.peak_out
  1171. self.w_knobs_left = self.ui.w_knobs
  1172. self.spacer_knobs = self.ui.layout_bottom.itemAt(1).spacerItem()
  1173. self.ready()
  1174. self.ui.led_midi.setColor(self.ui.led_midi.CALF)
  1175. #------------------------------------------------------------------
  1176. def getFixedHeight(self):
  1177. return 94 if max(self.peak_in.channelCount(), self.peak_out.channelCount()) < 2 else 106
  1178. #------------------------------------------------------------------
  1179. def editDialogPluginHintsChanged(self, pluginId, hints):
  1180. if hints & PLUGIN_HAS_CUSTOM_UI:
  1181. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont)
  1182. else:
  1183. self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont)
  1184. AbstractPluginSlot.editDialogPluginHintsChanged(self, pluginId, hints)
  1185. #------------------------------------------------------------------
  1186. def paintEvent(self, event):
  1187. isBlack = bool(self.fSkinStyle == "calf_black")
  1188. painter = QPainter(self)
  1189. painter.setBrush(Qt.transparent)
  1190. painter.setPen(QPen(QColor(20, 20, 20) if isBlack else QColor(75, 86, 99), 1))
  1191. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1192. painter.setPen(QPen(QColor(45, 45, 45) if isBlack else QColor(86, 99, 114), 1))
  1193. painter.drawLine(0, 0, self.width(), 0)
  1194. AbstractPluginSlot.paintEvent(self, event)
  1195. # ------------------------------------------------------------------------------------------------------------
  1196. class PluginSlot_Classic(AbstractPluginSlot):
  1197. def __init__(self, parent, host, pluginId):
  1198. AbstractPluginSlot.__init__(self, parent, host, pluginId, (0,0,0), "classic")
  1199. self.ui = ui_carla_plugin_classic.Ui_PluginWidget()
  1200. self.ui.setupUi(self)
  1201. # -------------------------------------------------------------
  1202. # Internal stuff
  1203. self.fColorTop = QColor(60, 60, 60)
  1204. self.fColorBottom = QColor(47, 47, 47)
  1205. self.fColorSeprtr = QColor(70, 70, 70)
  1206. # -------------------------------------------------------------
  1207. self.b_enable = self.ui.b_enable
  1208. self.b_gui = self.ui.b_gui
  1209. self.b_edit = self.ui.b_edit
  1210. self.label_name = self.ui.label_name
  1211. self.led_control = self.ui.led_control
  1212. self.led_midi = self.ui.led_midi
  1213. self.led_audio_in = self.ui.led_audio_in
  1214. self.led_audio_out = self.ui.led_audio_out
  1215. self.peak_in = self.ui.peak_in
  1216. self.peak_out = self.ui.peak_out
  1217. self.ready()
  1218. #------------------------------------------------------------------
  1219. def getFixedHeight(self):
  1220. return 36
  1221. #------------------------------------------------------------------
  1222. def paintEvent(self, event):
  1223. painter = QPainter(self)
  1224. painter.save()
  1225. areaX = self.ui.area_right.x()+7
  1226. width = self.width()
  1227. height = self.height()
  1228. painter.setPen(QPen(QColor(17, 17, 17), 1))
  1229. painter.setBrush(QColor(17, 17, 17))
  1230. painter.drawRect(0, 0, width, height)
  1231. painter.setPen(self.fColorSeprtr.lighter(110))
  1232. painter.setBrush(self.fColorBottom)
  1233. painter.setRenderHint(QPainter.Antialiasing, True)
  1234. # name -> leds arc
  1235. path = QPainterPath()
  1236. path.moveTo(areaX-20, height-4)
  1237. path.cubicTo(areaX, height-5, areaX-20, 4.75, areaX, 4.75)
  1238. path.lineTo(areaX, height-5)
  1239. painter.drawPath(path)
  1240. painter.setPen(self.fColorSeprtr)
  1241. painter.setRenderHint(QPainter.Antialiasing, False)
  1242. # separator lines
  1243. painter.drawLine(0, height-5, areaX-20, height-5)
  1244. painter.drawLine(areaX, 4, width, 4)
  1245. painter.setPen(self.fColorBottom)
  1246. painter.setBrush(self.fColorBottom)
  1247. # top, bottom and left lines
  1248. painter.drawLine(0, 0, width, 0)
  1249. painter.drawRect(0, height-4, areaX, 4)
  1250. painter.drawRoundedRect(areaX-20, height-5, areaX, 5, 22, 22)
  1251. painter.drawLine(0, 0, 0, height)
  1252. # fill the rest
  1253. painter.drawRect(areaX-1, 5, width, height)
  1254. # bottom 1px line
  1255. painter.setPen(self.fColorSeprtr)
  1256. painter.drawLine(0, height-1, width, height-1)
  1257. painter.restore()
  1258. AbstractPluginSlot.paintEvent(self, event)
  1259. # ------------------------------------------------------------------------------------------------------------
  1260. class PluginSlot_Compact(AbstractPluginSlot):
  1261. def __init__(self, parent, host, pluginId, skinColor, skinStyle):
  1262. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinColor, skinStyle)
  1263. self.ui = ui_carla_plugin_compact.Ui_PluginWidget()
  1264. self.ui.setupUi(self)
  1265. self.b_enable = self.ui.b_enable
  1266. self.b_gui = self.ui.b_gui
  1267. self.b_edit = self.ui.b_edit
  1268. self.label_name = self.ui.label_name
  1269. self.led_control = self.ui.led_control
  1270. self.led_midi = self.ui.led_midi
  1271. self.led_audio_in = self.ui.led_audio_in
  1272. self.led_audio_out = self.ui.led_audio_out
  1273. self.peak_in = self.ui.peak_in
  1274. self.peak_out = self.ui.peak_out
  1275. self.ready()
  1276. #------------------------------------------------------------------
  1277. def getFixedHeight(self):
  1278. if self.fSkinStyle == "calf_blue":
  1279. return 36
  1280. return 30
  1281. # ------------------------------------------------------------------------------------------------------------
  1282. class PluginSlot_Default(AbstractPluginSlot):
  1283. def __init__(self, parent, host, pluginId, skinColor, skinStyle):
  1284. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinColor, skinStyle)
  1285. self.ui = ui_carla_plugin_default.Ui_PluginWidget()
  1286. self.ui.setupUi(self)
  1287. # -------------------------------------------------------------
  1288. self.b_enable = self.ui.b_enable
  1289. self.b_gui = self.ui.b_gui
  1290. self.b_edit = self.ui.b_edit
  1291. self.label_name = self.ui.label_name
  1292. self.led_control = self.ui.led_control
  1293. self.led_midi = self.ui.led_midi
  1294. self.led_audio_in = self.ui.led_audio_in
  1295. self.led_audio_out = self.ui.led_audio_out
  1296. self.peak_in = self.ui.peak_in
  1297. self.peak_out = self.ui.peak_out
  1298. self.w_knobs_left = self.ui.w_knobs_left
  1299. self.w_knobs_right = self.ui.w_knobs_right
  1300. self.spacer_knobs = self.ui.layout_bottom.itemAt(1).spacerItem()
  1301. self.ready()
  1302. #------------------------------------------------------------------
  1303. def getFixedHeight(self):
  1304. return 80
  1305. #------------------------------------------------------------------
  1306. def paintEvent(self, event):
  1307. painter = QPainter(self)
  1308. painter.setBrush(Qt.transparent)
  1309. painter.setPen(QPen(QColor(42, 42, 42), 1))
  1310. painter.drawRect(0, 1, self.width()-1, self.getFixedHeight()-3)
  1311. painter.setPen(QPen(QColor(60, 60, 60), 1))
  1312. painter.drawLine(0, 0, self.width(), 0)
  1313. AbstractPluginSlot.paintEvent(self, event)
  1314. # ------------------------------------------------------------------------------------------------------------
  1315. class PluginSlot_Presets(AbstractPluginSlot):
  1316. def __init__(self, parent, host, pluginId, skinColor, skinStyle):
  1317. AbstractPluginSlot.__init__(self, parent, host, pluginId, skinColor, skinStyle)
  1318. self.ui = ui_carla_plugin_presets.Ui_PluginWidget()
  1319. self.ui.setupUi(self)
  1320. usingMidiPrograms = bool(skinStyle != "presets")
  1321. # -------------------------------------------------------------
  1322. # Set-up programs
  1323. if usingMidiPrograms:
  1324. programCount = self.host.get_midi_program_count(self.fPluginId)
  1325. else:
  1326. programCount = self.host.get_program_count(self.fPluginId)
  1327. if programCount > 0:
  1328. self.ui.cb_presets.setEnabled(True)
  1329. self.ui.label_presets.setEnabled(True)
  1330. for i in range(programCount):
  1331. if usingMidiPrograms:
  1332. progName = self.host.get_midi_program_data(self.fPluginId, i)['name']
  1333. else:
  1334. progName = self.host.get_program_name(self.fPluginId, i)
  1335. self.ui.cb_presets.addItem(progName)
  1336. if usingMidiPrograms:
  1337. curProg = self.host.get_current_midi_program_index(self.fPluginId)
  1338. else:
  1339. curProg = self.host.get_current_program_index(self.fPluginId)
  1340. self.ui.cb_presets.setCurrentIndex(curProg)
  1341. else:
  1342. self.ui.cb_presets.setEnabled(False)
  1343. self.ui.cb_presets.setVisible(False)
  1344. self.ui.label_presets.setEnabled(False)
  1345. self.ui.label_presets.setVisible(False)
  1346. # -------------------------------------------------------------
  1347. self.b_enable = self.ui.b_enable
  1348. self.b_gui = self.ui.b_gui
  1349. self.b_edit = self.ui.b_edit
  1350. self.cb_presets = self.ui.cb_presets
  1351. self.label_name = self.ui.label_name
  1352. self.label_presets = self.ui.label_presets
  1353. self.led_control = self.ui.led_control
  1354. self.led_midi = self.ui.led_midi
  1355. self.led_audio_in = self.ui.led_audio_in
  1356. self.led_audio_out = self.ui.led_audio_out
  1357. self.peak_in = self.ui.peak_in
  1358. self.peak_out = self.ui.peak_out
  1359. if skinStyle == "zynfx":
  1360. self.setupZynFxParams()
  1361. else:
  1362. self.w_knobs_left = self.ui.w_knobs_left
  1363. self.w_knobs_right = self.ui.w_knobs_right
  1364. self.spacer_knobs = self.ui.layout_bottom.itemAt(1).spacerItem()
  1365. self.ready()
  1366. if usingMidiPrograms:
  1367. self.ui.cb_presets.currentIndexChanged.connect(self.slot_midiProgramChanged)
  1368. else:
  1369. self.ui.cb_presets.currentIndexChanged.connect(self.slot_programChanged)
  1370. # -------------------------------------------------------------
  1371. def setupZynFxParams(self):
  1372. parameterCount = min(self.host.get_parameter_count(self.fPluginId), 8)
  1373. for i in range(parameterCount):
  1374. paramInfo = self.host.get_parameter_info(self.fPluginId, i)
  1375. paramData = self.host.get_parameter_data(self.fPluginId, i)
  1376. paramRanges = self.host.get_parameter_ranges(self.fPluginId, i)
  1377. if paramData['type'] != PARAMETER_INPUT:
  1378. continue
  1379. if paramData['hints'] & PARAMETER_IS_BOOLEAN:
  1380. continue
  1381. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1382. continue
  1383. paramName = paramInfo['name']
  1384. if paramName.startswith("unused"):
  1385. continue
  1386. # real zyn fx plugins
  1387. if self.fPluginInfo['label'] == "zynalienwah":
  1388. if i == 0: paramName = "Freq"
  1389. elif i == 1: paramName = "Rnd"
  1390. elif i == 2: paramName = "L type" # combobox
  1391. elif i == 3: paramName = "St.df"
  1392. elif i == 5: paramName = "Fb"
  1393. elif i == 7: paramName = "L/R"
  1394. elif self.fPluginInfo['label'] == "zynchorus":
  1395. if i == 0: paramName = "Freq"
  1396. elif i == 1: paramName = "Rnd"
  1397. elif i == 2: paramName = "L type" # combobox
  1398. elif i == 3: paramName = "St.df"
  1399. elif i == 6: paramName = "Fb"
  1400. elif i == 7: paramName = "L/R"
  1401. elif i == 8: paramName = "Flngr" # button
  1402. elif i == 9: paramName = "Subst" # button
  1403. elif self.fPluginInfo['label'] == "zyndistortion":
  1404. if i == 0: paramName = "LRc."
  1405. elif i == 4: paramName = "Neg." # button
  1406. elif i == 5: paramName = "LPF"
  1407. elif i == 6: paramName = "HPF"
  1408. elif i == 7: paramName = "St." # button
  1409. elif i == 8: paramName = "PF" # button
  1410. elif self.fPluginInfo['label'] == "zyndynamicfilter":
  1411. if i == 0: paramName = "Freq"
  1412. elif i == 1: paramName = "Rnd"
  1413. elif i == 2: paramName = "L type" # combobox
  1414. elif i == 3: paramName = "St.df"
  1415. elif i == 4: paramName = "LfoD"
  1416. elif i == 5: paramName = "A.S."
  1417. elif i == 6: paramName = "A.Inv." # button
  1418. elif i == 7: paramName = "A.M."
  1419. elif self.fPluginInfo['label'] == "zynecho":
  1420. if i == 1: paramName = "LRdl."
  1421. elif i == 2: paramName = "LRc."
  1422. elif i == 3: paramName = "Fb."
  1423. elif i == 4: paramName = "Damp"
  1424. elif self.fPluginInfo['label'] == "zynphaser":
  1425. if i == 0: paramName = "Freq"
  1426. elif i == 1: paramName = "Rnd"
  1427. elif i == 2: paramName = "L type" # combobox
  1428. elif i == 3: paramName = "St.df"
  1429. elif i == 5: paramName = "Fb"
  1430. elif i == 7: paramName = "L/R"
  1431. elif i == 8: paramName = "Subst" # button
  1432. elif i == 9: paramName = "Phase"
  1433. elif i == 11: paramName = "Dist"
  1434. elif self.fPluginInfo['label'] == "zynreverb":
  1435. if i == 2: paramName = "I.delfb"
  1436. elif i == 5: paramName = "LPF"
  1437. elif i == 6: paramName = "HPF"
  1438. elif i == 9: paramName = "R.S."
  1439. elif i == 10: paramName = "I.del"
  1440. else:
  1441. paramName = getParameterShortName(paramName)
  1442. widget = PixmapDial(self, i)
  1443. widget.setLabel(paramName)
  1444. widget.setMinimum(paramRanges['min'])
  1445. widget.setMaximum(paramRanges['max'])
  1446. widget.setPixmap(3)
  1447. widget.setCustomPaintColor(QColor(83, 173, 10))
  1448. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR)
  1449. widget.forceWhiteLabelGradientText()
  1450. widget.hide()
  1451. if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0:
  1452. widget.setEnabled(False)
  1453. self.fParameterList.append([i, widget])
  1454. self.ui.w_knobs_left.layout().addWidget(widget)
  1455. if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET:
  1456. widget = PixmapDial(self, PARAMETER_DRYWET)
  1457. widget.setLabel("Wet")
  1458. widget.setMinimum(0.0)
  1459. widget.setMaximum(1.0)
  1460. widget.setPixmap(3)
  1461. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET)
  1462. widget.forceWhiteLabelGradientText()
  1463. self.fParameterList.append([PARAMETER_DRYWET, widget])
  1464. self.ui.w_knobs_right.layout().addWidget(widget)
  1465. if self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME:
  1466. widget = PixmapDial(self, PARAMETER_VOLUME)
  1467. widget.setLabel("Volume")
  1468. widget.setMinimum(0.0)
  1469. widget.setMaximum(1.27)
  1470. widget.setPixmap(3)
  1471. widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL)
  1472. widget.forceWhiteLabelGradientText()
  1473. self.fParameterList.append([PARAMETER_VOLUME, widget])
  1474. self.ui.w_knobs_right.layout().addWidget(widget)
  1475. #------------------------------------------------------------------
  1476. def getFixedHeight(self):
  1477. return 80
  1478. #------------------------------------------------------------------
  1479. def paintEvent(self, event):
  1480. painter = QPainter(self)
  1481. painter.setBrush(Qt.transparent)
  1482. painter.setPen(QPen(QColor(50, 50, 50), 1))
  1483. painter.drawRect(0, 1, self.width()-1, self.height()-3)
  1484. painter.setPen(QPen(QColor(64, 64, 64), 1))
  1485. painter.drawLine(0, 0, self.width(), 0)
  1486. AbstractPluginSlot.paintEvent(self, event)
  1487. # ------------------------------------------------------------------------------------------------------------
  1488. def getColorAndSkinStyle(host, pluginId):
  1489. if False:
  1490. # kdevelop likes this :)
  1491. host = CarlaHostNull()
  1492. progCount = 0
  1493. pluginInfo = PyCarlaPluginInfo
  1494. pluginName = ""
  1495. pluginInfo = host.get_plugin_info(pluginId)
  1496. pluginName = host.get_real_plugin_name(pluginId)
  1497. pluginLabel = pluginInfo['label'].lower()
  1498. pluginMaker = pluginInfo['maker']
  1499. uniqueId = pluginInfo['uniqueId']
  1500. if pluginInfo['type'] in (PLUGIN_VST2, PLUGIN_VST3, PLUGIN_AU):
  1501. progCount = host.get_program_count(pluginId)
  1502. else:
  1503. progCount = host.get_midi_program_count(pluginId)
  1504. color = getColorFromCategory(pluginInfo['category'])
  1505. # Samplers
  1506. if pluginInfo['type'] == PLUGIN_SF2:
  1507. return (color, "sf2")
  1508. if pluginInfo['type'] == PLUGIN_SFZ:
  1509. return (color, "sfz")
  1510. # Calf
  1511. if pluginName.split(" ", 1)[0].lower() == "calf":
  1512. return (color, "calf_black" if "mono" in pluginLabel else "calf_blue")
  1513. # OpenAV
  1514. if pluginMaker == "OpenAV Productions":
  1515. return (color, "openav-old")
  1516. if pluginMaker == "OpenAV":
  1517. return (color, "openav")
  1518. # ZynFX
  1519. if pluginInfo['type'] == PLUGIN_INTERNAL:
  1520. if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH:
  1521. return (color, "zynfx")
  1522. if pluginInfo['type'] == PLUGIN_LADSPA:
  1523. if pluginLabel.startswith("zyn") and pluginMaker.startswith("Josep Andreu"):
  1524. return (color, "zynfx")
  1525. if pluginInfo['type'] == PLUGIN_LV2:
  1526. if pluginLabel.startswith("http://kxstudio.sf.net/carla/plugins/zyn") and pluginName != "ZynAddSubFX":
  1527. return (color, "zynfx")
  1528. # Presets
  1529. if progCount > 1 and (pluginInfo['hints'] & PLUGIN_USES_MULTI_PROGS) == 0:
  1530. if pluginInfo['type'] in (PLUGIN_VST2, PLUGIN_VST3, PLUGIN_AU):
  1531. return (color, "presets")
  1532. return (color, "mpresets")
  1533. # DISTRHO Plugins (needs to be last)
  1534. if pluginMaker.startswith("falkTX, ") or pluginMaker == "DISTRHO" or pluginLabel.startswith("http://distrho.sf.net/plugins/"):
  1535. return (color, pluginLabel.replace("http://distrho.sf.net/plugins/",""))
  1536. return (color, "default")
  1537. def createPluginSlot(parent, host, pluginId, options):
  1538. skinColor, skinStyle = getColorAndSkinStyle(host, pluginId)
  1539. if options['color'] is not None:
  1540. skinColor = options['color']
  1541. if options['skin']:
  1542. skinStyle = options['skin']
  1543. if skinStyle == "classic":
  1544. return PluginSlot_Classic(parent, host, pluginId)
  1545. if "compact" in skinStyle or options['compact']:
  1546. return PluginSlot_Compact(parent, host, pluginId, skinColor, skinStyle)
  1547. if skinStyle.startswith("calf"):
  1548. return PluginSlot_Calf(parent, host, pluginId, skinColor, skinStyle)
  1549. if skinStyle in ("mpresets", "presets", "zynfx"):
  1550. return PluginSlot_Presets(parent, host, pluginId, skinColor, skinStyle)
  1551. return PluginSlot_Default(parent, host, pluginId, skinColor, skinStyle)
  1552. # ------------------------------------------------------------------------------------------------------------
  1553. # Main Testing
  1554. if __name__ == '__main__':
  1555. from carla_app import CarlaApplication
  1556. from carla_host import initHost, loadHostSettings
  1557. import resources_rc
  1558. app = CarlaApplication("Carla-Skins")
  1559. host = initHost("Skins", None, False, False, False)
  1560. loadHostSettings(host)
  1561. host.engine_init("JACK", "Carla-Widgets")
  1562. host.add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, "", "", "zynreverb", 0, None, 0x0)
  1563. #host.add_plugin(BINARY_NATIVE, PLUGIN_DSSI, "/usr/lib/dssi/karplong.so", "karplong", "karplong", 0, None, 0x0)
  1564. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://www.openavproductions.com/sorcer", 0, None, 0x0)
  1565. #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None, 0x0)
  1566. host.set_active(0, True)
  1567. #gui = createPluginSlot(None, host, 0, True)
  1568. gui = PluginSlot_Compact(None, host, 0, (0, 0, 0), "default")
  1569. gui.testTimer()
  1570. gui.show()
  1571. app.exec_()