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.

mainwin.cc 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. // Modified by falkTX on Jan 2015 for inclusion in Carla
  5. //
  6. // This program is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 2 of the License, or
  9. // (at your option) 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. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. //
  20. // ----------------------------------------------------------------------
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <math.h>
  24. #include "styles.h"
  25. #include "global.h"
  26. #include "mainwin.h"
  27. namespace REV1 {
  28. Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient, ValueChangedCallback* valuecb) :
  29. A_thread ("Main"),
  30. X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel),
  31. _stop (false),
  32. _xres (xres),
  33. _jclient (jclient),
  34. _valuecb (valuecb)
  35. {
  36. X_hints H;
  37. char s [256];
  38. int i, x;
  39. _atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
  40. XSetWMProtocols (dpy (), win (), &_atom, 1);
  41. _atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);
  42. sprintf (s, "%s", jclient->jname ());
  43. x_set_title (s);
  44. H.position (xp, yp);
  45. H.minsize (XSIZE, YSIZE);
  46. H.maxsize (XSIZE, YSIZE);
  47. H.rname (xres->rname ());
  48. H.rclas (xres->rclas ());
  49. x_apply (&H);
  50. _ambis = xres->getb (".ambisonic", false);
  51. RotaryCtl::init (disp ());
  52. x = 0;
  53. _rotary [R_DELAY] = new Rlinctl (this, this, &r_delay_img, x, 0, 160, 5, 0.02, 0.100, 0.04, R_DELAY);
  54. _rotary [R_XOVER] = new Rlogctl (this, this, &r_xover_img, x, 0, 200, 5, 50.0, 1000.0, 200.0, R_XOVER);
  55. _rotary [R_RTLOW] = new Rlogctl (this, this, &r_rtlow_img, x, 0, 200, 5, 1.0, 8.0, 3.0, R_RTLOW);
  56. _rotary [R_RTMID] = new Rlogctl (this, this, &r_rtmid_img, x, 0, 200, 5, 1.0, 8.0, 2.0, R_RTMID);
  57. _rotary [R_FDAMP] = new Rlogctl (this, this, &r_fdamp_img, x, 0, 200, 5, 1.5e3, 24.0e3, 6.0e3, R_FDAMP);
  58. x += 315;
  59. _rotary [R_EQ1FR] = new Rlogctl (this, this, &r_parfr_img, x, 0, 180, 5, 40.0, 2.5e3, 160.0, R_EQ1FR);
  60. _rotary [R_EQ1GN] = new Rlinctl (this, this, &r_pargn_img, x, 0, 150, 5, -15.0, 15.0, 0.0, R_EQ1GN);
  61. x += 110;
  62. _rotary [R_EQ2FR] = new Rlogctl (this, this, &r_parfr_img, x, 0, 180, 5, 160.0, 10e3, 2.5e3, R_EQ2FR);
  63. _rotary [R_EQ2GN] = new Rlinctl (this, this, &r_pargn_img, x, 0, 150, 5, -15.0, 15.0, 0.0, R_EQ2GN);
  64. x += 110;
  65. _rotary [R_OPMIX] = new Rlinctl (this, this, &r_opmix_img, x, 0, 180, 5, 0.0 , 1.0, 0.5, R_OPMIX);
  66. _rotary [R_RGXYZ] = new Rlinctl (this, this, &r_rgxyz_img, x, 0, 180, 5, -9.0 , 9.0, 0.0, R_RGXYZ);
  67. for (i = 0; i < R_OPMIX; i++) _rotary [i]->x_map ();
  68. if (_ambis) _rotary [R_RGXYZ]->x_map ();
  69. else _rotary [R_OPMIX]->x_map ();
  70. x_add_events (ExposureMask);
  71. x_map ();
  72. set_time (0);
  73. inc_time (500000);
  74. }
  75. Mainwin::~Mainwin (void)
  76. {
  77. RotaryCtl::fini ();
  78. }
  79. int Mainwin::process (void)
  80. {
  81. int e;
  82. if (_stop) handle_stop ();
  83. e = get_event_timed ();
  84. switch (e)
  85. {
  86. case EV_TIME:
  87. handle_time ();
  88. break;
  89. }
  90. return e;
  91. }
  92. void Mainwin::handle_event (XEvent *E)
  93. {
  94. switch (E->type)
  95. {
  96. case Expose:
  97. expose ((XExposeEvent *) E);
  98. break;
  99. case ClientMessage:
  100. clmesg ((XClientMessageEvent *) E);
  101. break;
  102. }
  103. }
  104. void Mainwin::expose (XExposeEvent *E)
  105. {
  106. if (E->count) return;
  107. redraw ();
  108. }
  109. void Mainwin::clmesg (XClientMessageEvent *E)
  110. {
  111. if (E->message_type == _atom) _stop = true;
  112. }
  113. void Mainwin::handle_time (void)
  114. {
  115. inc_time (500000);
  116. // XFlush (dpy ());
  117. }
  118. void Mainwin::handle_stop (void)
  119. {
  120. put_event (EV_EXIT, 1);
  121. }
  122. void Mainwin::handle_callb (int type, X_window *W, XEvent *E)
  123. {
  124. RotaryCtl *R;
  125. int k;
  126. double v, v2;
  127. switch (type)
  128. {
  129. case RotaryCtl::PRESS:
  130. R = (RotaryCtl *) W;
  131. k = R->cbind ();
  132. switch (k)
  133. {
  134. default:
  135. ;
  136. }
  137. break;
  138. case RotaryCtl::DELTA:
  139. R = (RotaryCtl *) W;
  140. k = R->cbind ();
  141. switch (k)
  142. {
  143. case R_DELAY:
  144. v = _rotary [R_DELAY]->value ();
  145. _jclient->reverb ()->set_delay (v);
  146. _valuecb->valueChangedCallback (R_DELAY, v);
  147. break;
  148. case R_XOVER:
  149. v = _rotary [R_XOVER]->value ();
  150. _jclient->reverb ()->set_xover (v);
  151. _valuecb->valueChangedCallback (R_XOVER, v);
  152. break;
  153. case R_RTLOW:
  154. v = _rotary [R_RTLOW]->value ();
  155. _jclient->reverb ()->set_rtlow (v);
  156. _valuecb->valueChangedCallback (R_RTLOW, v);
  157. break;
  158. case R_RTMID:
  159. v = _rotary [R_RTMID]->value ();
  160. _jclient->reverb ()->set_rtmid (v);
  161. _valuecb->valueChangedCallback (R_RTMID, v);
  162. break;
  163. case R_FDAMP:
  164. v = _rotary [R_FDAMP]->value ();
  165. _jclient->reverb ()->set_fdamp (v);
  166. _valuecb->valueChangedCallback (R_FDAMP, v);
  167. break;
  168. case R_OPMIX:
  169. v = _rotary [R_OPMIX]->value ();
  170. _jclient->reverb ()->set_opmix (v);
  171. _valuecb->valueChangedCallback (R_OPMIX, v);
  172. break;
  173. case R_RGXYZ:
  174. v = _rotary [R_RGXYZ]->value ();
  175. _jclient->reverb ()->set_rgxyz (v);
  176. _valuecb->valueChangedCallback (R_RGXYZ, v);
  177. break;
  178. case R_EQ1FR:
  179. case R_EQ1GN:
  180. v = _rotary [R_EQ1FR]->value (), v2 = _rotary [R_EQ1GN]->value ();
  181. _jclient->reverb ()->set_eq1 (v, v2);
  182. _valuecb->valueChangedCallback (R_EQ1FR, v);
  183. _valuecb->valueChangedCallback (R_EQ1GN, v2);
  184. break;
  185. case R_EQ2FR:
  186. case R_EQ2GN:
  187. v = _rotary [R_EQ2FR]->value (), v2 = _rotary [R_EQ2GN]->value ();
  188. _jclient->reverb ()->set_eq2 (v, v2);
  189. _valuecb->valueChangedCallback (R_EQ2FR, v);
  190. _valuecb->valueChangedCallback (R_EQ2GN, v2);
  191. break;
  192. }
  193. break;
  194. }
  195. }
  196. void Mainwin::redraw (void)
  197. {
  198. int x;
  199. x = 0;
  200. XPutImage (dpy (), win (), dgc (), revsect_img, 0, 0, x, 0, 310, 75);
  201. x += 315;
  202. XPutImage (dpy (), win (), dgc (), eq1sect_img, 0, 0, x, 0, 110, 75);
  203. x += 110;
  204. XPutImage (dpy (), win (), dgc (), eq2sect_img, 0, 0, x, 0, 110, 75);
  205. x += 110;
  206. if (_ambis) XPutImage (dpy (), win (), dgc (), ambsect_img, 0, 0, x, 0, 70, 75);
  207. else XPutImage (dpy (), win (), dgc (), mixsect_img, 0, 0, x, 0, 70, 75);
  208. x += 70;
  209. }
  210. }