Experts of tape recording ( formats )

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

Dio wrote:
gilesgoat wrote:But now I am wondering, you say 5kbps .. this means you are recording a frequency of around 10Khz ? Isn't that a bit "much" for tape ?
No - one FM bit is encoded in either two transitions (i.e. one squarewave cycle at the higher frequency) or one transition and no transition (half a cycle at the lower frequency).

For your code, don't do a wait after you sample the bit. Just go back to the "find a clock pulse" routine and then it's resynchronised for the next pulse.
I don't get it yet ..

You say an '1' is encoded as '0101' ( two transitions ) and a '0' is encoded as '0111' ( for example - OR it could be '1010' and '1000' )

Now if all that "bit time" is 5000 bps this means that '0101' is 2 clock transitions in 1/5000 time so it's effectively 2 pulses at 10Khz NO ?

Am I getting something wrong ?
Giles the billy goat
"Baa"
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

And I am NOT SURE ABOUT THIS :
For your code, don't do a wait after you sample the bit. Just go back to the "find a clock pulse" routine and then it's resynchronised for the next pulse.
Suppose you have a "1" followed by a "0" ..

SO you have let's say a 0101 followed by a 0111 ...

Suppose you start at '0' level and you wait for a 0/1 transition ..

You will "lock" on the FIRST '1' of 0101 .. ( so the state you sample is '1' )

You wait 3/4 time you will be in the MIDDLE of the second '0' of 0101 .. ( so the state you sample is '0' )

At this point 1<>0 you sampled a "1" .. so far OK ..

But now, if you resart looking for a 0/1 transition, you are still in the middle of the second '0' of 0101 so your next "lock" will be on the last '1' of the 0101 ..

At this point you wait another 3/4 time you end up in the middle of the FIRST '0' of 0111 .. so again you have sampled a '1' first and a '0' next you think you have another "1".

So it seems to me I am misunderstanding something here ...
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Experts of tape recording ( formats )

Post by Dio »

A 1 bit is encoded as 11 (two transitions) while a 0 bit is encoded as 10 (one transition). It's just a clock pulse inserted between every bit.

If your data is say 0x36 ->

Code: Select all

Data:          0  0  1  1  0  1  1  0b
Transitions:  10 10 11 11 10 11 11 10
State:        HH LL HL HL HH LH LH LL
Then it's also easy to see that the decode is to repeat "wait for a clock pulse, wait 3/4 the time and check if a transition occurred in that time to extract the data"
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

Dio wrote:A 1 bit is encoded as 11 (two transitions) while a 0 bit is encoded as 10 (one transition). It's just a clock pulse inserted between every bit.

If your data is say 0x36 ->

Code: Select all

Data:          0  0  1  1  0  1  1  0b
Transitions:  10 10 11 11 10 11 11 10
State:        HH LL HL HL HH LH LH LL
Then it's also easy to see that the decode is to repeat "wait for a clock pulse, wait 3/4 the time and check if a transition occurred in that time to extract the data"
TO be clear "Transition" , suppose we start with '0' means a 0 to 1 thing so in your example :

Code: Select all

Data:          0  0  1  1  0  1  1  0b
Transitions:  10 10 11 11 10 11 11 10
State:        HH LL HL HL HH LH LH LL

Physical     0111 0111 0101 0101 0111 0101 0101 0111 

Also define "wait for a clock pulse" .. what do you mean with that ?

1. Wait for a 0 to 1 change OR
2. wait for a complete clock pulse 0 to 1 all the time for 1 clock pulse time

I mean suppose this is the pulse :

Code: Select all

