Packageorg.si.sion.utils
Classpublic class SiONUtil
InheritanceSiONUtil Inheritance Object

Utilities for SiON



Public Methods
 MethodDefined By
  
calcSampleLength(bpm:Number, beat16:Number = 4):Number
[static] Calculate sample length from 16th beat.
SiONUtil
  
extract(src:Sound, dst:Vector.<Number> = null, dstChannelCount:int = 1, length:int = 1048576, startPosition:int = -1):Vector.<Number>
[static] put Sound.extract() result into Vector.<Number>.
SiONUtil
  
extractDPCM(src:ByteArray, initValue:int = 0, dst:Vector.<Number> = null, dstChannelCount:int = 1):Vector.<Number>
[static] extract 2a03's DPCM data. DPCM frequency table = [ 0=k14o2e, 1=k18o2f+, 2=k13o2g+, 3=k16o2a, 4=k13o2b, 5=k16o3c+, 6=k17o3d+, 7=k14o3e, 8=k18o3f+, 9=k16o3a, 10=k20o3b, 11=k7o4c+, 12=k24o4e, 13=k13o4g+, 14=k5o4b, 15=k4o5e]
SiONUtil
  
extractYM2151ADPCM(src:ByteArray, dst:Vector.<Number> = null, dstChannelCount:int = 1):Vector.<Number>
[static] extract ADPCM data (YM2151).
SiONUtil
  
extractYM2608ADPCM(src:ByteArray, dst:Vector.<Number> = null, dstChannelCount:int = 1):Vector.<Number>
[static] extract ADPCM data (YM2608)
SiONUtil
  
getEndGap(src:Sound, rmsThreshold:Number = 0.01, maxLength:int = 1152):int
[static] Get end gap of Sound
SiONUtil
  
getHeadSilence(src:Sound, rmsThreshold:Number = 0.01):int
[static] Check silent length at the head of Sound.
SiONUtil
  
getPeakDistance(sample:Vector.<Number>):Number
[static] Detect distance[ms] of 2 peaks, [estimated bpm] = 60000/getPeakDistance().
SiONUtil
  
logTrans(data:Sound, dst:Vector.<int> = null, dstChannelCount:int = 2, sampleMax:int = 1048576, startPosition:int = 0, maximize:Boolean = true):Vector.<int>
[static] logarithmical transformation of Sound data.
SiONUtil
  
logTransByteArray(src:ByteArray, dst:Vector.<int> = null, dstChannelCount:int = 2, maximize:Boolean = true):Vector.<int>
[static] logarithmical transformation of ByteArray wave data.
SiONUtil
  
logTransVector(src:Vector.<Number>, srcChannelCount:int = 2, dst:Vector.<int> = null, dstChannelCount:int = 0, maximize:Boolean = true):Vector.<int>
[static] logarithmical transformation of Vector.<Number> wave data.
SiONUtil
  
waveColor(color:uint, waveType:int = 0, dst:Vector.<Number> = null):Vector.<Number>
[static] create Wave table Vector from wave color.
SiONUtil
Method Detail
calcSampleLength()method
public static function calcSampleLength(bpm:Number, beat16:Number = 4):Number

Calculate sample length from 16th beat.

Parameters

bpm:Number — Beat per minuits.
 
beat16:Number (default = 4) — Count of 16th beat.

Returns
Number — sample length.
extract()method 
public static function extract(src:Sound, dst:Vector.<Number> = null, dstChannelCount:int = 1, length:int = 1048576, startPosition:int = -1):Vector.<Number>

put Sound.extract() result into Vector.<Number>. This data is used for sampler module (%10).

Parameters

src:Sound — The Sound data extracting from.
 
dst:Vector.<Number> (default = null) — The Vector.<Number> instance to put result. You can pass null to create new Vector.<Number> inside.
 
dstChannelCount:int (default = 1) — channel count of extracted data. 1 for monoral, 2 for stereo.
 
length:int (default = 1048576) — The maximum sample count to extract. The length of returning vector is limited by this value.
 
startPosition:int (default = -1) — Start position to extract. -1 to set extraction continuously.

Returns
Vector.<Number> — extracted data.
extractDPCM()method 
public static function extractDPCM(src:ByteArray, initValue:int = 0, dst:Vector.<Number> = null, dstChannelCount:int = 1):Vector.<Number>

extract 2a03's DPCM data. DPCM frequency table = [ 0=k14o2e, 1=k18o2f+, 2=k13o2g+, 3=k16o2a, 4=k13o2b, 5=k16o3c+, 6=k17o3d+, 7=k14o3e, 8=k18o3f+, 9=k16o3a, 10=k20o3b, 11=k7o4c+, 12=k24o4e, 13=k13o4g+, 14=k5o4b, 15=k4o5e]

Parameters

src:ByteArray — The DPCM ByteArray data extracting from.
 
initValue:int (default = 0) — initial value of $4011.
 
dst:Vector.<Number> (default = null) — The Vector.<Number> instance to put result. You can pass null to create new Vector.<Number> inside.
 
dstChannelCount:int (default = 1) — channel count of extracted data. 1 for monoral, 2 for stereo.

Returns
Vector.<Number> — extracted data.
extractYM2151ADPCM()method 
public static function extractYM2151ADPCM(src:ByteArray, dst:Vector.<Number> = null, dstChannelCount:int = 1):Vector.<Number>

