I have an old audio cassette tape of digital data I converted to .wav and am hacking to recover the original data. I demodulated the 4K/2K FSK modulation with minimodem. Then I get stuck with insufficient understanding of the NRZI bit-stuffing algorithm. Short-cut: does anybody know of sox-like or minimodem-like program that does NRZI decoding through Linux pipes? Many references explain that bits are stuffed into NRZI data streams after 5 consecutive bits of one polarity. But to be precise, I haven't found a clarification. Does this mean: 1. a bit stuff happens after 5 bits, or 2. a bit stuff happens in order to prevent a run of 6 bits? By example, if the original data is ...11111001... does it get transmitted as is, or does a bit stuff occur to send the data ...111110001... ? If the bit-stuff is only to cause a transition after 5 bits, then the stuff is not necessary. But the docs say "after 5 bits" which would create unnecessary stuffs if the original data had inherent runs of exactly 5 bits.