Packageorg.si.sion
Classpublic class SiONDriver
InheritanceSiONDriver Inheritance flash.display.Sprite
Implements ISiOPMWaveInterface

SiONDriver class provides the driver of SiON's digital signal processor emulator. SiON's all basic operations are provided as SiONDriver's properties, methods and events. You can create only one SiONDriver instance in one SWF file, and the error appears when you try to create plural SiONDrivers.

View the examples

See also

SiONData
SiONVoice
org.si.sion.events.SiONEvent
org.si.sion.events.SiONTrackEvent
org.si.sion.module.SiOPMModule
org.si.sion.sequencer.SiMMLSequencer
org.si.sion.effector.SiEffectModule


Public Properties
 PropertyDefined By
  allowPluralDrivers : Boolean
[static] Allow plural drivers [CAUTION] This function is quite experimental and plural drivers require large memory area.
SiONDriver
  autoStop : Boolean
Auto stop when the sequence finished or fade-outed.
SiONDriver
  backgroundSound : Sound
[read-only] background sound
SiONDriver
  backgroundSoundFadeGapTime : Number
[read-only] background sound fading time in seconds
SiONDriver
  backgroundSoundFadeInTime : Number
[read-only] background sound fading in time in seconds
SiONDriver
  backgroundSoundFadeOutTime : Number
[read-only] background sound fading out time in seconds
SiONDriver
  backgroundSoundTrack : SiMMLTrack
[read-only] track for background sound
SiONDriver
  backgroundSoundVolume : Number
background sound volume
SiONDriver
  bitRate : Number
[read-only] bit rate, the value of 0 means the wave is represented as float value[-1 - +1].
SiONDriver
  bpm : Number
Beat par minute value of SiON's play.
SiONDriver
  bufferLength : int
[read-only] Streaming buffer length.
SiONDriver
  compileTime : int
[read-only] previous compiling time [ms].
SiONDriver
  data : SiONData
[read-only] Data to compile, render and process.
SiONDriver
  debugMode : Boolean
Debug mode, true; throw Error / false; throw ErrorEvent when error appears inside.
SiONDriver
  dispatchChangeBPMEventWhenPositionChanged : Boolean
dispatch CHANGE_BPM Event When position changed
SiONDriver
  effector : SiEffectModule
Effector module instance.
SiONDriver
  fader : Fader
[read-only] Fader to control fade-in/out.
SiONDriver
  isJobExecuting : Boolean
[read-only] Is job executing ?
SiONDriver
  isPaused : Boolean
[read-only] Is paused ?
SiONDriver
  isPlaying : Boolean
[read-only] Is streaming ?
SiONDriver
  jobProgress : Number
[read-only] progression of current compiling/rendering (0=start -> 1=finish).
SiONDriver
  jobQueueLength : int
[read-only] compiling/rendering jobs queue length.
SiONDriver
  jobQueueProgress : Number
[read-only] progression of all queued jobs (0=start -> 1=finish).
SiONDriver
  latency : Number
[read-only] streaming latency [ms].
SiONDriver
  maxTrackCount : int
The maximum limit of sound tracks.
SiONDriver
  midiModule : MIDIModule
[read-only] MIDI sound module
SiONDriver
  mmlString : String
[read-only] MML string (this property is only available during compiling).
SiONDriver
  module : SiOPMModule
SiOPM digital signal processor module instance.
SiONDriver
  mutex : SiONDriver
[static] [read-only] Instance of unique SiONDriver.
SiONDriver
  noteOnExceptionMode : int
Note on exception mode, this mode is refered when the noteOn() sound's track IDs are conflicted at the same moment.
SiONDriver
  pan : Number
Sound panning.
SiONDriver
  pauseWhileLoading : Boolean
pause while loading sound
SiONDriver
  position : Number
Get playing position[ms] of current data, or Set initial position of playing data.
SiONDriver
  processTime : int
[read-only] average processing time in 1sec [ms].
SiONDriver
  renderTime : int
[read-only] previous rendering time [ms].
SiONDriver
  sampleRate : Number
[read-only] Sample rate (44100 is only available in current version).
SiONDriver
  sequencer : SiMMLSequencer
Sequencer module instance.
SiONDriver
  sound : Sound
[read-only] flash.media.Sound instance to stream SiON's sound.
SiONDriver
  soundChannel : SoundChannel
[read-only] flash.media.SoundChannel instance of SiON's sound stream (this property is only available during streaming).
SiONDriver
  trackCount : int
[read-only] The number of sound tracks (this property is only available during streaming).
SiONDriver
  volume : Number
Sound volume.
SiONDriver
Public Methods
 MethodDefined By
  
SiONDriver(bufferLength:int = 2048, channelCount:int = 2, sampleRate:int = 44100, bitRate:int = 0)
Create driver to manage the synthesizer, sequencer and effector.
SiONDriver
  
Clear all of WaveTables, FM Voices, EnvelopTables, Sampler waves and PCM waves.
SiONDriver
  
Clear all listening sound list registerd by SiONDriver.listenLoadingStatus().
SiONDriver
  
compile(mml:String, data:SiONData = null):SiONData
Compile MML string to SiONData.
SiONDriver
  
compileQueue(mml:String, data:SiONData):int
Push queue job to compile MML string.
SiONDriver
  
dispatchUserDefinedTrackEvent(eventTriggerID:int, note:int):void
dispatch SiONTrackEvent.USER_DEFINED event with latency delay
SiONDriver
  
fadeIn(time:Number):void
Fade in all sound played by SiONDriver.
SiONDriver
  
fadeOut(time:Number):void
Fade out all sound played by SiONDriver.
SiONDriver
  