extract ADPCM data (YM2151). this algorism is from x68ksound.dll's source code. _freqTable:Array = [26, 31, 38, 43, 50];

Parameters

src:ByteArray — The ADPCM ByteArray data extracting from.
 
dst:Vector.<Number> (default = null) — The Vector.<Number> instance to put result. You can pass null to create new Vector.<Number> inside.
 
dstChannelCount:int (default = 1) — channel count of extracted data. 1 for monoral, 2 for stereo.

Returns
Vector.<Number> — extracted data.
extractYM2608ADPCM()method 
public static function extractYM2608ADPCM(src:ByteArray, dst:Vector.<Number> = null, dstChannelCount:int = 1):Vector.<Number>

extract ADPCM data (YM2608)

Parameters

src:ByteArray — The ADPCM ByteArray data extracting from.
 
dst:Vector.<Number> (default = null) — The Vector.<Number> instance to put result. You can pass null to create new Vector.<Number> inside.
 
dstChannelCount:int (default = 1) — channel count of extracted data. 1 for monoral, 2 for stereo.

Returns
Vector.<Number> — extracted data.
getEndGap()method 
public static function getEndGap(src:Sound, rmsThreshold:Number = 0.01, maxLength:int = 1152):int

Get end gap of Sound

Parameters

src:Sound — source Sound
 
rmsThreshold:Number (default = 0.01) — threshold level to detect sound.
 
maxLength:int (default = 1152) — maximum length to search [sample count]. ussually mp3's end gap is less than 1152.

Returns
int — silent length in sample count.
getHeadSilence()method 
public static function getHeadSilence(src:Sound, rmsThreshold:Number = 0.01):int

Check silent length at the head of Sound.

Parameters

src:Sound — source Sound
 
rmsThreshold:Number (default = 0.01) — threshold level to detect sound.

Returns
int — silent length in sample count.
getPeakDistance()method 
public static function getPeakDistance(sample:Vector.<Number>):Number

Detect distance[ms] of 2 peaks, [estimated bpm] = 60000/getPeakDistance().

Parameters

sample:Vector.<Number> — stereo samples, the length must be grater than 59136(stereo).

Returns
Number — distance[ms] of 2 peaks.
logTrans()method 
public static function logTrans(data:Sound, dst:Vector.<int> = null, dstChannelCount:int = 2, sampleMax:int = 1048576, startPosition:int = 0, maximize:Boolean = true):Vector.<int>

logarithmical transformation of Sound data. The transformed datas type is Vector.<int>. This data is used for PCM sound module (%7).

Parameters

data:Sound — The Sound data transforming from.
 
dst:Vector.<int> (default = null) — The Vector.<int> instance to put result. You can pass null to create new Vector.<int> inside.
 
dstChannelCount:int (default = 2) — channel count of destination samples. 0 sets same with srcChannelCount
 
sampleMax:int (default = 1048576) — The maximum sample count to transforme. The length of transformed data is limited by this value.
 
startPosition:int (default = 0) — Start position to extract. -1 to set extraction continuously.
 
maximize:Boolean (default = true) — maximize input sample

Returns
Vector.<int> — logarithmical transformed data.
logTransByteArray()method 
public static function logTransByteArray(src:ByteArray, dst:Vector.<int> = null, dstChannelCount:int = 2, maximize:Boolean = true):Vector.<int>

logarithmical transformation of ByteArray wave data. The transformed datas type is Vector.<int>. This data is used for PCM sound module (%7).

Parameters

src:ByteArray — The ByteArray wave data transforming from. This is ussualy from Sound.extract().
 
dst:Vector.<int> (default = null) — The Vector.<int> instance to put result. You can pass null to create new Vector.<int> inside.
 
dstChannelCount:int (default = 2) — channel count of destination samples. 0 sets same with srcChannelCount
 
maximize:Boolean (default = true)

Returns
Vector.<int> — logarithmical transformed data.
logTransVector()method 
public static function logTransVector(src:Vector.<Number>, srcChannelCount:int = 2, dst:Vector.<int> = null, dstChannelCount:int = 0, maximize:Boolean = true):Vector.<int>

logarithmical transformation of Vector.<Number> wave data. The transformed datas type is Vector.<int>. This data is used for PCM sound module (%7).

Parameters

src:Vector.<Number> — The Vector.<Number> wave data transforming from. This ussualy comes from SiONDriver.render().
 
srcChannelCount:int (default = 2) — channel count of source samples.
 
dst:Vector.<int> (default = null) — The Vector.<int> instance to put result. You can pass null to create new Vector.<int> inside.
 
dstChannelCount:int (default = 0) — channel count of destination samples. 0 sets same with srcChannelCount
 
maximize:Boolean (default = true)

Returns
Vector.<int> — logarithmical transformed data.
waveColor()method 
public static function waveColor(color:uint, waveType:int = 0, dst:Vector.<Number> = null):Vector.<Number>

create Wave table Vector from wave color.

Parameters

color:uint — wave color value
 
waveType:int (default = 0) — wave type (the voice number of '%5')
 
dst:Vector.<Number> (default = null) — returning Vector.<Number>. if null, allocate new Vector inside.

Returns
Vector.<Number>