root/as3/SiOPM/trunk/src/org/si/sound/PolyphonicSynthesizer.as

リビジョン 4421, 3.2 kB (コミッタ: keim, コミット時期: 1 年 前)

sion asdocSiON ver0.612 updated

Line 
1 //----------------------------------------------------------------------------------------------------
2 // Polyphonic synthesizer class
3 //  Copyright (c) 2009 keim All rights reserved.
4 //  Distributed under BSD-style license (see org.si.license.txt).
5 //----------------------------------------------------------------------------------------------------
6
7
8 package org.si.sound {
9     import org.si.sion.*;
10     import org.si.sion.sequencer.base.*;
11     import org.si.sion.sequencer.SiMMLTrack;
12     import org.si.sound.patterns.*;
13     import org.si.sound.namespaces._sound_object_internal;
14     import org.si.sound.synthesizers.*;
15    
16    
17     /** Polyphonic synthesizer class provides synthesizer with multi tracks.
18      */
19     public class PolyphonicSynthesizer extends MultiTrackSoundObject
20     {
21     // namespace
22     //----------------------------------------
23         use namespace _sound_object_internal;
24        
25        
26        
27        
28     // variables
29     //----------------------------------------
30        
31        
32        
33        
34     // properties
35     //----------------------------------------
36        
37        
38        
39        
40     // constructor
41     //----------------------------------------
42         /** constructor
43          *  @param synth synthesizer to play
44          */
45         function PolyphonicSynthesizer(synth:VoiceReference = null)
46         {
47             super("PolyphonicSynthesizer", synth);
48         }
49        
50        
51        
52        
53     // operations
54     //----------------------------------------
55         /** @private [protected] Reset */
56         override public function reset() : void
57         {
58             super.reset();
59         }
60        
61        
62         /** start streaming without any sounds */
63         override public function play() : void
64         {
65             _stopAllTracks();
66             _tracks = new Vector.<SiMMLTrack>();
67         }
68        
69        
70         /** stop all tracks */
71         override public function stop() : void
72         {
73             _stopAllTracks();
74         }
75        
76        
77         /** note on
78          *  @param note note number (0-128)
79          *  @param velocity velocity (0-128-255)
80          *  @param length length (1 = 16th beat length)
81          */
82         public function noteOn(note:int, velocity:int=128, length:int=0) : void
83         {
84             if (_tracks) {
85                 _length = length;
86                 _note = note;
87                 _track = _noteOn(_note, false);
88                 if (_track) _synthesizer._registerTrack(_track);
89                 _track.velocity = velocity;
90                 _tracks.push(_track);
91             }
92         }
93        
94        
95         /** note off
96          *  @param note note number to sound off (0-127)
97          */
98         public function noteOff(note:int, stopWithReset:Boolean = true) : void
99         {
100             var noteOffTracks:Vector.<SiMMLTrack> = _noteOff(note, stopWithReset);
101             for each (var t:SiMMLTrack in noteOffTracks) {
102                 _synthesizer._unregisterTracks(t);
103                 t.setDisposable();
104             }
105         }
106        
107        
108        
109        
110     // internal
111     //----------------------------------------
112     }
113 }
114
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。