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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. // Modified by falkTX on Jan-Apr 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, bool ambisonic, ValueChangedCallback* valuecb) :
  29. A_thread ("Main"),
  30. X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel),
  31. _stop (false),
  32. _ambis (ambisonic),
  33. _xres (xres),
  34. _valuecb (valuecb)
  35. {
  36. X_hints H;
  37. int i, x;
  38. _atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True);
  39. XSetWMProtocols (dpy (), win (), &_atom, 1);
  40. _atom = XInternAtom (dpy (), "WM_PROTOCOLS", True);
  41. H.position (xp, yp);
  42. H.minsize (XSIZE, YSIZE);
  43. H.maxsize (XSIZE, YSIZE);
  44. H.rname (xres->rname ());
  45. H.rclas (xres->rclas ());
  46. x_apply (&H);
  47. RotaryCtl::init (disp ());
  48. x = 0;
  49. _rotary [R_DELAY] = new Rlinctl (this, this, &r_delay_img, x, 0, 160, 5, 0.02, 0.100, 0.04, R_DELAY);
  50. _rotary [R_XOVER] = new Rlogctl (this, this, &r_xover_img, x, 0, 200, 5, 50.0, 1000.0, 200.0, R_XOVER);
  51. _rotary [R_RTLOW] = new Rlogctl (this, this, &r_rtlow_img, x, 0, 200, 5, 1.0, 8.0, 3.0, R_RTLOW);
  52. _rotary [R_RTMID] = new Rlogctl (this, this, &r_rtmid_img, x, 0, 200, 5, 1.0, 8.0, 2.0, R_RTMID);
  53. _rotary [R_FDAMP] = new Rlogctl (this, this, &r_fdamp_img, x, 0, 200, 5, 1.5e3, 24.0e3, 6.0e3, R_FDAMP);
  54. x += 315;
  55. _rotary [R_EQ1FR] = new Rlogctl (this, this, &r_parfr_img, x, 0, 180, 5, 40.0, 2.5e3, 160.0, R_EQ1FR);
  56. _rotary [R_EQ1GN] = new Rlinctl (this, this, &r_pargn_img, x, 0, 150, 5, -15.0, 15.0, 0.0, R_EQ1GN);
  57. x += 110;
  58. _rotary [R_EQ2FR] = new Rlogctl (this, this, &r_parfr_img, x, 0, 180, 5, 160.0, 10e3, 2.5e3, R_EQ2FR);
  59. _rotary [R_EQ2GN] = new Rlinctl (this, this, &r_pargn_img, x, 0, 150, 5, -15.0, 15.0, 0.0, R_EQ2GN);
  60. x += 110;
  61. _rotary [R_OPMIX] = new Rlinctl (this, this, &r_opmix_img, x, 0, 180, 5, 0.0 , 1.0, 0.5, R_OPMIX);
  62. _rotary [R_RGXYZ] = new Rlinctl (this, this, &r_rgxyz_img, x, 0, 180, 5, -9.0 , 9.0, 0.0, R_RGXYZ);
  63. for (i = 0; i < R_OPMIX; i++) _rotary [i]->x_map ();
  64. if (_ambis) _rotary [R_RGXYZ]->x_map ();
  65. else _rotary [R_OPMIX]->x_map ();
  66. x_add_events (ExposureMask);
  67. set_time (0);
  68. inc_time (50000);
  69. }
  70. Mainwin::~Mainwin (void)
  71. {
  72. RotaryCtl::fini ();
  73. }
  74. int Mainwin::process (void)
  75. {
  76. int e;
  77. if (_stop) handle_stop ();
  78. e = get_event_timed ();
  79. switch (e)
  80. {
  81. case EV_TIME:
  82. handle_time ();
  83. break;
  84. }
  85. return e;
  86. }
  87. void Mainwin::handle_event (XEvent *E)
  88. {
  89. switch (E->type)
  90. {
  91. case Expose:
  92. expose ((XExposeEvent *) E);
  93. break;
  94. case ClientMessage:
  95. clmesg ((XClientMessageEvent *) E);
  96. break;
  97. }
  98. }
  99. void Mainwin::expose (XExposeEvent *E)
  100. {
  101. if (E->count) return;
  102. redraw ();
  103. }
  104. void Mainwin::clmesg (XClientMessageEvent *E)
  105. {
  106. if (E->message_type == _atom) _stop = true;
  107. }
  108. void Mainwin::handle_time (void)
  109. {
  110. inc_time (5000);
  111. XFlush (dpy ());
  112. }
  113. void Mainwin::handle_stop (void)
  114. {
  115. put_event (EV_EXIT, 1);
  116. }
  117. void Mainwin::handle_callb (int type, X_window *W, XEvent *E)
  118. {
  119. RotaryCtl *R;
  120. int k;
  121. double v, v2;
  122. switch (type)
  123. {
  124. case RotaryCtl::PRESS:
  125. R = (RotaryCtl *) W;
  126. k = R->cbind ();
  127. switch (k)
  128. {
  129. default:
  130. ;
  131. }
  132. break;
  133. case RotaryCtl::DELTA:
  134. R = (RotaryCtl *) W;
  135. k = R->cbind ();
  136. switch (k)
  137. {
  138. case R_DELAY:
  139. v = _rotary [R_DELAY]->value ();
  140. _valuecb->valueChangedCallback (R_DELAY, v);
  141. break;
  142. case R_XOVER:
  143. v = _rotary [R_XOVER]->value ();
  144. _valuecb->valueChangedCallback (R_XOVER, v);
  145. break;
  146. case R_RTLOW:
  147. v = _rotary [R_RTLOW]->value ();
  148. _valuecb->valueChangedCallback (R_RTLOW, v);
  149. break;
  150. case R_RTMID:
  151. v = _rotary [R_RTMID]->value ();
  152. _valuecb->valueChangedCallback (R_RTMID, v);
  153. break;
  154. case R_FDAMP:
  155. v = _rotary [R_FDAMP]->value ();
  156. _valuecb->valueChangedCallback (R_FDAMP, v);
  157. break;
  158. case R_OPMIX:
  159. v = _rotary [R_OPMIX]->value ();
  160. _valuecb->valueChangedCallback (R_OPMIX, v);
  161. break;
  162. case R_RGXYZ:
  163. v = _rotary [R_RGXYZ]->value ();
  164. _valuecb->valueChangedCallback (R_RGXYZ, v);
  165. break;
  166. case R_EQ1FR:
  167. case R_EQ1GN:
  168. v = _rotary [R_EQ1FR]->value (), v2 = _rotary [R_EQ1GN]->value ();
  169. _valuecb->valueChangedCallback (R_EQ1FR, v);
  170. _valuecb->valueChangedCallback (R_EQ1GN, v2);
  171. break;
  172. case R_EQ2FR:
  173. case R_EQ2GN:
  174. v = _rotary [R_EQ2FR]->value (), v2 = _rotary [R_EQ2GN]->value ();
  175. _valuecb->valueChangedCallback (R_EQ2FR, v);
  176. _valuecb->valueChangedCallback (R_EQ2GN, v2);
  177. break;
  178. }
  179. break;
  180. }
  181. }
  182. void Mainwin::redraw (void)
  183. {
  184. int x;
  185. x = 0;
  186. XPutImage (dpy (), win (), dgc (), revsect_img, 0, 0, x, 0, 310, 75);
  187. x += 315;
  188. XPutImage (dpy (), win (), dgc (), eq1sect_img, 0, 0, x, 0, 110, 75);
  189. x += 110;
  190. XPutImage (dpy (), win (), dgc (), eq2sect_img, 0, 0, x, 0, 110, 75);
  191. x += 110;
  192. if (_ambis) XPutImage (dpy (), win (), dgc (), ambsect_img, 0, 0, x, 0, 70, 75);
  193. else XPutImage (dpy (), win (), dgc (), mixsect_img, 0, 0, x, 0, 70, 75);
  194. x += 70;
  195. }
  196. }