Packageorg.si.sion.utils
Classpublic class PCMSample
InheritancePCMSample Inheritance flash.events.EventDispatcher

PCM sample loader/saver



Public Properties
 PropertyDefined By
  baseNote : int
MIDI note number of base frequency
PCMSample
  basicInfoChunkID : String = sinf
[static] You should not change this property into "acid" !
PCMSample
  beatCount : int
beat count
PCMSample
  bitRate : int
bit rate, this function is used only for saveWaveByteArray, 8 or 16 is avairable.
PCMSample
  bpm : Number
beat per minutes
PCMSample
  channels : int
channel count, 1 for monoral, 2 for stereo
PCMSample
  extendedInfoChunkID : String = SiON
[static] extended chunk for SiON
PCMSample
  internalChannels : int
[read-only] channel count of internal samples.
PCMSample
  internalSampleRate : Number
[read-only] sample rate of internal samples.
PCMSample
  sampleLength : int
[read-only] sample length
PCMSample
  sampleRate : Number
sample rate [Hz]
PCMSample
  samples : Vector.<Number>
[read-only] samples in Vector.<Number> with properties of sampleRate and channels.
PCMSample
  sampleType : int
flags: 0x01 = oneshot, 0x02 = rootSet, 0x04 = stretch, 0x08 = diskbased
PCMSample
  timeSignatureDenominator : int
denominator of time signature
PCMSample
  timeSignatureNumber : int
number of time signature
PCMSample
  waveData : ByteArray
[read-only] wave sample data of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().
PCMSample
  waveDataBitRate : int
[read-only] bit rate of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().
PCMSample
  waveDataChannels : int
[read-only] channel count of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().
PCMSample
  waveDataChunks : *
[read-only] chunks of wave file, this property is only available after loadWaveFromByteArray().
PCMSample
  waveDataSampleRate : Number
[read-only] sample rate of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().
PCMSample
Protected Properties
 PropertyDefined By
  _appendPosition : int
append position
PCMSample
  _cache : Vector.<Number>
converted sample cache
PCMSample
  _cacheChannels : int
converted sample cache channel count
PCMSample
  _cacheSampleRate : Number
converted sample cache sample rate
PCMSample
  _channels : int
channel count of internal wave sample
PCMSample
  _extractPosition : Number
extract position
PCMSample
  _outputBitRate : int
bit rate of wave file
PCMSample
  _outputChannels : int
channel count of output
PCMSample
  _outputSampleRate : Number
sample rate of output
PCMSample
  _sampleRate : int
sample rate of internal wave sample
PCMSample
  _samples : Vector.<Number>
internal wave sample in 44.1kHz Number
PCMSample
  _waveData : ByteArrayExt = null
wave data
PCMSample
  _waveDataBitRate : int
wave data bit rate
PCMSample
  _waveDataChannels : int
wave data channel count
PCMSample
  _waveDataChunks : * = null
chunks of wave data
PCMSample
  _waveDataFormatID : int
wave data format ID
PCMSample
  _waveDataSampleRate : Number
wave data sample rate
PCMSample
Public Methods
 MethodDefined By
  
PCMSample(channels:int = 2, sampleRate:int = 44100, samples:Vector.<Number> = null)
constructor
PCMSample
  
appendSamples(src:Vector.<Number>, sampleCount:int = 0, srcOffset:int = 0):PCMSample
append samples
PCMSample
  
appendSamplesFromByteArrayFloat(bytes:ByteArray, sampleCount:int = 0):PCMSample
append samples from ByteArray float (2ch/44.1kHz), The internal format should be 2ch/44.1kHz.
PCMSample
  
clear cache and waveData
PCMSample
  
clear wave data cache
PCMSample
  
extract(dst:Vector.<Number> = null, length:int = 0, offset:int = -1):Vector.<Number>
extract to Vector.<Number>
PCMSample
  
loadFromVector(src:Vector.<Number>, srcChannels:int = 2, srcSampleRate:Number = 44100, linear:Boolean = true):PCMSample
load sample from Vector.<Number>
PCMSample
  
loadWaveFromByteArray(waveFile:ByteArray):PCMSample
load from wave file byteArray.
PCMSample
  
readSTRCChunk(strcChunk:ByteArray):Array
[static] Try to read mysterious "strc" chunk.
PCMSample
  
save wave file as byteArray.
PCMSample
Property Detail
_appendPositionproperty
protected var _appendPosition:int

append position

_cacheproperty 
protected var _cache:Vector.<Number>

converted sample cache

_cacheChannelsproperty 
protected var _cacheChannels:int

converted sample cache channel count

_cacheSampleRateproperty 
protected var _cacheSampleRate:Number

converted sample cache sample rate

_channelsproperty 
protected var _channels:int

channel count of internal wave sample

_extractPositionproperty 
protected var _extractPosition:Number

extract position

_outputBitRateproperty 
protected var _outputBitRate:int

bit rate of wave file

_outputChannelsproperty 
protected var _outputChannels:int

channel count of output

_outputSampleRateproperty 
protected var _outputSampleRate:Number

sample rate of output

_sampleRateproperty 
protected var _sampleRate:int

sample rate of internal wave sample

_samplesproperty 
protected var _samples:Vector.<Number>

internal wave sample in 44.1kHz Number

_waveDataproperty 
protected var _waveData:ByteArrayExt = null

wave data

_waveDataBitRateproperty 
protected var _waveDataBitRate:int

wave data bit rate

_waveDataChannelsproperty 
protected var _waveDataChannels:int

wave data channel count

_waveDataChunksproperty 
protected var _waveDataChunks:* = null

chunks of wave data

_waveDataFormatIDproperty 
protected var _waveDataFormatID:int

wave data format ID

