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.

589 lines
15 KiB

7 years ago
7 years ago
  1. /*
  2. This file is part of "Interface Fractures III - Silicon".
  3. Copyright (c) 2015 Luka Prinčič, All rights reserved.
  4. This program is free software distributed under
  5. GNU General Public Licence. See COPYING for more info.
  6. - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7. gui_granul.scd - takes care of all GUI elements under
  8. the 'granul' tab...
  9. ********************************************************** */
  10. ~tab_views[~tab_names.at("granul")].layout = HLayout(
  11. VLayout( // left half starts here
  12. //~tab_views[~tab_names.at("granul")].layout.add(nil);
  13. //~granSynth1 = View.new(~tab_views[~tab_names.at("granul")]);
  14. //~granSynth1.background = Color.gray(0.5);
  15. //~granSynth1.layout = HLayout( // vert. layout:
  16. // Synth starts here --------------------------------------------------------------------
  17. HLayout(
  18. VLayout(
  19. StaticText().string_("GRANULATOR"),
  20. Button()
  21. .states_([
  22. ["OFF", Color.gray(0.2), Color.gray(0.8)],
  23. ["ON", Color.gray(0.8), Color.grey(0.2)] ])
  24. .mouseDownAction_({
  25. arg state;
  26. state.value.postln;
  27. if (state.value == 0) {
  28. ~granSynth = Synth(\Granny, [\bufnum, b]);
  29. } {
  30. ~granSynth.free;
  31. }
  32. })
  33. .minHeight_(70)
  34. .minWidth_(70),
  35. nil
  36. ),
  37. VLayout(
  38. PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
  39. StaticText().string_("Filter vs. Position"),
  40. Slider2D()
  41. .x_(0.05)
  42. .y_(0.05)
  43. .action_({ arg slider;
  44. ~granSynth.set(\pos, slider.x);
  45. ~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
  46. StaticText().string_("Position variation"),
  47. Slider(nil,Rect(0,0,50,10))
  48. .minHeight_(20)
  49. .thumbSize_(50)
  50. .action_({ arg posvar;
  51. posvar = posvar.value;
  52. ~granSynth.set(\posvar, posvar.value);
  53. })
  54. ),
  55. VLayout(
  56. StaticText().string_("Frequency of grains"),
  57. HLayout(
  58. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  59. .action_({ arg freq;
  60. freq = ((freq.value * 200) + 1).asInt;
  61. ~granSynth.set(\freq, freq.value); freq.value.postln;
  62. ~nbf.value_(freq)}),
  63. VLayout(nil,
  64. ~nbf = NumberBox(nil,Rect(0,0,1,1))
  65. .font_(Font("Sans",20))
  66. .maxWidth_(50)
  67. .minHeight_(30);
  68. )
  69. ),
  70. HLayout(
  71. StaticText().string_("variation"),
  72. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  73. .action_({ arg fvar;
  74. fvar = fvar.value * 2;
  75. ~granSynth.set(\fvar, fvar.value);
  76. })
  77. ),
  78. nil,
  79. StaticText().string_("Duration of grains"),
  80. HLayout(
  81. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  82. .action_({ arg dur;
  83. dur = dur.value;
  84. ~granSynth.set(\dur, dur.value);
  85. ~nbd.value_((dur.value * 100).asInt); }),
  86. VLayout(nil,
  87. ~nbd = NumberBox(nil,Rect(0,0,1,1))
  88. .font_(Font("Sans", 20))
  89. .maxWidth_(50)
  90. .minHeight_(30);)
  91. ),
  92. HLayout(StaticText().string_("variation"),
  93. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  94. .action_({ arg durvar;
  95. durvar = durvar.value * 2;
  96. ~granSynth.set(\durvar, durvar.value);
  97. })
  98. ),
  99. nil,
  100. StaticText().string_("Pitch"),
  101. HLayout(
  102. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  103. .action_({ arg pitch;
  104. pitch = pitch.value * 2;
  105. ~granSynth.set(\pitch, pitch.value);
  106. ~nbp.value_(pitch.value); }),
  107. VLayout(nil,
  108. ~nbp = NumberBox()
  109. .font_(Font("Sans", 20))
  110. .maxWidth_(50)
  111. .minHeight_(30);)
  112. ),
  113. HLayout(StaticText().string_("variation"),
  114. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  115. .action_({ arg pitchvar;
  116. pitchvar = pitchvar.value;
  117. ~granSynth.set(\pitchvar, pitchvar.value);
  118. })
  119. ),
  120. nil,
  121. StaticText().string_("Width (Stereo)"),
  122. HLayout(
  123. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  124. .action_({ arg width;
  125. width = width.value;
  126. ~granSynth.set(\width, width.value);
  127. ~nbw.value_(width.value);
  128. }),
  129. VLayout(nil,
  130. ~nbw = NumberBox()
  131. .font_(Font("Sans", 20))
  132. .maxWidth_(50)
  133. .minHeight_(30);)
  134. )
  135. ),
  136. VLayout(
  137. StaticText().string_("Gain")
  138. .align_(\center),
  139. Slider(nil, Rect(0,0,1,2))
  140. .minWidth_(50)
  141. .thumbSize_(50)
  142. .action_({ arg gain;
  143. ~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
  144. .valueAction_(0)
  145. ;
  146. )
  147. ), // synth ends here
  148. HLayout( // bottom left synth starts here --------------------------------------------------------------------
  149. VLayout(
  150. StaticText().string_("GRANULATOR"),
  151. Button()
  152. .states_([
  153. ["OFF", Color.gray(0.2), Color.gray(0.8)],
  154. ["ON", Color.gray(0.8), Color.grey(0.2)] ])
  155. .mouseDownAction_({
  156. arg state;
  157. state.value.postln;
  158. if (state.value == 0) {
  159. ~granSynth = Synth(\Granny, [\bufnum, b]);
  160. } {
  161. ~granSynth.free;
  162. }
  163. })
  164. .minHeight_(70)
  165. .minWidth_(70),
  166. nil
  167. ),
  168. VLayout(
  169. PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
  170. StaticText().string_("Filter vs. Position"),
  171. Slider2D()
  172. .x_(0.05)
  173. .y_(0.05)
  174. .action_({ arg slider;
  175. ~granSynth.set(\pos, slider.x);
  176. ~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
  177. StaticText().string_("Position variation"),
  178. Slider(nil,Rect(0,0,50,10))
  179. .minHeight_(20)
  180. .thumbSize_(50)
  181. .action_({ arg posvar;
  182. posvar = posvar.value;
  183. ~granSynth.set(\posvar, posvar.value);
  184. })
  185. ),
  186. VLayout(
  187. StaticText().string_("Frequency of grains"),
  188. HLayout(
  189. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  190. .action_({ arg freq;
  191. freq = ((freq.value * 200) + 1).asInt;
  192. ~granSynth.set(\freq, freq.value); freq.value.postln;
  193. ~nbf.value_(freq)}),
  194. VLayout(nil,
  195. ~nbf = NumberBox(nil,Rect(0,0,1,1))
  196. .font_(Font("Sans",20))
  197. .maxWidth_(50)
  198. .minHeight_(30);
  199. )
  200. ),
  201. HLayout(
  202. StaticText().string_("variation"),
  203. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  204. .action_({ arg fvar;
  205. fvar = fvar.value * 2;
  206. ~granSynth.set(\fvar, fvar.value);
  207. })
  208. ),
  209. nil,
  210. StaticText().string_("Duration of grains"),
  211. HLayout(
  212. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  213. .action_({ arg dur;
  214. dur = dur.value;
  215. ~granSynth.set(\dur, dur.value);
  216. ~nbd.value_((dur.value * 100).asInt); }),
  217. VLayout(nil,
  218. ~nbd = NumberBox(nil,Rect(0,0,1,1))
  219. .font_(Font("Sans", 20))
  220. .maxWidth_(50)
  221. .minHeight_(30);)
  222. ),
  223. HLayout(StaticText().string_("variation"),
  224. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  225. .action_({ arg durvar;
  226. durvar = durvar.value * 2;
  227. ~granSynth.set(\durvar, durvar.value);
  228. })
  229. ),
  230. nil,
  231. StaticText().string_("Pitch"),
  232. HLayout(
  233. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  234. .action_({ arg pitch;
  235. pitch = pitch.value * 2;
  236. ~granSynth.set(\pitch, pitch.value);
  237. ~nbp.value_(pitch.value); }),
  238. VLayout(nil,
  239. ~nbp = NumberBox()
  240. .font_(Font("Sans", 20))
  241. .maxWidth_(50)
  242. .minHeight_(30);)
  243. ),
  244. HLayout(StaticText().string_("variation"),
  245. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  246. .action_({ arg pitchvar;
  247. pitchvar = pitchvar.value;
  248. ~granSynth.set(\pitchvar, pitchvar.value);
  249. })
  250. ),
  251. nil,
  252. StaticText().string_("Width (Stereo)"),
  253. HLayout(
  254. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  255. .action_({ arg width;
  256. width = width.value;
  257. ~granSynth.set(\width, width.value);
  258. ~nbw.value_(width.value);
  259. }),
  260. VLayout(nil,
  261. ~nbw = NumberBox()
  262. .font_(Font("Sans", 20))
  263. .maxWidth_(50)
  264. .minHeight_(30);)
  265. )
  266. ),
  267. VLayout(
  268. StaticText().string_("Gain")
  269. .align_(\center),
  270. Slider(nil, Rect(0,0,1,2))
  271. .minWidth_(50)
  272. .thumbSize_(50)
  273. .action_({ arg gain;
  274. ~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
  275. .valueAction_(0)
  276. ;
  277. )
  278. ); // bottom left synth ends here
  279. ), // left half ends here
  280. VLayout( // right half starts here
  281. // left top synth starts here --------------------------------------------------------------------
  282. HLayout(
  283. VLayout(
  284. StaticText().string_("GRANULATOR"),
  285. Button()
  286. .states_([
  287. ["OFF", Color.gray(0.2), Color.gray(0.8)],
  288. ["ON", Color.gray(0.8), Color.grey(0.2)] ])
  289. .mouseDownAction_({
  290. arg state;
  291. state.value.postln;
  292. if (state.value == 0) {
  293. ~granSynth = Synth(\Granny, [\bufnum, b]);
  294. } {
  295. ~granSynth.free;
  296. }
  297. })
  298. .minHeight_(70)
  299. .minWidth_(70),
  300. nil
  301. ),
  302. VLayout(
  303. PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
  304. StaticText().string_("Filter vs. Position"),
  305. Slider2D()
  306. .x_(0.05)
  307. .y_(0.05)
  308. .action_({ arg slider;
  309. ~granSynth.set(\pos, slider.x);
  310. ~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
  311. StaticText().string_("Position variation"),
  312. Slider(nil,Rect(0,0,50,10))
  313. .minHeight_(20)
  314. .thumbSize_(50)
  315. .action_({ arg posvar;
  316. posvar = posvar.value;
  317. ~granSynth.set(\posvar, posvar.value);
  318. })
  319. ),
  320. VLayout(
  321. StaticText().string_("Frequency of grains"),
  322. HLayout(
  323. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  324. .action_({ arg freq;
  325. freq = ((freq.value * 200) + 1).asInt;
  326. ~granSynth.set(\freq, freq.value); freq.value.postln;
  327. ~nbf.value_(freq)}),
  328. VLayout(nil,
  329. ~nbf = NumberBox(nil,Rect(0,0,1,1))
  330. .font_(Font("Sans",20))
  331. .maxWidth_(50)
  332. .minHeight_(30);
  333. )
  334. ),
  335. HLayout(
  336. StaticText().string_("variation"),
  337. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  338. .action_({ arg fvar;
  339. fvar = fvar.value * 2;
  340. ~granSynth.set(\fvar, fvar.value);
  341. })
  342. ),
  343. nil,
  344. StaticText().string_("Duration of grains"),
  345. HLayout(
  346. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  347. .action_({ arg dur;
  348. dur = dur.value;
  349. ~granSynth.set(\dur, dur.value);
  350. ~nbd.value_((dur.value * 100).asInt); }),
  351. VLayout(nil,
  352. ~nbd = NumberBox(nil,Rect(0,0,1,1))
  353. .font_(Font("Sans", 20))
  354. .maxWidth_(50)
  355. .minHeight_(30);)
  356. ),
  357. HLayout(StaticText().string_("variation"),
  358. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  359. .action_({ arg durvar;
  360. durvar = durvar.value * 2;
  361. ~granSynth.set(\durvar, durvar.value);
  362. })
  363. ),
  364. nil,
  365. StaticText().string_("Pitch"),
  366. HLayout(
  367. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  368. .action_({ arg pitch;
  369. pitch = pitch.value * 2;
  370. ~granSynth.set(\pitch, pitch.value);
  371. ~nbp.value_(pitch.value); }),
  372. VLayout(nil,
  373. ~nbp = NumberBox()
  374. .font_(Font("Sans", 20))
  375. .maxWidth_(50)
  376. .minHeight_(30);)
  377. ),
  378. HLayout(StaticText().string_("variation"),
  379. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  380. .action_({ arg pitchvar;
  381. pitchvar = pitchvar.value;
  382. ~granSynth.set(\pitchvar, pitchvar.value);
  383. })
  384. ),
  385. nil,
  386. StaticText().string_("Width (Stereo)"),
  387. HLayout(
  388. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  389. .action_({ arg width;
  390. width = width.value;
  391. ~granSynth.set(\width, width.value);
  392. ~nbw.value_(width.value);
  393. }),
  394. VLayout(nil,
  395. ~nbw = NumberBox()
  396. .font_(Font("Sans", 20))
  397. .maxWidth_(50)
  398. .minHeight_(30);)
  399. )
  400. ),
  401. VLayout(
  402. StaticText().string_("Gain")
  403. .align_(\center),
  404. Slider(nil, Rect(0,0,1,2))
  405. .minWidth_(50)
  406. .thumbSize_(50)
  407. .action_({ arg gain;
  408. ~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
  409. .valueAction_(0)
  410. ;
  411. )
  412. ), // synth ends here
  413. HLayout( // bottom right synth starts here --------------------------------------------------------------------
  414. VLayout(
  415. StaticText().string_("GRANULATOR"),
  416. Button()
  417. .states_([
  418. ["OFF", Color.gray(0.2), Color.gray(0.8)],
  419. ["ON", Color.gray(0.8), Color.grey(0.2)] ])
  420. .mouseDownAction_({
  421. arg state;
  422. state.value.postln;
  423. if (state.value == 0) {
  424. ~granSynth = Synth(\Granny, [\bufnum, b]);
  425. } {
  426. ~granSynth.free;
  427. }
  428. })
  429. .minHeight_(70)
  430. .minWidth_(70),
  431. nil
  432. ),
  433. VLayout(
  434. PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
  435. StaticText().string_("Filter vs. Position"),
  436. Slider2D()
  437. .x_(0.05)
  438. .y_(0.05)
  439. .action_({ arg slider;
  440. ~granSynth.set(\pos, slider.x);
  441. ~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
  442. StaticText().string_("Position variation"),
  443. Slider(nil,Rect(0,0,50,10))
  444. .minHeight_(20)
  445. .thumbSize_(50)
  446. .action_({ arg posvar;
  447. posvar = posvar.value;
  448. ~granSynth.set(\posvar, posvar.value);
  449. })
  450. ),
  451. VLayout(
  452. StaticText().string_("Frequency of grains"),
  453. HLayout(
  454. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  455. .action_({ arg freq;
  456. freq = ((freq.value * 200) + 1).asInt;
  457. ~granSynth.set(\freq, freq.value); freq.value.postln;
  458. ~nbf.value_(freq)}),
  459. VLayout(nil,
  460. ~nbf = NumberBox(nil,Rect(0,0,1,1))
  461. .font_(Font("Sans",20))
  462. .maxWidth_(50)
  463. .minHeight_(30);
  464. )
  465. ),
  466. HLayout(
  467. StaticText().string_("variation"),
  468. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  469. .action_({ arg fvar;
  470. fvar = fvar.value * 2;
  471. ~granSynth.set(\fvar, fvar.value);
  472. })
  473. ),
  474. nil,
  475. StaticText().string_("Duration of grains"),
  476. HLayout(
  477. Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
  478. .action_({ arg dur;
  479. dur = dur.value;
  480. ~granSynth.set(\dur, dur.value);
  481. ~nbd.value_((dur.value * 100).asInt); }),
  482. VLayout(nil,
  483. ~nbd = NumberBox(nil,Rect(0,0,1,1))
  484. .font_(Font("Sans", 20))
  485. .maxWidth_(50)
  486. .minHeight_(30);)
  487. ),
  488. HLayout(StaticText().string_("variation"),
  489. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  490. .action_({ arg durvar;
  491. durvar = durvar.value * 2;
  492. ~granSynth.set(\durvar, durvar.value);
  493. })
  494. ),
  495. nil,
  496. StaticText().string_("Pitch"),
  497. HLayout(
  498. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  499. .action_({ arg pitch;
  500. pitch = pitch.value * 2;
  501. ~granSynth.set(\pitch, pitch.value);
  502. ~nbp.value_(pitch.value); }),
  503. VLayout(nil,
  504. ~nbp = NumberBox()
  505. .font_(Font("Sans", 20))
  506. .maxWidth_(50)
  507. .minHeight_(30);)
  508. ),
  509. HLayout(StaticText().string_("variation"),
  510. Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
  511. .action_({ arg pitchvar;
  512. pitchvar = pitchvar.value;
  513. ~granSynth.set(\pitchvar, pitchvar.value);
  514. })
  515. ),
  516. nil,
  517. StaticText().string_("Width (Stereo)"),
  518. HLayout(
  519. Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
  520. .action_({ arg width;
  521. width = width.value;
  522. ~granSynth.set(\width, width.value);
  523. ~nbw.value_(width.value);
  524. }),
  525. VLayout(nil,
  526. ~nbw = NumberBox()
  527. .font_(Font("Sans", 20))
  528. .maxWidth_(50)
  529. .minHeight_(30);)
  530. )
  531. ),
  532. VLayout(
  533. StaticText().string_("Gain")
  534. .align_(\center),
  535. Slider(nil, Rect(0,0,1,2))
  536. .minWidth_(50)
  537. .thumbSize_(50)
  538. .action_({ arg gain;
  539. ~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
  540. .valueAction_(0)
  541. ;
  542. )
  543. ); // bottom right synth ends here
  544. ); // right half ends here
  545. );
  546. ~tab_views[~tab_names.at("granul")].layout.margins = 2;