kewlhotrod

Visualizer

Dec 9th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. package
  2. {
  3. import Visualizer2.*;
  4. import flash.display.*;
  5. import flash.events.*;
  6. import flash.filters.*;
  7. import flash.media.*;
  8. import flash.utils.*;
  9. import flash.net.*;
  10. import flash.geom.*;
  11.  
  12. class Visualizer2 extends MovieClip
  13. {
  14. private var pic:Bitmap;
  15. private var ___height:uint;
  16. private var ___width:uint;
  17. private var sc:SoundChannel;
  18. private var s:Sound;
  19. private var res:Number = 2;
  20. private var gfx:BitmapData;
  21. private var zz:Number = 0;
  22. private var ba:ByteArray;
  23.  
  24. function Visualizer2(param3:Number, param4:Number)
  25. {
  26. s = new Sound();
  27. sc = new SoundChannel();
  28. ba = new ByteArray();
  29. res = 2;
  30. zz = 0;
  31. ___width = param3;
  32. ___height = param4;
  33. gfx = new BitmapData(param3,param4,false,0);
  34. pic = new Bitmap(gfx);
  35. addChildAt(pic, 0);
  36. EventManager.addEventListener(this,Event.ENTER_FRAME, processSpectrum);
  37. return;
  38. }// end function
  39.  
  40. private function processSpectrum(event:Event)
  41. {
  42. var _loc_2:Number = NaN;
  43. var _loc_3:int = 0;
  44. var _loc_4:BlurFilter = null;
  45. var _loc_5:* = undefined;
  46. var _loc_6:int = 0;
  47. SoundMixer.computeSpectrum(ba, true, 0);
  48. _loc_2 = ba.readFloat();
  49. l = Math.pow(_loc_2,3) * ___width / 10;
  50. _loc_3 = 0;
  51. while (_loc_3 < 1440)
  52. {
  53.  
  54. gfx.setPixel(l, _loc_3, 16777215 * Math.pow(_loc_3, 2));
  55. _loc_6 = 0;
  56. while (_loc_6 < res)
  57. {
  58.  
  59. gfx.setPixel(Math.sin(_loc_3 / 360 * Math.PI) * l + _loc_6 * (___width / res) - 50, _loc_3 / _loc_6, 16777215 * Math.pow(_loc_3, 2));
  60. _loc_6 = _loc_6 + 1;
  61. }
  62. _loc_3 = _loc_3 + 1;
  63. }
  64. _loc_4 = new BlurFilter(2,2);
  65. _loc_5 = new DisplacementMapFilter(gfx,new Point(0,0),2,1,zz * l / 6,zz + 3);
  66. gfx.applyFilter(gfx, new Rectangle(0, 0, ___width, ___height), new Point(0, 0), _loc_5);
  67. gfx.applyFilter(gfx, new Rectangle(0, 0, ___width, ___height), new Point(0, 0), _loc_4);
  68. zz = 4;
  69. return;
  70. }// end function
  71.  
  72.  
  73. public function removeSelf()
  74. {
  75. if (!parent)
  76. {
  77. return;
  78. }
  79. EventManager.removeAllListeners();
  80. pic.parent.removeChild(pic);
  81. parent.removeChild(this);
  82. }
  83. }
  84. }
  85.  
Add Comment
Please, Sign In to add comment