listenSoundLoadingStatus(sound:*, prior:int = -99999):Boolean
Listen loading status of flash.media.Sound instance.
SiONDriver
  
Create new user controlable track.
SiONDriver
  
noteOff(note:int, trackID:int = 0, delay:Number = 0, quant:Number = 0, stopImmediately:Boolean = false):Vector.<SiMMLTrack>
Note off.
SiONDriver
  
noteOn(note:int, voice:SiONVoice = null, length:Number = 0, delay:Number = 0, quant:Number = 0, trackID:int = 0, isDisposable:Boolean = true):SiMMLTrack
Note on.
SiONDriver
  
pause():void
Pause sound.
SiONDriver
  
play(data:* = null, resetEffector:Boolean = true):SoundChannel
Play SiONData or MML string.
SiONDriver
  
playSound(sampleNumber:int, length:Number = 0, delay:Number = 0, quant:Number = 0, trackID:int = 0, isDisposable:Boolean = true):SiMMLTrack
Play sound registered in sampler table (registered by setSamplerData()), same as noteOn(note, new SiONVoice(10), ...).
SiONDriver
  
render(data:*, renderBuffer:Vector.<Number> = null, renderBufferChannelCount:int = 2, resetEffector:Boolean = true):Vector.<Number>
Render wave data from MML string or SiONData.
SiONDriver
  
renderQueue(data:*, renderBuffer:Vector.<Number>, renderBufferChannelCount:int = 2, resetEffector:Boolean = false):int
Push queue job to render sound.
SiONDriver
  
reset():void
Reset signal processor.
SiONDriver
  
resume():void
Resume sound.
SiONDriver
  
sequenceOff(trackID:int, delay:Number = 0, quant:Number = 1, stopWithReset:Boolean = false):Vector.<SiMMLTrack>
Stop the sequences with synchronizing.
SiONDriver
  
sequenceOn(data:SiONData, voice:SiONVoice = null, length:Number = 0, delay:Number = 0, quant:Number = 1, trackID:int = 0, isDisposable:Boolean = true):Vector.<SiMMLTrack>
Play sequences with synchronizing.
SiONDriver
  
setBackgroundSound(sound:Sound, mixLevel:Number = 0.5, loopPoint:Number = -1):void
Play Sound as a background.
SiONDriver
  
setBackgroundSoundFadeTime(fadeInTime:Number, fadeOutTime:Number, gapTime:Number):void
set fading time of background sound
SiONDriver
  
setBeatCallbackInterval(length16th:Number = 1):void
Set callback interval of SiONTrackEvent.BEAT.
SiONDriver
  
setEnvelopTable(index:int, table:Vector.<int>, loopPoint:int = -1):void
Set envelop table data refered by @@,na,np,nt,nf,_@@,_na,_np,_nt and _nf.
SiONDriver
  
