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 77KB

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