Rockbox

Tasklist

FS#12435 - ZX Spectrum .tap codec

Attached to Project: Rockbox
Opened by George Manolaros (gmanol) - Friday, 09 December 2011, 14:34 GMT
Task Type Patches
Category Codecs
Status Unconfirmed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Release 3.9
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

This patch adds a new codec that playbacks ZX Spectrum .tap files. Created against trunk (revision 31187)
This task depends upon

Comment by George Manolaros (gmanol) - Friday, 09 December 2011, 14:40 GMT
the patch.
Comment by Torne Wuff (torne) - Friday, 09 December 2011, 15:14 GMT
You can't use floating point arithmetic on Rockbox, I'm afraid; almost none of our targets have hardware floating point. You'll need to do this using integers/fixedpoint...
Comment by MichaelGiacomelli (saratoga) - Friday, 09 December 2011, 15:35 GMT
Looking at the create_pulse function, I think its only called with constant arguments during the initialization. Perhaps you could eliminate all that floating point code just by precomputing the values in buffer[]?
Comment by George Manolaros (gmanol) - Friday, 09 December 2011, 15:49 GMT
@saratoga : Sure, this was my first thought but I found it more flexible creating the buffers with code. It was easier to experiment with pulse width/amplitude that way. And I don't think it is a big overhead even for software floating point support. @torne : Does the targets support software floating point?
Comment by Torne Wuff (torne) - Friday, 09 December 2011, 16:02 GMT
Software floating point apparently more or less works (though with restrictions) but it's *hundreds of times slower*. If it's just generating a table then including the data in the binary would be easier and reduce codec startup time probably significantly (and might actually produce *smaller* code; the table may well be less bytes than the floating point support code that gcc will generate for you)
Comment by George Manolaros (gmanol) - Friday, 09 December 2011, 16:17 GMT
Do you mind if I add a #define statement that switches the compilation between floating point / precalculated buffers? It is quite handy during development and I could use the code to produce the actual buffer[] contents.
Comment by Andree Buschmann (Buschel) - Saturday, 10 December 2011, 09:48 GMT
If you add a #define to switch between pre-calculated tables and the float calculations this should be fine. Can you please also provide an update of the manual (see ./manual/appendix/file_formats.tex) which introduces the new format and its supported metadata, as well as a sample file?

Edit: You should also insert AFMT_TAP after AFMT_KSS to avoid breaking older skins which depend on the codec order.
Comment by Andree Buschmann (Buschel) - Saturday, 10 December 2011, 11:22 GMT
I have added the manual changes and changed the location of tap-related definitions.

Edit: Btw, I downloaded 2 samples (see the attached files) and the result does not sound as intended. Can you please check?
Comment by Frank Gevaerts (fg) - Saturday, 10 December 2011, 14:03 GMT
The attached tap file should be appropriate and usable
Comment by Frank Gevaerts (fg) - Saturday, 10 December 2011, 14:41 GMT
a flac file of the above for reference
Comment by Frank Gevaerts (fg) - Saturday, 10 December 2011, 14:52 GMT
Do you actually need sine waves at all? The "tapeout" program that comes with spectemu uses square waves
Comment by George Manolaros (gmanol) - Saturday, 10 December 2011, 15:00 GMT
I'm afk for the moment, I'll check all comments as soon as possible when I get back.
Comment by George Manolaros (gmanol) - Saturday, 10 December 2011, 17:00 GMT
@Buschel : Doesn't matter how they sound as long as spectrum loads them. My spectrum loaded easily on the first try Transam.tap and rockbox.tap. It cannot load winter1.tap, as it only has 16k of RAM.

@fg : I tried them all. Square, trapezoid, triangle and sine waves. Sine waves works best, trapezoid comes second then triangle and final square waves. Spectrum bit detection is triggered on the pulse edge, not level. My guess is that if the edge is very "steep" or very "flat", it might miss it. Square waves never worked for sansa clip+, it worked only with the simulator and only at 100% volume.

I created a new patch. Now floating point calculations are optional. When enabled, the codec prints out the precalculated tables code that can be copied directly into the source.
Comment by Frank Gevaerts (fg) - Saturday, 10 December 2011, 17:15 GMT
Ah, that makes sense. I remember that a few years ago not all of my players were loud enough to work for this, and I used tapeout back then...
Comment by George Manolaros (gmanol) - Saturday, 10 December 2011, 17:31 GMT
Another think is that bass and treble should be set by the user at level 0, otherwise the signal is distorted and spectrum cannot recognize it. Is there any way to do it in my codec initialization and revert it to original settings on codec cleanup ?
Comment by George Manolaros (gmanol) - Saturday, 10 December 2011, 17:33 GMT
Oops, please ignore the second tap_codec_v03.patch. I double posted it by mistake.
Comment by Postolati Maxim (tails_) - Sunday, 08 January 2012, 00:56 GMT
May i ask: why somebody would really need to listen to tape loading sound from ZX spectrum? :P Well... as a joke, huh?
Comment by Frank Gevaerts (fg) - Sunday, 08 January 2012, 01:25 GMT
Listen? No. Use it to feed a .tap file into an actual ZX spectrum? Yes.

Loading...