root/as3/SiOPM/trunk/src/org/si/sion/SiONData.as

リビジョン 4594, 6.7 kB (コミッタ: keim, コミット時期: 10 ヶ月 前)

--

Line 
1 //----------------------------------------------------------------------------------------------------
2 // SiON data
3 //  Copyright (c) 2008 keim All rights reserved.
4 //  Distributed under BSD-style license (see org.si.license.txt).
5 //----------------------------------------------------------------------------------------------------
6
7
8 package org.si.sion {
9     import flash.media.Sound;
10     import org.si.sion.sequencer.SiMMLVoice;
11     import org.si.sion.sequencer.SiMMLData;
12     import org.si.sion.sequencer.SiMMLEnvelopTable;
13     import org.si.sion.sequencer.SiMMLEnvelopTable;
14     import org.si.sion.utils.SiONUtil;
15     import org.si.sion.module.ISiOPMWaveInterface;
16     import org.si.sion.module.SiOPMTable;
17     import org.si.sion.module.SiOPMWavePCMTable;
18     import org.si.sion.module.SiOPMWavePCMData;
19     import org.si.sion.module.SiOPMWaveSamplerTable;
20     import org.si.sion.module.SiOPMWaveSamplerData;
21     import org.si.sion.namespaces._sion_internal;
22
23    
24     /** The SiONData class provides musical score (and voice settings) data of SiON.
25      */
26     public class SiONData extends SiMMLData implements ISiOPMWaveInterface
27     {
28     // valiables
29     //----------------------------------------
30        
31        
32        
33        
34     // constructor
35     //----------------------------------------
36         function SiONData()
37         {
38         }
39        
40        
41        
42        
43     // setter
44     //----------------------------------------
45         /** Set PCM wave data rederd by %7.
46          *  @param index PCM data number.
47          *  @param data wave data, Sound, Vector.<Number> or Vector.<int> is available. The Sound instance is extracted internally, the maximum length to extract is SiOPMWavePCMData.maxSampleLengthFromSound[samples].
48          *  @param samplingNote Sampling wave's original note number, this allows decimal number
49          *  @param keyRangeFrom Assigning key range starts from (not implemented in current version)
50          *  @param keyRangeTo Assigning key range ends at (not implemented in current version)
51          *  @param srcChannelCount channel count of source data, 1 for monoral, 2 for stereo.
52          *  @param channelCount channel count of this data, 1 for monoral, 2 for stereo, 0 sets same with srcChannelCount.
53          *  @see #org.si.sion.module.SiOPMWavePCMData.maxSampleLengthFromSound
54          *  @see #org.si.sion.SiONDriver.render()
55          */
56         public function setPCMWave(index:int, data:*, samplingNote:Number=68, keyRangeFrom:int=0, keyRangeTo:int=127, srcChannelCount:int=2, channelCount:int=0) : SiOPMWavePCMData
57         {
58             var pcmTable:SiOPMWavePCMTable = _sion_internal::_getPCMVoice(index).waveData as SiOPMWavePCMTable
59             return (pcmTable) ? pcmTable.setSample(new SiOPMWavePCMData(data, int(samplingNote*64), srcChannelCount, channelCount), keyRangeFrom, keyRangeTo) : null;
60         }
61        
62        
63         /** Set sampler wave data refered by %10.
64          *  @param index note number. 0-127 for bank0, 128-255 for bank1.
65          *  @param data wave data, Sound, Vector.<Number> or Vector.<int> is available. The Sound is extracted when the length is shorter than SiOPMWaveSamplerData.extractThreshold[msec].
66          *  @param ignoreNoteOff True to set ignoring note off.
67          *  @param pan pan of this sample [-64 - 64].
68          *  @param srcChannelCount channel count of source data, 1 for monoral, 2 for stereo.
69          *  @param channelCount channel count of this data, 1 for monoral, 2 for stereo, 0 sets same with srcChannelCount.
70          *  @return created data instance
71          *  @see #org.si.sion.module.SiOPMWaveSamplerData.extractThreshold
72          *  @see #org.si.sion.SiONDriver.render()
73          */
74         public function setSamplerWave(index:int, data:*, ignoreNoteOff:Boolean=false, pan:int=0, srcChannelCount:int=2, channelCount:int=0) : SiOPMWaveSamplerData
75         {
76             var bank:int = (index>>SiOPMTable.NOTE_BITS) & (SiOPMTable.SAMPLER_TABLE_MAX-1);
77             return samplerTables[bank].setSample(new SiOPMWaveSamplerData(data, ignoreNoteOff, pan, srcChannelCount, channelCount), index & (SiOPMTable.NOTE_TABLE_SIZE-1));
78         }
79        
80
81         /** Set pcm voice
82          *  @param index PCM data number.
83          *  @param voice pcm voice to set, ussualy from SiONSoundFont
84          *  @return cloned internal voice data
85          */
86         public function setPCMVoice(index:int, voice:SiONVoice) : void
87         {
88             pcmVoices[index & (pcmVoices.length-1)] = voice;
89         }
90        
91        
92         /** Set sampler table
93          *  @param bank bank number
94          *  @param table sampler table class, ussualy from SiONSoundFont
95          *  @see SiONSoundFont
96          */
97         public function setSamplerTable(bank:int, table:SiOPMWaveSamplerTable) : void
98         {
99             samplerTables[bank & (samplerTables.length-1)] = table;
100         }
101        
102        
103         /** [NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setPCMWave instead of this function. @see #setPCMWave(). */
104         public function setPCMData(index:int, data:Vector.<Number>, samplingOctave:int=5, keyRangeFrom:int=0, keyRangeTo:int=127, isSourceDataStereo:Boolean=false) : SiOPMWavePCMData
105         {
106             return setPCMWave(index, data, samplingOctave*12+8, keyRangeFrom, keyRangeTo, (isSourceDataStereo)?2:1);
107         }
108        
109        
110         /** [NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setPCMWave instead of this function. @see #setPCMWave(). */
111         public function setPCMSound(index:int, sound:Sound, samplingOctave:int=5, keyRangeFrom:int=0, keyRangeTo:int=127) : SiOPMWavePCMData
112         {
113             return setPCMWave(index, sound, samplingOctave*12+8, keyRangeFrom, keyRangeTo, 1, 0);
114         }
115        
116        
117         /** [NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setSamplerWave instead of this function. @see #setSamplerWave(). */
118         public function setSamplerData(index:int, data:Vector.<Number>, ignoreNoteOff:Boolean=false, channelCount:int=1) : SiOPMWaveSamplerData
119         {
120             return setSamplerWave(index, data, ignoreNoteOff, 0, channelCount);
121         }
122        
123        
124         /** [NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setSamplerWave instead of this function. @see #setSamplerWave(). */
125         public function setSamplerSound(index:int, sound:Sound, ignoreNoteOff:Boolean=false, channelCount:int=2) : SiOPMWaveSamplerData
126         {
127             return setSamplerWave(index, sound, ignoreNoteOff, 0, channelCount);
128         }
129     }
130 }
131
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。