Beispiel #1
0
        // Read/assemble the next byte
        internal bool readByte(out byte result)
        {
            int theByte = 0;

            result = 0;

            if (this.EndOfFile)
            {
                return(false);
            }

            for (int i = 0; i < 8; i++)
            {
                //seek next wave
                this.WavePositions = this.seekWave();
                if ((this.WavePositions.max == -1) || this.EndOfFile)
                {
                    return(false);
                }
                else
                {
                    // build the byte based on wave "type"
                    theByte = theByte | (this.whatIsBit() << (7 - i));
                }
            }
            result = (byte)theByte;
            return(true);
        }
Beispiel #2
0
        // Search for the A5 byte -> Binary(10100101)
        internal bool seekA5Byte()
        {
            int theByte;

            // Skip past the "zero waves", until reaching a "one wave"
            do
            {
                this.WavePositions = this.seekWave();
            }while
            ((this.whatIsBit() == 0) && !this.EndOfFile);

            if (this.EndOfFile)
            {
                return(false);
            }

            theByte = 0;

            for (int i = 0; i < 8; i++)
            {
                // Find the next "wave"
                if (i != 0)
                {
                    this.WavePositions = this.seekWave();
                }
                // build the byte based on wave "type"
                theByte = theByte | (this.whatIsBit() << (7 - i));
            }
            //Binary(10100101)
            return(theByte == 0xA5);
        }
Beispiel #3
0
        internal WavePositionsStruct findSyncZero()
        {
            do
            {
                this.WavePositions = this.seekWave();
            }while
            ((this.whatIsBit() == 1) && !this.EndOfFile);

            // Statistics
            this.zeroWaveStart = this.WavePositions.start;
            // TODO: what if it's not a zero sync wave? Keep searching? iterate to end of file
            return(this.WavePositions);
        }
Beispiel #4
0
        // Searches for one wavelength beginning, minimum, crossover, maximum
        // (ignore end position, because that's the next start position)
        internal WavePositionsStruct seekWave()
        {
            WavePositionsStruct falseResult = new WavePositionsStruct(-1, -1, -1, -1);
            WavePositionsStruct result      = new WavePositionsStruct(0, 0, 0, 0);

            int position = -1;

            if ((position = this.seekCrossunder()) == -1)
            {
                return(falseResult);
            }
            else
            {
                result.start = position;
            }

            if ((position = this.seekMin()) == -1)
            {
                return(falseResult);
            }
            else
            {
                result.min = position;
            }

            if ((position = this.seekCrossover()) == -1)
            {
                return(falseResult);
            }
            else
            {
                result.crossover = position;
            }

            if ((position = this.seekMax()) == -1)
            {
                return(falseResult);
            }
            else
            {
                result.max = position;
            }

            return(result);
        }
        private bool findSyncZero(WaveSeeker waveSeeker)
        {
            WavePositionsStruct wavePositions = waveSeeker.findSyncZero();

            if (waveSeeker.EndOfFile)
            {
                infoTextBox.AppendText("Failed: Sync zero not found. End of File." + Environment.NewLine);
                return(false);
            }

            infoTextBox.AppendText(
                "Sync zero found. " +
                "(" + wavePositions.start +
                "," + wavePositions.min +
                "," + wavePositions.crossover +
                "," + wavePositions.max + ")" + Environment.NewLine
                );

            return(true);
        }