スキップしてメイン コンテンツに移動

投稿

ラベル(sound)が付いた投稿を表示しています

ActionScript 3.0: Play Sound with Drawing FFT Spectrum

I have written simple example for playing mp3 sound with drawing sound FFT spectrum. Here is the code. package utils.sound { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.utils.ByteArray; import flash.media.SoundMixer; import flash.media.Sound; import ui.Button; import flash.net.URLRequest; import flash.media.SoundChannel; public class SoundPlayerTemp extends Sprite { private static const MAX_CHANEL :int = 256; private var w:int = 1; private var maxSize:int = 400; private const OFFSET_Y:int = 20; private var urlReq :URLRequest = new URLRequest("file://c:/temp/test.mp3"); // any button is fine.... private var startButton:Button = new Button(maxSize - 50, 100, OFFSET_Y); private var snd:Sound = new Sound(); private var sndCh:SoundChannel; private var playState:B

ActionScript 3.0 でのSoundのメモリリーク解消方法

ActionScript 3.0のSoundクラスを用いてメモリ上にロードしたサウンドの開放方法が分からなかったので、Google先生で調べてみました。いくつか有用な記事が見つかりました。 Arrayの要素としてSoundオブジェクトを生成、deleteおよびnull代入によって開放を行うようです。 Memory Optimization Flash Action Script 3 AS3 - Working with Sound. 2010/3/25 追記 私もロードされたデータを開放できるSoundクラスを書いてみました。ご自由に利用してください。むむむ、余計な部分があって長過ぎですね。。。 package utils.sound { import flash.errors.IOError; import flash.events.Event; import flash.events.IOErrorEvent; import flash.media.ID3Info; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.net.URLRequest; public class SoundCacheCore { public static const LOADING:int = 0; public static const LOAD_COMPLETE:int = 1; public static const NO_LOAD:int = 2; private var _url:String; private var sound:Array; private var sndChannel:SoundChannel; private var _duration:Number; private var _loadStatus:int = NO_LOAD; private var _isPlaying:Boolean; private var _pauseTime:Number; private var _initialSoundVolume:Nu