PageRenderTime 1149ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/example/ipy_dx/dsound/soundfx.py

http://cwcpylib.googlecode.com/
Python | 1572 lines | 1465 code | 86 blank | 21 comment | 54 complexity | 04f89ed66f17f548de2c97c3e0d33c7c MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. """
  3. Description: DirectSound ????
  4. Author: Chui-Wen Chiu <sisimi.pchome@gmail.com>
  5. License: PYTHON SOFTWARE FOUNDATION LICENSE
  6. """
  7. __author__ = "Chui-Wen Chiu"
  8. __author_email__ = "cwchiu@hotmail.com"
  9. import clr
  10. # WinForm ????
  11. clr.AddReference("System")
  12. clr.AddReference("System.Drawing")
  13. clr.AddReference("System.Windows.Forms")
  14. # DirectX ??
  15. clr.AddReferenceByName("Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" )
  16. clr.AddReferenceByName("Microsoft.DirectX.DirectSound, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" )
  17. from System import *
  18. from System.IO import *
  19. from System.Collections import *
  20. from System.ComponentModel import *
  21. from System.Windows.Forms import *
  22. from System.Drawing import *
  23. from Microsoft.DirectX import *
  24. from Microsoft.DirectX.DirectSound import *
  25. class EffectInfo():
  26. def __init__(self):
  27. self._description=EffectDescription()
  28. self._EffectSettings=None
  29. self._Effect=None
  30. @property
  31. def Effect(self):
  32. return self._Effect
  33. @Effect.setter
  34. def Effect(self, value):
  35. self._Effect = value
  36. @property
  37. def EffectSettings(self):
  38. return self._EffectSettings
  39. @EffectSettings.setter
  40. def EffectSettings(self, value):
  41. self._EffectSettings = value
  42. @property
  43. def description(self):
  44. return self._description
  45. @description.setter
  46. def description(self, value):
  47. self._description = value
  48. class MyForm(Form):
  49. def __init__(self):
  50. self.applicationDevice = None
  51. self.applicationBuffer = None
  52. self.path = ''
  53. self.fileName = ''
  54. #self.effectDescription = ArrayList()
  55. self.effectDescription = []
  56. self.shouldLoop = False
  57. self.isIgnoringSettings = False
  58. self.currentIndex = 0
  59. self.InitializeComponent()
  60. self.InitDirectSound()
  61. self.ClearUI(True)
  62. def InitDirectSound(self):
  63. description = BufferDescription()
  64. wfx = WaveFormat()
  65. try:
  66. self.applicationDevice = Device()
  67. self.applicationDevice.SetCooperativeLevel(self, CooperativeLevel.Priority)
  68. except:
  69. MessageBox.Show("Unable to create sound device. Sample will now exit.")
  70. self.Close()
  71. raise
  72. def ClearUI(self, ClearControls):
  73. self.labelParamName1.Text =\
  74. self.labelParamValue1.Text =\
  75. self.labelParamName2.Text =\
  76. self.labelParamValue2.Text =\
  77. self.labelParamName3.Text =\
  78. self.labelParamValue3.Text =\
  79. self.labelParamName4.Text =\
  80. self.labelParamValue4.Text =\
  81. self.labelParamName5.Text =\
  82. self.labelParamValue5.Text =\
  83. self.labelParamName6.Text =\
  84. self.labelParamValue6.Text = ''
  85. if (ClearControls):
  86. self.groupboxFrameWaveform.Enabled =\
  87. self.radiobuttonTriangle.Enabled =\
  88. self.radiobuttonTriangle.Enabled =\
  89. self.radiobuttonRadioSine.Enabled =\
  90. self.groupboxFramePhase.Enabled =\
  91. self.radiobuttonRadioNeg180.Enabled =\
  92. self.radiobuttonRadioNeg90.Enabled =\
  93. self.radiobuttonRadioZero.Enabled =\
  94. self.radiobuttonRadio90.Enabled =\
  95. self.radiobuttonRadio180.Enabled = False
  96. self.trackbarSlider1.Minimum =\
  97. self.trackbarSlider2.Minimum =\
  98. self.trackbarSlider3.Minimum =\
  99. self.trackbarSlider4.Minimum =\
  100. self.trackbarSlider5.Minimum =\
  101. self.trackbarSlider6.Minimum = 0
  102. self.trackbarSlider1.Value =\
  103. self.trackbarSlider2.Value =\
  104. self.trackbarSlider3.Value =\
  105. self.trackbarSlider4.Value =\
  106. self.trackbarSlider5.Value =\
  107. self.trackbarSlider6.Value = 0
  108. self.trackbarSlider1.Enabled =\
  109. self.trackbarSlider2.Enabled =\
  110. self.trackbarSlider3.Enabled =\
  111. self.trackbarSlider4.Enabled =\
  112. self.trackbarSlider5.Enabled =\
  113. self.trackbarSlider6.Enabled = False
  114. def _Form1_Load(self, sender, e):
  115. try:
  116. self.ApplicationDevice = Device()
  117. self.ApplicationDevice.SetCooperativeLevel(self, CooperativeLevel.Priority)
  118. except:
  119. MessageBox.Show("Unable to create sound device. Sample will now exit.")
  120. self.Close()
  121. def Dispose(self, disposing):
  122. if (disposing):
  123. if (not self.applicationBuffer is None):
  124. self.applicationBuffer.Dispose()
  125. if (not self.applicationDevice is None):
  126. self.applicationDevice.Dispose()
  127. super(type(self), self).Dispose(disposing)
  128. def InitializeComponent(self):
  129. self.components = Container()
  130. self.buttonOk = Button()
  131. self.groupboxFrame = GroupBox()
  132. self.labelParamName1 = Label()
  133. self.labelParamValue1 = Label()
  134. self.trackbarSlider1 = TrackBar()
  135. self.labelParamMin1 = Label()
  136. self.labelParamMax1 = Label()
  137. self.labelParamName2 = Label()
  138. self.labelParamValue2 = Label()
  139. self.trackbarSlider2 = TrackBar()
  140. self.labelParamMin2 = Label()
  141. self.labelParamMax2 = Label()
  142. self.labelParamName3 = Label()
  143. self.labelParamValue3 = Label()
  144. self.trackbarSlider3 = TrackBar()
  145. self.labelParamMin3 = Label()
  146. self.labelParamMax3 = Label()
  147. self.labelParamName4 = Label()
  148. self.labelParamValue4 = Label()
  149. self.trackbarSlider4 = TrackBar()
  150. self.labelParamMin4 = Label()
  151. self.labelParamMax4 = Label()
  152. self.labelParamName5 = Label()
  153. self.labelParamValue5 = Label()
  154. self.trackbarSlider5 = TrackBar()
  155. self.labelParamMin5 = Label()
  156. self.labelParamMax5 = Label()
  157. self.labelParamName6 = Label()
  158. self.labelParamValue6 = Label()
  159. self.trackbarSlider6 = TrackBar()
  160. self.labelParamMin6 = Label()
  161. self.labelParamMax6 = Label()
  162. self.radiobuttonTriangle = RadioButton()
  163. self.radiobuttonSquare = RadioButton()
  164. self.radiobuttonRadioSine = RadioButton()
  165. self.groupboxFrameWaveform = GroupBox()
  166. self.buttonOpen = Button()
  167. self.labelTextFilename = Label()
  168. self.labelStatic2 = Label()
  169. self.labelTextStatus = Label()
  170. self.checkboxLoop = CheckBox()
  171. self.buttonPlay = Button()
  172. self.buttonStop = Button()
  173. self.labelStatic3 = Label()
  174. self.labelStatic4 = Label()
  175. self.radiobuttonRadioNeg180 = RadioButton()
  176. self.radiobuttonRadioNeg90 = RadioButton()
  177. self.radiobuttonRadioZero = RadioButton()
  178. self.radiobuttonRadio90 = RadioButton()
  179. self.radiobuttonRadio180 = RadioButton()
  180. self.groupboxFramePhase = GroupBox()
  181. self.groupboxEffects = GroupBox()
  182. self.buttonDelete = Button()
  183. self.listboxEffects = ListBox()
  184. self.comboEffects = ComboBox()
  185. self.timer1 = Timer(self.components)
  186. self.trackbarSlider1.BeginInit()
  187. self.trackbarSlider2.BeginInit()
  188. self.trackbarSlider3.BeginInit()
  189. self.trackbarSlider4.BeginInit()
  190. self.trackbarSlider5.BeginInit()
  191. self.trackbarSlider6.BeginInit()
  192. self.groupboxFrameWaveform.SuspendLayout()
  193. self.groupboxFramePhase.SuspendLayout()
  194. self.groupboxEffects.SuspendLayout()
  195. self.SuspendLayout()
  196. #
  197. # buttonOk
  198. #
  199. self.buttonOk.Location = Point(87, 432)
  200. self.buttonOk.Name = "buttonOk"
  201. self.buttonOk.Size = Size(67, 23)
  202. self.buttonOk.TabIndex = 0
  203. self.buttonOk.Text = "E&xit"
  204. self.buttonOk.Click += self.buttonOk_Click
  205. #
  206. # groupboxFrame
  207. #
  208. self.groupboxFrame.Location = Point(165, 76)
  209. self.groupboxFrame.Name = "groupboxFrame"
  210. self.groupboxFrame.Size = Size(525, 380)
  211. self.groupboxFrame.TabIndex = 1
  212. self.groupboxFrame.TabStop = False
  213. self.groupboxFrame.Text = "Parameters"
  214. #
  215. # labelParamName1
  216. #
  217. self.labelParamName1.Location = Point(169, 112)
  218. self.labelParamName1.Name = "labelParamName1"
  219. self.labelParamName1.Size = Size(117, 13)
  220. self.labelParamName1.TabIndex = 2
  221. self.labelParamName1.TextAlign = ContentAlignment.TopRight
  222. #
  223. # labelParamValue1
  224. #
  225. self.labelParamValue1.BorderStyle = BorderStyle.Fixed3D
  226. self.labelParamValue1.Location = Point(294, 112)
  227. self.labelParamValue1.Name = "labelParamValue1"
  228. self.labelParamValue1.Size = Size(67, 16)
  229. self.labelParamValue1.TabIndex = 3
  230. self.labelParamValue1.Text = "Value"
  231. self.labelParamValue1.TextAlign = ContentAlignment.TopCenter
  232. #
  233. # trackbarSlider1
  234. #
  235. self.trackbarSlider1.Location = Point(426, 112)
  236. self.trackbarSlider1.Name = "trackbarSlider1"
  237. self.trackbarSlider1.Size = Size(195, 45)
  238. self.trackbarSlider1.TabIndex = 4
  239. self.trackbarSlider1.Text = "Slider1"
  240. self.trackbarSlider1.TickStyle = TickStyle.None
  241. self.trackbarSlider1.Scroll += self.trackbarSliderScroll
  242. #
  243. # labelParamMin1
  244. #
  245. self.labelParamMin1.Location = Point(366, 112)
  246. self.labelParamMin1.Name = "labelParamMin1"
  247. self.labelParamMin1.Size = Size(60, 16)
  248. self.labelParamMin1.TabIndex = 5
  249. self.labelParamMin1.Text = "min"
  250. self.labelParamMin1.TextAlign = ContentAlignment.TopCenter
  251. #
  252. # labelParamMax1
  253. #
  254. self.labelParamMax1.Location = Point(627, 120)
  255. self.labelParamMax1.Name = "labelParamMax1"
  256. self.labelParamMax1.Size = Size(52, 13)
  257. self.labelParamMax1.TabIndex = 6
  258. self.labelParamMax1.Text = "max"
  259. self.labelParamMax1.TextAlign = ContentAlignment.TopCenter
  260. #
  261. # labelParamName2
  262. #
  263. self.labelParamName2.Location = Point(169, 160)
  264. self.labelParamName2.Name = "labelParamName2"
  265. self.labelParamName2.Size = Size(117, 13)
  266. self.labelParamName2.TabIndex = 7
  267. self.labelParamName2.TextAlign = ContentAlignment.TopRight
  268. #
  269. # labelParamValue2
  270. #
  271. self.labelParamValue2.BorderStyle = BorderStyle.Fixed3D
  272. self.labelParamValue2.Location = Point(294, 160)
  273. self.labelParamValue2.Name = "labelParamValue2"
  274. self.labelParamValue2.Size = Size(67, 16)
  275. self.labelParamValue2.TabIndex = 8
  276. self.labelParamValue2.Text = "Value"
  277. self.labelParamValue2.TextAlign = ContentAlignment.TopCenter
  278. #
  279. # trackbarSlider2
  280. #
  281. self.trackbarSlider2.Location = Point(426, 163)
  282. self.trackbarSlider2.Name = "trackbarSlider2"
  283. self.trackbarSlider2.Size = Size(195, 45)
  284. self.trackbarSlider2.TabIndex = 9
  285. self.trackbarSlider2.Text = "Slider1"
  286. self.trackbarSlider2.TickStyle = TickStyle.None
  287. self.trackbarSlider2.Scroll += self.trackbarSliderScroll
  288. #
  289. # labelParamMin2
  290. #
  291. self.labelParamMin2.Location = Point(366, 160)
  292. self.labelParamMin2.Name = "labelParamMin2"
  293. self.labelParamMin2.Size = Size(60, 16)
  294. self.labelParamMin2.TabIndex = 10
  295. self.labelParamMin2.Text = "min"
  296. self.labelParamMin2.TextAlign = ContentAlignment.TopCenter
  297. #
  298. # labelParamMax2
  299. #
  300. self.labelParamMax2.Location = Point(627, 168)
  301. self.labelParamMax2.Name = "labelParamMax2"
  302. self.labelParamMax2.Size = Size(52, 13)
  303. self.labelParamMax2.TabIndex = 11
  304. self.labelParamMax2.Text = "max"
  305. self.labelParamMax2.TextAlign = ContentAlignment.TopCenter
  306. #
  307. # labelParamName3
  308. #
  309. self.labelParamName3.Location = Point(169, 208)
  310. self.labelParamName3.Name = "labelParamName3"
  311. self.labelParamName3.Size = Size(117, 13)
  312. self.labelParamName3.TabIndex = 12
  313. self.labelParamName3.TextAlign = ContentAlignment.TopRight
  314. #
  315. # labelParamValue3
  316. #
  317. self.labelParamValue3.BorderStyle = BorderStyle.Fixed3D
  318. self.labelParamValue3.Location = Point(294, 208)
  319. self.labelParamValue3.Name = "labelParamValue3"
  320. self.labelParamValue3.Size = Size(67, 16)
  321. self.labelParamValue3.TabIndex = 13
  322. self.labelParamValue3.Text = "Value"
  323. self.labelParamValue3.TextAlign = ContentAlignment.TopCenter
  324. #
  325. # trackbarSlider3
  326. #
  327. self.trackbarSlider3.Location = Point(426, 208)
  328. self.trackbarSlider3.Name = "trackbarSlider3"
  329. self.trackbarSlider3.Size = Size(195, 45)
  330. self.trackbarSlider3.TabIndex = 14
  331. self.trackbarSlider3.Text = "Slider1"
  332. self.trackbarSlider3.TickStyle = TickStyle.None
  333. self.trackbarSlider3.Scroll += self.trackbarSliderScroll
  334. #
  335. # labelParamMin3
  336. #
  337. self.labelParamMin3.Location = Point(366, 208)
  338. self.labelParamMin3.Name = "labelParamMin3"
  339. self.labelParamMin3.Size = Size(60, 16)
  340. self.labelParamMin3.TabIndex = 15
  341. self.labelParamMin3.Text = "min"
  342. self.labelParamMin3.TextAlign = ContentAlignment.TopCenter
  343. #
  344. # labelParamMax3
  345. #
  346. self.labelParamMax3.Location = Point(627, 216)
  347. self.labelParamMax3.Name = "labelParamMax3"
  348. self.labelParamMax3.Size = Size(52, 13)
  349. self.labelParamMax3.TabIndex = 16
  350. self.labelParamMax3.Text = "max"
  351. self.labelParamMax3.TextAlign = ContentAlignment.TopCenter
  352. #
  353. # labelParamName4
  354. #
  355. self.labelParamName4.Location = Point(169, 256)
  356. self.labelParamName4.Name = "labelParamName4"
  357. self.labelParamName4.Size = Size(117, 13)
  358. self.labelParamName4.TabIndex = 17
  359. self.labelParamName4.TextAlign = ContentAlignment.TopRight
  360. #
  361. # labelParamValue4
  362. #
  363. self.labelParamValue4.BorderStyle = BorderStyle.Fixed3D
  364. self.labelParamValue4.Location = Point(294, 256)
  365. self.labelParamValue4.Name = "labelParamValue4"
  366. self.labelParamValue4.Size = Size(67, 16)
  367. self.labelParamValue4.TabIndex = 18
  368. self.labelParamValue4.Text = "Value"
  369. self.labelParamValue4.TextAlign = ContentAlignment.TopCenter
  370. #
  371. # trackbarSlider4
  372. #
  373. self.trackbarSlider4.Location = Point(426, 256)
  374. self.trackbarSlider4.Name = "trackbarSlider4"
  375. self.trackbarSlider4.Size = Size(195, 45)
  376. self.trackbarSlider4.TabIndex = 19
  377. self.trackbarSlider4.Text = "Slider1"
  378. self.trackbarSlider4.TickStyle = TickStyle.None
  379. self.trackbarSlider4.Scroll += self.trackbarSliderScroll
  380. #
  381. # labelParamMin4
  382. #
  383. self.labelParamMin4.Location = Point(366, 256)
  384. self.labelParamMin4.Name = "labelParamMin4"
  385. self.labelParamMin4.Size = Size(60, 16)
  386. self.labelParamMin4.TabIndex = 20
  387. self.labelParamMin4.Text = "min"
  388. self.labelParamMin4.TextAlign = ContentAlignment.TopCenter
  389. #
  390. # labelParamMax4
  391. #
  392. self.labelParamMax4.Location = Point(627, 256)
  393. self.labelParamMax4.Name = "labelParamMax4"
  394. self.labelParamMax4.Size = Size(52, 13)
  395. self.labelParamMax4.TabIndex = 21
  396. self.labelParamMax4.Text = "max"
  397. self.labelParamMax4.TextAlign = ContentAlignment.TopCenter
  398. #
  399. # labelParamName5
  400. #
  401. self.labelParamName5.Location = Point(169, 304)
  402. self.labelParamName5.Name = "labelParamName5"
  403. self.labelParamName5.Size = Size(117, 13)
  404. self.labelParamName5.TabIndex = 22
  405. self.labelParamName5.TextAlign = ContentAlignment.TopRight
  406. #
  407. # labelParamValue5
  408. #
  409. self.labelParamValue5.BorderStyle = BorderStyle.Fixed3D
  410. self.labelParamValue5.Location = Point(294, 304)
  411. self.labelParamValue5.Name = "labelParamValue5"
  412. self.labelParamValue5.Size = Size(67, 16)
  413. self.labelParamValue5.TabIndex = 23
  414. self.labelParamValue5.Text = "Value"
  415. self.labelParamValue5.TextAlign = ContentAlignment.TopCenter
  416. #
  417. # trackbarSlider5
  418. #
  419. self.trackbarSlider5.Location = Point(426, 304)
  420. self.trackbarSlider5.Name = "trackbarSlider5"
  421. self.trackbarSlider5.Size = Size(195, 45)
  422. self.trackbarSlider5.TabIndex = 24
  423. self.trackbarSlider5.Text = "Slider1"
  424. self.trackbarSlider5.TickStyle = TickStyle.None
  425. self.trackbarSlider5.Scroll += self.trackbarSliderScroll
  426. #
  427. # labelParamMin5
  428. #
  429. self.labelParamMin5.Location = Point(366, 304)
  430. self.labelParamMin5.Name = "labelParamMin5"
  431. self.labelParamMin5.Size = Size(60, 16)
  432. self.labelParamMin5.TabIndex = 25
  433. self.labelParamMin5.Text = "min"
  434. self.labelParamMin5.TextAlign = ContentAlignment.TopCenter
  435. #
  436. # labelParamMax5
  437. #
  438. self.labelParamMax5.Location = Point(627, 312)
  439. self.labelParamMax5.Name = "labelParamMax5"
  440. self.labelParamMax5.Size = Size(52, 13)
  441. self.labelParamMax5.TabIndex = 26
  442. self.labelParamMax5.Text = "max"
  443. self.labelParamMax5.TextAlign = ContentAlignment.TopCenter
  444. #
  445. # labelParamName6
  446. #
  447. self.labelParamName6.Location = Point(169, 352)
  448. self.labelParamName6.Name = "labelParamName6"
  449. self.labelParamName6.Size = Size(117, 13)
  450. self.labelParamName6.TabIndex = 27
  451. self.labelParamName6.TextAlign = ContentAlignment.TopRight
  452. #
  453. # labelParamValue6
  454. #
  455. self.labelParamValue6.BorderStyle = BorderStyle.Fixed3D
  456. self.labelParamValue6.Location = Point(294, 352)
  457. self.labelParamValue6.Name = "labelParamValue6"
  458. self.labelParamValue6.Size = Size(67, 16)
  459. self.labelParamValue6.TabIndex = 28
  460. self.labelParamValue6.Text = "Value"
  461. self.labelParamValue6.TextAlign = ContentAlignment.TopCenter
  462. #
  463. # trackbarSlider6
  464. #
  465. self.trackbarSlider6.Location = Point(426, 352)
  466. self.trackbarSlider6.Name = "trackbarSlider6"
  467. self.trackbarSlider6.Size = Size(195, 45)
  468. self.trackbarSlider6.TabIndex = 29
  469. self.trackbarSlider6.Text = "Slider1"
  470. self.trackbarSlider6.TickStyle = TickStyle.None
  471. self.trackbarSlider6.Scroll += self.trackbarSliderScroll
  472. #
  473. # labelParamMin6
  474. #
  475. self.labelParamMin6.Location = Point(366, 352)
  476. self.labelParamMin6.Name = "labelParamMin6"
  477. self.labelParamMin6.Size = Size(60, 16)
  478. self.labelParamMin6.TabIndex = 30
  479. self.labelParamMin6.Text = "min"
  480. self.labelParamMin6.TextAlign = ContentAlignment.TopCenter
  481. #
  482. # labelParamMax6
  483. #
  484. self.labelParamMax6.Location = Point(627, 352)
  485. self.labelParamMax6.Name = "labelParamMax6"
  486. self.labelParamMax6.Size = Size(52, 13)
  487. self.labelParamMax6.TabIndex = 31
  488. self.labelParamMax6.Text = "max"
  489. self.labelParamMax6.TextAlign = ContentAlignment.TopCenter
  490. #
  491. # radiobuttonTriangle
  492. #
  493. self.radiobuttonTriangle.Location = Point(16, 16)
  494. self.radiobuttonTriangle.Name = "radiobuttonTriangle"
  495. self.radiobuttonTriangle.Size = Size(69, 16)
  496. self.radiobuttonTriangle.TabIndex = 32
  497. self.radiobuttonTriangle.Text = "Triangle"
  498. self.radiobuttonTriangle.CheckedChanged += self.trackbarSliderScroll
  499. #
  500. # radiobuttonSquare
  501. #
  502. self.radiobuttonSquare.Location = Point(88, 16)
  503. self.radiobuttonSquare.Name = "radiobuttonSquare"
  504. self.radiobuttonSquare.Size = Size(64, 16)
  505. self.radiobuttonSquare.TabIndex = 33
  506. self.radiobuttonSquare.Text = "Square"
  507. self.radiobuttonSquare.CheckedChanged += self.trackbarSliderScroll
  508. #
  509. # radiobuttonRadioSine
  510. #
  511. self.radiobuttonRadioSine.Location = Point(152, 16)
  512. self.radiobuttonRadioSine.Name = "radiobuttonRadioSine"
  513. self.radiobuttonRadioSine.Size = Size(48, 16)
  514. self.radiobuttonRadioSine.TabIndex = 34
  515. self.radiobuttonRadioSine.Text = "Sine"
  516. self.radiobuttonRadioSine.CheckedChanged += self.trackbarSliderScroll
  517. #
  518. # buttonOpen
  519. #
  520. self.buttonOpen.Location = Point(12, 12)
  521. self.buttonOpen.Name = "buttonOpen"
  522. self.buttonOpen.TabIndex = 47
  523. self.buttonOpen.Text = "&Open File"
  524. self.buttonOpen.Click += self.buttonOpen_Click
  525. #
  526. # labelTextFilename
  527. #
  528. self.labelTextFilename.BorderStyle = BorderStyle.Fixed3D
  529. self.labelTextFilename.Location = Point(94, 14)
  530. self.labelTextFilename.Name = "labelTextFilename"
  531. self.labelTextFilename.Size = Size(595, 20)
  532. self.labelTextFilename.TabIndex = 48
  533. self.labelTextFilename.Text = "Filename"
  534. self.labelTextFilename.TextAlign = ContentAlignment.MiddleLeft
  535. #
  536. # labelStatic2
  537. #
  538. self.labelStatic2.Location = Point(19, 44)
  539. self.labelStatic2.Name = "labelStatic2"
  540. self.labelStatic2.Size = Size(67, 16)
  541. self.labelStatic2.TabIndex = 49
  542. self.labelStatic2.Text = "Status"
  543. #
  544. # labelTextStatus
  545. #
  546. self.labelTextStatus.BorderStyle = BorderStyle.Fixed3D
  547. self.labelTextStatus.Location = Point(94, 44)
  548. self.labelTextStatus.Name = "labelTextStatus"
  549. self.labelTextStatus.Size = Size(595, 20)
  550. self.labelTextStatus.TabIndex = 50
  551. self.labelTextStatus.Text = "No file loaded."
  552. self.labelTextStatus.TextAlign = ContentAlignment.MiddleLeft
  553. #
  554. # checkboxLoop
  555. #
  556. self.checkboxLoop.Location = Point(42, 376)
  557. self.checkboxLoop.Name = "checkboxLoop"
  558. self.checkboxLoop.Size = Size(86, 16)
  559. self.checkboxLoop.TabIndex = 51
  560. self.checkboxLoop.Text = "&Loop Sound"
  561. self.checkboxLoop.CheckedChanged += self.checkboxLoop_CheckedChanged
  562. #
  563. # buttonPlay
  564. #
  565. self.buttonPlay.Location = Point(10, 400)
  566. self.buttonPlay.Name = "buttonPlay"
  567. self.buttonPlay.Size = Size(67, 23)
  568. self.buttonPlay.TabIndex = 52
  569. self.buttonPlay.Text = "&Play"
  570. self.buttonPlay.Click += self.buttonPlay_Click
  571. #
  572. # buttonStop
  573. #
  574. self.buttonStop.Location = Point(87, 400)
  575. self.buttonStop.Name = "buttonStop"
  576. self.buttonStop.Size = Size(67, 23)
  577. self.buttonStop.TabIndex = 53
  578. self.buttonStop.Text = "&Stop"
  579. self.buttonStop.Enabled = False
  580. self.buttonStop.Click += self.buttonStop_Click
  581. #
  582. # labelStatic3
  583. #
  584. self.labelStatic3.BorderStyle = BorderStyle.Fixed3D
  585. self.labelStatic3.Location = Point(372, 88)
  586. self.labelStatic3.Name = "labelStatic3"
  587. self.labelStatic3.Size = Size(52, 16)
  588. self.labelStatic3.TabIndex = 62
  589. self.labelStatic3.Text = "Min"
  590. self.labelStatic3.TextAlign = ContentAlignment.TopCenter
  591. #
  592. # labelStatic4
  593. #
  594. self.labelStatic4.BorderStyle = BorderStyle.Fixed3D
  595. self.labelStatic4.Location = Point(627, 88)
  596. self.labelStatic4.Name = "labelStatic4"
  597. self.labelStatic4.Size = Size(52, 16)
  598. self.labelStatic4.TabIndex = 64
  599. self.labelStatic4.Text = "Max"
  600. self.labelStatic4.TextAlign = ContentAlignment.TopCenter
  601. #
  602. # radiobuttonRadioNeg180
  603. #
  604. self.radiobuttonRadioNeg180.Location = Point(16, 16)
  605. self.radiobuttonRadioNeg180.Name = "radiobuttonRadioNeg180"
  606. self.radiobuttonRadioNeg180.Size = Size(45, 16)
  607. self.radiobuttonRadioNeg180.TabIndex = 65
  608. self.radiobuttonRadioNeg180.Text = "-180"
  609. self.radiobuttonRadioNeg180.CheckedChanged += self.trackbarSliderScroll
  610. #
  611. # radiobuttonRadioNeg90
  612. #
  613. self.radiobuttonRadioNeg90.Location = Point(72, 16)
  614. self.radiobuttonRadioNeg90.Name = "radiobuttonRadioNeg90"
  615. self.radiobuttonRadioNeg90.Size = Size(39, 16)
  616. self.radiobuttonRadioNeg90.TabIndex = 66
  617. self.radiobuttonRadioNeg90.Text = "-90"
  618. self.radiobuttonRadioNeg90.CheckedChanged += self.trackbarSliderScroll
  619. #
  620. # radiobuttonRadioZero
  621. #
  622. self.radiobuttonRadioZero.Location = Point(120, 16)
  623. self.radiobuttonRadioZero.Name = "radiobuttonRadioZero"
  624. self.radiobuttonRadioZero.Size = Size(30, 16)
  625. self.radiobuttonRadioZero.TabIndex = 67
  626. self.radiobuttonRadioZero.Text = "0"
  627. self.radiobuttonRadioZero.CheckedChanged += self.trackbarSliderScroll
  628. #
  629. # radiobuttonRadio90
  630. #
  631. self.radiobuttonRadio90.Location = Point(152, 16)
  632. self.radiobuttonRadio90.Name = "radiobuttonRadio90"
  633. self.radiobuttonRadio90.Size = Size(36, 16)
  634. self.radiobuttonRadio90.TabIndex = 68
  635. self.radiobuttonRadio90.Text = "90"
  636. self.radiobuttonRadio90.CheckedChanged += self.trackbarSliderScroll
  637. #
  638. # radiobuttonRadio180
  639. #
  640. self.radiobuttonRadio180.Location = Point(200, 16)
  641. self.radiobuttonRadio180.Name = "radiobuttonRadio180"
  642. self.radiobuttonRadio180.Size = Size(42, 16)
  643. self.radiobuttonRadio180.TabIndex = 69
  644. self.radiobuttonRadio180.Text = "180"
  645. self.radiobuttonRadio180.CheckedChanged += self.trackbarSliderScroll
  646. #
  647. # labelTextFilename
  648. #
  649. self.labelTextFilename.BorderStyle = BorderStyle.Fixed3D
  650. self.labelTextFilename.Location = Point(94, 14)
  651. self.labelTextFilename.Name = "labelTextFilename"
  652. self.labelTextFilename.Size = Size(595, 20)
  653. self.labelTextFilename.TabIndex = 48
  654. self.labelTextFilename.Text = "Filename"
  655. self.labelTextFilename.TextAlign = ContentAlignment.MiddleLeft
  656. #
  657. # labelStatic2
  658. #
  659. self.labelStatic2.Location = Point(19, 44)
  660. self.labelStatic2.Name = "labelStatic2"
  661. self.labelStatic2.Size = Size(67, 16)
  662. self.labelStatic2.TabIndex = 49
  663. self.labelStatic2.Text = "Status"
  664. #
  665. # labelTextStatus
  666. #
  667. self.labelTextStatus.BorderStyle = BorderStyle.Fixed3D
  668. self.labelTextStatus.Location = Point(94, 44)
  669. self.labelTextStatus.Name = "labelTextStatus"
  670. self.labelTextStatus.Size = Size(595, 20)
  671. self.labelTextStatus.TabIndex = 50
  672. self.labelTextStatus.Text = "No file loaded."
  673. self.labelTextStatus.TextAlign = ContentAlignment.MiddleLeft
  674. #
  675. # checkboxLoop
  676. #
  677. self.checkboxLoop.Location = Point(42, 376)
  678. self.checkboxLoop.Name = "checkboxLoop"
  679. self.checkboxLoop.Size = Size(86, 16)
  680. self.checkboxLoop.TabIndex = 51
  681. self.checkboxLoop.Text = "&Loop Sound"
  682. self.checkboxLoop.CheckedChanged += self.checkboxLoop_CheckedChanged
  683. #
  684. # buttonPlay
  685. #
  686. self.buttonPlay.Location = Point(10, 400)
  687. self.buttonPlay.Name = "buttonPlay"
  688. self.buttonPlay.Size = Size(67, 23)
  689. self.buttonPlay.TabIndex = 52
  690. self.buttonPlay.Text = "&Play"
  691. self.buttonPlay.Click += self.buttonPlay_Click
  692. #
  693. # buttonStop
  694. #
  695. self.buttonStop.Location = Point(87, 400)
  696. self.buttonStop.Name = "buttonStop"
  697. self.buttonStop.Size = Size(67, 23)
  698. self.buttonStop.TabIndex = 53
  699. self.buttonStop.Text = "&Stop"
  700. self.buttonStop.Enabled = False
  701. self.buttonStop.Click += self.buttonStop_Click
  702. #
  703. # labelStatic3
  704. #
  705. self.labelStatic3.BorderStyle = BorderStyle.Fixed3D
  706. self.labelStatic3.Location = Point(372, 88)
  707. self.labelStatic3.Name = "labelStatic3"
  708. self.labelStatic3.Size = Size(52, 16)
  709. self.labelStatic3.TabIndex = 62
  710. self.labelStatic3.Text = "Min"
  711. self.labelStatic3.TextAlign = ContentAlignment.TopCenter
  712. #
  713. # labelStatic4
  714. #
  715. self.labelStatic4.BorderStyle = BorderStyle.Fixed3D
  716. self.labelStatic4.Location = Point(627, 88)
  717. self.labelStatic4.Name = "labelStatic4"
  718. self.labelStatic4.Size = Size(52, 16)
  719. self.labelStatic4.TabIndex = 64
  720. self.labelStatic4.Text = "Max"
  721. self.labelStatic4.TextAlign = ContentAlignment.TopCenter
  722. #
  723. # radiobuttonRadioNeg180
  724. #
  725. self.radiobuttonRadioNeg180.Location = Point(16, 16)
  726. self.radiobuttonRadioNeg180.Name = "radiobuttonRadioNeg180"
  727. self.radiobuttonRadioNeg180.Size = Size(45, 16)
  728. self.radiobuttonRadioNeg180.TabIndex = 65
  729. self.radiobuttonRadioNeg180.Text = "-180"
  730. self.radiobuttonRadioNeg180.CheckedChanged += self.trackbarSliderScroll
  731. #
  732. # radiobuttonRadioNeg90
  733. #
  734. self.radiobuttonRadioNeg90.Location = Point(72, 16)
  735. self.radiobuttonRadioNeg90.Name = "radiobuttonRadioNeg90"
  736. self.radiobuttonRadioNeg90.Size = Size(39, 16)
  737. self.radiobuttonRadioNeg90.TabIndex = 66
  738. self.radiobuttonRadioNeg90.Text = "-90"
  739. self.radiobuttonRadioNeg90.CheckedChanged += self.trackbarSliderScroll
  740. #
  741. # radiobuttonRadioZero
  742. #
  743. self.radiobuttonRadioZero.Location = Point(120, 16)
  744. self.radiobuttonRadioZero.Name = "radiobuttonRadioZero"
  745. self.radiobuttonRadioZero.Size = Size(30, 16)
  746. self.radiobuttonRadioZero.TabIndex = 67
  747. self.radiobuttonRadioZero.Text = "0"
  748. self.radiobuttonRadioZero.CheckedChanged += self.trackbarSliderScroll
  749. #
  750. # radiobuttonRadio90
  751. #
  752. self.radiobuttonRadio90.Location = Point(152, 16)
  753. self.radiobuttonRadio90.Name = "radiobuttonRadio90"
  754. self.radiobuttonRadio90.Size = Size(36, 16)
  755. self.radiobuttonRadio90.TabIndex = 68
  756. self.radiobuttonRadio90.Text = "90"
  757. self.radiobuttonRadio90.CheckedChanged += self.trackbarSliderScroll
  758. #
  759. # radiobuttonRadio180
  760. #
  761. self.radiobuttonRadio180.Location = Point(200, 16)
  762. self.radiobuttonRadio180.Name = "radiobuttonRadio180"
  763. self.radiobuttonRadio180.Size = Size(42, 16)
  764. self.radiobuttonRadio180.TabIndex = 69
  765. self.radiobuttonRadio180.Text = "180"
  766. self.radiobuttonRadio180.CheckedChanged += self.trackbarSliderScroll
  767. #
  768. # buttonDelete
  769. #
  770. self.buttonDelete.Location = Point(40, 248)
  771. self.buttonDelete.Name = "buttonDelete"
  772. self.buttonDelete.Size = Size(64, 24)
  773. self.buttonDelete.TabIndex = 3
  774. self.buttonDelete.Text = "Delete"
  775. self.buttonDelete.Click += self.buttonDelete_Click
  776. #
  777. # listboxEffects
  778. #
  779. self.listboxEffects.Location = Point(8, 48)
  780. self.listboxEffects.Name = "listboxEffects"
  781. self.listboxEffects.Size = Size(128, 186)
  782. self.listboxEffects.TabIndex = 2
  783. self.listboxEffects.KeyUp += KeyEventHandler(self.listboxEffects_KeyUp)
  784. self.listboxEffects.SelectedIndexChanged += self.listboxEffects_SelectedIndexChanged
  785. #
  786. # timer1
  787. #
  788. self.timer1.Interval = 50
  789. self.timer1.Tick += self.timer1_Tick
  790. #
  791. # groupboxFrameWaveform
  792. #
  793. self.groupboxFrameWaveform.Controls.AddRange(Array[Control] ([\
  794. self.radiobuttonSquare,\
  795. self.radiobuttonTriangle,\
  796. self.radiobuttonRadioSine\
  797. ]))
  798. self.groupboxFrameWaveform.Location = Point(180, 400)
  799. self.groupboxFrameWaveform.Name = "groupboxFrameWaveform"
  800. self.groupboxFrameWaveform.Size = Size(225, 42)
  801. self.groupboxFrameWaveform.TabIndex = 35
  802. self.groupboxFrameWaveform.TabStop = False
  803. self.groupboxFrameWaveform.Text = "Waveform"
  804. #
  805. # groupboxFramePhase
  806. #
  807. self.groupboxFramePhase.Controls.AddRange(Array[Control] ([
  808. self.radiobuttonRadioNeg180,
  809. self.radiobuttonRadioNeg90,
  810. self.radiobuttonRadioZero,
  811. self.radiobuttonRadio90,
  812. self.radiobuttonRadio180
  813. ]))
  814. self.groupboxFramePhase.Location = Point(420, 400)
  815. self.groupboxFramePhase.Name = "groupboxFramePhase"
  816. self.groupboxFramePhase.Size = Size(247, 42)
  817. self.groupboxFramePhase.TabIndex = 63
  818. self.groupboxFramePhase.TabStop = False
  819. self.groupboxFramePhase.Text = "Phase (Degrees)"
  820. #
  821. # groupboxEffects
  822. #
  823. self.groupboxEffects.Controls.AddRange(Array[Control] ([
  824. self.buttonDelete,
  825. self.listboxEffects,
  826. self.comboEffects
  827. ]))
  828. self.groupboxEffects.Location = Point(8, 80)
  829. self.groupboxEffects.Name = "groupboxEffects"
  830. self.groupboxEffects.Size = Size(144, 280)
  831. self.groupboxEffects.TabIndex = 71
  832. self.groupboxEffects.TabStop = False
  833. self.groupboxEffects.Text = "Effects"
  834. #
  835. # comboEffects
  836. #
  837. self.comboEffects.DropDownStyle = ComboBoxStyle.DropDownList
  838. self.comboEffects.Items.AddRange(Array[Object] ([
  839. "Chorus",
  840. "Compressor",
  841. "Distortion",
  842. "Echo",
  843. "Flanger",
  844. "Gargle",
  845. "Waves Reverb",
  846. "ParamEq"
  847. ]))
  848. self.comboEffects.Location = Point(8, 16)
  849. self.comboEffects.Name = "comboEffects"
  850. self.comboEffects.Size = Size(128, 21)
  851. self.comboEffects.TabIndex = 1
  852. self.comboEffects.SelectedValueChanged += self.comboEffects_SelectedValueChanged
  853. self.Controls.AddRange(Array[Control] ([
  854. self.groupboxEffects,
  855. self.buttonOk,
  856. self.labelParamName1,
  857. self.labelParamValue1,
  858. self.trackbarSlider1,
  859. self.labelParamMin1,
  860. self.labelParamMax1,
  861. self.labelParamName2,
  862. self.labelParamValue2,
  863. self.trackbarSlider2,
  864. self.labelParamMin2,
  865. self.labelParamMax2,
  866. self.labelParamName3,
  867. self.labelParamValue3,
  868. self.trackbarSlider3,
  869. self.labelParamMin3,
  870. self.labelParamMax3,
  871. self.labelParamName4,
  872. self.labelParamValue4,
  873. self.trackbarSlider4,
  874. self.labelParamMin4,
  875. self.labelParamMax4,
  876. self.labelParamName5,
  877. self.labelParamValue5,
  878. self.trackbarSlider5,
  879. self.labelParamMin5,
  880. self.labelParamMax5,
  881. self.labelParamName6,
  882. self.labelParamValue6,
  883. self.trackbarSlider6,
  884. self.labelParamMin6,
  885. self.labelParamMax6,
  886. self.buttonOpen,
  887. self.labelTextFilename,
  888. self.labelStatic2,
  889. self.labelTextStatus,
  890. self.checkboxLoop,
  891. self.buttonPlay,
  892. self.buttonStop,
  893. self.labelStatic3,
  894. self.labelStatic4,
  895. self.groupboxFrameWaveform,
  896. self.groupboxFramePhase,
  897. self.groupboxFrame
  898. ]))
  899. # Form
  900. self.AcceptButton = self.buttonOk
  901. self.ClientSize = Size(700, 472)
  902. self.FormBorderStyle = FormBorderStyle.FixedSingle
  903. self.Location = Point(150, 160)
  904. self.MaximizeBox = False
  905. self.Name = "MainForm"
  906. self.Text = "SoundFX - Sound effects applied to Device.SecondaryBuffer"
  907. self.Closing += CancelEventHandler(self.MainForm_Closing)
  908. self.trackbarSlider1.EndInit()
  909. self.trackbarSlider2.EndInit()
  910. self.trackbarSlider3.EndInit()
  911. self.trackbarSlider4.EndInit()
  912. self.trackbarSlider5.EndInit()
  913. self.trackbarSlider6.EndInit()
  914. self.groupboxFrameWaveform.ResumeLayout(False)
  915. self.groupboxFramePhase.ResumeLayout(False)
  916. self.groupboxEffects.ResumeLayout(False)
  917. self.ResumeLayout(False)
  918. def trackbarSliderScroll(self, sender, e):
  919. # We're ignoring settings right now
  920. if self.isIgnoringSettings:
  921. return
  922. eff = self.effectDescription[self.currentIndex]
  923. efftype = eff.Effect.GetType()
  924. if (clr.GetClrType(ChorusEffect) == efftype):
  925. temp = EffectsChorus()
  926. temp.WetDryMix = self.trackbarSlider1.Value
  927. temp.Frequency = self.trackbarSlider4.Value
  928. temp.Feedback = self.trackbarSlider3.Value
  929. temp.Depth = self.trackbarSlider2.Value
  930. temp.Delay = self.trackbarSlider5.Value
  931. if (True == self.radiobuttonRadioSine.Checked):
  932. temp.Waveform = ChorusEffect.WaveSin
  933. else:
  934. temp.Waveform = ChorusEffect.WaveTriangle
  935. if (True == self.radiobuttonRadioNeg180.Checked):
  936. temp.Phase = ChorusEffect.PhaseNegative180
  937. elif (True == self.radiobuttonRadioNeg90.Checked):
  938. temp.Phase = ChorusEffect.PhaseNegative90
  939. elif (True == self.radiobuttonRadioZero.Checked):
  940. temp.Phase = ChorusEffect.PhaseZero
  941. elif (True == self.radiobuttonRadio90.Checked):
  942. temp.Phase = ChorusEffect.Phase90
  943. elif (True == self.radiobuttonRadio180.Checked):
  944. temp.Phase = ChorusEffect.Phase180
  945. eff.EffectSettings = temp
  946. eff.Effect.AllParameters = temp
  947. elif (clr.GetClrType(CompressorEffect) == efftype):
  948. temp = EffectsCompressor()
  949. temp.Gain = self.trackbarSlider1.Value
  950. temp.Attack = self.trackbarSlider2.Value
  951. temp.Release = self.trackbarSlider3.Value
  952. temp.Threshold = self.trackbarSlider4.Value
  953. temp.Ratio = self.trackbarSlider5.Value
  954. temp.Predelay = self.trackbarSlider6.Value
  955. eff.EffectSettings = temp
  956. eff.Effect.AllParameters = temp
  957. elif (clr.GetClrType(DistortionEffect) == efftype):
  958. temp = EffectsDistortion()
  959. temp.Gain = self.trackbarSlider1.Value
  960. temp.Edge = self.trackbarSlider2.Value
  961. temp.PostEqCenterFrequency = self.trackbarSlider3.Value
  962. temp.PostEqBandwidth = self.trackbarSlider4.Value
  963. temp.PreLowpassCutoff = self.trackbarSlider5.Value
  964. eff.EffectSettings = temp
  965. eff.Effect.AllParameters = temp
  966. elif (clr.GetClrType(EchoEffect) == efftype):
  967. temp = EffectsEcho()
  968. temp.WetDryMix = self.trackbarSlider1.Value
  969. temp.Feedback = self.trackbarSlider2.Value
  970. temp.LeftDelay = self.trackbarSlider3.Value
  971. temp.RightDelay = self.trackbarSlider4.Value
  972. temp.PanDelay = self.trackbarSlider5.Value
  973. eff.EffectSettings = temp
  974. eff.Effect.AllParameters = temp
  975. elif (clr.GetClrType(FlangerEffect) == efftype):
  976. temp = EffectsFlanger()
  977. temp.WetDryMix = self.trackbarSlider1.Value
  978. temp.Depth = self.trackbarSlider2.Value
  979. temp.Feedback = self.trackbarSlider3.Value
  980. temp.Frequency = self.trackbarSlider4.Value
  981. temp.Delay = self.trackbarSlider5.Value
  982. if (True == self.radiobuttonRadioSine.Checked):
  983. temp.Waveform = FlangerEffect.WaveSin
  984. else:
  985. temp.Waveform = FlangerEffect.WaveTriangle
  986. if (True == self.radiobuttonRadioNeg180.Checked):
  987. temp.Phase = ChorusEffect.PhaseNegative180
  988. elif (True == self.radiobuttonRadioNeg90.Checked):
  989. temp.Phase = ChorusEffect.PhaseNegative90
  990. elif (True == self.radiobuttonRadioZero.Checked):
  991. temp.Phase = ChorusEffect.PhaseZero
  992. elif (True == self.radiobuttonRadio90.Checked):
  993. temp.Phase = ChorusEffect.Phase90
  994. elif (True == self.radiobuttonRadio180.Checked):
  995. temp.Phase = ChorusEffect.Phase180
  996. eff.EffectSettings = temp
  997. eff.Effect.AllParameters = temp
  998. elif (clr.GetClrType(GargleEffect) == efftype):
  999. temp = EffectsGargle()
  1000. temp.RateHz = self.trackbarSlider1.Value
  1001. if (self.radiobuttonSquare.Checked):
  1002. temp.WaveShape = GargleEffect.WaveSquare
  1003. else:
  1004. temp.WaveShape = GargleEffect.WaveTriangle
  1005. if (True == self.radiobuttonSquare.Checked):
  1006. temp.WaveShape = GargleEffect.WaveSquare
  1007. else:
  1008. temp.WaveShape = GargleEffect.WaveTriangle
  1009. eff.EffectSettings = temp
  1010. eff.Effect.AllParameters = temp
  1011. elif (clr.GetClrType(ParamEqEffect) == efftype):
  1012. temp = EffectsParamEq()
  1013. temp.Center = self.trackbarSlider1.Value
  1014. temp.Bandwidth = self.trackbarSlider2.Value
  1015. temp.Gain = self.trackbarSlider3.Value
  1016. eff.EffectSettings = temp
  1017. eff.Effect.AllParameters = temp
  1018. elif (clr.GetClrType(WavesReverbEffect) == efftype):
  1019. temp = EffectsWavesReverb()
  1020. temp.InGain = self.trackbarSlider1.Value
  1021. temp.ReverbMix = self.trackbarSlider2.Value
  1022. temp.ReverbTime = (.001 * self.trackbarSlider3.Value)
  1023. temp.HighFrequencyRtRatio = (.001 * self.trackbarSlider4.Value)
  1024. eff.EffectSettings = temp
  1025. eff.Effect.AllParameters = temp
  1026. self.effectDescription[self.currentIndex] = eff
  1027. self.UpdateUI(False)
  1028. def buttonOk_Click(self, sender, e):
  1029. """
  1030. ???????
  1031. """
  1032. self.Close()
  1033. def buttonOpen_Click(self, sender, e):
  1034. """
  1035. ???????
  1036. """
  1037. description = BufferDescription()
  1038. ofd = OpenFileDialog()
  1039. self.labelTextStatus.Text = "Loading file..."
  1040. # ?????? (?? C:\WINDOWS\MEDIA)
  1041. if ('' == self.path):
  1042. self.path = Environment.SystemDirectory.Substring(0, Environment.SystemDirectory.LastIndexOf("\\")) + "\\media"
  1043. ofd.DefaultExt = ".wav"
  1044. ofd.Filter = "Wave Files|*.wav|All Files|*.*"
  1045. ofd.FileName = self.fileName
  1046. ofd.InitialDirectory = self.path
  1047. if (not None is self.applicationBuffer):
  1048. self.applicationBuffer.Stop()
  1049. self.applicationBuffer.SetCurrentPosition(0)
  1050. # ????
  1051. if (DialogResult.Cancel == ofd.ShowDialog(self)):
  1052. if(not None is self.applicationBuffer):
  1053. self.applicationBuffer.Dispose()
  1054. self.labelTextStatus.Text = "No file loaded."
  1055. return
  1056. self.fileName = ''
  1057. description.ControlEffects = True
  1058. # ?????? SecondaryBuffer
  1059. try:
  1060. self.applicationBuffer = SecondaryBuffer(ofd.FileName, description, self.applicationDevice)
  1061. except(BufferTooSmallException):
  1062. self.labelTextStatus.Text = "Wave file is too small to be used with effects."
  1063. return
  1064. except(FormatException):
  1065. # Invalid file was used. Managed DirectSound tries to convert any files less than
  1066. # 8 bit to 8 bit. Some drivers don't support this conversion, so make sure to
  1067. # catch the FormatException if it's thrown.
  1068. self.labelTextStatus.Text = "Failed to create SecondaryBuffer from selected file."
  1069. return
  1070. # ????
  1071. if (not None is self.applicationBuffer):
  1072. self.fileName = ofd.FileName
  1073. self.path = self.fileName.Substring(0, self.fileName.LastIndexOf("\\"))
  1074. self.labelTextFilename.Text = self.fileName
  1075. def checkboxLoop_CheckedChanged(self, sender, e):
  1076. """
  1077. ???????????
  1078. """
  1079. self.shouldLoop = self.checkboxLoop.Checked
  1080. def buttonPlay_Click(self, sender, e):
  1081. """
  1082. ???????
  1083. """
  1084. if (not None is self.applicationBuffer):
  1085. self.applicationBuffer.Play(0, BufferPlayFlags.Looping if self.shouldLoop else BufferPlayFlags.Default)
  1086. self.timer1.Enabled = True
  1087. self.buttonStop.Enabled = True
  1088. self.buttonPlay.Enabled = False
  1089. self.comboEffects.Enabled = False
  1090. self.labelTextStatus.Text="Sound playing."
  1091. def buttonStop_Click(self, sender, e):
  1092. """
  1093. ???????
  1094. """
  1095. if (not None is self.applicationBuffer):
  1096. if self.applicationBuffer.Status.Playing:
  1097. self.applicationBuffer.Stop()
  1098. self.applicationBuffer.SetCurrentPosition(0)
  1099. self.timer1.Enabled = False
  1100. self.buttonStop.Enabled = False
  1101. self.buttonPlay.Enabled = True
  1102. self.comboEffects.Enabled = True
  1103. self.labelTextStatus.Text="Sound stopped."
  1104. def buttonDelete_Click(self, sender, e):
  1105. """
  1106. ???????
  1107. """
  1108. self.DeleteEffect()
  1109. def AddEffect(self, temp):
  1110. """
  1111. ????
  1112. """
  1113. ret = None
  1114. fx = None
  1115. WasPlaying = False
  1116. count = 0
  1117. if (not None is temp):
  1118. #fx = Array.CreateInstance(EffectDescription, len(temp))
  1119. #fx = []
  1120. count = len(temp)
  1121. if (True == self.applicationBuffer.Status.Playing):
  1122. WasPlaying = True
  1123. self.applicationBuffer.Stop()
  1124. # Store the current params for each effect.
  1125. fx = [elem.description for elem in temp]
  1126. try:
  1127. ret = self.applicationBuffer.SetEffects( Array[EffectDescription](fx) )
  1128. except DirectXException as inst:
  1129. labelTextStatus.Text = "Unable to set effect on the buffer. Some effects can't be set on 8 bit wave files."
  1130. # Revert to the last valid effects.
  1131. if (len(temp) <= 1):
  1132. return False
  1133. fx = Array.CreateInstance(EffectDescription, len(temp) -1)
  1134. for i in range(count - 1):
  1135. fx[i] = temp[i].description
  1136. try:
  1137. self.applicationBuffer.SetEffects(fx)
  1138. except(DirectXException):
  1139. pass
  1140. return False
  1141. # Restore the params for each effect.
  1142. for i in range(count):
  1143. eff = EffectInfo()
  1144. eff.Effect = self.applicationBuffer.GetEffects(i)
  1145. eff.EffectSettings = temp[i].EffectSettings
  1146. eff.description = temp[i].description
  1147. efftype = eff.Effect.GetType()
  1148. if (clr.GetClrType(ChorusEffect) == efftype):
  1149. if (not None is eff.EffectSettings):
  1150. eff.Effect.AllParameters = eff.EffectSettings
  1151. else:
  1152. eff.EffectSettings = eff.Effect.AllParameters
  1153. elif (clr.GetClrType ==efftype) :
  1154. if (not None is eff.EffectSettings):
  1155. eff.Effect.AllParameters = eff.EffectSettings
  1156. else:
  1157. eff.EffectSettings = eff.Effect.AllParameters
  1158. elif (clr.GetClrType(DistortionEffect) == efftype):
  1159. if (not None is eff.EffectSettings):
  1160. eff.Effect.AllParameters = eff.EffectSettings
  1161. else:
  1162. eff.EffectSettings = eff.Effect.AllParameters
  1163. elif (clr.GetClrType(EchoEffect) == efftype):
  1164. if (not None is eff.EffectSettings):
  1165. eff.Effect.AllParameters = eff.EffectSettings
  1166. else:
  1167. eff.EffectSettings = eff.Effect.AllParameters
  1168. elif (clr.GetClrType(FlangerEffect) == efftype):
  1169. if (not None is eff.EffectSettings):
  1170. eff.Effect.AllParameters = eff.EffectSettings
  1171. else:
  1172. eff.EffectSettings = eff.Effect.AllParameters
  1173. elif (clr.GetClrType(GargleEffect) == efftype):
  1174. if (not None is eff.EffectSettings):
  1175. eff.Effect.AllParameters = eff.EffectSettings
  1176. else:
  1177. eff.EffectSettings = eff.Effect.AllParameters
  1178. elif (clr.GetClrType(ParamEqEffect) == efftype):
  1179. if (not None is eff.EffectSettings):
  1180. eff.Effect.AllParameters = eff.EffectSettings
  1181. else:
  1182. eff.EffectSettings = eff.Effect.AllParameters
  1183. elif (clr.GetClrType(WavesReverbEffect) == efftype):
  1184. if (not None is eff.EffectSettings):
  1185. eff.Effect.AllParameters = eff.EffectSettings
  1186. else:
  1187. eff.EffectSettings = eff.Effect.AllParameters
  1188. temp[i] = eff
  1189. if (WasPlaying):
  1190. self.applicationBuffer.Play(0, BufferPlayFlags.Looping if shouldLoop else BufferPlayFlags.Default)
  1191. if (not None is temp):
  1192. if ((1 == ret[-1]) or (2 == ret[-1]) ):
  1193. return True
  1194. return False
  1195. def DeleteEffect(self):
  1196. temp = None
  1197. if (-1 == listboxEffects.SelectedIndex) :
  1198. return
  1199. self.effectDescription.RemoveAt(listboxEffects.SelectedIndex)
  1200. if (effectDescription.Count > 0):
  1201. #temp = EffectInfo[effectDescription.Count]
  1202. temp = Array.CreateInstance(EffectInfo, self.effectDescription.Count)
  1203. self.effectDescription.CopyTo(temp, 0)
  1204. self.AddEffect(temp)
  1205. self.listboxEffects.Items.RemoveAt(self.listboxEffects.SelectedIndex)
  1206. self.listboxEffects.SelectedIndex = self.currentIndex = 0
  1207. else:
  1208. temp = None
  1209. self.AddEffect(temp)
  1210. self.listboxEffects.Items.Clear()
  1211. self.ClearUI(True)
  1212. self.effectDescription.Clear()
  1213. if (not None is temp):
  1214. self.effectDescription.AddRange(temp)
  1215. def listboxEffects_KeyUp(self, sender, e):
  1216. if (e.KeyCode == Keys.Delete):
  1217. self.DeleteEffect()
  1218. def listboxEffects_SelectedIndexChanged(self, sender, e):
  1219. """
  1220. ?????????
  1221. """
  1222. if (-1 == self.listboxEffects.SelectedIndex):
  1223. return
  1224. self.currentIndex = self.listboxEffects.SelectedIndex
  1225. # Make sure we don't update any settings while updating the UI
  1226. self.isIgnoringSettings = True
  1227. self.UpdateUI(True)
  1228. self.isIgnoringSettings = False
  1229. def UpdateUI(self, MoveControls):
  1230. """
  1231. ?? UI
  1232. """
  1233. self.ClearUI(MoveControls)
  1234. efftype = self.effectDescription[self.currentIndex].Effect.GetType()
  1235. eff = self.effectDescription[self.currentIndex].Effect
  1236. if (clr.GetClrType(ChorusEffect) == efftype):
  1237. temp = eff.AllParameters
  1238. if (MoveControls):
  1239. self.trackbarSlider1.Minimum = int(ChorusEffect.WetDryMixMin)
  1240. self.trackbarSlider1.Maximum = int(ChorusEffect.WetDryMixMax)
  1241. self.trackbarSlider1.Value = int(temp.WetDryMix)
  1242. self.trackbarSlider2.Minimum = int(ChorusEffect.DepthMin)
  1243. self.trackbarSlider2.Maximum = int(ChorusEffect.DepthMax)
  1244. self.trackbarSlider2.Value = int(temp.Depth)
  1245. self.trackbarSlider3.Minimum = int(ChorusEffect.FeedbackMin)
  1246. self.trackbarSlider3.Maximum = int(ChorusEffect.FeedbackMax)
  1247. self.trackbarSlider3.Value = int(temp.Feedback)
  1248. self.trackbarSlider4.Minimum = int(ChorusEffect.FrequencyMin)
  1249. self.trackbarSlider4.Maximum = int(ChorusEffect.FrequencyMax)
  1250. self.trackbarSlider4.Value = int(temp.Frequency)
  1251. self.trackbarSlider5.Minimum = int(ChorusEffect.DelayMin)
  1252. self.trackbarSlider5.Maximum = int(ChorusEffect.DelayMax)
  1253. self.trackbarSlider5.Value = int(temp.Delay)
  1254. if (ChorusEffect.WaveSin == temp.Waveform):
  1255. self.radiobuttonRadioSine.Checked = True
  1256. else:
  1257. self.radiobuttonTriangle.Checked = True
  1258. if (ChorusEffect.PhaseNegative180 == temp.Phase):
  1259. self.radiobuttonRadioNeg180.Checked = True
  1260. elif (ChorusEffect.PhaseNegative90 == temp.Phase):
  1261. self.radiobuttonRadioNeg90.Checked = True
  1262. elif (ChorusEffect.PhaseZero == temp.Phase):
  1263. self.radiobuttonRadioZero.Checked = True
  1264. elif (ChorusEffect.Phase90 == temp.Phase):
  1265. self.radiobuttonRadio90.Checked = True
  1266. elif (ChorusEffect.Phase180 == temp.Phase):
  1267. self.radiobuttonRadio180.Checked = True
  1268. self.groupboxFramePhase.Enabled = self.radiobuttonRadioNeg180.Enabled = self.radiobuttonRadioNeg90.Enabled =\
  1269. self.radiobuttonRadioZero.Enabled = self.radiobuttonRadio90.Enabled = self.radiobuttonRadio180.Enabled =\
  1270. self.groupboxFrameWaveform.Enabled = self.radiobuttonRadioSine.Enabled =\
  1271. self.radiobuttonTriangle.Enabled = True
  1272. self.trackbarSlider1.Enabled = self.trackbarSlider2.Enabled = self.trackbarSlider3.Enabled =\
  1273. self.trackbarSlider4.Enabled = self.trackbarSlider5.Enabled = True
  1274. self.labelParamValue1.Text = temp.WetDryMix.ToString()
  1275. self.labelParamName1.Text = "Wet/Dry Mix (%)"
  1276. self.labelParamValue2.Text = temp.Depth.ToString()
  1277. self.labelParamName2.Text = "Depth (%)"
  1278. self.labelParamValue3.Text = temp.Feedback.ToString()
  1279. self.labelParamName3.Text = "Feedback (%)"
  1280. self.labelParamValue4.Text = temp.Frequency.ToString()
  1281. self.labelParamName4.Text = "Frequency (Hz)"
  1282. self.labelParamValue5.Text = temp.Delay.ToString()
  1283. self.labelParamName5.Text = "Delay (ms)"
  1284. elif (clr.GetClrType(CompressorEffect) == efftype) :
  1285. temp = eff.AllParameters
  1286. if (MoveControls):
  1287. self.trackbarSlider1.Minimum = int(CompressorEffect.GainMin)
  1288. self.trackbarSlider1.Maximum = int(CompressorEffect.GainMax)
  1289. self.trackbarSlider1.Value = int(temp.Gain)
  1290. self.trackbarSlider2.Minimum = int(CompressorEffect.AttackMin)
  1291. self.trackbarSlider2.Maximum = int(CompressorEffect.AttackMax)
  1292. self.trackbarSlider2.Value = int(temp.Attack)
  1293. self.trackbarSlider3.Minimum = int(CompressorEffect.ReleaseMin)
  1294. self.trackbarSlider3.Maximum = int(CompressorEffect.ReleaseMax)
  1295. self.trackbarSlider3.Value = int(temp.Release)
  1296. self.trackbarSlider4.Minimum = int(CompressorEffect.ThresholdMin)
  1297. self.trackbarSlider4.Maximum = int(CompressorEffect.ThresholdMax)
  1298. self.trackbarSlider4.Value = int(temp.Threshold)
  1299. self.trackbarSlider5.Minimum = int(CompressorEffect.RatioMin)
  1300. self.trackbarSlider5.Maximum = int(CompressorEffect.RatioMax)
  1301. self.trackbarSlider5.Value = int(temp.Ratio)
  1302. self.trackbarSlider6.Minimum = int(CompressorEffect.PreDelayMin)
  1303. self.trackbarSlider6.Maximum = int(CompressorEffect.PreDelayMax)
  1304. self.trackbarSlider6.Value = int(temp.Predelay)
  1305. self.trackbarSlider1.Enabled = self.trackbarSlider2.Enabled = self.trackbarSlider3.Enabled = \
  1306. self.trackbarSlider4.Enabled = self.trackbarSlider5.Enabled = self.trackbarSlider6.Enabled = True
  1307. self.labelParamValue1.Text = temp.Gain.ToString()
  1308. self.labelParamName1.Text = "Gain (dB)"
  1309. self.labelParamName2.Text = "Attack (ms)"
  1310. self.labelParamValue2.Text = temp.Attack.ToString()
  1311. self.labelParamName3.Text = "Release (ms)"
  1312. self.labelParamValue3.Text = temp.Release.ToString()
  1313. self.labelParamName4.Text = "Threshold (dB)"
  1314. self.labelParamValue4.Text = temp.Threshold.ToString()
  1315. self.labelParamName5.Text = "Ratio (x:1)"
  1316. self.labelParamValue5.Text = temp.Ratio.ToString()
  1317. self.labelParamName6.Text = "Predelay (ms)"
  1318. self.labelParamValue6.Text = temp.Predelay.ToString()
  1319. elif (clr.GetClrType(DistortionEffect) == efftype):
  1320. temp = eff.AllParameters
  1321. if (MoveControls):
  1322. self.trackbarSlider1.Minimum = int(DistortionEffect.GainMin)
  1323. self.trackbarSlider1.Maximum = int(DistortionEffect.GainMax)
  1324. self.trackbarSlider1.Value = int(temp.Gain)
  1325. self.trackbarSlider2.Minimum = int(DistortionEffect.EdgeMin)
  1326. self.trackbarSlider2.Maximum = int(DistortionEffect.EdgeMax)
  1327. self.trackbarSlider2.Value = int(temp.Edge)
  1328. self.trackbarSlider3.Minimum = int(DistortionEffect.PostEqCenterFrequencyMin)
  1329. self.trackbarSlider3.Maximum = int(DistortionEffect.PostEqCenterFrequencyMax)
  1330. self.trackbarSlider3.Value = int(temp.PostEqCenterFrequency)
  1331. self.trackbarSlider4.Minimum = int(DistortionEffect.PostEqBandwidthMin)
  1332. self.trackbarSlider4.Maximum = int(DistortionEffect.PostEqBandwidthMax)
  1333. self.trackbarSlider4.Value = int(temp.PostEqBandwidth)
  1334. self.trackbarSlider5.Minimum = int(DistortionEffect.PreLowPassCutoffMin)
  1335. self.trackbarSlider5.Maximum = int(DistortionEffect.PreLowPassCutoffMax)
  1336. self.trackbarSlider5.Value = int(temp.PreLowpassCutoff)
  1337. self.trackbarSlider1.Enabled = self.trackbarSlider2.Enabled = self.trackbarSlider3.Enabled =\
  1338. self.trackbarSlider4.Enabled = self.trackbarSlider5.Enabled = True
  1339. self.labelParamName1.Text = "Gain (dB)"
  1340. self.labelParamValue1.Text = temp.Gain.ToString()
  1341. self.labelParamName2.Text = "Edge (%)"
  1342. self.labelParamValue2.Text = temp.Edge.ToString()
  1343. self.labelParamName3.Text = "PostEQ Center Freq (Hz)"
  1344. self.labelParamValue3.Text = temp.PostEqCenterFrequency.ToString()
  1345. self.labelParamName4.Text = "PostEQ Bandwidth (Hz)"
  1346. self.labelParamValue4.Text = temp.PostEqBandwidth.ToString()
  1347. self.labelParamName5.Text = "PreLowpass Cutoff (Hz)"
  1348. self.labelParamValue5.Text = temp.PreLowpassCutoff.ToString()
  1349. elif (clr.GetClrType(EchoEffect) == efftype):
  1350. temp = eff.AllParameters
  1351. if (MoveControls):
  1352. self.trackbarSlider1.Minimum = int(EchoEffect.WetDryMixMin)
  1353. self.trackbarSlider1.Maximum = int(EchoEffect.WetDryMixMax)
  1354. self.trackbarSlider1.Value = int(temp.WetDryMix)
  1355. self.trackbarSlider2.Minimum = int(EchoEffect.FeedbackMin)
  1356. self.trackbarSlider2.Maximum = int(EchoEffect.FeedbackMax)
  1357. self.trackbarSlider2.Value = int(temp.Feedback)
  1358. self.trackbarSlider3.Minimum = int(EchoEffect.LeftDelayMin)
  1359. self.trackbarSlider3.Maximum = int(EchoEffect.LeftDelayMax)
  1360. self.trackbarSlider3.Value = int(temp.LeftDelay)
  1361. self.trackbarSlider4.Minimum = int(EchoEffect.RightDelayMin)
  1362. self.trackbarSlider4.Maximum = int(EchoEffect.RightDelayMax)
  1363. self.trackbarSlider4.Value = int(temp.RightDelay)
  1364. self.trackbarSlider5.Minimum = int(EchoEffect.PanDelayMin)
  1365. self.trackbarSlider5.Maximum = int(EchoEffect.PanDelayMax)
  1366. self.trackbarSlider5.Value = int(temp.PanDelay)
  1367. self.trackbarSlider1.Enabled = self.trackbarSlider2.Enabled = self.trackbarSlider3.Enabled =\
  1368. self.trackbarSlider4.Enabled = self.trackbarSlider5.Enabled = True
  1369. self.labelParamName1.Text = "Wet/Dry Mix (%)"
  1370. self.labelParamValue1.Text = temp.WetDryMix.ToString()
  1371. self.labelParamName2.Text = "Feedback (%)"
  1372. self.labelParamValue2.Text = temp.Feedback.ToString()
  1373. self.labelParamName3.Text = "Left Delay (ms)"
  1374. self.labelParamValue3.Text = temp.LeftDelay.ToString()
  1375. self.labelParamName4.Text = "Right Delay (ms)"
  1376. self.labelParamValue4.Text = temp.RightDelay.ToString()
  1377. self.labelParamName5.Text = "Pan Delay (bool)"
  1378. self.labelParamValue5.Text = temp.PanDelay.ToString()
  1379. elif (clr.GetClrType(FlangerEffect) == efftype):
  1380. temp = eff.AllParameters
  1381. if (MoveControls) :
  1382. self.trackbarSlider1.Minimum = int(FlangerEffect.WetDryMixMin)
  1383. self.trackbarSlider1.Maximum = int(FlangerEffect.WetDryMixMax)
  1384. self.trackbarSlider1.Value = int(temp.WetDryMix)
  1385. self.trackbarSlider2.Minimum = int(FlangerEffect.DepthMin)
  1386. self.trackbarSlider2.Maximum = int(FlangerEffect.DepthMax)
  1387. self.trackbarSlider2.Value = int(temp.Depth)
  1388. self.trackbarSlider3.Minimum = int(FlangerEffect.FeedbackMin)
  1389. self.trackbarSlider3.Maximum = int(FlangerEffect.FeedbackMax)
  1390. self.trackbarSlider3.Value = int(temp.Feedback)
  1391. self.trackbarSlider4.Minimum = int(FlangerEffect.FrequencyMin)
  1392. self.trackbarSlider4.Maximum = int(FlangerEffect.FrequencyMax)
  1393. self.trackbarSlider4.Value = int(temp.Frequency)
  1394. self.trackbarSlider5.Minimum = int(FlangerEffect.DelayMin)
  1395. self.trackbarSlider5.Maximum = int(FlangerEffect.DelayMax)
  1396. self.trackbarSlider5.Value = int(temp.Delay)
  1397. if (ChorusEffect.WaveSin == temp.Waveform):
  1398. self.radiobuttonRadioSine.Checked = True
  1399. else:
  1400. self.radiobuttonTriangle.Checked = True
  1401. if (FlangerEffect.PhaseNeg180 == temp.Phase):
  1402. self.radiobuttonRadioNeg180.Checked = True
  1403. elif (FlangerEffect.PhaseNeg90 == temp.Phase):
  1404. self.radiobuttonRadioNeg90.Checked = True
  1405. elif (FlangerEffect.PhaseZero == temp.Phase):
  1406. self.radiobuttonRadioZero.Checked = True
  1407. elif (FlangerEffect.Phase90 == temp.Phase):
  1408. self.radiobuttonRadio90.Checked = True
  1409. elif (FlangerEffect.Phase180 == temp.Phase):
  1410. self.radiobuttonRadio180.Checked = True
  1411. self.groupboxFramePhase.Enabled = self.radiobuttonRadioNeg180.Enabled = self.radiobuttonRadioNeg90.Enabled =\
  1412. self.radiobuttonRadioZero.Enabled = self.radiobuttonRadio90.Enabled = self.radiobuttonRadio180.Enabled =\
  1413. self.groupboxFrameWaveform.Enabled = self.radiobuttonRadioSine.Enabled = self.radiobuttonTriangle.Enabled = True
  1414. self.trackbarSlider1.Enabled = self.trackbarSlider2.Enabled = self.trackbarSlider3.Enabled =\
  1415. self.trackbarSlider4.Enabled = self.trackbarSlider5