Beispiel #1
0
func bitstream(stream string) []datatypes.Bit {
	bits := make([]datatypes.Bit, 32)
	for i, c := range stream {
		if string(c) == "1" {
			bits[i] = datatypes.Bit(true)
		} else {
			bits[i] = datatypes.Bit(false)
		}
	}
	return bits
}
Beispiel #2
0
// StreamToBits converts samples to bits using the bitlength specified.
// Observe that POCSAG signifies a high bit with a low frequency.
func StreamToBits(stream []int16, bitlength int) []datatypes.Bit {

	bits := make([]datatypes.Bit, (len(stream)/bitlength)+1)
	b := 0

	for a := 0; a < len(stream); a += bitlength {

		sample := stream[a]
		if a > 2 && a < len(stream)-2 {
			// let the samples before and after influence our sample, to prevent spike errors
			sample = (stream[a-1] / 2) + stream[a] + (stream[a+1] / 2)
		}

		bits[b] = datatypes.Bit((sample < 0))
		b += 1

	}

	return bits
}