public override void ReadHeaderFromStream(Stream stream, ref uint orderNumber) { this.orderNumber = orderNumber; name = ModuleUtils.ReadString0(stream, 22); length = (uint)ModuleUtils.ReadWordSwap(stream) * 2; // Length sizeInBytes = length; fineTune = stream.ReadByte() & 0xF; // finetune Value>7 means negative 8..15= -8..-1 fineTune = (fineTune > 7) ? fineTune - 16 : fineTune; int vol = stream.ReadByte(); // volume 64 is maximum volume = (vol > 64) ? 1.0f : (float)vol / 64.0f; //// Repeat start and stop repeatStart = (uint)ModuleUtils.ReadWordSwap(stream) * 2; repeatLength = (uint)ModuleUtils.ReadWordSwap(stream) * 2; repeatStop = repeatStart + repeatLength; if (length < 4) { length = 0; } if (length > 0) { if (repeatStart > length) { repeatStart = length; } if (repeatStop > length) { repeatStop = length; } if (repeatStart >= repeatStop || repeatStop <= 8 || (repeatStop - repeatStart) <= 4) { repeatStart = repeatStop = 0; loopType = 0; } if (repeatStart < repeatStop) { loopType = ModuleConst.LOOP_ON; } } else { loopType = 0; } repeatLength = (uint)(repeatStop - repeatStart); }