REALLY technical details about the Spectrum loading signal

For experts to discuss very technical stuff and newbies to ask why the Spectrum they bought off ebay doesn't work.
Post Reply
User avatar
TMD2003
Rick Dangerous
Posts: 2047
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

REALLY technical details about the Spectrum loading signal

Post by TMD2003 »

In an attempt to unlock the arcane secrets of the SAM Coupé blocks on the Enigma tapes, I will need to know more about the way the Spectrum (and, presumably, the SAM Coupé) actually records data to tape.

All I know is, there are three frequencies used: 800 Hz for the pilot tone, and 1 kHz and 2 kHz to generate the 1s and 0s.

But there I was also thinking that 1s and 0s were an equal number of cycles. That was, until I wrote this program:
10 POKE 65368,255
20 POKE 65369,0
30 POKE 65370,170
RUN it, SAVE "bob" CODE 65368,3 then run that through TZX2WAV, open it in Audacity and it should confirm what I thought 1s and 0s looked like, as a waveform.

It doesn't.

After the pilot tone there is a single cycle at 2 kHz.
Then there are SIXTEEN cycles at 1 kHz, representing 11111111.
Then there are EIGHT cycles at 2 kHz, representing 00000000.
Fair enough, I thought: a 1 is two cycles at 1 kHz, a 0 is one cycle at 2 kHz, hence a 1 is four times as long as a 0, when I'd thought it was twice as long.

But now the plot thickens... ONE cycle at 1 kHz, then ONE cycle at 2 kHz, repeated EIGHT times, makes 10101010... somehow. That doesn't tally with what I'd observed for 11111111.

The Spectrum manual doesn't go into this kind of ridiculously technical detail about what 1s and 0s look like when they're recorded to tape. Why would they, at the time - who bought a Spectrum and then viewed the content of their tapes with an oscilloscope? I know I didn't, not least because I was still in single digits until the +2B was released.

Is there someone out there, possibly someone who has written a tape manipulation utility, who has an accurate explanation of what constitutes a 1 and a 0?
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
Guesser
Manic Miner
Posts: 646
Joined: Wed Nov 15, 2017 2:35 pm
Contact:

Re: REALLY technical details about the Spectrum loading signal

Post by Guesser »

The spectrum doesn't really care about audio waves. All it's interested in is edges, and the number of clock cycles that pass between them.
https://sinclair.wiki.zxnet.co.uk/wiki/ ... _interface

The reason you see 16 1 bits at the start is because the data block starts with FF to indicate it's a data block
User avatar
TMD2003
Rick Dangerous
Posts: 2047
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

Re: REALLY technical details about the Spectrum loading signal

Post by TMD2003 »

Guesser wrote: Thu Jul 27, 2023 12:55 am The spectrum doesn't really care about audio waves. All it's interested in is edges, and the number of clock cycles that pass between them.
https://sinclair.wiki.zxnet.co.uk/wiki/ ... _interface
The reason you see 16 1 bits at the start is because the data block starts with FF to indicate it's a data block
...and now I see there's a checksum byte at the end, which... doesn't quite explain the extra 10101010. If it's supposed to all the data bytes XORed together, that'd be 01010101 - unless that initial 11111111 counts as well, in which case it'd be right.
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
WhatHoSnorkers
Manic Miner
Posts: 256
Joined: Tue Dec 10, 2019 3:22 pm

Re: REALLY technical details about the Spectrum loading signal

Post by WhatHoSnorkers »

I had a "clever" idea of trying to get the loading noises to make a tune, so I produced a file of every single byte value and tried to find what the notes were. It was interesting at least with this dodgy app on my phone.

I couldn't work out the logic of what noise was what though.
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
User avatar
TMD2003
Rick Dangerous
Posts: 2047
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

Re: REALLY technical details about the Spectrum loading signal

Post by TMD2003 »

So it wasn't you who wrote the Imperial March as a loading signal, then...
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
Pegaz
Dynamite Dan
Posts: 1210
Joined: Mon Nov 13, 2017 1:44 pm

Re: REALLY technical details about the Spectrum loading signal

Post by Pegaz »

There is a demo that plays tune from loading noise, but I can't find it right now...
edit:
I think I found it, although there may be others:
https://easyupload.io/kt3ws2
User avatar
SkoolKid
Manic Miner
Posts: 418
Joined: Wed Nov 15, 2017 3:07 pm

Re: REALLY technical details about the Spectrum loading signal

Post by SkoolKid »

As @Guesser said, the Spectrum only cares about edges, i.e. the boundaries between pulses, where a pulse is created by either MIC on or MIC off lasting for a certain number of T-states.

Everything you could possibly need know about the standard Spectrum loading signal can be found in the disassembly of the ROM's SA-BYTES routine. It's a fairly short and simple routine.
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
User avatar
WhatHoSnorkers
Manic Miner
Posts: 256
Joined: Tue Dec 10, 2019 3:22 pm

Re: REALLY technical details about the Spectrum loading signal

Post by WhatHoSnorkers »

TMD2003 wrote: Thu Jul 27, 2023 9:45 am So it wasn't you who wrote the Imperial March as a loading signal, then...
I was inspired by that! I tried to do my "theme tune" in a similar way and then got fed up/distracted.
I have a little YouTube channel of nonsense
https://www.youtube.com/c/JamesOGradyWhatHoSnorkers
User avatar
p13z
Manic Miner
Posts: 621
Joined: Sun Feb 17, 2019 10:41 pm
Location: UK
Contact:

Re: REALLY technical details about the Spectrum loading signal

Post by p13z »

Pegaz wrote: Thu Jul 27, 2023 11:36 am There is a demo that plays tune from loading noise, but I can't find it right now...
edit:
I think I found it, although there may be others:
https://easyupload.io/kt3ws2

I played around and did some tunes years back. It was only when I uploaded one to youtube, and it started showing me related videos, that I found out I had just re-invented the wheel with this. There were some Russian coders who had gone as far as making loading noise trackers, complete with arpeggios, drum tracks and more harmonious signals than I managed to produce.

This was my attempt:
cj7hawk
Manic Miner
Posts: 361
Joined: Sat Sep 25, 2021 9:11 am

Re: REALLY technical details about the Spectrum loading signal

Post by cj7hawk »

Colour me impressed, any by colour I mean with attribute clash...

But still impressed nonetheless :)

Nice work!
User avatar
1024MAK
Bugaboo
Posts: 3172
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: REALLY technical details about the Spectrum loading signal

Post by 1024MAK »

Also some information on the tape system here ;-)

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer being good this year.
Post Reply