var sampleRate:int=0;
if (waveReader.sampleRate == 44100)
{
sampleRate=3;
}
else if (waveReader.sampleRate == 22050)
{
sampleRate=2;
}
else if (waveReader.sampleRate == 11025)
{
sampleRate=1;
}
// WRITE SOUNDSTREAMHEADER2 TAG
writeRecordHeader(defineSound, 45, 4);
writeUBits(defineSound, 4, 0);
writeUBits(defineSound, 2, sampleRate);
writeUBits(defineSound, 1, sampleSize);
writeUBits(defineSound, 1, waveReader.channels - 1);
writeUBits(defineSound, 4, 0);
writeUBits(defineSound, 2, sampleRate);
writeUBits(defineSound, 1, sampleSize);
writeUBits(defineSound, 1, waveReader.channels - 1);
defineSound.writeShort(0);
// Write The linkage Class
for (var m:int=0; m < linkageClass.length; m++)
{
defineSound.writeByte(linkageClass[m]);
}
// WRITE DEFINESOUND TAG
writeRecordHeader(defineSound, 14, waveReader.bytes.length - 44 + 7);
defineSound.writeShort(1); // Sound Id
var compression:int=0; // only raw sound for now
defineSound.writeByte((compression << 4) + (sampleRate << 2) + (sampleSize << 1) + waveReader.channels - 1); //Sound Format + Sample Rate + SampleSize + Channels