| 1 |
//---------------------------------------------------------------------------------------------------- |
|---|
| 2 |
// SiON Voice data |
|---|
| 3 |
// Copyright (c) 2008 keim All rights reserved. |
|---|
| 4 |
// Distributed under BSD-style license (see org.si.license.txt). |
|---|
| 5 |
//---------------------------------------------------------------------------------------------------- |
|---|
| 6 |
|
|---|
| 7 |
package org.si.sion { |
|---|
| 8 |
import flash.media.Sound; |
|---|
| 9 |
import org.si.sion.utils.Translator; |
|---|
| 10 |
import org.si.sion.sequencer.SiMMLVoice; |
|---|
| 11 |
import org.si.sion.module.ISiOPMWaveInterface; |
|---|
| 12 |
import org.si.sion.module.SiOPMTable; |
|---|
| 13 |
import org.si.sion.module.SiOPMChannelParam; |
|---|
| 14 |
import org.si.sion.module.SiOPMOperatorParam; |
|---|
| 15 |
import org.si.sion.module.SiOPMWavePCMData; |
|---|
| 16 |
import org.si.sion.module.SiOPMWavePCMTable; |
|---|
| 17 |
import org.si.sion.module.SiOPMWaveSamplerData; |
|---|
| 18 |
import org.si.sion.module.SiOPMWaveSamplerTable; |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
/** SiONVoice class provides all of voice setting parameters of SiON. |
|---|
| 22 |
* @see org.si.sion.module.SiOPMChannelParam |
|---|
| 23 |
* @see org.si.sion.module.SiOPMOperatorParam |
|---|
| 24 |
*/ |
|---|
| 25 |
public class SiONVoice extends SiMMLVoice implements ISiOPMWaveInterface |
|---|
| 26 |
{ |
|---|
| 27 |
// constant |
|---|
| 28 |
//-------------------------------------------------- |
|---|
| 29 |
static public const CHIPTYPE_SIOPM:String = ""; |
|---|
| 30 |
static public const CHIPTYPE_OPL:String = "OPL"; |
|---|
| 31 |
static public const CHIPTYPE_OPM:String = "OPM"; |
|---|
| 32 |
static public const CHIPTYPE_OPN:String = "OPN"; |
|---|
| 33 |
static public const CHIPTYPE_OPX:String = "OPX"; |
|---|
| 34 |
static public const CHIPTYPE_MA3:String = "MA3"; |
|---|
| 35 |
static public const CHIPTYPE_PMS_GUITAR:String = "PMSGuitar"; |
|---|
| 36 |
static public const CHIPTYPE_ANALOG_LIKE:String = "AnalogLike"; |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
// variables |
|---|
| 42 |
//-------------------------------------------------- |
|---|
| 43 |
/** voice name */ |
|---|
| 44 |
public var name:String; |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
// constrctor |
|---|
| 50 |
//-------------------------------------------------- |
|---|
| 51 |
/** create new SiONVoice instance with '%' parameters, attack rate, release rate and pitchShift. |
|---|
| 52 |
* @param moduleType Module type. 1st argument of '%'. |
|---|
| 53 |
* @param channelNum Channel number. 2nd argument of '%'. |
|---|
| 54 |
* @param ar Attack rate (0-63). |
|---|
| 55 |
* @param rr Release rate (0-63). |
|---|
| 56 |
* @param dt pitchShift (64=1halftone). |
|---|
| 57 |
* @param con connection type of 2nd operator, -1 sets 1operator voice. |
|---|
| 58 |
* @param ws2 wave shape of 2nd operator. |
|---|
| 59 |
* @param dt2 pitchShift of 2nd operator (64=1halftone). |
|---|
| 60 |
*/ |
|---|
| 61 |
function SiONVoice(moduleType:int=5, channelNum:int=0, ar:int=63, rr:int=63, dt:int=0, connectionType:int=-1, ws2:int=0, dt2:int=0) |
|---|
| 62 |
{ |
|---|
| 63 |
super(); |
|---|
| 64 |
name = ""; |
|---|
| 65 |
updateTrackParamaters = true; |
|---|
| 66 |
|
|---|
| 67 |
setModuleType(moduleType, channelNum); |
|---|
| 68 |
channelParam.operatorParam[0].ar = ar; |
|---|
| 69 |
channelParam.operatorParam[0].rr = rr; |
|---|
| 70 |
pitchShift = dt; |
|---|
| 71 |
if (connectionType >= 0) { |
|---|
| 72 |
channelParam.opeCount = 5; |
|---|
| 73 |
channelParam.alg = (connectionType<=2) ? connectionType : 0; |
|---|
| 74 |
channelParam.operatorParam[0].setPGType(channelNum); |
|---|
| 75 |
channelParam.operatorParam[1].setPGType(ws2); |
|---|
| 76 |
channelParam.operatorParam[1].detune = dt2; |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
// operation |
|---|
| 84 |
//-------------------------------------------------- |
|---|
| 85 |
/** create clone voice. */ |
|---|
| 86 |
public function clone() : SiONVoice |
|---|
| 87 |
{ |
|---|
| 88 |
var newVoice:SiONVoice = new SiONVoice(); |
|---|
| 89 |
newVoice.copyFrom(this); |
|---|
| 90 |
newVoice.name = name; |
|---|
| 91 |
return newVoice; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
// FM parameter setter / getter |
|---|
| 98 |
//-------------------------------------------------- |
|---|
| 99 |
/** Set by #@ parameters Array */ |
|---|
| 100 |
public function set param(args:Array) : void { Translator.setParam(channelParam, args); chipType = ""; } |
|---|
| 101 |
|
|---|
| 102 |
/** Set by #OPL@ parameters Array */ |
|---|
| 103 |
public function set paramOPL(args:Array) : void { Translator.setOPLParam(channelParam, args); chipType = "OPL"; } |
|---|
| 104 |
|
|---|
| 105 |
/** Set by #OPM@ parameters Array */ |
|---|
| 106 |
public function set paramOPM(args:Array) : void { Translator.setOPMParam(channelParam, args); chipType = "OPM"; } |
|---|
| 107 |
|
|---|
| 108 |
/** Set by #OPN@ parameters Array */ |
|---|
| 109 |
public function set paramOPN(args:Array) : void { Translator.setOPNParam(channelParam, args); chipType = "OPN"; } |
|---|
| 110 |
|
|---|
| 111 |
/** Set by #OPX@ parameters Array */ |
|---|
| 112 |
public function set paramOPX(args:Array) : void { Translator.setOPXParam(channelParam, args); chipType = "OPX"; } |
|---|
| 113 |
|
|---|
| 114 |
/** Set by #MA@ parameters Array */ |
|---|
| 115 |
public function set paramMA3(args:Array) : void { Translator.setMA3Param(channelParam, args); chipType = "MA3"; } |
|---|
| 116 |
|
|---|
| 117 |
/** Get #AL@ parameters by Array */ |
|---|
| 118 |
public function set paramAL(args:Array) : void { Translator.setALParam(channelParam, args); chipType = "AnalogLike"; } |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
/** Get #@ parameters by Array */ |
|---|
| 122 |
public function get param() : Array { return Translator.getParam(channelParam); } |
|---|
| 123 |
|
|---|
| 124 |
/** Get #OPL@ parameters by Array */ |
|---|
| 125 |
public function get paramOPL() : Array { return Translator.getOPLParam(channelParam); } |
|---|
| 126 |
|
|---|
| 127 |
/** Get #OPM@ parameters by Array */ |
|---|
| 128 |
public function get paramOPM() : Array { return Translator.getOPMParam(channelParam); } |
|---|
| 129 |
|
|---|
| 130 |
/** Get #OPN@ parameters by Array */ |
|---|
| 131 |
public function get paramOPN() : Array { return Translator.getOPNParam(channelParam); } |
|---|
| 132 |
|
|---|
| 133 |
/** Get #OPX@ parameters by Array */ |
|---|
| 134 |
public function get paramOPX() : Array { return Translator.getOPXParam(channelParam); } |
|---|
| 135 |
|
|---|
| 136 |
/** Get #MA@ parameters by Array */ |
|---|
| 137 |
public function get paramMA3() : Array { return Translator.getMA3Param(channelParam); } |
|---|
| 138 |
|
|---|
| 139 |
/** Get #AL@ parameters by Array */ |
|---|
| 140 |
public function get paramAL() : Array { return Translator.getALParam(channelParam); } |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
/** get FM voice setting MML. |
|---|
| 144 |
* @param index voice number. |
|---|
| 145 |
* @param type chip type. choose string from SiONVoice.CHIPTYPE_* or null to detect automatically. |
|---|
| 146 |
* @param appendPostfixMML append postfix MML of voice settings. |
|---|
| 147 |
* @return mml string of this voice setting. |
|---|
| 148 |
*/ |
|---|
| 149 |
public function getMML(index:int, type:String = null, appendPostfixMML:Boolean = true) : String { |
|---|
| 150 |
if (type == null) type = chipType; |
|---|
| 151 |
var mml:String = "" |
|---|
| 152 |
switch (type) { |
|---|
| 153 |
case "OPL": mml = "#OPL@" + String(index) + Translator.mmlOPLParam(channelParam, " ", "\n", name); break; |
|---|
| 154 |
case "OPM": mml = "#OPM@" + String(index) + Translator.mmlOPMParam(channelParam, " ", "\n", name); break; |
|---|
| 155 |
case "OPN": mml = "#OPN@" + String(index) + Translator.mmlOPNParam(channelParam, " ", "\n", name); break; |
|---|
| 156 |
case "OPX": mml = "#OPX@" + String(index) + Translator.mmlOPXParam(channelParam, " ", "\n", name); break; |
|---|
| 157 |
case "MA3": mml = "#MA@" + String(index) + Translator.mmlMA3Param(channelParam, " ", "\n", name); break; |
|---|
| 158 |
case "AnalogLike": mml = "#AL@" + String(index) + Translator.mmlALParam (channelParam, " ", "\n", name); break; |
|---|
| 159 |
default: mml = "#@" + String(index) + Translator.mmlParam (channelParam, " ", "\n", name); break; |
|---|
| 160 |
} |
|---|
| 161 |
if (appendPostfixMML) { |
|---|
| 162 |
var postfix:String = Translator.mmlVoiceSetting(this); |
|---|
| 163 |
if (postfix != "") mml += "\n" + postfix; |
|---|
| 164 |
} |
|---|
| 165 |
return mml + ";"; |
|---|
| 166 |
} |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
/** set FM voice by MML. |
|---|
| 170 |
* @param mml MML string. |
|---|
| 171 |
* @return voice index number. returns -1 when error. |
|---|
| 172 |
*/ |
|---|
| 173 |
public function setByMML(mml:String) : int { |
|---|
| 174 |
// separating |
|---|
| 175 |
initialize(); |
|---|
| 176 |
var rexNum:RegExp = new RegExp("(#[A-Z]*@)\\s*(\\d+)\\s*{(.*?)}(.*?);", "ms"), |
|---|
| 177 |
rexNam:RegExp = new RegExp("^.*?(//\\s*(.+?))?[\\n\\r]"), |
|---|
| 178 |
res:* = rexNum.exec(mml); |
|---|
| 179 |
if (res) { |
|---|
| 180 |
var cmd:String = String(res[1]), |
|---|
| 181 |
prm:String = String(res[3]), |
|---|
| 182 |
pfx:String = String(res[4]), |
|---|
| 183 |
voiceIndex:int = int(res[2]); |
|---|
| 184 |
switch (cmd) { |
|---|
| 185 |
case "#@": { Translator.parseParam (channelParam, prm); chipType = ""; }break; |
|---|
| 186 |
case "#OPL@":{ Translator.parseOPLParam(channelParam, prm); chipType = "OPL"; }break; |
|---|
| 187 |
case "#OPM@":{ Translator.parseOPMParam(channelParam, prm); chipType = "OPM"; }break; |
|---|
| 188 |
case "#OPN@":{ Translator.parseOPNParam(channelParam, prm); chipType = "OPN"; }break; |
|---|
| 189 |
case "#OPX@":{ Translator.parseOPXParam(channelParam, prm); chipType = "OPX"; }break; |
|---|
| 190 |
case "#MA@": { Translator.parseMA3Param(channelParam, prm); chipType = "MA3"; }break; |
|---|
| 191 |
case "#AL@": { Translator.parseALParam (channelParam, prm); chipType = "AnalogLike"; }break; |
|---|
| 192 |
default: return -1; |
|---|
| 193 |
} |
|---|
| 194 |
Translator.parseVoiceSetting(this, pfx); |
|---|
| 195 |
res = rexNam.exec(prm); |
|---|
| 196 |
name = (res && res[2]) ? String(res[2]) : ""; |
|---|
| 197 |
return voiceIndex; |
|---|
| 198 |
} |
|---|
| 199 |
return -1; |
|---|
| 200 |
} |
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
// Voice setter |
|---|
| 205 |
//-------------------------------------------------- |
|---|
| 206 |
/** initializer */ |
|---|
| 207 |
override public function initialize() : void |
|---|
| 208 |
{ |
|---|
| 209 |
super.initialize(); |
|---|
| 210 |
name = ""; |
|---|
| 211 |
updateTrackParamaters = true; |
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
/** Set as PCM voice (Sound with pitch shift, LPF envlope). |
|---|
| 216 |
* @param data wave data, Sound, Vector.<Number> or Vector.<int> is available. The Sound instance is extracted internally. |
|---|
| 217 |
* @param samplingOctave sampling data's original note |
|---|
| 218 |
* @return PCM data instance as SiOPMWavePCMData |
|---|
| 219 |
* @see org.si.sion.module.SiOPMWavePCMData |
|---|
| 220 |
*/ |
|---|
| 221 |
public function setPCMVoice(data:*, samplingOctave:int=68, srcChannelCount:int=2, channelCount:int=0) : SiOPMWavePCMData |
|---|
| 222 |
{ |
|---|
| 223 |
moduleType = 7; |
|---|
| 224 |
return (waveData = new SiOPMWavePCMData(data, samplingOctave*768+512, srcChannelCount, channelCount)) as SiOPMWavePCMData; |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
/** Set as Sampler voice (Sound without pitch shift, LPF envlope). |
|---|
| 229 |
* @param data wave data, Sound, Vector.<Number> or Vector.<int> is available. The Sound is extracted when the length is shorter than 4[sec]. |
|---|
| 230 |
* @param ignoreNoteOff flag to ignore note off |
|---|
| 231 |
* @param channelCount channel count of streaming, 1 for monoral, 2 for stereo. |
|---|
| 232 |
* @return MP3 data instance as SiOPMWaveSamplerData |
|---|
| 233 |
* @see org.si.sion.module.SiOPMWaveSamplerData |
|---|
| 234 |
*/ |
|---|
| 235 |
public function setMP3Voice(wave:Sound, ignoreNoteOff:Boolean=false, channelCount:int=2) : SiOPMWaveSamplerData |
|---|
| 236 |
{ |
|---|
| 237 |
moduleType = 10; |
|---|
| 238 |
return (waveData = new SiOPMWaveSamplerData(wave, ignoreNoteOff, 0, 2, channelCount)) as SiOPMWaveSamplerData; |
|---|
| 239 |
} |
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
/** Set PCM wave data rederd by %7. |
|---|
| 243 |
* @param index PCM data number. |
|---|
| 244 |
* @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]. |
|---|
| 245 |
* @param samplingNote Sampling wave's original note number, this allows decimal number |
|---|
| 246 |
* @param keyRangeFrom Assigning key range starts from (not implemented in current version) |
|---|
| 247 |
* @param keyRangeTo Assigning key range ends at (not implemented in current version) |
|---|
| 248 |
* @param srcChannelCount channel count of source data, 1 for monoral, 2 for stereo. |
|---|
| 249 |
* @param channelCount channel count of this data, 1 for monoral, 2 for stereo, 0 sets same with srcChannelCount. |
|---|
| 250 |
* @see #org.si.sion.module.SiOPMWavePCMData.maxSampleLengthFromSound |
|---|
| 251 |
* @see #org.si.sion.SiONDriver.render() |
|---|
| 252 |
*/ |
|---|
| 253 |
public function setPCMWave(index:int, data:*, samplingNote:Number=68, keyRangeFrom:int=0, keyRangeTo:int=127, srcChannelCount:int=2, channelCount:int=0) : SiOPMWavePCMData |
|---|
| 254 |
{ |
|---|
| 255 |
if (moduleType != 7 || channelNum != index) waveData = null; |
|---|
| 256 |
moduleType = 7; |
|---|
| 257 |
channelNum = index; |
|---|
| 258 |
var pcmTable:SiOPMWavePCMTable = (waveData as SiOPMWavePCMTable) || new SiOPMWavePCMTable(); |
|---|
| 259 |
var pcmData:SiOPMWavePCMData = new SiOPMWavePCMData(data, int(samplingNote*64), srcChannelCount, channelCount); |
|---|
| 260 |
pcmTable.setSample(pcmData, keyRangeFrom, keyRangeTo); |
|---|
| 261 |
waveData = pcmTable; |
|---|
| 262 |
return pcmData; |
|---|
| 263 |
} |
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
/** Set sampler wave data refered by %10. |
|---|
| 267 |
* @param index note number. 0-127 for bank0, 128-255 for bank1. |
|---|
| 268 |
* @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]. |
|---|
| 269 |
* @param ignoreNoteOff True to set ignoring note off. |
|---|
| 270 |
* @param pan pan of this sample [-64 - 64]. |
|---|
| 271 |
* @param srcChannelCount channel count of source data, 1 for monoral, 2 for stereo. |
|---|
| 272 |
* @param channelCount channel count of this data, 1 for monoral, 2 for stereo, 0 sets same with srcChannelCount. |
|---|
| 273 |
* @return created data instance |
|---|
| 274 |
* @see #org.si.sion.module.SiOPMWaveSamplerData.extractThreshold |
|---|
| 275 |
* @see #org.si.sion.SiONDriver.render() |
|---|
| 276 |
*/ |
|---|
| 277 |
public function setSamplerWave(index:int, data:*, ignoreNoteOff:Boolean=false, pan:int=0, srcChannelCount:int=2, channelCount:int=0) : SiOPMWaveSamplerData |
|---|
| 278 |
{ |
|---|
| 279 |
moduleType = 10; |
|---|
| 280 |
var samplerTable:SiOPMWaveSamplerTable = (waveData as SiOPMWaveSamplerTable) || new SiOPMWaveSamplerTable(); |
|---|
| 281 |
var sampleData:SiOPMWaveSamplerData = new SiOPMWaveSamplerData(data, ignoreNoteOff, pan, srcChannelCount, channelCount); |
|---|
| 282 |
samplerTable.setSample(sampleData, index & (SiOPMTable.NOTE_TABLE_SIZE-1)); |
|---|
| 283 |
waveData = samplerTable; |
|---|
| 284 |
return sampleData; |
|---|
| 285 |
} |
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
/** Set sampler table |
|---|
| 289 |
* @param table sampler table class, ussualy get from SiONSoundFont |
|---|
| 290 |
* @return this instance |
|---|
| 291 |
* @see SiONSoundFont |
|---|
| 292 |
*/ |
|---|
| 293 |
public function setSamplerTable(table:SiOPMWaveSamplerTable) : SiONVoice |
|---|
| 294 |
{ |
|---|
| 295 |
moduleType = 10; |
|---|
| 296 |
waveData = table; |
|---|
| 297 |
return this; |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
/** Set as phisical modeling synth guitar voice. |
|---|
| 302 |
* @param ar attack rate of plunk energy |
|---|
| 303 |
* @param dr decay rate of plunk energy |
|---|
| 304 |
* @param tl total level of plunk energy |
|---|
| 305 |
* @param fixedPitch plunk noise pitch |
|---|
| 306 |
* @param ws wave shape of plunk |
|---|
| 307 |
* @param tension sustain rate of the tone |
|---|
| 308 |
* @return this SiONVoice instance |
|---|
| 309 |
*/ |
|---|
| 310 |
public function setPMSGuitar(ar:int=48, dr:int=48, tl:int=0, fixedPitch:int=68, ws:int=20, tension:int=8) : SiONVoice |
|---|
| 311 |
{ |
|---|
| 312 |
moduleType = 11; |
|---|
| 313 |
channelNum = 1; |
|---|
| 314 |
param = [1, 0, 0, ws, ar, dr, 0, 63, 15, tl, 0, 0, 1, 0, 0, 0, 0, fixedPitch]; |
|---|
| 315 |
pmsTension = tension; |
|---|
| 316 |
chipType = "PMSGuitar"; |
|---|
| 317 |
return this; |
|---|
| 318 |
} |
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
/** Set as analog like synth voice. |
|---|
| 322 |
* @param connectionType Connection type, 0=normal, 1=ring, 2=sync, 3=fm. |
|---|
| 323 |
* @param ws1 Wave shape for osc1. |
|---|
| 324 |
* @param ws2 Wave shape for osc2. |
|---|
| 325 |
* @param balance balance between osc1 and 2 (-64 - 64). -64 for only osc1, 0 for same volume, 64 for only osc2. |
|---|
| 326 |
* @param vco2pitch pitch difference in osc1 and 2. 64 for 1 halftone. |
|---|
| 327 |
* @return this SiONVoice instance |
|---|
| 328 |
*/ |
|---|
| 329 |
public function setAnalogLike(connectionType:int, ws1:int=1, ws2:int=1, balance:int=0, vco2pitch:int=0) : SiONVoice |
|---|
| 330 |
{ |
|---|
| 331 |
channelParam.opeCount = 5; |
|---|
| 332 |
channelParam.alg = (connectionType>=0 && connectionType<=3) ? connectionType : 0; |
|---|
| 333 |
channelParam.operatorParam[0].setPGType(ws1); |
|---|
| 334 |
channelParam.operatorParam[1].setPGType(ws2); |
|---|
| 335 |
|
|---|
| 336 |
if (balance > 64) balance = 64; |
|---|
| 337 |
else if (balance < -64) balance = -64; |
|---|
| 338 |
|
|---|
| 339 |
var tltable:Vector.<int> = SiOPMTable.instance.eg_lv2tlTable; |
|---|
| 340 |
channelParam.operatorParam[0].tl = tltable[64-balance]; |
|---|
| 341 |
channelParam.operatorParam[1].tl = tltable[balance+64]; |
|---|
| 342 |
|
|---|
| 343 |
channelParam.operatorParam[0].detune = 0; |
|---|
| 344 |
channelParam.operatorParam[1].detune = vco2pitch; |
|---|
| 345 |
|
|---|
| 346 |
chipType = "AnalogLike"; |
|---|
| 347 |
|
|---|
| 348 |
return this; |
|---|
| 349 |
} |
|---|
| 350 |
|
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
// Optional settings |
|---|
| 355 |
//-------------------------------------------------- |
|---|
| 356 |
/** Set envelop parameters of all operators. |
|---|
| 357 |
* @param ar Attack rate (0-63). |
|---|
| 358 |
* @param dr Decay rate (0-63). |
|---|
| 359 |
* @param sr Sustain rate (0-63). |
|---|
| 360 |
* @param rr Release rate (0-63). |
|---|
| 361 |
* @param sl Sustain level (0-15). |
|---|
| 362 |
* @param tl Total level (0-127). |
|---|
| 363 |
*/ |
|---|
| 364 |
public function setEnvelop(ar:int, dr:int, sr:int, rr:int, sl:int, tl:int) : SiONVoice |
|---|
| 365 |
{ |
|---|
| 366 |
for (var i:int=0; i<4; i++) { |
|---|
| 367 |
var opp:SiOPMOperatorParam = channelParam.operatorParam[i]; |
|---|
| 368 |
opp.ar = ar; |
|---|
| 369 |
opp.dr = dr; |
|---|
| 370 |
opp.sr = sr; |
|---|
| 371 |
opp.rr = rr; |
|---|
| 372 |
opp.sl = sl; |
|---|
| 373 |
opp.tl = tl; |
|---|
| 374 |
} |
|---|
| 375 |
return this; |
|---|
| 376 |
} |
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 |
/** Set filter envelop parameters. |
|---|
| 380 |
* @param filterType filter type (0:Low-pass, 1:Band-pass, 2:High-pass) |
|---|
| 381 |
* @param cutoff filter cutoff (0-128) |
|---|
| 382 |
* @param resonance filter resonance (0-9) |
|---|
| 383 |
* @param far filter attack rate (0-63) |
|---|
| 384 |
* @param fdr1 filter decay rate 1 (0-63) |
|---|
| 385 |
* @param fdr2 filter decay rate 2 (0-63) |
|---|
| 386 |
* @param frr filter release rate (0-63) |
|---|
| 387 |
* @param fdc1 filter decay cutoff 1 (0-128) |
|---|
| 388 |
* @param fdc2 filter decay cutoff 2 (0-128) |
|---|
| 389 |
* @param fsc filter sustain cutoff (0-128) |
|---|
| 390 |
* @param frc filter release cutoff (0-128) |
|---|
| 391 |
* @return this SiONVoice instance |
|---|
| 392 |
*/ |
|---|
| 393 |
public function setFilterEnvelop(filterType:int=0, cutoff:int=128, resonance:int=0, far:int=0, fdr1:int=0, fdr2:int=0, frr:int=0, fdc1:int=128, fdc2:int=64, fsc:int=32, frc:int=128) : SiONVoice |
|---|
| 394 |
{ |
|---|
| 395 |
channelParam.filterType = filterType; |
|---|
| 396 |
channelParam.cutoff = cutoff; |
|---|
| 397 |
channelParam.resonance = resonance; |
|---|
| 398 |
channelParam.far = far; |
|---|
| 399 |
channelParam.fdr1 = fdr1; |
|---|
| 400 |
channelParam.fdr2 = fdr2; |
|---|
| 401 |
channelParam.frr = frr; |
|---|
| 402 |
channelParam.fdc1 = fdc1; |
|---|
| 403 |
channelParam.fdc2 = fdc2; |
|---|
| 404 |
channelParam.fsc = fsc; |
|---|
| 405 |
channelParam.frc = frc; |
|---|
| 406 |
return this; |
|---|
| 407 |
} |
|---|
| 408 |
|
|---|
| 409 |
|
|---|
| 410 |
/** [Pleas use setFilterEnvelop() instead of this function]. Set low pass filter envelop parameters. This function is for compatibility of old versions. |
|---|
| 411 |
* @param cutoff LP filter cutoff (0-128) |
|---|
| 412 |
* @param resonance LP filter resonance (0-9) |
|---|
| 413 |
* @param far LP filter attack rate (0-63) |
|---|
| 414 |
* @param fdr1 LP filter decay rate 1 (0-63) |
|---|
| 415 |
* @param fdr2 LP filter decay rate 2 (0-63) |
|---|
| 416 |
* @param frr LP filter release rate (0-63) |
|---|
| 417 |
* @param fdc1 LP filter decay cutoff 1 (0-128) |
|---|
| 418 |
* @param fdc2 LP filter decay cutoff 2 (0-128) |
|---|
| 419 |
* @param fsc LP filter sustain cutoff (0-128) |
|---|
| 420 |
* @param frc LP filter release cutoff (0-128) |
|---|
| 421 |
* @return this SiONVoice instance |
|---|
| 422 |
* @see setFilterEnvelop() |
|---|
| 423 |
*/ |
|---|
| 424 |
public function setLPFEnvelop(cutoff:int=128, resonance:int=0, far:int=0, fdr1:int=0, fdr2:int=0, frr:int=0, fdc1:int=128, fdc2:int=64, fsc:int=32, frc:int=128) : SiONVoice |
|---|
| 425 |
{ |
|---|
| 426 |
return setFilterEnvelop(0, cutoff, resonance, far, fdr1, fdr2, frr, fdc1, fdc2, fsc, frc); |
|---|
| 427 |
} |
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
/** Set amplitude modulation parameters (same as "ma" command of MML). |
|---|
| 431 |
* @param depth start modulation depth (same as 1st argument) |
|---|
| 432 |
* @param end_depth end modulation depth (same as 2nd argument) |
|---|
| 433 |
* @param delay changing delay (same as 3rd argument) |
|---|
| 434 |
* @param term changing term (same as 4th argument) |
|---|
| 435 |
* @return this instance |
|---|
| 436 |
*/ |
|---|
| 437 |
public function setAmplitudeModulation(depth:int=0, end_depth:int=0, delay:int=0, term:int=0) : SiONVoice |
|---|
| 438 |
{ |
|---|
| 439 |
channelParam.amd = amDepth = depth; |
|---|
| 440 |
amDepthEnd = end_depth; |
|---|
| 441 |
amDelay = delay; |
|---|
| 442 |
amTerm = term; |
|---|
| 443 |
return this; |
|---|
| 444 |
} |
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
/** Set amplitude modulation parameters (same as "mp" command of MML). |
|---|
| 448 |
* @param depth start modulation depth (same as 1st argument) |
|---|
| 449 |
* @param end_depth end modulation depth (same as 2nd argument) |
|---|
| 450 |
* @param delay changing delay (same as 3rd argument) |
|---|
| 451 |
* @param term changing term (same as 4th argument) |
|---|
| 452 |
* @return this instance |
|---|
| 453 |
*/ |
|---|
| 454 |
public function setPitchModulation(depth:int=0, end_depth:int=0, delay:int=0, term:int=0) : SiONVoice |
|---|
| 455 |
{ |
|---|
| 456 |
channelParam.pmd = pmDepth = depth; |
|---|
| 457 |
pmDepthEnd = end_depth; |
|---|
| 458 |
pmDelay = delay; |
|---|
| 459 |
pmTerm = term; |
|---|
| 460 |
return this; |
|---|
| 461 |
} |
|---|
| 462 |
} |
|---|
| 463 |
} |
|---|
| 464 |
|
|---|
| 465 |
|
|---|