_waveDataSampleRateproperty 
protected var _waveDataSampleRate:Number

wave data sample rate

baseNoteproperty 
public var baseNote:int

MIDI note number of base frequency

basicInfoChunkIDproperty 
public static var basicInfoChunkID:String = sinf

You should not change this property into "acid" !

beatCountproperty 
public var beatCount:int

beat count

bitRateproperty 
bitRate:int

bit rate, this function is used only for saveWaveByteArray, 8 or 16 is avairable.


Implementation
    public function get bitRate():int
    public function set bitRate(value:int):void
bpmproperty 
public var bpm:Number

beat per minutes

channelsproperty 
channels:int

channel count, 1 for monoral, 2 for stereo


Implementation
    public function get channels():int
    public function set channels(value:int):void
extendedInfoChunkIDproperty 
public static var extendedInfoChunkID:String = SiON

extended chunk for SiON

internalChannelsproperty 
internalChannels:int  [read-only]

channel count of internal samples.


Implementation
    public function get internalChannels():int
internalSampleRateproperty 
internalSampleRate:Number  [read-only]

sample rate of internal samples.


Implementation
    public function get internalSampleRate():Number
sampleLengthproperty 
sampleLength:int  [read-only]

sample length


Implementation
    public function get sampleLength():int
sampleRateproperty 
sampleRate:Number

sample rate [Hz]


Implementation
    public function get sampleRate():Number
    public function set sampleRate(value:Number):void
samplesproperty 
samples:Vector.<Number>  [read-only]

samples in Vector.<Number> with properties of sampleRate and channels.


Implementation
    public function get samples():Vector.<Number>
sampleTypeproperty 
public var sampleType:int

flags: 0x01 = oneshot, 0x02 = rootSet, 0x04 = stretch, 0x08 = diskbased

timeSignatureDenominatorproperty 
public var timeSignatureDenominator:int

denominator of time signature

timeSignatureNumberproperty 
public var timeSignatureNumber:int

number of time signature

waveDataproperty 
waveData:ByteArray  [read-only]

wave sample data of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().


Implementation
    public function get waveData():ByteArray
waveDataBitRateproperty 
waveDataBitRate:int  [read-only]

bit rate of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().


Implementation
    public function get waveDataBitRate():int
waveDataChannelsproperty 
waveDataChannels:int  [read-only]

channel count of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().


Implementation
    public function get waveDataChannels():int
waveDataChunksproperty 
waveDataChunks:*  [read-only]

chunks of wave file, this property is only available after loadWaveFromByteArray().


Implementation
    public function get waveDataChunks():*
waveDataSampleRateproperty 
waveDataSampleRate:Number  [read-only]

sample rate of original wave file, this property is only available after loadWaveFromByteArray() or saveWaveAsByteArray().


Implementation
    public function get waveDataSampleRate():Number
Constructor Detail
PCMSample()Constructor
public function PCMSample(channels:int = 2, sampleRate:int = 44100, samples:Vector.<Number> = null)

constructor

Parameters
channels:int (default = 2)
 
sampleRate:int (default = 44100)
 
samples:Vector.<Number> (default = null)
Method Detail
appendSamples()method
public function appendSamples(src:Vector.<Number>, sampleCount:int = 0, srcOffset:int = 0):PCMSample

append samples

Parameters

src:Vector.<Number> — buffering source. This should be same format as internalSampleRate and internalChannels
 
sampleCount:int (default = 0) — sample count to append. 0 appends all samples.
 
srcOffset:int (default = 0) — position (in samples) start appending from.

Returns
PCMSample
appendSamplesFromByteArrayFloat()method 
public function appendSamplesFromByteArrayFloat(bytes:ByteArray, sampleCount:int = 0):PCMSample

append samples from ByteArray float (2ch/44.1kHz), The internal format should be 2ch/44.1kHz.

Parameters

bytes:ByteArray — buffering source. The format should be float vector of 2ch/44.1kHz.
 
sampleCount:int (default = 0) — sample count to append. 0 appends all samples.

Returns
PCMSample
clearCache()method 
public function clearCache():PCMSample

clear cache and waveData

Returns
PCMSample
clearWaveDataCache()method 
public function clearWaveDataCache():PCMSample

clear wave data cache

Returns
PCMSample
extract()method 
public function extract(dst:Vector.<Number> = null, length:int = 0, offset:int = -1):Vector.<Number>

extract to Vector.<Number>

Parameters

dst:Vector.<Number> (default = null)
 
length:int (default = 0)
 
offset:int (default = -1)

Returns
Vector.<Number>
loadFromVector()method 
public function loadFromVector(src:Vector.<Number>, srcChannels:int = 2, srcSampleRate:Number = 44100, linear:Boolean = true):PCMSample

load sample from Vector.<Number>

Parameters

src:Vector.<Number> — source vector of Number.
 
srcChannels:int (default = 2) — channel count of source.
 
srcSampleRate:Number (default = 44100) — sample rate of source.
 
linear:Boolean (default = true) — exchange sampling rate by linear interpolation, set false to use samples nearest by.

Returns
PCMSample
loadWaveFromByteArray()method 
public function loadWaveFromByteArray(waveFile:ByteArray):PCMSample

load from wave file byteArray.

Parameters

waveFile:ByteArray — ByteArray of wave file.

Returns
PCMSample
readSTRCChunk()method 
public static function readSTRCChunk(strcChunk:ByteArray):Array

Try to read mysterious "strc" chunk.

Parameters

strcChunk:ByteArray — strc chunk data.

Returns
Array — positions
saveWaveAsByteArray()method 
public function saveWaveAsByteArray():ByteArray

save wave file as byteArray.

Returns
ByteArray — waveFile ByteArray of wave file.