チェンジセット 1230: as3/sazameki/branches/fp10/src/org
- コミット日時:
- 2008/09/02 13:46:56 (4 年前)
- ファイル:
-
- as3/sazameki/branches/fp10/src/org/sazameki/audio/core/AudioSamples.as (更新) (1 diff)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/ctrlEvent/events/NoteOn.as (更新) (1 diff)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/MultiSamplePlayer/ProcessData.as (更新) (1 diff)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/MultiSamplePlayer/Voice.as (更新) (1 diff)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/tenoran/Tenoran.as (更新) (1 diff)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/tenoran/TenoranBtn.as (更新) (3 diffs)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/tenoran/TenoranUI.as (更新) (10 diffs)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer/Region.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer/WaveSlicer.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer/algorithm (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer/algorithm/EvenIntervalSlice.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer/algorithm/ISlicerAlgorithm.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/waveSlicer/algorithm/RandomBeatSlice.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/parameter (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/parameter/IParameter.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/parameter/Parameter.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/parameter/ParameterExponential.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/AudioProcessor.as (更新) (2 diffs)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/IAudioProcessor.as (更新) (2 diffs)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/effects/Delay.as (更新) (4 diffs)
- as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/filter/ResonatFilter.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/data/RingBuffer.as (更新) (2 diffs)
- as3/sazameki/branches/fp10/src/org/sazameki/ui/AbstructGui.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/ui/IParameterAssignable.as (追加)
- as3/sazameki/branches/fp10/src/org/sazameki/ui/Knob.as (追加)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/sazameki/branches/fp10/src/org/sazameki/audio/core/AudioSamples.as
r874 r1230 13 13 14 14 private var _setting:AudioSetting; 15 //TODO: サンプルがmonoのときは、rightにleftのサンプルの参照を入れておくようにする 。15 //TODO: サンプルがmonoのときは、rightにleftのサンプルの参照を入れておくようにする? 16 16 public function AudioSamples(setting:AudioSetting,length:int=0) 17 17 { as3/sazameki/branches/fp10/src/org/sazameki/audio/ctrlEvent/events/NoteOn.as
r649 r1230 11 11 public var channel:uint; 12 12 13 public function NoteOn(noteNumber:uint, velocity:Number = 1.0, channel:uint = 0)13 public function NoteOn(noteNumber:uint, velocity:Number = 0.8, channel:uint = 0) 14 14 { 15 15 this.note = noteNumber; as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/MultiSamplePlayer/ProcessData.as
r649 r1230 21 21 _samples = new AudioSamples(new AudioSetting(), length); 22 22 _events = new CtrlEventList(length); 23 24 23 } 25 24 public function get events():CtrlEventList { return _events; } as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/MultiSamplePlayer/Voice.as
r874 r1230 23 23 private var _fadeOutSpeed:Number = 0.01; 24 24 25 public function Voice(inst:Instrument,noteNum:uint,startOffset:uint=0,velocity:Number= 1.0)25 public function Voice(inst:Instrument,noteNum:uint,startOffset:uint=0,velocity:Number=0.8) 26 26 { 27 27 _inst = inst; as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/tenoran/Tenoran.as
r874 r1230 136 136 } 137 137 138 public function get map():Vector.<int> { return _map; } 139 140 public function set map(value:Vector.<int>):void 141 { 142 _map = value; 143 } 144 138 145 } 139 146 as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/tenoran/TenoranBtn.as
r874 r1230 28 28 private var _cnt:int; 29 29 30 public function TenoranBtn(xIdx:int,yIdx:int) 30 private var _parent:TenoranUI; 31 public function TenoranBtn(xIdx:int,yIdx:int,ui:TenoranUI) 31 32 { 33 _parent = ui; 32 34 addEventListener(MouseEvent.MOUSE_DOWN, onClick); 33 35 addEventListener(MouseEvent.ROLL_OVER, onOver); … … 39 41 btnOn2.alpha = 0; 40 42 addChild(btnOn2); 43 41 44 } 42 45 43 46 private function onOver(e:MouseEvent):void 44 47 { 45 if (e.buttonDown )48 if (e.buttonDown && _parent.isMouseDown) 46 49 { 47 50 onClick(e); … … 62 65 63 66 public function get isOn():Boolean { return _isOn; } 67 public function set isOn(value:Boolean):void 68 { 69 _isOn = value; 70 btnOn.visible = _isOn; 71 } 64 72 65 73 public function lightOn():void as3/sazameki/branches/fp10/src/org/sazameki/audio/engine/tenoran/TenoranUI.as
r874 r1230 10 10 import flash.text.TextFormat; 11 11 import flash.utils.setTimeout; 12 import jp.zkdesign.utility.StageUtility; 12 13 /** 13 14 * ... … … 30 31 private var swingTf:TextField; 31 32 33 internal var isMouseDown:Boolean=false; 34 32 35 public function TenoranUI(tenoran:Tenoran) 33 36 { … … 43 46 for (var k:int = 0; k < 16; ++k) 44 47 { 45 var btn:TenoranBtn = new TenoranBtn(i, k );48 var btn:TenoranBtn = new TenoranBtn(i, k, this); 46 49 47 50 btn.x = btnSize * i + btnOffsetX; … … 74 77 var bpmAddBtn:TenoranCtrlBtn = new TenoranCtrlBtn(); 75 78 bpmAddBtn.addEventListener(MouseEvent.CLICK, onBpmAdd); 76 bpmAddBtn.x = 120;79 bpmAddBtn.x = 50; 77 80 bpmAddBtn.y = 485; 78 81 addChild(bpmAddBtn); … … 80 83 var bpmSubBtn:TenoranCtrlBtn = new TenoranCtrlBtn(); 81 84 bpmSubBtn.addEventListener(MouseEvent.CLICK, onBpmSub); 82 bpmSubBtn.x = 150;85 bpmSubBtn.x = 80; 83 86 bpmSubBtn.y = 485; 84 87 addChild(bpmSubBtn); … … 86 89 var swingAddBtn:TenoranCtrlBtn = new TenoranCtrlBtn(); 87 90 swingAddBtn.addEventListener(MouseEvent.CLICK, onSwingAdd); 88 swingAddBtn.x = 358;91 swingAddBtn.x = 120; 89 92 swingAddBtn.y = 485; 90 93 addChild(swingAddBtn); … … 92 95 var swingSubBtn:TenoranCtrlBtn = new TenoranCtrlBtn(); 93 96 swingSubBtn.addEventListener(MouseEvent.CLICK, onSwingSub); 94 swingSubBtn.x = 388;97 swingSubBtn.x = 150; 95 98 swingSubBtn.y = 485; 96 99 addChild(swingSubBtn); 97 100 101 var resetBtn:TenoranCtrlBtn = new TenoranCtrlBtn(); 102 resetBtn.addEventListener(MouseEvent.CLICK, onReset); 103 resetBtn.x = 484; 104 resetBtn.y = 80; 105 addChild(resetBtn); 106 107 addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 108 addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 109 StageUtility.getStage().addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 98 110 111 } 112 113 private function onReset(e:MouseEvent):void 114 { 115 var btn:TenoranBtn; 116 for (var i:int = 0; i < 16;++i) 117 { 118 for (var k:int = 0; k < 16; ++k) 119 { 120 btn = btns[i][k]; 121 btn.isOn = false; 122 } 123 } 124 } 125 126 private function onMouseDown(e:MouseEvent):void 127 { 128 isMouseDown = true; 129 } 130 131 private function onMouseUp(e:MouseEvent):void 132 { 133 isMouseDown = false; 99 134 } 100 135 … … 102 137 { 103 138 tenoran.swing -= 0.1; 104 swingTf.text = String( tenoran.swing);139 swingTf.text = String(Math.round(tenoran.swing*10)/10); 105 140 } 106 141 … … 108 143 { 109 144 tenoran.swing += 0.1; 110 swingTf.text = String( tenoran.swing);145 swingTf.text = String(Math.round(tenoran.swing*10)/10); 111 146 } 112 147 … … 148 183 } 149 184 } 185 186 public function allOff():void 187 { 188 189 } 150 190 } 151 191 } as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/AudioProcessor.as
r649 r1230 2 2 { 3 3 import flash.events.EventDispatcher; 4 import org.sazameki.audio.core.AudioSamples; 4 5 import org.sazameki.audio.core.AudioSetting; 5 6 import org.sazameki.audio.core.SampleBuffer; … … 34 35 } 35 36 36 public function process Audio(samples:SampleBuffer):void{37 public function process(samples:AudioSamples):void{ 37 38 38 39 } as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/IAudioProcessor.as
r649 r1230 1 1 package org.sazameki.audio.processor 2 2 { 3 import org.sazameki.audio.core.AudioSetting; 4 import org.sazameki.audio.core.SampleBuffer; 3 import org.sazameki.audio.core.AudioSamples; 5 4 6 5 /** … … 11 10 { 12 11 13 function processAudio(samples:SampleBuffer):void; 12 function process(samples:AudioSamples):void; 13 /* 14 14 function get parameterFormat():String; 15 15 function get description():String; 16 16 function get isEnvelope():Boolean; 17 17 function trigger():void; 18 function initialize(setting:AudioSetting,basicParams:Array=null,additionalProcessors:Object=null):void; } 18 */ 19 } 20 19 21 20 22 } as3/sazameki/branches/fp10/src/org/sazameki/audio/processor/effects/Delay.as
r649 r1230 11 11 */ 12 12 13 /*14 * Licensed under the MIT License15 *16 * Copyright (c) 2008 Takaaki Yamazaki17 *18 * Permission is hereby granted, free of charge, to any person obtaining a copy19 * of this software and associated documentation files (the "Software"), to deal20 * in the Software without restriction, including without limitation the rights21 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell22 * copies of the Software, and to permit persons to whom the Software is23 * furnished to do so, subject to the following conditions:24 *25 * The above copyright notice and this permission notice shall be included in26 * all copies or substantial portions of the Software.27 *28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE31 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,33 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN34 * THE SOFTWARE.35 */36 13 37 14 package org.sazameki.audio.processor.effects { 15 import org.sazameki.audio.core.AudioSamples; 16 import org.sazameki.audio.core.AudioSetting; 38 17 import org.sazameki.audio.core.Sample; 39 18 import org.sazameki.audio.engine.ssGenerator.SsAudioSetting; 19 import org.sazameki.audio.parameter.Parameter; 40 20 import org.sazameki.audio.processor.AudioProcessor; 21 import org.sazameki.audio.processor.IAudioProcessor; 41 22 import org.sazameki.audio.processor.SsAudioProcessor; 42 23 import org.sazameki.data.RingArray; 24 import org.sazameki.data.RingBuffer; 43 25 44 public class Delay extendsAudioProcessor26 public class Delay implements IAudioProcessor 45 27 { 46 28 47 private var _buffer:RingArray; 29 private var _bufferL:RingBuffer; 30 private var _bufferR:RingBuffer; 48 31 private var _length:int; 49 private var _ feedback:Number;50 private var _ dry:Number;51 private var _ wet:Number;32 private var _delayTime:Parameter = new Parameter(1, 1000); 33 private var _feedback:Parameter = new Parameter(0, 1); 34 private var _mix:Parameter = new Parameter(0, 1); 52 35 53 public function Delay() { 36 public function Delay(delayTimeMs:Number=500,feedBack:Number=0.5,mix:Number=0.3) { 37 _delayTime.value = delayTimeMs; 38 _feedback.value = feedBack; 39 _mix.value = mix; 40 //バッファサイズ=delay timeの最大値*サンプルレート(44100) 41 _bufferL = new RingBuffer(Math.ceil(_delayTime.max * 44.1)); 42 _bufferR = new RingBuffer(Math.ceil(_delayTime.max * 44.1)); 54 43 55 44 } 56 override public function get description():String{45 /*override public function get description():String{ 57 46 return "delay effect."; 58 47 } … … 60 49 return 'delay time(ms)-feedback(0-1)-wet(0-1)-[dry(0-1)]'; 61 50 } 62 override public function initialize(setting:SsAudioSetting, basicParams:Array = null, additionalProcessors:Object = null):void{ 51 52 override public function initialize(setting:AudioSetting, basicParams:Array = null, additionalProcessors:Object = null):void{ 63 53 super.initialize(setting, basicParams, additionalProcessors); 64 54 … … 84 74 85 75 } 86 87 override public function processAudio(samples:Array):void{ 88 var smpl:Sample; 89 var delaySmpl:Sample; 90 var len:int=samples.length; 91 var tmpSmpl:Sample=new Sample(); 76 */ 77 public function process(samples:AudioSamples):void 78 { 92 79 93 for(var i:int;i<len;i++){ 94 smpl=samples[i]; 95 delaySmpl=_buffer.getAt(0); 80 var delayCount:int = _delayTime.value * 44.1; 81 var feedback:Number = _feedback.value; 82 var wet:Number = _mix.value; 83 var dry:Number = 1 - wet; 84 85 var i:int = 0; 86 var len:int = samples.length; 87 var left:Vector.<Number>=samples.left; 88 var inputSig:Number; 89 var wetSig:Number; 90 for (; i < len; i++) 91 { 92 inputSig = left[i]; 93 wetSig = inputSig + _bufferL.head * feedback; 94 _bufferL.setAt(delayCount, wetSig); 95 left[i] = inputSig * dry + wetSig * wet; 96 96 97 //一時保存 98 tmpSmpl.left=smpl.left; 99 tmpSmpl.right=smpl.right; 97 _bufferL.next(); 100 98 101 //mix 102 smpl.left=smpl.left*_dry+delaySmpl.left*_wet; 103 smpl.right=smpl.right*_dry+delaySmpl.right*_wet; 104 105 //save 106 delaySmpl.left=tmpSmpl.left+delaySmpl.left*_feedback; 107 delaySmpl.right=tmpSmpl.right+delaySmpl.right*_feedback; 108 109 _buffer.next(); 110 99 } 100 if (samples.setting.channels == 2) 101 { 102 var right:Vector.<Number>=samples.right; 103 for (i = 0; i < len; i++) 104 { 105 inputSig = right[i]; 106 wetSig = inputSig + _bufferR.head * feedback; 107 _bufferR.setAt(delayCount, wetSig); 108 right[i] = inputSig * dry + wetSig * wet; 109 110 _bufferR.next(); 111 112 } 113 111 114 } 112 115 … … 116 119 } 117 120 121 public function get delayTime():Parameter { return _delayTime; } 122 123 public function get feedback():Parameter { return _feedback; } 124 125 public function get mix():Parameter { return _mix; } 126 118 127 } 119 128 as3/sazameki/branches/fp10/src/org/sazameki/data/RingBuffer.as
r364 r1230 37 37 38 38 public class RingBuffer { 39 private var _buffer: Array;39 private var _buffer:Vector.<Number> 40 40 private var _length:int; 41 41 private var _currentIdx:int; … … 44 44 public function RingBuffer(length:int=10) { 45 45 _length=length; 46 _buffer =new Array();46 _buffer = new Vector.<Number>(_length); 47 47 _currentIdx=0; 48 48 _sum=0; 49 49 } 50 50 51 public function setAt(idx:int, value:Number):void 52 { 53 idx = _currentIdx + idx; 54 while (idx > _length) 55 { 56 idx -= _length; 57 } 58 while (idx < 0) 59 { 60 idx += _length; 61 } 62 _buffer[idx] = value; 63 64 } 65 public function getAt(idx:int):Number 66 { 67 idx = _currentIdx + idx; 68 while (idx >= _length) 69 { 70 idx -= _length; 71 } 72 while (idx < 0) 73 { 74 idx += _length; 75 } 76 return(_buffer[idx]); 77 } 78 79 public function get head():Number 80 { 81 return _buffer[_currentIdx]; 82 } 83 public function set head(value:Number):void 84 { 85 _buffer[_currentIdx] = value; 86 } 87 public function next():void 88 { 89 _currentIdx++; 90 if (_currentIdx >= _length) 91 { 92 _currentIdx -= _length; 93 } 94 } 95 public function prev():void 96 { 97 _currentIdx--; 98 if (_currentIdx < 0) 99 { 100 _currentIdx += _length; 101 } 102 } 103 104 105 106 51 107 public function setLength(length:int,clear:Boolean=true):void{ 52 108 _length=length; 53 _buffer=new Array();109 _buffer=new Vector.<Number>(length); 54 110 55 111 }

