/src/Zend/Media/Id3/Frame/Rvrb.php

http://php-reader.googlecode.com/ · PHP · 331 lines · 125 code · 35 blank · 171 comment · 1 complexity · 10e10ee040f01aa2df9987205dfbe8c4 MD5 · raw file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Media
  17. * @subpackage ID3
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Rvrb.php 177 2010-03-09 13:13:34Z svollbehr $
  21. */
  22. /**#@+ @ignore */
  23. require_once 'Zend/Media/Id3/Frame.php';
  24. /**#@-*/
  25. /**
  26. * The <i>Reverb</i> is yet another subjective frame, with which you can adjust
  27. * echoes of different kinds. Reverb left/right is the delay between every
  28. * bounce in milliseconds. Reverb bounces left/right is the number of bounces
  29. * that should be made. $FF equals an infinite number of bounces. Feedback is
  30. * the amount of volume that should be returned to the next echo bounce. $00 is
  31. * 0%, $FF is 100%. If this value were $7F, there would be 50% volume reduction
  32. * on the first bounce, 50% of that on the second and so on. Left to left means
  33. * the sound from the left bounce to be played in the left speaker, while left
  34. * to right means sound from the left bounce to be played in the right speaker.
  35. *
  36. * Premix left to right is the amount of left sound to be mixed in the right
  37. * before any reverb is applied, where $00 id 0% and $FF is 100%. Premix right
  38. * to left does the same thing, but right to left. Setting both premix to $FF
  39. * would result in a mono output (if the reverb is applied symmetric). There
  40. * may only be one RVRB frame in each tag.
  41. *
  42. * @category Zend
  43. * @package Zend_Media
  44. * @subpackage ID3
  45. * @author Sven Vollbehr <sven@vollbehr.eu>
  46. * @author Ryan Butterfield <buttza@gmail.com>
  47. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  48. * @license http://framework.zend.com/license/new-bsd New BSD License
  49. * @version $Id: Rvrb.php 177 2010-03-09 13:13:34Z svollbehr $
  50. */
  51. final class Zend_Media_Id3_Frame_Rvrb extends Zend_Media_Id3_Frame
  52. {
  53. /** @var integer */
  54. private $_reverbLeft;
  55. /** @var integer */
  56. private $_reverbRight;
  57. /** @var integer */
  58. private $_reverbBouncesLeft;
  59. /** @var integer */
  60. private $_reverbBouncesRight;
  61. /** @var integer */
  62. private $_reverbFeedbackLtoL;
  63. /** @var integer */
  64. private $_reverbFeedbackLtoR;
  65. /** @var integer */
  66. private $_reverbFeedbackRtoR;
  67. /** @var integer */
  68. private $_reverbFeedbackRtoL;
  69. /** @var integer */
  70. private $_premixLtoR;
  71. /** @var integer */
  72. private $_premixRtoL;
  73. /**
  74. * Constructs the class with given parameters and parses object related
  75. * data.
  76. *
  77. * @param Zend_Io_Reader $reader The reader object.
  78. * @param Array $options The options array.
  79. */
  80. public function __construct($reader = null, &$options = array())
  81. {
  82. parent::__construct($reader, $options);
  83. if ($this->_reader === null) {
  84. return;
  85. }
  86. $this->_reverbLeft = $this->_reader->readUInt16BE();
  87. $this->_reverbRight = $this->_reader->readUInt16BE();
  88. $this->_reverbBouncesLeft = $this->_reader->readUInt8();
  89. $this->_reverbBouncesRight = $this->_reader->readUInt8();
  90. $this->_reverbFeedbackLtoL = $this->_reader->readUInt8();
  91. $this->_reverbFeedbackLtoR = $this->_reader->readUInt8();
  92. $this->_reverbFeedbackRtoR = $this->_reader->readUInt8();
  93. $this->_reverbFeedbackRtoL = $this->_reader->readUInt8();
  94. $this->_premixLtoR = $this->_reader->readUInt8();
  95. $this->_premixRtoL = $this->_reader->readUInt8();
  96. }
  97. /**
  98. * Returns the left reverb.
  99. *
  100. * @return integer
  101. */
  102. public function getReverbLeft()
  103. {
  104. return $this->_reverbLeft;
  105. }
  106. /**
  107. * Sets the left reverb.
  108. *
  109. * @param integer $reverbLeft The left reverb.
  110. */
  111. public function setReverbLeft($reverbLeft)
  112. {
  113. return $this->_reverbLeft = $reverbLeft;
  114. }
  115. /**
  116. * Returns the right reverb.
  117. *
  118. * @return integer
  119. */
  120. public function getReverbRight()
  121. {
  122. return $this->_reverbRight;
  123. }
  124. /**
  125. * Sets the right reverb.
  126. *
  127. * @param integer $reverbRight The right reverb.
  128. */
  129. public function setReverbRight($reverbRight)
  130. {
  131. return $this->_reverbRight = $reverbRight;
  132. }
  133. /**
  134. * Returns the left reverb bounces.
  135. *
  136. * @return integer
  137. */
  138. public function getReverbBouncesLeft()
  139. {
  140. return $this->_reverbBouncesLeft;
  141. }
  142. /**
  143. * Sets the left reverb bounces.
  144. *
  145. * @param integer $reverbBouncesLeft The left reverb bounces.
  146. */
  147. public function setReverbBouncesLeft($reverbBouncesLeft)
  148. {
  149. $this->_reverbBouncesLeft = $reverbBouncesLeft;
  150. }
  151. /**
  152. * Returns the right reverb bounces.
  153. *
  154. * @return integer
  155. */
  156. public function getReverbBouncesRight()
  157. {
  158. return $this->_reverbBouncesRight;
  159. }
  160. /**
  161. * Sets the right reverb bounces.
  162. *
  163. * @param integer $reverbBouncesRight The right reverb bounces.
  164. */
  165. public function setReverbBouncesRight($reverbBouncesRight)
  166. {
  167. $this->_reverbBouncesRight = $reverbBouncesRight;
  168. }
  169. /**
  170. * Returns the left-to-left reverb feedback.
  171. *
  172. * @return integer
  173. */
  174. public function getReverbFeedbackLtoL()
  175. {
  176. return $this->_reverbFeedbackLtoL;
  177. }
  178. /**
  179. * Sets the left-to-left reverb feedback.
  180. *
  181. * @param integer $reverbFeedbackLtoL The left-to-left reverb feedback.
  182. */
  183. public function setReverbFeedbackLtoL($reverbFeedbackLtoL)
  184. {
  185. $this->_reverbFeedbackLtoL = $reverbFeedbackLtoL;
  186. }
  187. /**
  188. * Returns the left-to-right reverb feedback.
  189. *
  190. * @return integer
  191. */
  192. public function getReverbFeedbackLtoR()
  193. {
  194. return $this->_reverbFeedbackLtoR;
  195. }
  196. /**
  197. * Sets the left-to-right reverb feedback.
  198. *
  199. * @param integer $reverbFeedbackLtoR The left-to-right reverb feedback.
  200. */
  201. public function setReverbFeedbackLtoR($reverbFeedbackLtoR)
  202. {
  203. $this->_reverbFeedbackLtoR = $reverbFeedbackLtoR;
  204. }
  205. /**
  206. * Returns the right-to-right reverb feedback.
  207. *
  208. * @return integer
  209. */
  210. public function getReverbFeedbackRtoR()
  211. {
  212. return $this->_reverbFeedbackRtoR;
  213. }
  214. /**
  215. * Sets the right-to-right reverb feedback.
  216. *
  217. * @param integer $reverbFeedbackRtoR The right-to-right reverb feedback.
  218. */
  219. public function setReverbFeedbackRtoR($reverbFeedbackRtoR)
  220. {
  221. $this->_reverbFeedbackRtoR = $reverbFeedbackRtoR;
  222. }
  223. /**
  224. * Returns the right-to-left reverb feedback.
  225. *
  226. * @return integer
  227. */
  228. public function getReverbFeedbackRtoL()
  229. {
  230. return $this->_reverbFeedbackRtoL;
  231. }
  232. /**
  233. * Sets the right-to-left reverb feedback.
  234. *
  235. * @param integer $reverbFeedbackRtoL The right-to-left reverb feedback.
  236. */
  237. public function setReverbFeedbackRtoL($reverbFeedbackRtoL)
  238. {
  239. $this->_reverbFeedbackRtoL = $reverbFeedbackRtoL;
  240. }
  241. /**
  242. * Returns the left-to-right premix.
  243. *
  244. * @return integer
  245. */
  246. public function getPremixLtoR()
  247. {
  248. return $this->_premixLtoR;
  249. }
  250. /**
  251. * Sets the left-to-right premix.
  252. *
  253. * @param integer $premixLtoR The left-to-right premix.
  254. */
  255. public function setPremixLtoR($premixLtoR)
  256. {
  257. $this->_premixLtoR = $premixLtoR;
  258. }
  259. /**
  260. * Returns the right-to-left premix.
  261. *
  262. * @return integer
  263. */
  264. public function getPremixRtoL()
  265. {
  266. return $this->_premixRtoL;
  267. }
  268. /**
  269. * Sets the right-to-left premix.
  270. *
  271. * @param integer $premixRtoL The right-to-left premix.
  272. */
  273. public function setPremixRtoL($premixRtoL)
  274. {
  275. $this->_premixRtoL = $premixRtoL;
  276. }
  277. /**
  278. * Writes the frame raw data without the header.
  279. *
  280. * @param Zend_Io_Writer $writer The writer object.
  281. * @return void
  282. */
  283. protected function _writeData($writer)
  284. {
  285. $writer->writeUInt16BE($this->_reverbLeft)
  286. ->writeUInt16BE($this->_reverbRight)
  287. ->writeUInt8($this->_reverbBouncesLeft)
  288. ->writeUInt8($this->_reverbBouncesRight)
  289. ->writeUInt8($this->_reverbFeedbackLtoL)
  290. ->writeUInt8($this->_reverbFeedbackLtoR)
  291. ->writeUInt8($this->_reverbFeedbackRtoR)
  292. ->writeUInt8($this->_reverbFeedbackRtoL)
  293. ->writeUInt8($this->_premixLtoR)
  294. ->writeUInt8($this->_premixRtoL);
  295. }
  296. }