Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First release of the whole Flod package

  • Loading branch information...
commit 49ba14f2162b37a7ac53f6b9c542430584cc4007 0 parents
@photonstorm authored
Showing with 25,621 additions and 0 deletions.
  1. BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay with Flectrum.fla
  2. BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay with Flectrum.swf
  3. BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay.fla
  4. BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay.swf
  5. +447 −0 Flod Beginners Guide/Flash CS4/neoart/flectrum/Flectrum.as
  6. +129 −0 Flod Beginners Guide/Flash CS4/neoart/flectrum/SoundEx.as
  7. +191 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModChannel.as
  8. +60 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModCommand.as
  9. +35 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModCommandEx.as
  10. +28 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModData.as
  11. +135 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModFlod.as
  12. +605 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModProcessor.as
  13. +294 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModProcessorEx.as
  14. +77 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModSample.as
  15. +245 −0 Flod Beginners Guide/Flash CS4/neoart/flod/ModSong.as
  16. BIN  Flod Beginners Guide/Flash CS4/the_enemy_within.mod
  17. +81 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/Flod Beginners Guide.as3proj
  18. BIN  Flod Beginners Guide/FlexSDK+FlashDevelop/bin/FlodBeginnersGuide.swf
  19. +21 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/obj/FlodBeginnersGuideConfig.xml
  20. +229 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/Main.as
  21. BIN  Flod Beginners Guide/FlexSDK+FlashDevelop/src/assets/180_degrees_dsx_trsi.mod
  22. BIN  Flod Beginners Guide/FlexSDK+FlashDevelop/src/assets/FlectrumMeter.png
  23. BIN  Flod Beginners Guide/FlexSDK+FlashDevelop/src/assets/FlectrumMeter2.png
  24. BIN  Flod Beginners Guide/FlexSDK+FlashDevelop/src/assets/background.jpg
  25. BIN  Flod Beginners Guide/FlexSDK+FlashDevelop/src/assets/banja_dsx_trsi.mod
  26. +447 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flectrum/Flectrum.as
  27. +129 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flectrum/SoundEx.as
  28. +191 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModChannel.as
  29. +60 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModCommand.as
  30. +35 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModCommandEx.as
  31. +28 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModData.as
  32. +135 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModFlod.as
  33. +605 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModProcessor.as
  34. +294 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModProcessorEx.as
  35. +77 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModSample.as
  36. +245 −0 Flod Beginners Guide/FlexSDK+FlashDevelop/src/neoart/flod/ModSong.as
  37. +7 −0 Flod Beginners Guide/readme.txt
  38. BIN  Flod Beginners Guide/screen.psd
  39. +128 −0 FlodEx/FlodEx.as
  40. BIN  FlodEx/FlodEx.fla
  41. BIN  FlodEx/FlodEx.swf
  42. +704 −0 FlodEx/assets/Delta1.s
  43. +138 −0 FlodEx/assets/Delta1Format.txt
  44. +623 −0 FlodEx/assets/Delta1Mine.s
  45. +734 −0 FlodEx/assets/Delta2.s
  46. +136 −0 FlodEx/assets/Delta2Format.txt
  47. +617 −0 FlodEx/assets/Delta2Mine.s
  48. +1,259 −0 FlodEx/assets/DigitalMugician.s
  49. +137 −0 FlodEx/assets/DigitalMugicianFormat.txt
  50. +1,278 −0 FlodEx/assets/DigitalMugicianMine.s
  51. +1,717 −0 FlodEx/assets/DigitalMugician_4-7_Mine.s
  52. +871 −0 FlodEx/assets/SidMon2.s
  53. +191 −0 FlodEx/assets/SidMon2Format.txt
  54. +17 −0 FlodEx/assets/TFMXFormat.txt
  55. +44 −0 FlodEx/history.txt
  56. +12 −0 FlodEx/license.txt
  57. +196 −0 FlodEx/neoart/flod/amiga/Amiga.as
  58. +61 −0 FlodEx/neoart/flod/amiga/AmigaChannel.as
  59. +71 −0 FlodEx/neoart/flod/amiga/AmigaFilter.as
  60. +121 −0 FlodEx/neoart/flod/amiga/AmigaPlayer.as
  61. +23 −0 FlodEx/neoart/flod/amiga/AmigaSample.as
  62. +18 −0 FlodEx/neoart/flod/amiga/Sample.as
  63. +20 −0 FlodEx/neoart/flod/delta1/D1Command.as
  64. +361 −0 FlodEx/neoart/flod/delta1/D1Player.as
  65. +38 −0 FlodEx/neoart/flod/delta1/D1Sample.as
  66. +134 −0 FlodEx/neoart/flod/delta1/D1Song.as
  67. +18 −0 FlodEx/neoart/flod/delta1/D1Step.as
  68. +63 −0 FlodEx/neoart/flod/delta1/D1Voice.as
  69. +20 −0 FlodEx/neoart/flod/delta2/D2Command.as
  70. +273 −0 FlodEx/neoart/flod/delta2/D2Player.as
  71. +29 −0 FlodEx/neoart/flod/delta2/D2Sample.as
  72. +144 −0 FlodEx/neoart/flod/delta2/D2Song.as
  73. +18 −0 FlodEx/neoart/flod/delta2/D2Step.as
  74. +71 −0 FlodEx/neoart/flod/delta2/D2Voice.as
  75. +9 −0 FlodEx/neoart/flod/digitalmugician/DMCommand.as
  76. +186 −0 FlodEx/neoart/flod/digitalmugician/DMModule.as
  77. +694 −0 FlodEx/neoart/flod/digitalmugician/DMPlayer.as
  78. +23 −0 FlodEx/neoart/flod/digitalmugician/DMSample.as
  79. +15 −0 FlodEx/neoart/flod/digitalmugician/DMSong.as
  80. +7 −0 FlodEx/neoart/flod/digitalmugician/DMStep.as
  81. +52 −0 FlodEx/neoart/flod/digitalmugician/DMVoice.as
  82. +202 −0 FlodEx/neoart/flod/digitalmugician/old_DMModule.as
  83. +714 −0 FlodEx/neoart/flod/digitalmugician/old_DMPlayer.as
  84. +375 −0 FlodEx/neoart/flod/futurecomposer/FCPlayer.as
  85. +209 −0 FlodEx/neoart/flod/futurecomposer/FCSong.as
  86. +92 −0 FlodEx/neoart/flod/futurecomposer/FCVoice.as
  87. BIN  FlodEx/neoart/flod/futurecomposer/waveforms.bin
  88. +21 −0 FlodEx/neoart/flod/sidmon1/S1Command.as
  89. +399 −0 FlodEx/neoart/flod/sidmon1/S1Player.as
  90. +34 −0 FlodEx/neoart/flod/sidmon1/S1Sample.as
  91. +337 −0 FlodEx/neoart/flod/sidmon1/S1Song.as
  92. +18 −0 FlodEx/neoart/flod/sidmon1/S1Step.as
  93. +60 −0 FlodEx/neoart/flod/sidmon1/S1Voice.as
  94. +21 −0 FlodEx/neoart/flod/sidmon2/S2Command.as
  95. +37 −0 FlodEx/neoart/flod/sidmon2/S2Instrument.as
  96. +359 −0 FlodEx/neoart/flod/sidmon2/S2Player.as
  97. +25 −0 FlodEx/neoart/flod/sidmon2/S2Sample.as
  98. +231 −0 FlodEx/neoart/flod/sidmon2/S2Song.as
  99. +19 −0 FlodEx/neoart/flod/sidmon2/S2Step.as
  100. +67 −0 FlodEx/neoart/flod/sidmon2/S2Voice.as
  101. +20 −0 FlodEx/neoart/flod/soundmon/BPCommand.as
  102. +491 −0 FlodEx/neoart/flod/soundmon/BPPlayer.as
  103. +42 −0 FlodEx/neoart/flod/soundmon/BPSample.as
  104. +187 −0 FlodEx/neoart/flod/soundmon/BPSong.as
  105. +19 −0 FlodEx/neoart/flod/soundmon/BPStep.as
  106. +79 −0 FlodEx/neoart/flod/soundmon/BPVoice.as
  107. +25 −0 FlodPro/FlodPro.as
  108. BIN  FlodPro/FlodPro.swf
  109. BIN  FlodPro/assets/FlectrumMeter.png
  110. BIN  FlodPro/assets/Screen.png
  111. BIN  FlodPro/assets/VolumeMeter.png
  112. +11 −0 FlodPro/license.txt
  113. +447 −0 FlodPro/neoart/flectrum/Flectrum.as
  114. +129 −0 FlodPro/neoart/flectrum/SoundEx.as
  115. +191 −0 FlodPro/neoart/flod/ModChannel.as
  116. +60 −0 FlodPro/neoart/flod/ModCommand.as
  117. +35 −0 FlodPro/neoart/flod/ModCommandEx.as
  118. +28 −0 FlodPro/neoart/flod/ModData.as
  119. +135 −0 FlodPro/neoart/flod/ModFlod.as
  120. +601 −0 FlodPro/neoart/flod/ModProcessor.as
  121. +294 −0 FlodPro/neoart/flod/ModProcessorEx.as
  122. +77 −0 FlodPro/neoart/flod/ModSample.as
  123. +245 −0 FlodPro/neoart/flod/ModSong.as
  124. +126 −0 FlodPro/neoart/flodpro/Button.as
  125. +107 −0 FlodPro/neoart/flodpro/Control.as
  126. +40 −0 FlodPro/neoart/flodpro/Invalidate.as
  127. +164 −0 FlodPro/neoart/flodpro/Label.as
  128. +86 −0 FlodPro/neoart/flodpro/Meters.as
  129. +76 −0 FlodPro/neoart/flodpro/NumericLabel.as
  130. +190 −0 FlodPro/neoart/flodpro/Panel.as
  131. +558 −0 FlodPro/neoart/flodpro/ProPlayer.as
  132. +190 −0 FlodPro/neoart/flodpro/Slider.as
  133. +36 −0 FlodPro/neoart/flodpro/SliderEvent.as
  134. +87 −0 FlodPro/neoart/flodpro/Spin.as
  135. +67 −0 FlodPro/neoart/flodpro/StateButton.as
  136. +41 −0 FlodPro/neoart/flodpro/Theme.as
  137. +69 −0 FlodPro/neoart/flodpro/TimerEx.as
  138. +146 −0 FlodPro/neoart/flodpro/Tip.as
  139. +83 −0 FlodPro/neoart/flodpro/ToggleButton.as
  140. +86 −0 Flym/Flym.as
  141. BIN  Flym/Flym.fla
  142. BIN  Flym/Flym.swf
  143. +34 −0 Flym/neoart/flym/Digidrum.as
  144. +337 −0 Flym/neoart/flym/LHa.as
  145. +34 −0 Flym/neoart/flym/LHaHeader.as
  146. +42 −0 Flym/neoart/flym/Sample.as
  147. +47 −0 Flym/neoart/flym/YmChannel.as
  148. +70 −0 Flym/neoart/flym/YmConst.as
  149. +296 −0 Flym/neoart/flym/YmProcessor.as
  150. +151 −0 Flym/neoart/flym/YmSong.as
  151. BIN  Media/background.png
  152. BIN  Media/glass.png
  153. BIN  Media/logo.png
  154. +21 −0 README.txt
  155. BIN  Sample Tunes/mod/MangaPart1.mod
  156. BIN  Sample Tunes/mod/Monday.mod
  157. BIN  Sample Tunes/mod/StardustMemories.mod
  158. BIN  Sample Tunes/mod/Tinytune.mod
  159. BIN  Sample Tunes/mod/sound-of-da-lunatic.mod
  160. BIN  Sample Tunes/ym/mad_max-calimero.ym
  161. BIN  Sample Tunes/ym/mad_max-comic_bakery.ym
  162. BIN  Sample Tunes/ym/mad_max-end_theme.ym
  163. BIN  Sample Tunes/ym/mad_max-leaving_terramis_level_tune4.ym
  164. BIN  Sample Tunes/ym/mad_max-level16_fullscreen.ym
  165. BIN  Sample Tunes/ym/mad_max-new_sid_tune1.ym
  166. BIN  Sample Tunes/ym/mad_max-new_sid_tune2.ym
  167. BIN  Sample Tunes/ym/mad_max-one_man_and_his_droid.ym
  168. BIN  Sample Tunes/ym/mad_max-prehistoric_tale1.ym
  169. BIN  Sample Tunes/ym/mad_max-prehistoric_tale_intro.ym
  170. BIN  Sample Tunes/ym/mad_max-replicants_wobbly_sprites.ym
  171. BIN  Sample Tunes/ym/mad_max-rings_of_medusa2_1.ym
  172. BIN  Sample Tunes/ym/mad_max-rings_of_medusa2_2.ym
  173. BIN  Sample Tunes/ym/mad_max-starpaws.ym
  174. BIN  Sample Tunes/ym/mad_max-tcb_scroller.ym
  175. BIN  Sample Tunes/ym/mad_max-thanatos.ym
  176. BIN  Sample Tunes/ym/mad_max-there_are_many_sheep_in_mongolia.ym
BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay with Flectrum.fla
Binary file not shown
BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay with Flectrum.swf
Binary file not shown
BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay.fla
Binary file not shown
BIN  Flod Beginners Guide/Flash CS4/Basic Mod Replay.swf
Binary file not shown
447 Flod Beginners Guide/Flash CS4/neoart/flectrum/Flectrum.as
@@ -0,0 +1,447 @@
+/* Flectrum version 1.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flectrum {
+ import flash.display.*;
+ import flash.events.*;
+ import flash.geom.*;
+ import flash.utils.*;
+
+ public class Flectrum extends Sprite {
+ public static const UP: String = "up";
+ public static const LEFT: String = "left";
+ public static const DOWN: String = "down";
+ public static const RIGHT:String = "right";
+
+ public static const METER:String = "meter";
+ public static const DECAY:String = "decay";
+ public static const PEAKS:String = "peaks";
+
+ public var backgroundBeat:Boolean;
+
+ protected var timer:Timer;
+ protected var meter:BitmapData;
+ protected var background:Bitmap;
+ protected var foreground:Bitmap;
+ protected var buffer:BitmapData;
+ protected var input:BitmapData;
+ protected var output:BitmapData;
+
+ protected var levels:Vector.<Number>;
+ protected var spectrum:Vector.<Number>;
+ protected var destPoint:Point;
+ protected var sourceRect:Rectangle;
+ protected var sectionWidth:int;
+ protected var sectionHeight:int;
+ protected var realHeight:int;
+
+ protected var m_soundEx:SoundEx;
+ protected var m_direction:String = UP;
+ protected var m_mode:String = PEAKS;
+ protected var m_columns:int;
+ protected var m_columnSize:int = 10;
+ protected var m_columnSpacing:int = 2;
+ protected var m_rows:int;
+ protected var m_rowSize:int = 3;
+ protected var m_rowSpacing:int = 1;
+ protected var m_showBackground:Boolean = true;
+ protected var m_backgroundAlpha:Number = 0.2;
+ protected var m_decay:Number = 0.02;
+ protected var m_decayAlpha:uint = 0xd0000000;
+ protected var m_peaksAlpha:uint = 0xff000000;
+
+ protected var m_colors:Array = [0xff3939, 0xffb320, 0xfff820, 0x50d020];
+ protected var m_alphas:Array = [1, 1, 1, 1];
+ protected var m_ratios:Array = [20, 105, 145, 250];
+
+ public function Flectrum(soundEx:SoundEx, columns:int = 15, rows:int = 32) {
+ this.soundEx = soundEx;
+ m_columns = columns;
+ m_rows = rows;
+ mouseEnabled = false;
+ tabEnabled = false;
+
+ background = new Bitmap(null, "always", true);
+ foreground = new Bitmap(null, "always", true);
+ levels = new Vector.<Number>;
+ spectrum = new Vector.<Number>;
+ destPoint = new Point();
+ sourceRect = new Rectangle();
+
+ timer = new Timer(45);
+ timer.addEventListener(TimerEvent.TIMER, peaksHandler);
+ reset();
+ }
+
+ public function useBitmap(image:BitmapData):void {
+ meter = image.clone();
+ clone();
+ }
+
+ public function useDraw():void {
+ meter.dispose();
+ meter = null;
+ draw();
+ }
+
+ protected function reset():void {
+ timer.reset();
+ levels.length = m_columns;
+ for (var i:int = 0; i < m_columns; ++i) levels[i] = 0;
+ while (numChildren) removeChildAt(0);
+
+ background.alpha = m_backgroundAlpha;
+ background.rotation = 0;
+ background.x = 0;
+ background.y = 0;
+ foreground.rotation = 0;
+ foreground.x = 0;
+ foreground.y = 0;
+ if (meter) clone(); else draw();
+ }
+
+ protected function start():void {
+ if (!soundEx) return;
+ timer.reset();
+ timer.start();
+ }
+
+ protected function clone():void {
+ sectionWidth = meter.width + m_columnSpacing;
+ sectionHeight = m_rowSize + m_rowSpacing;
+ realHeight = meter.height + m_rowSpacing;
+
+ var h:int = meter.height, i:int, w:int = m_columns * sectionWidth - m_columnSpacing;
+
+ output = new BitmapData(w, h, true, 0);
+ buffer = output.clone();
+ output.lock();
+ destPoint.x = 0;
+
+ for (i = 0; i < m_columns; ++i) {
+ output.copyPixels(meter, meter.rect, destPoint);
+ destPoint.x += sectionWidth;
+ }
+ m_rows = realHeight / sectionHeight;
+
+ if (m_rowSpacing > 0) {
+ sourceRect.width = w;
+ sourceRect.height = m_rowSpacing;
+ sourceRect.y = h - sectionHeight;
+
+ for (i = 0; i < m_rows; ++i) {
+ output.fillRect(sourceRect, 0);
+ sourceRect.y -= sectionHeight;
+ }
+ }
+ output.unlock();
+ destPoint.x = 0;
+ sourceRect.width = m_columnSize = meter.width;
+
+ input = buffer.clone();
+ input.threshold(output, output.rect, destPoint, "==", 0xff000000, 0x00ffffff, 0xffffffff, true);
+ output.fillRect(output.rect, 0);
+
+ background.bitmapData = input;
+ if (m_showBackground) addChild(background);
+ foreground.bitmapData = output;
+ addChild(foreground);
+ if (m_direction != UP) direction = m_direction;
+ }
+
+ protected function draw():void {
+ visible = false;
+ sectionWidth = m_columnSize + m_columnSpacing;
+ sectionHeight = m_rowSize + m_rowSpacing;
+ realHeight = m_rows * sectionHeight;
+
+ var h:int = realHeight - m_rowSpacing, i:int, matrix:Matrix,
+ p:int = m_rowSize, w:int = m_columns * sectionWidth - m_columnSpacing;
+
+ if (m_colors.length < 2) {
+ graphics.beginFill(m_colors[0], m_alphas[0]);
+ } else {
+ matrix = new Matrix();
+ matrix.createGradientBox(w, h, Math.PI * 0.5, 0, 0);
+ graphics.beginGradientFill(GradientType.LINEAR, m_colors, m_alphas, m_ratios, matrix, SpreadMethod.PAD, InterpolationMethod.LINEAR_RGB);
+ }
+ graphics.drawRect(0, 0, w, h);
+ graphics.endFill();
+
+ for (i = 0; i < m_rows; ++i) {
+ graphics.beginFill(0, 1);
+ graphics.drawRect(0, p, w, m_rowSpacing);
+ graphics.endFill();
+ p += sectionHeight;
+ }
+ p = m_columnSize;
+
+ for (i = 1; i < m_columns; ++i) {
+ graphics.beginFill(0, 1);
+ graphics.drawRect(p, 0, m_columnSpacing, h);
+ graphics.endFill();
+ p += sectionWidth;
+ }
+ output = new BitmapData(w, h, true, 0);
+ buffer = output.clone();
+ output.draw(this);
+ graphics.clear();
+
+ input = buffer.clone();
+ input.threshold(output, output.rect, destPoint, "==", 0xff000000, 0x00ffffff, 0xffffffff, true);
+ output.fillRect(output.rect, 0);
+
+ background.bitmapData = input;
+ if (m_showBackground) addChild(background);
+ foreground.bitmapData = output;
+ addChild(foreground);
+
+ sourceRect.width = m_columnSize;
+ if (m_direction != UP) direction = m_direction;
+ visible = true;
+ }
+
+ protected function startHandler(e:Event):void {
+ m_soundEx.removeEventListener(SoundEx.SOUND_START, startHandler);
+ m_soundEx.addEventListener(SoundEx.SOUND_STOP, stopHandler);
+ m_soundEx.addEventListener(Event.SOUND_COMPLETE, stopHandler);
+ timer.removeEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
+ timer.repeatCount = 0;
+ start();
+ }
+
+ protected function stopHandler(e:Event):void {
+ var i:int, t:Number = 0.0;
+ for (i = 0; i < m_columns; ++i)
+ if (levels[i] > t) t = levels[i];
+
+ m_soundEx.removeEventListener(Event.SOUND_COMPLETE, stopHandler);
+ m_soundEx.removeEventListener(SoundEx.SOUND_STOP, stopHandler);
+ m_soundEx.addEventListener(SoundEx.SOUND_START, startHandler);
+
+ timer.reset();
+ timer.repeatCount = int(t / m_decay) + 1;
+ timer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
+ timer.start();
+ }
+
+ protected function completeHandler(e:Event):void {
+ if (backgroundBeat) background.alpha = m_backgroundAlpha;
+ timer.reset();
+ timer.removeEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
+ }
+
+ protected function meterHandler(e:TimerEvent):void {
+ var h:int, i:int;
+ spectrum = m_soundEx.getStereoAdd(m_columns);
+ buffer.fillRect(buffer.rect, 0);
+ sourceRect.x = 0;
+
+ for (i = 0; i < m_columns; ++i) {
+ h = int(spectrum[i] * m_rows) * sectionHeight;
+ sourceRect.height = h;
+ sourceRect.y = realHeight - h;
+ buffer.fillRect(sourceRect, 0xff000000);
+ sourceRect.x += sectionWidth;
+ }
+ output.copyPixels(input, input.rect, destPoint, buffer);
+ if (backgroundBeat) background.alpha = m_soundEx.peak;
+ e.updateAfterEvent();
+ }
+
+ protected function decayHandler(e:TimerEvent):void {
+ var a:Number, h:int, i:int;
+ spectrum = m_soundEx.getStereoSampling(m_columns);
+ output.lock();
+ sourceRect.x = 0;
+ buffer.fillRect(buffer.rect, m_decayAlpha);
+ output.copyPixels(output, output.rect, destPoint, buffer);
+ buffer.fillRect(buffer.rect, 0);
+
+ for (i = 0; i < m_columns; ++i) {
+ a = spectrum[i];
+ if (a > levels[i]) levels[i] = a;
+ h = int(levels[i] * m_rows) * sectionHeight;
+ sourceRect.height = h;
+ sourceRect.y = realHeight - h;
+ buffer.fillRect(sourceRect, m_peaksAlpha);
+ sourceRect.x += sectionWidth;
+ levels[i] -= m_decay;
+ }
+ output.copyPixels(input, input.rect, destPoint, buffer, null, true);
+ output.unlock();
+ if (backgroundBeat) background.alpha = m_soundEx.peak;
+ e.updateAfterEvent();
+ }
+
+ protected function peaksHandler(e:TimerEvent):void {
+ var a:Number, h:int, i:int;
+ spectrum = m_soundEx.getStereoAdd(m_columns);
+ buffer.fillRect(buffer.rect, 0);
+ sourceRect.x = 0;
+
+ for (i = 0; i < m_columns; ++i) {
+ a = spectrum[i];
+ h = int(a * m_rows) * sectionHeight;
+ sourceRect.height = h;
+ sourceRect.y = realHeight - h;
+ buffer.fillRect(sourceRect, 0xff000000);
+
+ if (a > levels[i]) {
+ levels[i] = a;
+ } else {
+ h = int(levels[i] * m_rows) * sectionHeight;
+ sourceRect.y = realHeight - h;
+ }
+
+ sourceRect.height = m_rowSize;
+ buffer.fillRect(sourceRect, m_peaksAlpha);
+ sourceRect.x += sectionWidth;
+ levels[i] -= m_decay;
+ }
+ output.copyPixels(input, input.rect, destPoint, buffer);
+ if (backgroundBeat) background.alpha = m_soundEx.peak;
+ e.updateAfterEvent();
+ }
+
+ public function get soundEx():SoundEx { return m_soundEx; }
+ public function set soundEx(value:SoundEx):void {
+ if (m_soundEx) m_soundEx.removeEventListener(SoundEx.SOUND_START, startHandler);
+ m_soundEx = value;
+ value.addEventListener(SoundEx.SOUND_START, startHandler);
+ }
+
+ public function get direction():String { return m_direction; }
+ public function set direction(value:String):void {
+ if (value == m_direction || !Flectrum[value.toUpperCase()]) return;
+
+ switch (value) {
+ case UP:
+ foreground.rotation = 0;
+ foreground.x = 0;
+ foreground.y = 0;
+ break;
+ case LEFT:
+ foreground.rotation = 270;
+ foreground.x = 0;
+ foreground.y = foreground.height;
+ break;
+ case DOWN:
+ foreground.rotation = 180;
+ foreground.x = foreground.width;
+ foreground.y = foreground.height;
+ break;
+ case RIGHT:
+ foreground.rotation = 90;
+ foreground.x = foreground.width;
+ foreground.y = 0;
+ break;
+ }
+ background.rotation = foreground.rotation;
+ background.x = foreground.x;
+ background.y = foreground.y;
+ m_direction = value;
+ }
+
+ public function get mode():String { return m_mode; }
+ public function set mode(value:String):void {
+ if (value == m_mode || !Flectrum[value.toUpperCase()]) return;
+ timer.removeEventListener(TimerEvent.TIMER, this[m_mode +"Handler"]);
+ timer.addEventListener(TimerEvent.TIMER, this[value +"Handler"]);
+ m_mode = value;
+ }
+
+ public function get delay():int { return timer.delay; }
+ public function set delay(value:int):void {
+ timer.delay = value;
+ }
+
+ public function get columns():int { return m_columns; }
+ public function set columns(value:int):void {
+ if (value == m_columns) return;
+ if (value < 2) value = 2;
+ else if (value > 256) value = 256;
+ m_columns = value;
+ reset();
+ }
+
+ public function get columnSize():int { return m_columnSize; }
+ public function set columnSize(value:int):void {
+ if (value == m_columnSize) return;
+ if (value < 1) value = 1;
+ m_columnSize = value;
+ reset();
+ }
+
+ public function get columnSpacing():int { return m_columnSpacing; }
+ public function set columnSpacing(value:int):void {
+ if (value == m_columnSpacing) return;
+ m_columnSpacing = value;
+ reset();
+ }
+
+ public function get rows():int { return m_rows; }
+ public function set rows(value:int):void {
+ if (value == m_rows) return;
+ if (value < 3) value = 3;
+ m_rows = value;
+ reset();
+ }
+
+ public function get rowSize():int { return m_rowSize; }
+ public function set rowSize(value:int):void {
+ if (value == m_rowSize) return;
+ if (value < 1) value = 1;
+ m_rowSize = value;
+ reset();
+ }
+
+ public function get rowSpacing():int { return m_rowSpacing; }
+ public function set rowSpacing(value:int):void {
+ if (value == m_rowSpacing) return;
+ m_rowSpacing = value;
+ reset();
+ }
+
+ public function get showBackground():Boolean { return m_showBackground; }
+ public function set showBackground(value:Boolean):void {
+ if (value == m_showBackground) return;
+ m_showBackground = value;
+ reset();
+ }
+
+ public function get backgroundAlpha():Number { return m_backgroundAlpha; }
+ public function set backgroundAlpha(value:Number):void {
+ background.alpha = m_backgroundAlpha = value;
+ }
+
+ public function get decay():Number { return m_decay; }
+ public function set decay(value:Number):void {
+ if (value < 0) value = 0;
+ else if (value > 1) value = 1;
+ m_decay = value;
+ }
+
+ public function get decayAlpha():Number { return m_decayAlpha / 255; }
+ public function set decayAlpha(value:Number):void {
+ if (value < 0) value = 0;
+ else if (value > 1) value = 1;
+ m_decayAlpha = int(value * 255) << 24;
+ }
+
+ public function get peaksAlpha():Number { return m_peaksAlpha / 255; }
+ public function set peaksAlpha(value:Number):void {
+ if (value < 0) value = 0;
+ else if (value > 1) value = 1;
+ m_peaksAlpha = int(value * 255) << 24;
+ }
+ }
+}
129 Flod Beginners Guide/Flash CS4/neoart/flectrum/SoundEx.as
@@ -0,0 +1,129 @@
+/* Flectrum version 1.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flectrum {
+ import flash.events.*;
+ import flash.media.*;
+ import flash.utils.*;
+
+ public class SoundEx extends Sound {
+ public static const SOUND_START:String = "soundStart";
+ public static const SOUND_STOP:String = "soundStop";
+
+ public var fourier:Boolean;
+ public var stretchFactor:int;
+
+ protected var soundChannel:SoundChannel;
+ protected var computed:ByteArray;
+ protected var spectrum:Vector.<Number>;
+
+ private const TABLE:Vector.<int> = Vector.<int>([
+ 0, 0,128,85,64,51,42,36,32,28,25,23,21,19,18,17,16,15,14,13,12,12,11,11,10,10, 9, 9, 9, 8, 8, 8,
+ 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
+
+ public function SoundEx(fourier:Boolean = false, stretchFactor:int = 2) {
+ this.fourier = fourier;
+ this.stretchFactor = stretchFactor;
+ computed = new ByteArray();
+ spectrum = new Vector.<Number>;
+ super();
+ }
+
+ override public function play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel {
+ soundChannel = super.play(startTime, loops, sndTransform);
+ soundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
+ dispatchEvent(new Event(SOUND_START));
+ return soundChannel;
+ }
+
+ public function stop():void {
+ if (!soundChannel) return;
+ soundChannel.stop();
+ dispatchEvent(new Event(SOUND_STOP));
+ soundChannel = null;
+ }
+
+ public function get peak():Number {
+ if (!soundChannel) return 0;
+ var a:Number = soundChannel.leftPeak;
+ a += soundChannel.rightPeak;
+ return a * 0.5;
+ }
+
+ public function get leftPeak():Number {
+ if (!soundChannel) return 0;
+ return soundChannel.leftPeak;
+ }
+
+ public function get rightPeak():Number {
+ if (!soundChannel) return 0;
+ return soundChannel.rightPeak;
+ }
+
+ public function get position():Number {
+ if (!soundChannel) return 0;
+ return soundChannel.position;
+ }
+
+ public function getStereoSampling(interval:int = 256):Vector.<Number> {
+ var a:Number, i:int, offset:int = TABLE[interval] << 2, p:int;
+ SoundMixer.computeSpectrum(computed, fourier, stretchFactor);
+ spectrum.length = interval;
+
+ for (i = 0; i < interval; ++i) {
+ p += offset;
+ computed.position = p;
+ a = computed.readFloat();
+ computed.position = p + 1024;
+ a += computed.readFloat();
+ if (a < 0) a = -a;
+ a *= 0.5;
+ spectrum[i] = a * (2 - a);
+ }
+ return spectrum;
+ }
+
+ public function getStereoAdd(interval:int = 256):Vector.<Number> {
+ var a:Number, i:int, j:int, len:int = TABLE[interval], p:int, s:Number;
+ SoundMixer.computeSpectrum(computed, fourier, stretchFactor);
+ spectrum.length = interval;
+
+ for (i = 0; i < interval; ++i) {
+ a = 0;
+ s = 0;
+ for (j = 0; j < len; ++j) {
+ computed.position = p;
+ a = computed.readFloat();
+ computed.position = p + 1024;
+ a += computed.readFloat();
+ if (a < 0) a = -a;
+ s += a;
+ p += 4;
+ }
+ s /= len;
+ spectrum[i] = s * (2 - s);
+ }
+ return spectrum;
+ }
+
+ protected function soundCompleteHandler(e:Event):void {
+ soundChannel.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
+ dispatchEvent(new Event(Event.SOUND_COMPLETE));
+ soundChannel = null;
+ }
+ }
+}
191 Flod Beginners Guide/Flash CS4/neoart/flod/ModChannel.as
@@ -0,0 +1,191 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+
+ public class ModChannel {
+ public var id:int;
+ public var mute:Boolean;
+ public var panning:Number = 1.0;
+ public var command:ModCommand;
+ public var sample:ModSample;
+
+ public var period:int;
+ public var note:int;
+ public var volume:int;
+ public var phase:Number = 0.0;
+ public var sampleLen:int;
+ public var sampleOffset:int;
+ public var wavePos:int;
+
+ public var voicePeriod:int;
+ public var voiceSample:ModSample;
+ public var voiceVolume:int;
+
+ public var glissando:Boolean;
+ public var invertPos:int;
+ public var invertSpeed:int;
+ public var loopRow:int;
+ public var loopCounter:int;
+ public var portaPeriod:int;
+ public var portaSpeed:int;
+ public var tremoloDepth:int;
+ public var tremoloPos:int;
+ public var tremoloRetrig:Boolean = true;
+ public var tremoloSpeed:int;
+ public var tremoloWave:int;
+ public var vibratoDepth:int;
+ public var vibratoPos:int;
+ public var vibratoRetrig:Boolean = true;
+ public var vibratoSpeed:int;
+ public var vibratoWave:int;
+
+ protected var m_finetune:int;
+
+ protected const FUNK_TABLE:Vector.<int> = Vector.<int>([
+ 0, 5, 6, 7, 8, 10, 11, 13, 16, 19, 22, 26, 32, 43, 64, 128]);
+
+ protected const VIBRATO_TABLE:Vector.<int> = Vector.<int>([
+ 0, 24, 49, 74, 97, 120, 141, 161, 180, 197, 212, 224,
+ 235, 244, 250, 253, 255, 253, 250, 244, 235, 224, 212, 197,
+ 180, 161, 141, 120, 97, 74, 49, 24]);
+
+ public function ModChannel(id:int, sample:ModSample) {
+ this.id = id;
+ this.sample = this.voiceSample = sample;
+ command = new ModCommand();
+ if ((++id & 2) == 0) panning = -panning;
+ }
+
+ public function get finetune():int { return m_finetune; }
+ public function set finetune(value:int):void {
+ m_finetune = value * 36;
+ }
+
+ public function invertLoop():void {
+ invertPos += FUNK_TABLE[invertSpeed];
+
+ if (invertPos >= 128) {
+ invertPos = 0;
+ if (++wavePos >= sampleLen) wavePos = sample.loopStart;
+ sample.wave[wavePos] = -sample.wave[wavePos];
+ }
+ }
+
+ public function karplusStrong():void {
+ var i:int, len:int = sample.length - 2;
+
+ for (i = sample.loopStart; i < len;)
+ sample.wave[i] = (sample.wave[i] + sample.wave[++i]) * 0.5;
+
+ sample.wave[++i] = (sample.wave[i] + sample.wave[0]) * 0.5;
+ }
+
+ public function tonePortamento():void {
+ if (period >= portaPeriod) {
+ if ((period -= portaSpeed) < portaPeriod) {
+ period = portaPeriod;
+ portaPeriod = 0;
+ }
+ } else {
+ if ((period += portaSpeed) > portaPeriod) {
+ period = portaPeriod;
+ portaPeriod = 0;
+ }
+ }
+
+ if (glissando) {
+ for (var i:int = 0; i < 36; ++i)
+ if (period > ModFlod.PERIODS[i]) break;
+ i--;
+ period = ModFlod.PERIODS[m_finetune + i];
+ }
+ voicePeriod = period;
+ }
+
+ public function tremolo():void {
+ var pos:int = tremoloPos & 31, delta:int = 255;
+
+ switch (tremoloWave) {
+ case 0:
+ delta = VIBRATO_TABLE[pos];
+ break;
+ case 1:
+ pos <<= 3;
+ if (tremoloPos < 0) delta -= pos;
+ else delta = pos;
+ break;
+ }
+
+ delta = (delta * tremoloDepth) >> 6;
+
+ if (tremoloPos < 0) voiceVolume = volume - delta;
+ else voiceVolume = volume + delta;
+ if (voiceVolume < 0) voiceVolume = 0;
+ else if (voiceVolume > 64) voiceVolume = 64;
+
+ if ((tremoloPos += tremoloSpeed) > 31) tremoloPos -= 64;
+ }
+
+ public function vibrato():void {
+ var pos:int = vibratoPos & 31, delta:int = 255;
+
+ switch (vibratoWave) {
+ case 0:
+ delta = VIBRATO_TABLE[pos];
+ break;
+ case 1:
+ pos <<= 3;
+ if (vibratoPos < 0) delta -= pos;
+ else delta = pos;
+ break;
+ }
+
+ delta = (delta * vibratoDepth) >> 7;
+
+ if (vibratoPos < 0) voicePeriod = period - delta;
+ else voicePeriod = period + delta;
+
+ if ((vibratoPos += vibratoSpeed) > 31) vibratoPos -= 64;
+ }
+
+ public function volumeSlide():void {
+ if (command.px != 0) volume += command.px;
+ else if (command.py != 0) volume -= command.py;
+ if (volume < 0) volume = 0;
+ else if (volume > 64) volume = 64;
+
+ voiceVolume = volume;
+ }
+
+ public function reset(sample:ModSample):void {
+ this.sample = this.voiceSample = sample;
+ command = new ModCommand();
+ m_finetune = 0;
+
+ period = note = 0;
+ volume = phase = 0;
+ sampleLen = sampleOffset = 0;
+ wavePos = voicePeriod = voiceVolume = 0;
+
+ invertPos = invertSpeed = 0;
+ loopRow = loopCounter = 0;
+ portaPeriod = portaSpeed = 0;
+ tremoloDepth = tremoloPos = 0;
+ tremoloSpeed = tremoloWave = 0;
+ vibratoDepth = vibratoPos = 0;
+ vibratoSpeed = vibratoWave = 0;
+ glissando = false;
+ tremoloRetrig = true;
+ vibratoRetrig = true;
+ }
+ }
+}
60 Flod Beginners Guide/Flash CS4/neoart/flod/ModCommand.as
@@ -0,0 +1,60 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+ import flash.utils.*;
+
+ public class ModCommand {
+ public var period:int;
+ public var note:int;
+ public var sample:int;
+ public var effect:int;
+ public var param:int;
+ public var xeffect:int;
+ public var xparam:int;
+ public var noEffect:Boolean;
+ public var noParams:Boolean;
+ public var text:String;
+
+ public function get px():int {
+ return param >> 4;
+ }
+
+ public function get py():int {
+ return param & 0x0f;
+ }
+
+ public function initialize(stream:ByteArray):void {
+ var b1:int = stream.readUnsignedByte(),
+ b2:int = stream.readUnsignedByte(),
+ b3:int = stream.readUnsignedByte(),
+ b4:int = stream.readUnsignedByte();
+
+ period = ((b1 & 0x0f) << 8) | b2;
+ sample = ((b1 & 0xf0) | ((b3 & 0xf0) >> 4)) & 0x1f;
+ effect = b3 & 0x0f;
+ param = b4;
+
+ if ((b4 = param >> 4) != 0) {
+ if (effect == ModFlod.EX_EFFECT) {
+ xeffect = b4;
+ xparam = param & 0x0f;
+ }
+ }
+ for (var i:int = 0; i < 37; ++i)
+ if (period >= ModFlod.PERIODS[i]) break;
+
+ note = i;
+ if (effect == 0 && xparam == 0 && param == 0) noEffect = true;
+ if (period == 0 && sample == 0 && noEffect) noParams = true;
+ }
+ }
+}
35 Flod Beginners Guide/Flash CS4/neoart/flod/ModCommandEx.as
@@ -0,0 +1,35 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+ import flash.utils.*;
+
+ public class ModCommandEx extends ModCommand {
+
+ public static const NOTES:Vector.<String> = Vector.<String>([
+ "C-1", "C#1", "D-1", "D#1", "E-1", "F-1", "F#1", "G-1", "G#1", "A-1", "A#1", "B-1",
+ "C-2", "C#2", "D-2", "D#2", "E-2", "F-2", "F#2", "G-2", "G#2", "A-2", "A#2", "B-2",
+ "C-3", "C#3", "D-3", "D#3", "E-3", "F-3", "F#3", "G-3", "G#3", "A-3", "A#3", "B-3",
+ "---", "---"]);
+
+ override public function initialize(stream:ByteArray):void {
+ var pad:String;
+ super.initialize(stream);
+
+ text = NOTES[note];
+ pad = "00"+ sample.toString(16).toUpperCase();
+ text += pad.substr(-2);
+ text += effect.toString(16).toUpperCase();
+ pad = "00"+ param.toString(16).toUpperCase();
+ text += pad.substr(-2);
+ }
+ }
+}
28 Flod Beginners Guide/Flash CS4/neoart/flod/ModData.as
@@ -0,0 +1,28 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+
+ public class ModData {
+ public var periods:Vector.<int>;
+ public var volumes:Vector.<Number>;
+ public var position:int;
+ public var row:int;
+ public var samplesTick:int;
+ public var tempo:int;
+ public var speed:int;
+
+ public function ModData(numChannels:int) {
+ periods = new Vector.<int>(numChannels, true);
+ volumes = new Vector.<Number>(numChannels << 1, true);
+ }
+ }
+}
135 Flod Beginners Guide/Flash CS4/neoart/flod/ModFlod.as
@@ -0,0 +1,135 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+
+ public class ModFlod {
+ public static const ENCODING:String = "us-ascii";
+
+ public static const DEFAULT_TEMPO:int = 125;
+ public static const DEFAULT_SPEED:int = 6;
+ public static const PATTERN_LENGTH:int = 64;
+ public static const PATTERN_100: int = 100;
+
+ public static const PAL_CIATEMPO: int = 110250
+ public static const PAL_VBLTEMPO: Number = 7.584381;
+ public static const PAL_SPEED: Number = 80.42845804;
+ public static const NTSC_CIATEMPO:int = 91875;
+ public static const NTSC_VBLTEMPO:Number = 6.3152;
+ public static const NTSC_SPEED: Number = 81.16882086;
+
+ public static const UNSUPPORTED: int = 0;
+ public static const ULTIMATE_ST: int = 1;
+ public static const SOUNDTRACKER: int = 2;
+ public static const ULTIMATE_ST2: int = 3;
+ public static const SOUNDTRACKER_9: int = 4;
+ public static const MASTERTRACKER: int = 5;
+ public static const SOUNDTRACKER_20:int = 6;
+ public static const SOUNDTRACKER_23:int = 7;
+ public static const SOUNDTRACKER_24:int = 8;
+ public static const NOISETRACKER_10:int = 9;
+ public static const NOISETRACKER_11:int = 10;
+ public static const SOUNDTRACKER_25:int = 11;
+ public static const NOISETRACKER_12:int = 12;
+ public static const STARTREKKER_10: int = 13;
+ public static const SOUNDTRACKER_26:int = 14;
+ public static const STARTREKKER_12: int = 15;
+ public static const PROTRACKER_10: int = 16;
+ public static const PROTRACKER_20: int = 17;
+ public static const PROTRACKER_22: int = 18;
+ public static const PROTRACKER_30: int = 19;
+ public static const MULTITRACKER: int = 20;
+
+ public static const ARPEGGIO: int = 0x00;
+ public static const PORTAMENTO_UP: int = 0x01;
+ public static const PORTAMENTO_DOWN: int = 0x02;
+ public static const TONE_PORTAMENTO: int = 0x03;
+ public static const VIBRATO: int = 0x04;
+ public static const TONE_PORTA_VOLUME_SLIDE:int = 0x05;
+ public static const VIBRATO_VOLUME_SLIDE: int = 0x06;
+ public static const TREMOLO: int = 0x07;
+ public static const UNUSED: int = 0x08;
+ public static const SAMPLE_OFFSET: int = 0x09;
+ public static const VOLUME_SLIDE: int = 0x0a;
+ public static const POSITION_JUMP: int = 0x0b;
+ public static const SET_VOLUME: int = 0x0c;
+ public static const PATTERN_BREAK: int = 0x0d;
+ public static const EX_EFFECT: int = 0x0e;
+ public static const SET_SPEED: int = 0x0f;
+
+ public static const SET_FILTER: int = 0x00;
+ public static const FINE_SLIDE_UP: int = 0x01;
+ public static const FINE_SLIDE_DOWN: int = 0x02;
+ public static const GLISSANDO_CONTROL: int = 0x03;
+ public static const VIBRATO_CONTROL: int = 0x04;
+ public static const SET_FINETUNE: int = 0x05;
+ public static const PATTERN_LOOP: int = 0x06;
+ public static const TREMOLO_CONTROL: int = 0x07;
+ public static const KARPLUS_STRONG: int = 0x08;
+ public static const RETRIG_NOTE: int = 0x09;
+ public static const FINE_VOLUME_UP: int = 0x0a;
+ public static const FINE_VOLUME_DOWN: int = 0x0b;
+ public static const NOTE_CUT: int = 0x0c;
+ public static const NOTE_DELAY: int = 0x0d;
+ public static const PATTERN_DELAY: int = 0x0e;
+ public static const INVERT_LOOP: int = 0x0f;
+
+ public static const PERIODS:Vector.<int> = Vector.<int>([
+ 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453,
+ 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226,
+ 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113,
+ 850, 802, 757, 715, 674, 637, 601, 567, 535, 505, 477, 450,
+ 425, 401, 379, 357, 337, 318, 300, 284, 268, 253, 239, 225,
+ 213, 201, 189, 179, 169, 159, 150, 142, 134, 126, 119, 113,
+ 844, 796, 752, 709, 670, 632, 597, 563, 532, 502, 474, 447,
+ 422, 398, 376, 355, 335, 316, 298, 282, 266, 251, 237, 224,
+ 211, 199, 188, 177, 167, 158, 149, 141, 133, 125, 118, 112,
+ 838, 791, 746, 704, 665, 628, 592, 559, 528, 498, 470, 444,
+ 419, 395, 373, 352, 332, 314, 296, 280, 264, 249, 235, 222,
+ 209, 198, 187, 176, 166, 157, 148, 140, 132, 125, 118, 111,
+ 832, 785, 741, 699, 660, 623, 588, 555, 524, 495, 467, 441,
+ 416, 392, 370, 350, 330, 312, 294, 278, 262, 247, 233, 220,
+ 208, 196, 185, 175, 165, 156, 147, 139, 131, 124, 117, 110,
+ 826, 779, 736, 694, 655, 619, 584, 551, 520, 491, 463, 437,
+ 413, 390, 368, 347, 328, 309, 292, 276, 260, 245, 232, 219,
+ 206, 195, 184, 174, 164, 155, 146, 138, 130, 123, 116, 109,
+ 820, 774, 730, 689, 651, 614, 580, 547, 516, 487, 460, 434,
+ 410, 387, 365, 345, 325, 307, 290, 274, 258, 244, 230, 217,
+ 205, 193, 183, 172, 163, 154, 145, 137, 129, 122, 115, 109,
+ 814, 768, 725, 684, 646, 610, 575, 543, 513, 484, 457, 431,
+ 407, 384, 363, 342, 323, 305, 288, 272, 256, 242, 228, 216,
+ 204, 192, 181, 171, 161, 152, 144, 136, 128, 121, 114, 108,
+ 907, 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480,
+ 453, 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240,
+ 226, 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120,
+ 900, 850, 802, 757, 715, 675, 636, 601, 567, 535, 505, 477,
+ 450, 425, 401, 379, 357, 337, 318, 300, 284, 268, 253, 238,
+ 225, 212, 200, 189, 179, 169, 159, 150, 142, 134, 126, 119,
+ 894, 844, 796, 752, 709, 670, 632, 597, 563, 532, 502, 474,
+ 447, 422, 398, 376, 355, 335, 316, 298, 282, 266, 251, 237,
+ 223, 211, 199, 188, 177, 167, 158, 149, 141, 133, 125, 118,
+ 887, 838, 791, 746, 704, 665, 628, 592, 559, 528, 498, 470,
+ 444, 419, 395, 373, 352, 332, 314, 296, 280, 264, 249, 235,
+ 222, 209, 198, 187, 176, 166, 157, 148, 140, 132, 125, 118,
+ 881, 832, 785, 741, 699, 660, 623, 588, 555, 524, 494, 467,
+ 441, 416, 392, 370, 350, 330, 312, 294, 278, 262, 247, 233,
+ 220, 208, 196, 185, 175, 165, 156, 147, 139, 131, 123, 117,
+ 875, 826, 779, 736, 694, 655, 619, 584, 551, 520, 491, 463,
+ 437, 413, 390, 368, 347, 328, 309, 292, 276, 260, 245, 232,
+ 219, 206, 195, 184, 174, 164, 155, 146, 138, 130, 123, 116,
+ 868, 820, 774, 730, 689, 651, 614, 580, 547, 516, 487, 460,
+ 434, 410, 387, 365, 345, 325, 307, 290, 274, 258, 244, 230,
+ 217, 205, 193, 183, 172, 163, 154, 145, 137, 129, 122, 115,
+ 862, 814, 768, 725, 684, 646, 610, 575, 543, 513, 484, 457,
+ 431, 407, 384, 363, 342, 323, 305, 288, 272, 256, 242, 228,
+ 216, 203, 192, 181, 171, 161, 152, 144, 136, 128, 121, 114]);
+ }
+}
605 Flod Beginners Guide/Flash CS4/neoart/flod/ModProcessor.as
@@ -0,0 +1,605 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+ import flash.events.*;
+ import flash.media.*;
+ import flash.utils.*;
+
+ public class ModProcessor {
+ public const AMIGA_500: int = 0;
+ public const AMIGA_1200:int = 1;
+
+ public const FILTER_AUTOMATIC:int = 0;
+ public const FILTER_FORCE_OFF:int = 1;
+ public const FILTER_FORCE_ON: int = 2;
+
+ public var sound:Sound;
+ public var soundChannel:SoundChannel;
+ public var soundChannelPos:Number = 0.0;
+ public var song:ModSong;
+
+ public var amigaModel:int = AMIGA_1200;
+ public var externalReplay:Boolean;
+ public var forceFilter:int = FILTER_FORCE_OFF;
+ public var loopSong:Boolean;
+ public var stereo:Number = 1.0;
+ public var isPlaying:Boolean;
+
+ protected var bufferL:Vector.<Number>;
+ protected var bufferR:Vector.<Number>;
+ protected var filterL:Vector.<Number>;
+ protected var filterR:Vector.<Number>;
+ protected var samplesTick:int;
+ protected var samplesLeft:int;
+ protected var complete:Boolean;
+
+ protected var channel:ModChannel;
+ protected var channels:Vector.<ModChannel>;
+ protected var numChannels:int;
+ protected var tempo:int;
+ protected var speed:int = ModFlod.DEFAULT_SPEED;
+ protected var timer:int = speed;
+ protected var tempoCia:int = ModFlod.PAL_CIATEMPO;
+ protected var tempoVbl:Number = ModFlod.PAL_VBLTEMPO;
+ protected var periodSpeed:Number = ModFlod.PAL_SPEED;
+
+ protected var ledFilter:Boolean;
+ protected var patternLength:int;
+ protected var position:int;
+ protected var row:int;
+ protected var jumpPosition:Boolean;
+ protected var breakPattern:Boolean;
+ protected var breakPosition:int;
+ protected var delayPattern:int;
+
+ protected const BUFFER_SIZE:int = 8192;
+ protected const MIN_PERIOD: int = 113;
+ protected const MAX_PERIOD: int = 856;
+
+ protected const A51_FILTER:Number = 0.4860348337215757;
+ protected const A52_FILTER:Number = 0.9314955486749749;
+ protected const LED_FILTER:Number = 0.5213345843532200;
+
+ protected const VOLUMES:Vector.<Number> = Vector.<Number>([
+ 0, 0.00390625, 0.0078125, 0.01171875, 0.015625, 0.01953125, 0.0234375, 0.02734375,
+ 0.03125, 0.03515625, 0.0390625, 0.04296875, 0.046875, 0.05078125, 0.0546875, 0.05859375,
+ 0.0625, 0.06640625, 0.0703125, 0.07421875, 0.078125, 0.08203125, 0.0859375, 0.08984375,
+ 0.09375, 0.09765625, 0.1015625, 0.10546875, 0.109375, 0.11328125, 0.1171875, 0.12109375,
+ 0.125, 0.12890625, 0.1328125, 0.13671875, 0.140625, 0.14453125, 0.1484375, 0.15234375,
+ 0.15625, 0.16015625, 0.1640625, 0.16796875, 0.171875, 0.17578125, 0.1796875, 0.18359375,
+ 0.1875, 0.19140625, 0.1953125, 0.19921875, 0.203125, 0.20703125, 0.2109375, 0.21484375,
+ 0.21875, 0.22265625, 0.2265625, 0.23046875, 0.234375, 0.23828125, 0.2421875, 0.24609375,
+ 0.25]);
+
+ public function ModProcessor() {
+ bufferL = new Vector.<Number>(BUFFER_SIZE, true);
+ bufferR = new Vector.<Number>(BUFFER_SIZE, true);
+ filterL = new Vector.<Number>(5, true);
+ filterR = new Vector.<Number>(5, true);
+ }
+
+ public function load(stream:ByteArray, extended:Boolean = false):Boolean {
+ song = new ModSong(stream, extended);
+ numChannels = song.numChannels;
+ patternLength = song.patternLength;
+ channels = new Vector.<ModChannel>(numChannels, true);
+
+ for (var i:int = 0; i < numChannels; ++i)
+ channels[i] = new ModChannel(i, song.samples[0]);
+ return song.supported;
+ }
+
+ public function play(soundProcessor:Sound = null):Boolean {
+ if (!song || !song.supported) return false;
+ if (soundChannelPos == 0) {
+ reset();
+ setTempo(song.tempo);
+ for (var i:int = 0; i < numChannels; ++i)
+ channels[i].reset(song.samples[0]);
+ }
+ sound = soundProcessor ? soundProcessor : new Sound();
+ sound.addEventListener(SampleDataEvent.SAMPLE_DATA, mixer);
+ soundChannel = sound.play(soundChannelPos);
+ soundChannelPos = 0;
+ isPlaying = true;
+ return true;
+ }
+
+ public function pause():void {
+ if (!song || !song.supported) return;
+ soundChannelPos = soundChannel.position;
+ soundChannel.stop();
+ sound.removeEventListener(SampleDataEvent.SAMPLE_DATA, mixer);
+ isPlaying = false;
+ }
+
+ public function stop():void {
+ if (!song || !song.supported) return;
+ soundChannel.stop();
+ sound.removeEventListener(SampleDataEvent.SAMPLE_DATA, mixer);
+ soundChannelPos = 0;
+ isPlaying = false;
+ }
+
+ public function set ntsc(val:Boolean):void {
+ if (val) {
+ tempoCia = ModFlod.NTSC_CIATEMPO;
+ tempoVbl = ModFlod.NTSC_VBLTEMPO;
+ periodSpeed = ModFlod.NTSC_SPEED;
+ } else {
+ tempoCia = ModFlod.PAL_CIATEMPO;
+ tempoVbl = ModFlod.PAL_VBLTEMPO;
+ periodSpeed = ModFlod.PAL_SPEED;
+ }
+ }
+
+ protected function reset():void {
+ samplesLeft = 0;
+ speed = timer = ModFlod.DEFAULT_SPEED;
+ position = row = 0;
+ jumpPosition = false;
+ breakPattern = false;
+ breakPosition = 0;
+ delayPattern = 0;
+ complete = false;
+ }
+
+ protected function mixer(e:SampleDataEvent):void {
+ var bufferSize:int = BUFFER_SIZE, i:int, j:int, mixed:int, toMix:int, mixPos:int, sample:ModSample,
+ size:int, volL:Number, volR:Number, volume:Number, waveData:Number, waveSpeed:Number;
+
+ while (mixed < bufferSize) {
+ if (samplesLeft == 0) {
+ if (++timer < speed) {
+ updateFx();
+ } else {
+ timer = 0;
+ if (complete) {
+ sound.removeEventListener(SampleDataEvent.SAMPLE_DATA, mixer);
+ bufferSize = mixPos + samplesLeft;
+ break;
+ }
+ process();
+ }
+ if (jumpPosition) {
+ row = breakPosition;
+ breakPosition = 0;
+ jumpPosition = false;
+
+ if (++position >= song.length) {
+ if (!loopSong) complete = true;
+ position = song.restart;
+ }
+ }
+ samplesLeft = samplesTick;
+ }
+ toMix = samplesLeft;
+ if ((mixed + toMix) > bufferSize) toMix = bufferSize - mixed;
+ size = mixPos + toMix;
+
+ for (i = 0; i < numChannels; ++i) {
+ channel = channels[i];
+ sample = channel.voiceSample;
+ if (sample.length == 0) continue;
+ volume = VOLUMES[channel.voiceVolume];
+ waveSpeed = periodSpeed / channel.voicePeriod;
+
+ if (channel.panning < 0) {
+ volL = volume * (1 + stereo);
+ volR = volume * (1 - stereo);
+ } else {
+ volL = volume * (1 - stereo);
+ volR = volume * (1 + stereo);
+ }
+
+ for (j = mixPos; j < size; ++j) {
+ if (channel.phase < 0) {
+ channel.phase++;
+ bufferL[j] += 0;
+ bufferR[j] += 0;
+ continue;
+ }
+ channel.phase += waveSpeed;
+ if (channel.phase >= channel.sampleLen) {
+ sample = channel.voiceSample = channel.sample;
+ channel.phase = sample.loopStart;
+ channel.sampleLen = sample.loopStart + sample.repeatLen;
+ if (sample.length == 0) break;
+ }
+
+ if (!channel.mute) {
+ waveData = sample.wave[int(channel.phase)];
+ bufferL[j] += waveData * volL;
+ bufferR[j] += waveData * volR;
+ }
+ }
+ }
+ mixed += toMix;
+ mixPos = size;
+ samplesLeft -= toMix;
+ }
+
+ if (forceFilter == FILTER_FORCE_OFF) {
+ for (i = 0; i < bufferSize; ++i) {
+ e.data.writeFloat(bufferL[i]);
+ bufferL[i] = 0;
+ e.data.writeFloat(bufferR[i]);
+ bufferR[i] = 0;
+ }
+ } else {
+ for (i = 0; i < bufferSize; ++i) {
+ e.data.writeFloat(filter(bufferL[i], filterL));
+ bufferL[i] = 0;
+ e.data.writeFloat(filter(bufferR[i], filterR));
+ bufferR[i] = 0;
+ }
+ }
+ }
+
+ protected function process():void {
+ var com:ModCommand, i:int, j:int, sample:ModSample;
+
+ if (delayPattern == 0) {
+ j = ((song.positions[position] * patternLength) + row) * numChannels;
+
+ for (i = 0; i < numChannels; ++i) {
+ channel = channels[i];
+ com = channel.command;
+ if (com.noParams) channel.voicePeriod = channel.period;
+ com = channel.command = song.patterns[j + i];
+
+ if (com.sample) {
+ sample = channel.sample = song.samples[com.sample];
+ channel.finetune = sample.finetune;
+ channel.voiceVolume = channel.volume = sample.volume;
+ }
+ if (com.period == 0) {
+ updateMoreFx();
+ continue;
+ }
+
+ if (com.xeffect == ModFlod.SET_FINETUNE)
+ channel.finetune = com.xparam;
+ else if (com.effect == ModFlod.TONE_PORTAMENTO ||
+ com.effect == ModFlod.TONE_PORTA_VOLUME_SLIDE) {
+ channel.portaPeriod = ModFlod.PERIODS[channel.finetune + com.note];
+ if (channel.period == channel.portaPeriod) channel.portaPeriod = 0;
+ updateMoreFx();
+ continue;
+ }
+ channel.note = com.note;
+ channel.period = ModFlod.PERIODS[channel.finetune + com.note];
+
+ if (com.xeffect == ModFlod.NOTE_DELAY) {
+ updateMoreFx();
+ continue;
+ }
+ if (channel.vibratoRetrig) channel.vibratoPos = 0;
+ if (channel.tremoloRetrig) channel.tremoloPos = 0;
+
+ channel.phase = 0;
+ channel.sampleLen = channel.sample.length;
+ channel.wavePos = channel.sample.loopStart;
+
+ channel.voicePeriod = channel.period;
+ channel.voiceSample = channel.sample;
+ updateMoreFx();
+ }
+ } else {
+ updateFx();
+ }
+ row++;
+
+ if (delayPattern != 0)
+ if (--delayPattern != 0) row--;
+
+ if (breakPattern) {
+ breakPattern = false;
+ row = breakPosition;
+ breakPosition = 0;
+ }
+ jumpPosition ||= Boolean(row >= patternLength);
+ }
+
+ protected function updateFx():void {
+ var com:ModCommand, i:int;
+
+ for (i = 0; i < numChannels; ++i) {
+ channel = channels[i];
+ com = channel.command;
+ if (channel.invertSpeed) channel.invertLoop();
+
+ if (com.noEffect) {
+ channel.voicePeriod = channel.period;
+ continue;
+ }
+ switch (com.effect) {
+ case ModFlod.ARPEGGIO:
+ switch (timer % 3) {
+ case 1:
+ channel.voicePeriod = ModFlod.PERIODS[channel.finetune + (channel.note + com.px)];
+ continue;
+ case 2:
+ channel.voicePeriod = ModFlod.PERIODS[channel.finetune + (channel.note + com.py)];
+ continue;
+ }
+ channel.voicePeriod = channel.period;
+ continue;
+
+ case ModFlod.PORTAMENTO_UP:
+ channel.period -= com.param;
+ if (channel.period < MIN_PERIOD) channel.period = MIN_PERIOD;
+ channel.voicePeriod = channel.period;
+ continue;
+
+ case ModFlod.PORTAMENTO_DOWN:
+ channel.period += com.param;
+ if (channel.period > MAX_PERIOD) channel.period = MAX_PERIOD;
+ channel.voicePeriod = channel.period;
+ continue;
+
+ case ModFlod.TONE_PORTAMENTO:
+ if (com.param != 0) channel.portaSpeed = com.param;
+ if (channel.portaPeriod != 0) channel.tonePortamento();
+ continue;
+
+ case ModFlod.VIBRATO:
+ if (com.py != 0) channel.vibratoDepth = com.py;
+ if (com.px != 0) channel.vibratoSpeed = com.px;
+ channel.vibrato();
+ continue;
+
+ case ModFlod.TONE_PORTA_VOLUME_SLIDE:
+ if (channel.portaPeriod != 0) channel.tonePortamento();
+ channel.volumeSlide();
+ continue;
+
+ case ModFlod.VIBRATO_VOLUME_SLIDE:
+ channel.vibrato();
+ channel.volumeSlide();
+ continue;
+
+ case ModFlod.EX_EFFECT:
+ updateExtendedFx();
+ continue;
+ }
+ channel.voicePeriod = channel.period;
+
+ switch (com.effect) {
+ case ModFlod.TREMOLO:
+ if (com.py != 0) channel.tremoloDepth = com.py;
+ if (com.px != 0) channel.tremoloSpeed = com.px;
+ channel.tremolo();
+ continue;
+
+ case ModFlod.VOLUME_SLIDE:
+ channel.volumeSlide();
+ continue;
+ }
+ }
+ }
+
+ protected function updateMoreFx():void {
+ var com:ModCommand = channel.command;
+ if (externalReplay) { if (channel.invertSpeed) channel.invertLoop(); }
+
+ switch (com.effect) {
+ case ModFlod.SAMPLE_OFFSET:
+ if (com.param != 0) channel.sampleOffset = com.param << 8;
+ if (channel.sampleOffset > channel.sampleLen) channel.phase = channel.sampleLen;
+ else channel.phase = channel.sampleOffset;
+ return;
+
+ case ModFlod.POSITION_JUMP:
+ if (!loopSong) {
+ var l:int = song.length - 1, p:int = song.numPatterns - 1;
+ if ((position == l && com.param != l) || (song.positions[position] == p && com.param != p)) {
+ complete = true;
+ return;
+ }
+ }
+ position = com.param - 1;
+ breakPosition = 0;
+ jumpPosition = true;
+ return;
+
+ case ModFlod.PATTERN_BREAK:
+ breakPosition = (com.px * 10) + com.py;
+ jumpPosition = true;
+ if (breakPosition >= patternLength) {
+ breakPosition = 0;
+ jumpPosition = false;
+ }
+ return;
+
+ case ModFlod.EX_EFFECT:
+ updateExtendedFx();
+ return;
+
+ case ModFlod.SET_SPEED:
+ timer = 0;
+ if (com.param > 0x1f)
+ setTempo(com.param);
+ else if (com.param > 0)
+ speed = com.param;
+ else complete = true;
+ return;
+
+ case ModFlod.SET_VOLUME:
+ channel.volume = com.param;
+ if (channel.volume < 0) channel.volume = 0;
+ else if (channel.volume > 64) channel.volume = 64;
+ channel.voiceVolume = channel.volume;
+ return;
+ }
+ channel.voicePeriod = channel.period;
+ }
+
+ protected function updateExtendedFx():void {
+ var com:ModCommand = channel.command;
+
+ switch (com.xeffect) {
+ case ModFlod.SET_FILTER:
+ ledFilter = Boolean(com.xparam != 0);
+ return;
+
+ case ModFlod.FINE_SLIDE_UP:
+ if (timer == 0) {
+ channel.period -= com.xparam;
+ if (channel.period < MIN_PERIOD) channel.period = MIN_PERIOD;
+ channel.voicePeriod = channel.period;
+ }
+ return;
+
+ case ModFlod.FINE_SLIDE_DOWN:
+ if (timer == 0) {
+ channel.period += com.xparam;
+ if (channel.period > MAX_PERIOD) channel.period = MAX_PERIOD;
+ channel.voicePeriod = channel.period;
+ }
+ return;
+
+ case ModFlod.GLISSANDO_CONTROL:
+ channel.glissando = Boolean(com.xparam != 0);
+ return;
+
+ case ModFlod.VIBRATO_CONTROL:
+ channel.vibratoWave = com.xparam;
+ channel.vibratoRetrig = Boolean(channel.vibratoWave < 4);
+ return;
+
+ case ModFlod.SET_FINETUNE:
+ channel.finetune = com.xparam & 0x0f;
+ return;
+
+ case ModFlod.PATTERN_LOOP:
+ if (timer == 0) {
+ if (com.xparam == 0) {
+ channel.loopRow = row;
+ } else {
+ if (channel.loopCounter == 0) {
+ channel.loopCounter = com.xparam;
+ } else {
+ channel.loopCounter--;
+ }
+ if (channel.loopCounter != 0) {
+ breakPosition = channel.loopRow;
+ breakPattern = true;
+ }
+ }
+ }
+ return;
+
+ case ModFlod.TREMOLO_CONTROL:
+ channel.tremoloWave = com.xparam;
+ channel.tremoloRetrig = Boolean(channel.tremoloWave < 4);
+ return;
+
+ case ModFlod.KARPLUS_STRONG:
+ channel.karplusStrong();
+ return;
+
+ case ModFlod.RETRIG_NOTE:
+ if (com.param != 0) {
+ if (timer != 0 || com.period == 0) {
+ if (timer % com.xparam == 0) channel.phase = 0;
+ }
+ }
+ return;
+
+ case ModFlod.FINE_VOLUME_UP:
+ if (timer == 0) {
+ channel.volume += com.xparam;
+ if (channel.volume > 64) channel.volume = 64;
+ channel.voiceVolume = channel.volume;
+ }
+ return;
+
+ case ModFlod.FINE_VOLUME_DOWN:
+ if (timer == 0) {
+ channel.volume -= com.xparam;
+ if (channel.volume < 0) channel.volume = 0;
+ channel.voiceVolume = channel.volume;
+ }
+ return;
+
+ case ModFlod.NOTE_CUT:
+ if (timer >= com.xparam)
+ channel.voiceVolume = channel.volume = 0;
+ return;
+
+ case ModFlod.NOTE_DELAY:
+ if (timer == com.xparam) {
+ if (com.period != 0) {
+ channel.phase = -35;
+ channel.sampleLen = channel.sample.length;
+ channel.wavePos = channel.sample.loopStart;
+ channel.voicePeriod = channel.period;
+ channel.voiceSample = channel.sample;
+ }
+ }
+ return;
+
+ case ModFlod.PATTERN_DELAY:
+ if (timer == 0) {
+ if (delayPattern == 0) delayPattern = com.xparam + 1;
+ }
+ return;
+
+ case ModFlod.INVERT_LOOP:
+ if (timer == 0) {
+ channel.invertSpeed = com.xparam;
+ if (channel.invertSpeed) channel.invertLoop();
+ }
+ return;
+ }
+ }
+
+ protected function setTempo(bpm:int):void {
+ if (ModSong.version < ModFlod.PROTRACKER_10) samplesTick = (240 - bpm) * tempoVbl;
+ else samplesTick = tempoCia / bpm;
+ tempo = bpm;
+ }
+
+ protected function filter(input:Number, state:Vector.<Number>):Number {
+ var output:Number, value:Number = LED_FILTER, delta:Number = 1 - value;
+
+ switch (amigaModel) {
+ case AMIGA_1200:
+ output = input;
+ if (ledFilter || forceFilter) {
+ state[1] = value * output + delta * state[1] + 1e-18 - 1e-18;
+ state[2] = value * state[1] + delta * state[2] + 1e-18 - 1e-18;
+ state[3] = value * state[2] + delta * state[3] + 1e-18 - 1e-18;
+ output = state[3];
+ }
+ break;
+
+ case AMIGA_500:
+ state[0] = A51_FILTER * input + (1 - A51_FILTER) * state[0] + 1e-18 - 1e-18;
+ state[1] = A52_FILTER * state[0] + (1 - A52_FILTER) * state[1] + 1e-18 - 1e-18;
+ output = state[1];
+
+ if (ledFilter || forceFilter) {
+ state[2] = value * output + delta * state[2] + 1e-18 - 1e-18;
+ state[3] = value * state[2] + delta * state[3] + 1e-18 - 1e-18;
+ state[4] = value * state[3] + delta * state[4] + 1e-18 - 1e-18;
+ output = state[4];
+ }
+ break;
+ }
+ if (output > 1.0) output = 1.0;
+ else if (output < -1.0) output = -1.0;
+ return output;
+ }
+ }
+}
294 Flod Beginners Guide/Flash CS4/neoart/flod/ModProcessorEx.as
@@ -0,0 +1,294 @@
+/* Flod (replay) version 2.0
+ 2009/08/15
+ Christian Corti
+ Neoart Costa Rica
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+package neoart.flod {
+ import flash.events.*;
+ import flash.media.*;
+ import flash.utils.*;
+
+ public class ModProcessorEx extends ModProcessor {
+ public var data:Vector.<ModData>;
+ public var index:int;
+ public var record:Boolean;
+
+ protected var info:ModData;
+ protected var wave:ByteArray;
+
+ public function ModProcessorEx() {
+ super();
+ wave = new ByteArray();
+ }
+
+ public function get available():Boolean {
+ return Boolean(wave.length > 2);
+ }
+
+ public function get output():ByteArray {
+ var wav:ByteArray = new ByteArray();
+ wav.endian = "littleEndian";
+ wav.writeUTFBytes("RIFF");
+ wav.writeInt(wave.length + 44);
+ wav.writeUTFBytes("WAVEfmt ");
+ wav.writeInt(16);
+ wav.writeShort(1);
+ wav.writeShort(2);
+ wav.writeInt(44100);
+ wav.writeInt(44100 << 1);
+ wav.writeShort(2);
+ wav.writeShort(8);
+ wav.writeUTFBytes("data");
+ wav.writeInt(wave.length);
+ wav.writeBytes(wave);
+ wav.position = 0;
+ return wav;
+ }
+
+ public function toggleChannel(id:int):void {
+ if (id < 0 || id >= numChannels) return;
+ if (!channels || !channels[id]) return;
+ channels[id].mute = !(channels[id].mute);
+ }
+
+ override public function load(stream:ByteArray, extended:Boolean = true):Boolean {
+ return super.load(stream, true);
+ }
+
+ override public function play(soundProcessor:Sound = null):Boolean {
+ if (soundChannelPos == 0) {
+ wave.clear();
+ wave.writeByte(128);
+ wave.writeByte(128);
+ resetData();
+ }
+ return super.play(soundProcessor);
+ }
+
+ public function duration():int {
+ var com:ModCommand, i:int, j:int, l:int = song.length - 1, p:int = song.numPatterns - 1, totalSamples:int,
+ loopCounter:Vector.<int> = new Vector.<int>(numChannels, true),
+ loopRow:Vector.<int> = new Vector.<int>(numChannels, true);
+
+ reset();
+ setTempo(song.tempo);
+
+ while (position <= l) {
+ j = ((song.positions[position] * patternLength) + row) * numChannels;
+ for (i = 0; i < numChannels; ++i) {
+ com = song.patterns[j + i];
+
+ if (com.effect == ModFlod.POSITION_JUMP) {
+ if ((position == l && com.param != l) || (song.positions[position] == p && com.param != p)) {
+ complete = true;
+ } else {
+ position = com.param - 1;
+ breakPosition = 0;
+ jumpPosition = true;
+ }
+ } else if (com.effect == ModFlod.PATTERN_BREAK) {
+ if (song.title == "bloood") break;
+ breakPosition = (com.px * 10) + com.py;
+ jumpPosition = true;
+ if (breakPosition >= patternLength) {
+ breakPosition = 0;
+ jumpPosition = false;
+ }
+
+ } else if (com.effect == ModFlod.SET_SPEED) {
+ if (com.param > 0x1f)
+ setTempo(com.param);
+ else if (com.param > 0)
+ speed = com.param;
+ else complete = true;
+
+ } else if (com.xeffect == ModFlod.PATTERN_LOOP) {
+ if (com.xparam == 0) {
+ loopRow[i] = row;
+ } else {
+ if (loopCounter[i] == 0) {
+ loopCounter[i] = com.xparam;
+ } else {
+ loopCounter[i]--;
+ }
+ if (loopCounter[i] != 0) {
+ breakPosition = loopRow[i];
+ breakPattern = true;
+ }
+ }
+ } else if (com.xeffect == ModFlod.PATTERN_DELAY) {
+ if (delayPattern == 0) delayPattern = com.xparam + 1;
+ }
+ }
+ if (complete) break;
+ row++;
+ if (delayPattern != 0)
+ if (--delayPattern != 0) row--;
+
+ if (breakPattern) {
+ breakPattern = false;
+ row = breakPosition;
+ breakPosition = 0;
+ }
+ jumpPosition ||= Boolean(row >= patternLength);
+
+ if (jumpPosition) {
+ row = breakPosition;
+ breakPosition = 0;
+ jumpPosition = false;
+ position++;
+ }
+ totalSamples += (samplesTick * speed);
+ }
+ reset();
+ return totalSamples;
+ }
+
+ override protected function mixer(e:SampleDataEvent):void {
+ var bufferSize:int = BUFFER_SIZE, i:int, j:int, mixed:int, toMix:int, mixPos:int,
+ sample:ModSample, size:int, volL:Number, volR:Number, volume:Number, waveData:Number, waveSpeed:Number;
+
+ while (mixed < bufferSize) {
+ if (samplesLeft == 0) {
+ if (++timer < speed) {
+ updateFx();
+ } else {
+ timer = 0;
+ info = data[index];
+ info.row = row;
+ info.position = position;
+ if (complete) {
+ sound.removeEventListener(SampleDataEvent.SAMPLE_DATA, mixer);
+ bufferSize = mixPos + samplesLeft;
+ break;
+ }
+ process();
+ info.samplesTick = samplesTick;
+ info.speed = speed;
+ info.tempo = tempo;
+ if (++index >= patternLength) index = 0;
+ }
+ if (jumpPosition) {
+ row = breakPosition;
+ breakPosition = 0;
+ jumpPosition = false;
+
+ if (++position >= song.length) {
+ if (!loopSong) complete = true;
+ position = song.restart;
+ }
+ }
+ samplesLeft = samplesTick;
+ }
+ toMix = samplesLeft;
+ if ((mixed + toMix) > bufferSize) toMix = bufferSize - mixed;
+ size = mixPos + toMix;
+
+ for (i = 0; i < numChannels; ++i) {
+ channel = channels[i];
+ sample = channel.voiceSample;
+ if (sample.length == 0) continue;
+ volume = VOLUMES[channel.voiceVolume];
+ waveSpeed = periodSpeed / channel.voicePeriod;
+
+ if (channel.panning < 0) {
+ volL = volume * (1 + stereo);
+ volR = volume * (1 - stereo);