setPCMData(index:int, data:Vector.<Number>, samplingOctave:int = 5, keyRangeFrom:int = 0, keyRangeTo:int = 127, isSourceDataStereo:Boolean = false):SiOPMWavePCMData
[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setPCMWave instead of this function.
SiONDriver
  
setPCMSound(index:int, sound:Sound, samplingOctave:int = 5, keyRangeFrom:int = 0, keyRangeTo:int = 127):SiOPMWavePCMData
[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setPCMWave instead of this function.
SiONDriver
  
setPCMVoice(index:int, voice:SiONVoice):void
Set pcm voice
SiONDriver
  
setPCMWave(index:int, data:*, samplingNote:Number = 69, keyRangeFrom:int = 0, keyRangeTo:int = 127, srcChannelCount:int = 2, channelCount:int = 0):SiOPMWavePCMData
Set PCM wave data rederd by %7.
SiONDriver
  
setSamplerData(index:int, data:Vector.<Number>, ignoreNoteOff:Boolean = false, channelCount:int = 1):SiOPMWaveSamplerData
[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setSamplerWave instead of this function.
SiONDriver
  
setSamplerSound(index:int, sound:Sound, ignoreNoteOff:Boolean = false, channelCount:int = 2):SiOPMWaveSamplerData
[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setSamplerWave instead of this function.
SiONDriver
  
Set sampler table
SiONDriver
  
setSamplerWave(index:int, data:*, ignoreNoteOff:Boolean = false, pan:int = 0, srcChannelCount:int = 2, channelCount:int = 0):SiOPMWaveSamplerData
Set sampler wave data refered by %10.
SiONDriver
  
setSoundReferenceTable(soundReferenceTable:* = null):void
Set hash table of Sound instance refered from #SAMPLER and #PCMWAVE commands.
SiONDriver
  
setTimerInterruption(length16th:Number = 1, callback:Function = null):void
Set timer interruption.
SiONDriver
  
setVoice(index:int, voice:SiONVoice):void
Set wave table data refered by %6.
SiONDriver
  
setWaveTable(index:int, table:Vector.<Number>):SiOPMWaveTable
Set wave table data refered by %4.
SiONDriver
  
startQueue(interval:int = 500):int
Execute all elements queued by compileQueue() and renderQueue().
SiONDriver
  
stop():void
Stop sound.
SiONDriver
  
Stop background sound.
SiONDriver
Events
 Event Summary Defined By
   Dispatch on beat while streaming.SiONDriver
   Dispatch when the bpm changes.SiONDriver
   Dispatch when fade in is finished.SiONDriver
   Dispatch when fade out is finished.SiONDriver
   Dispatch while fading.SiONDriver
   Dispatch when finish executing all sequences.SiONDriver
   Dispatch when the sound ends.SiONDriver
   Dispatch when the note off appears in the sequence with "%t" command.SiONDriver
   Dispatch when the sound starts.SiONDriver
   Dispatch when the note on appears in the sequence with "%t" command.SiONDriver
   Dispatch when cancel all queued jobs.SiONDriver
   Dispatch when finish all queued jobs.SiONDriver
   Dispatch when executing queued jobs.SiONDriver
   Dispatch while streaming.SiONDriver
   Dispatch when start streaming.SiONDriver
   Dispatch when stop streaming.SiONDriver
Public Constants
 ConstantDefined By
  NEM_IGNORE : int = 0
[static] note-on exception mode "ignore", SiON does not consider about track ID's conflict in noteOn() method (default).
SiONDriver
  NEM_OVERWRITE : int = 2
[static] note-on exception mode "overwrite", Overwrite current note when the track IDs are conflicted.
SiONDriver
  NEM_REJECT : int = 1
[static] note-on exception mode "reject", Reject new note when the track IDs are conflicted.
SiONDriver
  NEM_SHIFT : int = 3
[static] note-on exception mode "shift", Shift the sound timing to next quantize when the track IDs are conflicted.
SiONDriver
  VERSION : String = 0.6.6.0
[static] version number
SiONDriver
Property Detail
allowPluralDriversproperty
allowPluralDrivers:Boolean

Allow plural drivers [CAUTION] This function is quite experimental and plural drivers require large memory area.


Implementation
    public static function get allowPluralDrivers():Boolean
    public static function set allowPluralDrivers(value:Boolean):void
autoStopproperty 
autoStop:Boolean

Auto stop when the sequence finished or fade-outed.

The default value is false.


Implementation
    public function get autoStop():Boolean
    public function set autoStop(value:Boolean):void
backgroundSoundproperty 
backgroundSound:Sound  [read-only]

background sound


Implementation
    public function get backgroundSound():Sound
backgroundSoundFadeGapTimeproperty 
backgroundSoundFadeGapTime:Number  [read-only]

background sound fading time in seconds


Implementation
    public function get backgroundSoundFadeGapTime():Number
backgroundSoundFadeInTimeproperty 
backgroundSoundFadeInTime:Number  [read-only]

background sound fading in time in seconds


Implementation
    public function get backgroundSoundFadeInTime():Number
backgroundSoundFadeOutTimeproperty 
backgroundSoundFadeOutTime:Number  [read-only]

background sound fading out time in seconds


Implementation
    public function get backgroundSoundFadeOutTime():Number
backgroundSoundTrackproperty 
backgroundSoundTrack:SiMMLTrack  [read-only]

track for background sound


Implementation
    public function get backgroundSoundTrack():SiMMLTrack
backgroundSoundVolumeproperty 
backgroundSoundVolume:Number

background sound volume

The default value is 0.5.


Implementation
    public function get backgroundSoundVolume():Number
    public function set backgroundSoundVolume(value:Number):void
bitRateproperty 
bitRate:Number  [read-only]

bit rate, the value of 0 means the wave is represented as float value[-1 - +1].


Implementation
    public function get bitRate():Number
bpmproperty 
bpm:Number

Beat par minute value of SiON's play.

The default value is 120.


Implementation
    public function get bpm():Number
    public function set bpm(value:Number):void
bufferLengthproperty 
bufferLength:int  [read-only]

Streaming buffer length.


Implementation
    public function get bufferLength():int
compileTimeproperty 
compileTime:int  [read-only]

previous compiling time [ms].


Implementation
    public function get compileTime():int
dataproperty 
data:SiONData  [read-only]

Data to compile, render and process.


Implementation
    public function get data():SiONData
debugModeproperty 
debugMode:Boolean

Debug mode, true; throw Error / false; throw ErrorEvent when error appears inside.

The default value is false.


Implementation
    public function get debugMode():Boolean
    public function set debugMode(value:Boolean):void
dispatchChangeBPMEventWhenPositionChangedproperty 
dispatchChangeBPMEventWhenPositionChanged:Boolean

dispatch CHANGE_BPM Event When position changed

The default value is true.


Implementation
    public function get dispatchChangeBPMEventWhenPositionChanged():Boolean
    public function set dispatchChangeBPMEventWhenPositionChanged(value:Boolean):void
effectorproperty 
public var effector:SiEffectModule

Effector module instance.

faderproperty 
fader:Fader  [read-only]

Fader to control fade-in/out. You can check activity by "fader.isActive".


Implementation
    public function get fader():Fader
isJobExecutingproperty 
isJobExecuting:Boolean  [read-only]

Is job executing ?


Implementation
    public function get isJobExecuting():Boolean
isPausedproperty 
isPaused:Boolean  [read-only]

Is paused ?


Implementation
    public function get isPaused():Boolean
isPlayingproperty 
isPlaying:Boolean  [read-only]

Is streaming ?


Implementation
    public function get isPlaying():Boolean
jobProgressproperty 
jobProgress:Number  [read-only]

progression of current compiling/rendering (0=start -> 1=finish).


Implementation
    public function get jobProgress():Number
jobQueueLengthproperty 
jobQueueLength:int  [read-only]

compiling/rendering jobs queue length.


Implementation
    public function get jobQueueLength():int
jobQueueProgressproperty 
jobQueueProgress:Number  [read-only]

progression of all queued jobs (0=start -> 1=finish).


Implementation
    public function get jobQueueProgress():Number
latencyproperty 
latency:Number  [read-only]

streaming latency [ms].


Implementation
    public function get latency():Number
maxTrackCountproperty 
maxTrackCount:int

The maximum limit of sound tracks.

The default value is 128.


Implementation
    public function get maxTrackCount():int
    public function set maxTrackCount(value:int):void
midiModuleproperty 
midiModule:MIDIModule  [read-only]

MIDI sound module


Implementation
    public function get midiModule():MIDIModule
mmlStringproperty 
mmlString:String  [read-only]

MML string (this property is only available during compiling).


Implementation
    public function get mmlString():String
moduleproperty 
public var module:SiOPMModule

SiOPM digital signal processor module instance.

mutexproperty 
mutex:SiONDriver  [read-only]

Instance of unique SiONDriver. null when new SiONDriver is not created yet.


Implementation
    public static function get mutex():SiONDriver
noteOnExceptionModeproperty 
noteOnExceptionMode:int

Note on exception mode, this mode is refered when the noteOn() sound's track IDs are conflicted at the same moment. This value have to be SiONDriver.NEM_

The default value is NEM_IGNORE..


Implementation
    public function get noteOnExceptionMode():int
    public function set noteOnExceptionMode(value:int):void

See also

panproperty 
pan:Number

Sound panning.


Implementation
    public function get pan():Number
    public function set pan(value:Number):void
pauseWhileLoadingproperty 
pauseWhileLoading:Boolean

pause while loading sound

The default value is true.


Implementation
    public function get pauseWhileLoading():Boolean
    public function set pauseWhileLoading(value:Boolean):void
positionproperty 
position:Number

Get playing position[ms] of current data, or Set initial position of playing data.

The default value is 0.


Implementation
    public function get position():Number
    public function set position(value:Number):void
processTimeproperty 
processTime:int  [read-only]

average processing time in 1sec [ms].


Implementation
    public function get processTime():int
renderTimeproperty 
renderTime:int  [read-only]

previous rendering time [ms].


Implementation
    public function get renderTime():int
sampleRateproperty 
sampleRate:Number  [read-only]

Sample rate (44100 is only available in current version).


Implementation
    public function get sampleRate():Number
sequencerproperty 
public var sequencer:SiMMLSequencer

Sequencer module instance.

soundproperty 
sound:Sound  [read-only]

flash.media.Sound instance to stream SiON's sound.


Implementation
    public function get sound():Sound
soundChannelproperty 
soundChannel:SoundChannel  [read-only]

flash.media.SoundChannel instance of SiON's sound stream (this property is only available during streaming).


Implementation
    public function get soundChannel():SoundChannel
trackCountproperty 
trackCount:int  [read-only]

The number of sound tracks (this property is only available during streaming).


Implementation
    public function get trackCount():int
volumeproperty 
volume:Number

Sound volume.


Implementation
    public function get volume():Number
    public function set volume(value:Number):void
Constructor Detail
SiONDriver()Constructor
public function SiONDriver(bufferLength:int = 2048, channelCount:int = 2, sampleRate:int = 44100, bitRate:int = 0)

Create driver to manage the synthesizer, sequencer and effector. Only one SiONDriver instance can be created.

Parameters
bufferLength:int (default = 2048) — Buffer size of sound stream. The value of 8192, 4096 or 2048 is available.
 
channelCount:int (default = 2) — Channel count. 1(monoral) or 2(stereo) is available.
 
sampleRate:int (default = 44100) — Sampling ratio of wave. 44100 is only available in current version.
 
bitRate:int (default = 0) — Bit ratio of wave. 0 means float value [-1 to 1].
Method Detail
clearAllUserTables()method
public function clearAllUserTables():void

Clear all of WaveTables, FM Voices, EnvelopTables, Sampler waves and PCM waves.

See also

clearSoundLoadingList()method 
public function clearSoundLoadingList():void

Clear all listening sound list registerd by SiONDriver.listenLoadingStatus().

compile()method 
public function compile(mml:String, data:SiONData = null):SiONData

Compile MML string to SiONData.

Parameters

mml:String — MML string to compile.
 
data:SiONData (default = null) — SiONData to compile. The SiONDriver creates new SiONData instance when this argument is null.

Returns
SiONData — Compiled data.
compileQueue()method 
public function compileQueue(mml:String, data:SiONData):int

Push queue job to compile MML string. Start compiling after calling startQueue.

Parameters

mml:String — MML string to compile.
 
data:SiONData — SiONData to compile.

Returns
int — Queue length.

See also

dispatchUserDefinedTrackEvent()method 
public function dispatchUserDefinedTrackEvent(eventTriggerID:int, note:int):void

dispatch SiONTrackEvent.USER_DEFINED event with latency delay

Parameters

eventTriggerID:int — SiONTrackEvent.eventTriggerID
 
note:int — SiONTrackEvent.note

fadeIn()method 
public function fadeIn(time:Number):void

Fade in all sound played by SiONDriver. You can set this method before calling play().

Parameters

time:Number — Fading time [second].

fadeOut()method 
public function fadeOut(time:Number):void

Fade out all sound played by SiONDriver.

Parameters

time:Number — Fading time [second].

forceDispatchStreamEvent()method 
_sion_internal function forceDispatchStreamEvent(dispatch:Boolean = true):void

Force dispatch stream event. The SiONEvent.STREAM is dispatched only when the event listener is set BEFORE calling play(). You can let SiONDriver to dispatch SiONEvent.STREAM event by this function.

Parameters

dispatch:Boolean (default = true) — Set true to force dispatching. Or set false to not dispatching if there are no listeners.

listenSoundLoadingStatus()method 
public function listenSoundLoadingStatus(sound:*, prior:int = -99999):Boolean

Listen loading status of flash.media.Sound instance. When SiONDriver.pauseWhileLoading is true, SiONDriver starts streaming after all Sound instances passed by this function are loaded.

Parameters

sound:* — Sound or SoundLoader instance to listern
 
prior:int (default = -99999) — listening priority

Returns
Boolean — return false when the sound is loaded already.

See also

newUserControlableTrack()method 
public function newUserControlableTrack(trackID:int = 0):SiMMLTrack

Create new user controlable track. This function only is available after play().

Parameters

trackID:int (default = 0)

Returns
SiMMLTrack — new user controlable track. This track is NOT disposable.
noteOff()method 
public function noteOff(note:int, trackID:int = 0, delay:Number = 0, quant:Number = 0, stopImmediately:Boolean = false):Vector.<SiMMLTrack>

Note off. This function only is available after play(). The NOTE_OFF_STREAM event is dispatched inside.

Parameters

note:int — note number [-1-127]. The value of -1 ignores note number.
 
trackID:int (default = 0) — track id to note off.
 
delay:Number (default = 0) — note off delay units in 16th beat.
 
quant:Number (default = 0) — quantize in 16th beat. 0 sets no quantization. 4 sets quantization by 4th beat.
 
stopImmediately:Boolean (default = false) — stop sound with reseting channel's process

Returns
Vector.<SiMMLTrack> — All SiMMLTracks switched key off.
noteOn()method 
public function noteOn(note:int, voice:SiONVoice = null, length:Number = 0, delay:Number = 0, quant:Number = 0, trackID:int = 0, isDisposable:Boolean = true):SiMMLTrack

Note on. This function only is available after play(). The NOTE_ON_STREAM event is dispatched inside.

Parameters

note:int — note number [0-127].
 
voice:SiONVoice (default = null) — SiONVoice to play note. You can specify null, but it sets only a default square wave.
 
length:Number (default = 0) — note length in 16th beat. 0 sets no note off, this means you should call noteOff().
 
delay:Number (default = 0) — note on delay units in 16th beat.
 
quant:Number (default = 0) — quantize in 16th beat. 0 sets no quantization. 4 sets quantization by 4th beat.
 
trackID:int (default = 0) — new tracks id (0-65535).
 
isDisposable:Boolean (default = true) — use disposable track. The disposable track will free automatically when finished rendering. This means you should not keep a dieposable track in your code perpetually. If you want to keep track, set this argument false. And after using, call SiMMLTrack::setDisposal() to disposed by system. [REMARKS] Not disposable track is kept in the system perpetually while streaming, this may causes critical performance loss.

Returns
SiMMLTrack — SiMMLTrack to play the note.
pause()method 
public function pause():void

Pause sound. You can resume it by resume() or play().

See also

resume()
play()
play()method 
public function play(data:* = null, resetEffector:Boolean = true):SoundChannel

Play SiONData or MML string.

Parameters

data:* (default = null) — SiONData, mml String, Sound object, mp3 file URLRequest or SMFData object to play. You can pass null when resume after pause or streaming without any data.
 
resetEffector:Boolean (default = true) — reset all effectors before play data.

Returns
SoundChannel — SoundChannel instance to play data. This instance is same as soundChannel property.

See also

playSound()method 
public function playSound(sampleNumber:int, length:Number = 0, delay:Number = 0, quant:Number = 0, trackID:int = 0, isDisposable:Boolean = true):SiMMLTrack

Play sound registered in sampler table (registered by setSamplerData()), same as noteOn(note, new SiONVoice(10), ...).

Parameters

sampleNumber:int — sample number [0-127].
 
length:Number (default = 0) — note length in 16th beat. 0 sets no note off, this means you should call noteOff().
 
delay:Number (default = 0) — note on delay units in 16th beat.
 
quant:Number (default = 0) — quantize in 16th beat. 0 sets no quantization. 4 sets quantization by 4th beat.
 
trackID:int (default = 0) — new tracks id (0-65535).
 
isDisposable:Boolean (default = true) — use disposable track. The disposable track will free automatically when finished rendering. This means you should not keep a dieposable track in your code perpetually. If you want to keep track, set this argument false. And after using, SiMMLTrack::setDisposal() to disposed by system. [REMARKS] Not disposable track is kept perpetually in the system while streaming, this may causes critical performance loss.

Returns
SiMMLTrack — SiMMLTrack to play the note.
render()method 
public function render(data:*, renderBuffer:Vector.<Number> = null, renderBufferChannelCount:int = 2, resetEffector:Boolean = true):Vector.<Number>

Render wave data from MML string or SiONData. This method may take long time, please consider the using renderQueue() instead.

Parameters

data:* — SiONData or mml String to play.
 
renderBuffer:Vector.<Number> (default = null) — Rendering target. null to create new buffer. The length of this argument limits the rendering length (except for 0).
 
renderBufferChannelCount:int (default = 2) — Channel count of renderBuffer. 2 for stereo and 1 for monoral.
 
resetEffector:Boolean (default = true) — reset all effectors before play data.

Returns
Vector.<Number> — rendered wave data as Vector.<Number>.
renderQueue()method 
public function renderQueue(data:*, renderBuffer:Vector.<Number>, renderBufferChannelCount:int = 2, resetEffector:Boolean = false):int

Push queue job to render sound. Start rendering after calling startQueue.

Parameters

data:* — SiONData or mml String to render.
 
renderBuffer:Vector.<Number> — Rendering target. The length of renderBuffer limits rendering length except for 0.
 
renderBufferChannelCount:int (default = 2) — Channel count of renderBuffer. 2 for stereo and 1 for monoral.
 
resetEffector:Boolean (default = false)

Returns
int — Queue length.

See also

reset()method 
public function reset():void

Reset signal processor. The effector and sequencer will not be reset. If you want to reset all, call SiONDriver.stop() instead.

resume()method 
public function resume():void

Resume sound. same as play() after pause().

See also

pause()
sequenceOff()method 
public function sequenceOff(trackID:int, delay:Number = 0, quant:Number = 1, stopWithReset:Boolean = false):Vector.<SiMMLTrack>

Stop the sequences with synchronizing. This function only is available after play().

Parameters

trackID:int — tracks id to stop.
 
delay:Number (default = 0) — sequence off delay units in 16th beat.
 
quant:Number (default = 1) — quantize in 16th beat. 0 sets no quantization. 4 sets quantization by 4th beat.
 
stopWithReset:Boolean (default = false) — stop sound with reseting channel's process

Returns
Vector.<SiMMLTrack> — list of SiMMLTracks stopped to play sequence.
sequenceOn()method 
public function sequenceOn(data:SiONData, voice:SiONVoice = null, length:Number = 0, delay:Number = 0, quant:Number = 1, trackID:int = 0, isDisposable:Boolean = true):Vector.<SiMMLTrack>

Play sequences with synchronizing. This function only is available after play().

Parameters

data:SiONData — The SiONData including sequences. This data is used only for sequences. The system ignores wave, envelop and voice data.
 
voice:SiONVoice (default = null) — SiONVoice to play sequence. The voice setting in the sequence has priority.
 
length:Number (default = 0) — note length in 16th beat. 0 sets no note off, this means you should call noteOff().
 
delay:Number (default = 0) — note on delay units in 16th beat.
 
quant:Number (default = 1) — quantize in 16th beat. 0 sets no quantization. 4 sets quantization by 4th beat.
 
trackID:int (default = 0) — new tracks id (0-65535).
 
isDisposable:Boolean (default = true) — use disposable track. The disposable track will free automatically when finished rendering. This means you should not keep a dieposable track in your code perpetually. If you want to keep track, set this argument false. And after using, call SiMMLTrack::setDisposal() to disposed by system. [REMARKS] Not disposable track is kept in the system perpetually while streaming, this may causes critical performance loss.

Returns
Vector.<SiMMLTrack> — list of SiMMLTracks to play sequence.
setBackgroundSound()method 
public function setBackgroundSound(sound:Sound, mixLevel:Number = 0.5, loopPoint:Number = -1):void

Play Sound as a background.

Parameters

sound:Sound — Sound instance to play background.
 
mixLevel:Number (default = 0.5) — Mixing level (0-1), this value same as backgroundSoundVolume.
 
loopPoint:Number (default = -1) — loop point in second. -1 sets no loop

See also

backgroundSound
setBackgroundSoundFadeTime()method 
public function setBackgroundSoundFadeTime(fadeInTime:Number, fadeOutTime:Number, gapTime:Number):void

set fading time of background sound

Parameters

fadeInTime:Number — fade in time [sec]. positive value only
 
fadeOutTime:Number — fade out time [sec]. positive value only
 
gapTime:Number — gap between 2 sound [sec]. You can specify negative values to play with cross fading.

setBeatCallbackInterval()method 
public function setBeatCallbackInterval(length16th:Number = 1):void

Set callback interval of SiONTrackEvent.BEAT.

Parameters

length16th:Number (default = 1) — Interval in 16th beat. 2^n is only available(1,2,4,8,16....).

setEnvelopTable()method 
public function setEnvelopTable(index:int, table:Vector.<int>, loopPoint:int = -1):void

Set envelop table data refered by @@,na,np,nt,nf,_@@,_na,_np,_nt and _nf.

Parameters

index:int — envelop table number.
 
table:Vector.<int> — envelop table vector.
 
loopPoint:int (default = -1) — returning point index of looping. -1 sets no loop.

setPCMData()method 
public function setPCMData(index:int, data:Vector.<Number>, samplingOctave:int = 5, keyRangeFrom:int = 0, keyRangeTo:int = 127, isSourceDataStereo:Boolean = false):SiOPMWavePCMData

[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setPCMWave instead of this function.

Parameters

index:int
 
data:Vector.<Number>
 
samplingOctave:int (default = 5)
 
keyRangeFrom:int (default = 0)
 
keyRangeTo:int (default = 127)
 
isSourceDataStereo:Boolean (default = false)

Returns
SiOPMWavePCMData

See also

setPCMSound()method 
public function setPCMSound(index:int, sound:Sound, samplingOctave:int = 5, keyRangeFrom:int = 0, keyRangeTo:int = 127):SiOPMWavePCMData

[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setPCMWave instead of this function.

Parameters

index:int
 
sound:Sound
 
samplingOctave:int (default = 5)
 
keyRangeFrom:int (default = 0)
 
keyRangeTo:int (default = 127)

Returns
SiOPMWavePCMData

See also

setPCMVoice()method 
public function setPCMVoice(index:int, voice:SiONVoice):void

Set pcm voice

Parameters

index:int — PCM data number.
 
voice:SiONVoice — pcm voice to set, ussualy from SiONSoundFont

See also

SiONSoundFont
setPCMWave()method 
public function setPCMWave(index:int, data:*, samplingNote:Number = 69, keyRangeFrom:int = 0, keyRangeTo:int = 127, srcChannelCount:int = 2, channelCount:int = 0):SiOPMWavePCMData

Set PCM wave data rederd by %7.

Parameters

index:int — PCM data number.
 
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].
 
samplingNote:Number (default = 69) — Sampling wave's original note number, this allows decimal number
 
keyRangeFrom:int (default = 0) — Assigning key range starts from (not implemented in current version)
 
keyRangeTo:int (default = 127) — Assigning key range ends at (not implemented in current version)
 
srcChannelCount:int (default = 2) — channel count of source data, 1 for monoral, 2 for stereo.
 
channelCount:int (default = 0) — channel count of this data, 1 for monoral, 2 for stereo, 0 sets same with srcChannelCount.

Returns
SiOPMWavePCMData

See also

setSamplerData()method 
public function setSamplerData(index:int, data:Vector.<Number>, ignoreNoteOff:Boolean = false, channelCount:int = 1):SiOPMWaveSamplerData

[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setSamplerWave instead of this function.

Parameters

index:int
 
data:Vector.<Number>
 
ignoreNoteOff:Boolean (default = false)
 
channelCount:int (default = 1)

Returns
SiOPMWaveSamplerData

See also

setSamplerSound()method 
public function setSamplerSound(index:int, sound:Sound, ignoreNoteOff:Boolean = false, channelCount:int = 2):SiOPMWaveSamplerData

[NOT RECOMMENDED] This function is for a compatibility with previous versions, please use setSamplerWave instead of this function.

Parameters

index:int
 
sound:Sound
 
ignoreNoteOff:Boolean (default = false)
 
channelCount:int (default = 2)

Returns
SiOPMWaveSamplerData

See also

setSamplerTable()method 
public function setSamplerTable(bank:int, table:SiOPMWaveSamplerTable):void

Set sampler table

Parameters

bank:int — bank number
 
table:SiOPMWaveSamplerTable — sampler table class, ussualy from SiONSoundFont

See also

SiONSoundFont
setSamplerWave()method 
public function setSamplerWave(index:int, data:*, ignoreNoteOff:Boolean = false, pan:int = 0, srcChannelCount:int = 2, channelCount:int = 0):SiOPMWaveSamplerData

Set sampler wave data refered by %10.

Parameters

index:int — note number. 0-127 for bank0, 128-255 for bank1.
 
data:* — wave data, Sound, Vector.<Number> or Vector.<int> is available. The Sound is extracted when the length is shorter than SiOPMWaveSamplerData.extractThreshold[msec].
 
ignoreNoteOff:Boolean (default = false) — True to set ignoring note off.
 
pan:int (default = 0) — pan of this sample [-64 - 64].
 
srcChannelCount:int (default = 2) — channel count of source data, 1 for monoral, 2 for stereo.
 
channelCount:int (default = 0) — channel count of this data, 1 for monoral, 2 for stereo, 0 sets same with srcChannelCount.

Returns
SiOPMWaveSamplerData — created data instance

See also

setSoundReferenceTable()method 
public function setSoundReferenceTable(soundReferenceTable:* = null):void

Set hash table of Sound instance refered from #SAMPLER and #PCMWAVE commands. You have to set this table BEFORE compile mml.

Parameters

soundReferenceTable:* (default = null)

setTimerInterruption()method 
public function setTimerInterruption(length16th:Number = 1, callback:Function = null):void

Set timer interruption.

Parameters

length16th:Number (default = 1) — Interupting interval in 16th beat.
 
callback:Function (default = null) — Callback function. the Type is function():void.

setVoice()method 
public function setVoice(index:int, voice:SiONVoice):void

Set wave table data refered by %6.

Parameters

index:int — wave table number.
 
voice:SiONVoice — voice to register.

setWaveTable()method 
public function setWaveTable(index:int, table:Vector.<Number>):SiOPMWaveTable

Set wave table data refered by %4.

Parameters

index:int — wave table number.
 
table:Vector.<Number> — wave shape vector ranges in -1 to 1.

Returns
SiOPMWaveTable
startQueue()method 
public function startQueue(interval:int = 500):int

Execute all elements queued by compileQueue() and renderQueue(). After calling this function, the SiONEvent.QUEUE_PROGRESS, SiONEvent.QUEUE_COMPLETE and ErrorEvent.ERROR events will be dispatched. The SiONEvent.QUEUE_PROGRESS is dispatched when it's executing queued job. The SiONEvent.QUEUE_COMPLETE is dispatched when finish all queued jobs. The ErrorEvent.ERROR is dispatched when some error appears during the compile.

Parameters

interval:int (default = 500) — Interupting interval

Returns
int — Queue length.

See also

stop()method 
public function stop():void

Stop sound.

stopBackgroundSound()method 
public function stopBackgroundSound():void

Stop background sound.

Event Detail
beat Event
Event Object Type: org.si.sion.events.SiONTrackEvent
SiONTrackEvent.type property = org.si.sion.events.SiONTrackEvent.BEAT

Dispatch on beat while streaming. This event is called in each beat timing on frame. When you want to listen this event, you have to set addEventListener() before SiONDriver.play().

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance playing now.
dataSiONData instance playing now. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull.
tracknull
eventTriggerIDCounter in 16th beat.
note0
bufferIndexBuffering index
changeBPM Event  
Event Object Type: org.si.sion.events.SiONTrackEvent
SiONTrackEvent.type property = org.si.sion.events.SiONTrackEvent.CHANGE_BPM

Dispatch when the bpm changes.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance.
dataSiONData instance. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
tracknull
eventTriggerIDnull
note0
bufferIndexBuffering index
fadeInComplete Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.FADE_IN_COMPLETE

Dispatch when fade in is finished. This event is dispatched after SiONEvent.STREAM.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance to stop streaming.
dataSiONData instance playing now. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBufferByteArray instance of this stream. The length is twice of SiONDriver.bufferLength in the unit of float. You can get the renderd wave data by this propertiy.
fadeOutComplete Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.FADE_OUT_COMPLETE

Dispatch when fade out is finished. This event is dispatched after SiONEvent.STREAM.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance to stop streaming.
dataSiONData instance playing now. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBufferByteArray instance of this stream. The length is twice of SiONDriver.bufferLength in the unit of float. You can get the renderd wave data by this propertiy.
fadeProgress Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.FADE_PROGRESS

Dispatch while fading. This event is dispatched after SiONEvent.STREAM.

The properties of the event object have the following values:

PropertyValue
cancelabletrue to cancel fading.
driverSiONDriver instance to stop streaming.
dataSiONData instance playing now. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
finishSequence Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.FINISH_SEQUENCE

Dispatch when finish executing all sequences.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance playing now.
dataSiONData instance playing now.
streamBuffernull
noteOffFrame Event  
Event Object Type: org.si.sion.events.SiONTrackEvent
SiONTrackEvent.type property = org.si.sion.events.SiONTrackEvent.NOTE_OFF_FRAME

Dispatch when the sound ends.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance.
dataSiONData instance. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
trackSiMMLTrack instance executing sequence.
eventTriggerIDTrigger ID specifyed in "%t" commands 1st argument.
noteNote number.
bufferIndexBuffering index
noteOffStream Event  
Event Object Type: org.si.sion.events.SiONTrackEvent
SiONTrackEvent.type property = org.si.sion.events.SiONTrackEvent.NOTE_OFF_STREAM

Dispatch when the note off appears in the sequence with "%t" command.

The properties of the event object have the following values:

PropertyValue
cancelabletrue; mute the note
driverSiONDriver instance.
dataSiONData instance. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
trackSiMMLTrack instance executing sequence.
eventTriggerIDTrigger ID specifyed in "%t" commands 1st argument.
noteNote number.
bufferIndexBuffering index
noteOnFrame Event  
Event Object Type: org.si.sion.events.SiONTrackEvent
SiONTrackEvent.type property = org.si.sion.events.SiONTrackEvent.NOTE_ON_FRAME

Dispatch when the sound starts.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance.
dataSiONData instance. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
trackSiMMLTrack instance executing sequence.
eventTriggerIDTrigger ID specifyed in "%t" commands 1st argument.
noteNote number.
bufferIndexBuffering index
noteOnStream Event  
Event Object Type: org.si.sion.events.SiONTrackEvent
SiONTrackEvent.type property = org.si.sion.events.SiONTrackEvent.NOTE_ON_STREAM

Dispatch when the note on appears in the sequence with "%t" command.

The properties of the event object have the following values:

PropertyValue
cancelabletrue; mute the note
driverSiONDriver instance.
dataSiONData instance. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
trackSiMMLTrack instance executing sequence.
eventTriggerIDTrigger ID specifyed in "%t" commands 1st argument.
noteNote number.
bufferIndexBuffering index
queueCancel Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.QUEUE_CANCEL

Dispatch when cancel all queued jobs.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance compiled/rendered.
driver.mmlStringnull
datanull
streamBuffernull
queueComplete Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.QUEUE_COMPLETE

Dispatch when finish all queued jobs.

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance compiled/rendered.
driver.mmlStringMML string compiled. null when the job is "render".
dataSiONData instance compiled/rendered.
streamBuffernull
queueProgress Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.QUEUE_PROGRESS

Dispatch when executing queued jobs.

The properties of the event object have the following values:

PropertyValue
cancelabletrue; Cancel compiling/rendering immediately.
driverSiONDriver instance compiling/rendering compiling now.
driver.mmlStringMML string compiling now. null when the job is "render".
dataSiONData instance compiling/rendering now. This data is not available when compiling.
streamBuffernull
stream Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.STREAM

Dispatch while streaming. This event is called inside SiONDriver.play() after SiONEvent.STREAM_START, and each streaming timing.

The properties of the event object have the following values:

PropertyValue
cancelabletrue; Stop streaming. SiONDriver.stop() s called inside
driverSiONDriver instance playing now.
dataSiONData instance playing now. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBufferByteArray instance of this stream. The length is twice of SiONDriver.bufferLength in the unit of float. You can get the renderd wave data by this propertiy.
streamStart Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.STREAM_START

Dispatch when start streaming. This event is called inside SiONDriver.play() before SiONEvent.STREAM.

The properties of the event object have the following values:

PropertyValue
cancelabletrue; Cancel to start streaming.
driverSiONDriver instance to start streaming.
dataSiONData instance to start streaming. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
streamStop Event  
Event Object Type: org.si.sion.events.SiONEvent
SiONEvent.type property = org.si.sion.events.SiONEvent.STREAM_STOP

Dispatch when stop streaming. This event is dispatched inside SiONDriver.stop().

The properties of the event object have the following values:

PropertyValue
cancelablefalse
driverSiONDriver instance to stop streaming.
dataSiONData instance to stop streaming. This property is null if you call SiONDriver.play() with null of the 1st argument.
streamBuffernull
Constant Detail
NEM_IGNOREConstant
public static const NEM_IGNORE:int = 0

note-on exception mode "ignore", SiON does not consider about track ID's conflict in noteOn() method (default).

NEM_OVERWRITEConstant 
public static const NEM_OVERWRITE:int = 2

note-on exception mode "overwrite", Overwrite current note when the track IDs are conflicted.

NEM_REJECTConstant 
public static const NEM_REJECT:int = 1

note-on exception mode "reject", Reject new note when the track IDs are conflicted.

NEM_SHIFTConstant 
public static const NEM_SHIFT:int = 3

note-on exception mode "shift", Shift the sound timing to next quantize when the track IDs are conflicted.

VERSIONConstant 
public static const VERSION:String = 0.6.6.0

version number

Examples
1) The simplest sample. Create new instance and call play with MML string.
// create driver instance.
var driver:SiONDriver = new SiONDriver();
// call play() with mml string whenever you want to play sound.
driver.play("t100 l8 [ ccggaag4 ffeeddc4 | [ggffeed4]2 ]2");