___/""""\___/""""\___
When you say "wait for a clock pulse" at what point do you "lock" is it in ( # marks the point ) :

Case A:

Code: Select all

___/#"""\___/""""\___
OR is it in , Case B :

Code: Select all

___/"""#\___/""""\___
In case A if you then wait 3/4 time ( BIT time or CLOCK time ?? ) you will be here '.' marks the spot

Code: Select all

___/#"""\_._/""""\___
In case B you will be here :

Code: Select all

___/"""#\___/""."\___
I think Case B would be wrong because you'd read '1' '1' so you think it's 'no change' it's a "0" while in case 'A' you'd read '1' '0' so it's a change it's a '1'

But now let' see CASE A with a 11 10 togeher

Code: Select all

___/#"""\_._/""""\___/"""" """"\__
If after I am at '.' I look for another transition then I'll find '*'

Code: Select all

___/#"""\_._/*"""\___/"""" """"\__
Then if I wait another 3/4 I'll find 'x'

Code: Select all

___/#"""\_._/*"""\_x_/"""" """"\__
Which is wrong ... so what am I missing here ?
Giles the billy goat
"Baa"
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

Screw it all, I think I am misunderstanding your explanation about encoding ..

So assuming with start with a line of '1' .. you mean 00000 is really coded as '11' '00' '11' '00' '11'

While 11111 would be '10' '10' '10' '10' '10' ???

I tough you meant '1' is TWO transitions and '0' is ONE transition so I understood that '1' had to be '1010' and '0' had to be '1000' ...

I am still confused about how the encoding is ( PICS needed ! )
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Experts of tape recording ( formats )

Post by Dio »

I use H and L to refer to the actual data on the tape. But yes, 0000 is HH LL HH LL and 1111 is HL HL HL HL.

That wikipedia link on MFM has all the diagrams.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

Dio wrote:I use H and L to refer to the actual data on the tape. But yes, 0000 is HH LL HH LL and 1111 is HL HL HL HL.

That wikipedia link on MFM has all the diagrams.
OK .. after MUCH re-thinking again let's state things a bit more precisely ..

1. let's call the "bit time" Tbit = 1 / Baud_Rate
2. in every Tbit time ( or "cell" ) two things can happen : OR there's a transition ( from 0 to 1 OR 1 to 0 ) OR there's NO transition ( state remains watever it is )
3. at the beginning of each new "bit cell" the state must be the COMPLEMENT of what it ended , i.e. if the last thing ended in '0' it must start with an '1' and so on

Without '3' a stream of '0' would be a constant 1.1.1.1 or 0.0.0.0 createing a DC issue, instead it becomes a string of 00 11 00 11 00 11

Also this mean that an '1' could be a '01' and/or an '10' both are the same '1' ..

Also "we have to know a starting state", i.e. we have to assume we start looking from "edges" for example from a 0 to 1 transition.

So the algorithm, re-checked REALLY works as

1. start with 'state A = 0',

2. read B = IN
3. if B == A GOTO 2

3. wait 3/4 Tbit

4. read A = IN
5. if ( A <> B ) is a '1' otherwise is a '0'
6. goto 2

I think that works, the point is at any bit you need to flip also the state for the new transition.

Also I think you need to establish if you start with a 0 to 1 or an 1 to 0, you need to set what is the initial "A" I think.

At this point one of these week ends I am going to "add a mic/ear port" to my z80 thing for some tests ..
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Experts of tape recording ( formats )

Post by Dio »

Yes, that works.

To solve the latter problem, you need to sync up first. One method is just to use 10101010 pulses - since all the data bits are 0, it guarantees a lock on to the clock bits). You need to check you've seen 'enough' of these to avoid having locked onto something spurious. Then you can look for a specific value in the data stream or just the first nonzero data bit as a start mark.

Or you can do something like the Spectrum does, which is have 5 seconds of a pilot tone, and then a start marker.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

One interesting experiment, but probably a bit too complex to be done, would be to totally bypass the "recorder bias" on the head ( but I am not 100% sure about how all that works, I'd need to study more ) ..

If I understand correctly a tape recorder fundamentally "modulates" the BF signal ( music ) coming in with some HF "carrier", in order to have ENOUGH NSNSNS magnetic transitions on the tape.

This also limits the max freq you can record on tape.

But with a data FM recorded you really should not need all that, provided your data rate is fast enough, in that way you should really get "the max recording speed".

But I am not sure how messy would be to modify a tape recorder/player for that.

[edit] : https://en.wikipedia.org/wiki/Tape_bias

Which means in theory you could record/read from 40 to 100 Khz about, that is a 'massive' data rate !
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Experts of tape recording ( formats )

Post by Dio »

This is an interesting one. On all the digital-path tape recorders I've seen schematics for (Atari, Spectrum +2, C64) I've seen no bias circuitry in the write path. It may not be necessary when you're sending in a large-amplitude signal since the main purpose of bias is to linearise the signal in low-level regimes.

All the legacy systems also have some noise filtering that would stop this working, though. While it worked on an emulator, I couldn't get a Spectrum to talk to 16kbit FM from WAV file, although again I've wondered if the Harlequin might give it a go.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

Dio wrote:This is an interesting one. On all the digital-path tape recorders I've seen schematics for (Atari, Spectrum +2, C64) I've seen no bias circuitry in the write path. It may not be necessary when you're sending in a large-amplitude signal since the main purpose of bias is to linearise the signal in low-level regimes.

All the legacy systems also have some noise filtering that would stop this working, though. While it worked on an emulator, I couldn't get a Spectrum to talk to 16kbit FM from WAV file, although again I've wondered if the Harlequin might give it a go.
I had a quick look at a couple of schematics ( C64 datasette and ZX +2 ) .. I am .. confused ... an audio tape recorder is MUCH more complex also I am amazed that the ERASE head JUST have a DC static field to erase ?? I was convinced it needed a special AC field to properly erase.

However "quick look just be eye" I think they both has some LP filter and/or band limiter on, definitely what shocks me is that ZX/C64 dedicated tape has also some Schmitt Triggers so you get a "clean" TTL waveform out ( in theory ) .. this is MUCH different from the ZX loading from "a generic analog tape".

I'd expect the C64/ZX+2 tape be "miles more reliable" than a standard tape .. or maybe not .. that's .. interesting question as well ..
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Experts of tape recording ( formats )

Post by Dio »

Yes, I have wondered about every bit of that too, particularly the simplicity of it all and the DC erase. One guess is that it doesn't matter if the tape is just magnetised hard to one magnetisation rather than demagnetised if you're just going to blast hard magnetisation from the record head over it again.

The Spectrum analogue path does have an approximation of a Schmitt trigger inside the ULA. It's clearly nowhere near as good as the circuit on the Harlequin though, which is a 13kHz low-pass filter (much higher than the Spectrum filters) followed by a comparator/amplifier (interestingly wired). It's way more friendly than the Spectrum one, especially to line level signals.

There are interesting questions around filters too, people forget that filters can mess up phase (and hence edge timing). To me it looks like the BBC has its low-pass filter wrong and managed to drop the filter right into the required range of tones, and I wonder if that's why a lot of BBC sites go on about tape absolute phase in a way that nobody in any other emulation community cares about...
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Re: Experts of tape recording ( formats )

Post by gilesgoat »

Dio wrote:Yes, I have wondered about every bit of that too, particularly the simplicity of it all and the DC erase. One guess is that it doesn't matter if the tape is just magnetised hard to one magnetisation rather than demagnetised if you're just going to blast hard magnetisation from the record head over it again.

The Spectrum analogue path does have an approximation of a Schmitt trigger inside the ULA. It's clearly nowhere near as good as the circuit on the Harlequin though, which is a 13kHz low-pass filter (much higher than the Spectrum filters) followed by a comparator/amplifier (interestingly wired). It's way more friendly than the Spectrum one, especially to line level signals.

There are interesting questions around filters too, people forget that filters can mess up phase (and hence edge timing). To me it looks like the BBC has its low-pass filter wrong and managed to drop the filter right into the required range of tones, and I wonder if that's why a lot of BBC sites go on about tape absolute phase in a way that nobody in any other emulation community cares about...
I am getting "a small culture" about magnetic recording, according to stuff I found "DC erasing" is BAD, creates lot of noise, you should "AC erase" using some 40 .. 100 Khz wave that often is used as "Bias Oscillator" as well.

I am guessing that - IN THEORY - if you drive the head "fast enough" so let's say your digital modulation is around that you would not need bias ? Also you could pulse the erasing head yourself so to get a better erasing ?

If they are on a separate connectors ( I think they are ) I am tempted to create an "alternative circuit board" for C64 datasette may need mind you to create an HW FM modulator/demodulator .. need to think about it ..
Giles the billy goat
"Baa"
User avatar
Dio
Sheepie Whore
Sheepie Whore
Posts: 18887
Joined: Mon May 31, 2004 1:08 pm 0
Location: Newcastle UK

Re: Experts of tape recording ( formats )

Post by Dio »

You never 'need' bias, but it improves audio quality by linearising the tape transfer function. For digital signals it seems unimportant.
Post Reply