Browse Source

revert changes (was cutting small sfxs)

ncannasse 10 năm trước cách đây
mục cha
commit
0d6e2e8a04
1 tập tin đã thay đổi với 2 bổ sung4 xóa
  1. 2 4
      hxd/snd/Mp3Data.hx

+ 2 - 4
hxd/snd/Mp3Data.hx

@@ -8,7 +8,6 @@ class Mp3Data extends Data {
 	var buffer : haxe.io.Bytes;
 	var onEnd : Void -> Void;
 	#end
-	var startPos : Int;
 
 	public function new( bytes : haxe.io.Bytes ) {
 		var mp = new format.mp3.Reader(new haxe.io.BytesInput(bytes)).read();
@@ -26,8 +25,7 @@ class Mp3Data extends Data {
 			var startEnd = (frame.get(lame + 21) << 16) | (frame.get(lame + 22) << 8) | frame.get(lame + 23);
 			var start = startEnd >> 12;
 			var end = startEnd & ((1 << 12) - 1);
-			startPos = start + 1152;
-			samples -= end + startPos;
+			samples -= start + end + 1152; // first frame is empty
 		}
 		#if flash
 		snd = new flash.media.Sound();
@@ -67,7 +65,7 @@ class Mp3Data extends Data {
 		#if flash
 		var b = out.getData();
 		b.position = outPos;
-		snd.extract(b, sampleCount, sampleStart + startPos);
+		snd.extract(b, sampleCount, sampleStart + 2257 /* MAGIC_DELAY, silence added at mp3 start */ );
 		#elseif js
 		if( buffer == null ) {
 			// not yet available : fill with blanks