Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST track playing slow #22

Open
Gunstick opened this issue Feb 18, 2023 · 6 comments
Open

ST track playing slow #22

Gunstick opened this issue Feb 18, 2023 · 6 comments

Comments

@Gunstick
Copy link

This track is playing too slow:
https://sndh.atari.org/?ID=1441

I am speculating that it's because of the 200Hz?
Checked with command line: same problem.

@frno7
Copy link
Owner

frno7 commented Feb 18, 2023

Hmm. Stax/Es_Geht_Oder.sndh doesn’t seem to have any SNDH tag indicating it’s supposed to be played at 200 Hz:

% psgplay -i Stax/Es_Geht_Oder.sndh
psgplay: warning: Stax/Es_Geht_Oder.sndh: missing HDNS tag
path Stax/Es_Geht_Oder.sndh
tag field COMM Stax
tag field RIPP Grazey / PHF
tag field CONV Grazey / PHF
tag field TITL Es Geht! Oder
tag field ## 1
header size 88
data size 75038

The SNDH format documentation is clear on the matter of defaulting to 50 Hz:

psgplay/doc/sndhv21.txt

Lines 82 to 83 in f44740e

;Timer C - The default timer if nothing is specified. Default speed
; is 50Hz. Use Timer C playback wherever possible. It hooks

It’s relatively easy to fixup an SNDH header, as explained in the disassembly section of the README file, if you’d like to give it a try by adding a presumably missing TC200 tag? :-) Here’s an example of having that tag:

% psgplay -i 505/Spacedisko.sndh
psgplay: warning: 505/Spacedisko.sndh: tag TITL malformed whitespace
psgplay: error: 505/Spacedisko.sndh: unrecognised data in 32 bytes at offset 136
path 505/Spacedisko.sndh
tag field TC 200
tag field COMM xyce & 505
tag field RIPP Evil
tag field CONV Music-Mon V2.5e
tag field TITL SPACEDISKO      
header size 136
data size 39258

@Gunstick
Copy link
Author

For me, there is a TC200 in the file. But it's after the ##1, so maybe psgplay ignores it?

$ strings Es_Geht_Oder_unice.sndh 
|SNDHCOMMStax
RIPPGrazey / PHF
CONVGrazey / PHF
TITLEs Geht! Oder
##01
TC200
 _Nu
a<"z

Trying my own tooling...

$ patchsndh.py 
usage: patchsndh.py [-h] [--composer COMPOSER] [--title TITLE] [--year YEAR]
                    [--converter CONVERTER] [--ripper RIPPER] [--force]
                    filename

Luckily I made the script output what it finds, and there is TC200 there:

$ patchsndh.py Es_Geht_Oder_unice.sndh 
composer: b'Stax'
ripper: b'Grazey / PHF'
converter: b'Grazey / PHF'
title: b'Es Geht! Oder'
subtunes: b'01'
timer C: b'200'

But the script hangs while reading the header. There should be an "end of header". So there is clearly something bad with the file.

@frno7
Copy link
Owner

frno7 commented Feb 19, 2023

For me, there is a TC200 in the file. But it's after the ##1, so maybe psgplay ignores it?

Arbitrary tag ordering is accepted, except that PSG play expects the HDNS tag to be absolutely last, but it isn’t, so it complains with psgplay: warning: Stax/Es_Geht_Oder.sndh: missing HDNS tag. Maybe it could be more forgiving, but then again, it’d be even better to actually fix the SNDH file.

But the script hangs while reading the header.

PSG play infers that the tags are bounded by the branch targets,

psgplay/lib/psgplay/sndh.c

Lines 314 to 316 in f44740e

branch_bound(&bound, 0, data, 4);
branch_bound(&bound, 4, data, 8);
branch_bound(&bound, 8, data, 12);

so no tags beyond _init, as shown with psgplay --disassemble-header Stax/Es_Geht_Oder.sndh:

init:
        bra.w   _init                           ; init
exit:
        bra.w   _exit                           ; exit
play:
        bra.w   _play                           ; play
sndh:
        dc.b    $53,$4e,$44,$48,$43,$4f,$4d,$4d ; SNDHCOMM
        dc.b    $53,$74,$61,$78,$00,$52,$49,$50 ; Stax.RIP
        dc.b    $50,$47,$72,$61,$7a,$65,$79,$20 ; PGrazey 
        dc.b    $2f,$20,$50,$48,$46,$00,$43,$4f ; / PHF.CO
        dc.b    $4e,$56,$47,$72,$61,$7a,$65,$79 ; NVGrazey
        dc.b    $20,$2f,$20,$50,$48,$46,$00,$54 ;  / PHF.T
        dc.b    $49,$54,$4c,$45,$73,$20,$47,$65 ; ITLEs Ge
        dc.b    $68,$74,$21,$20,$4f,$64,$65,$72 ; ht! Oder
        dc.b    $00,$23,$23,$30,$31,$00,$54,$43 ; .##01.TC
        dc.b    $32,$30,$30,$00                 ; 200.
_init:
        dc.b    $61,$00,$00,$c0,$41,$fa,$66,$00
        dc.b    $22,$08,$41,$fa,$13,$f2,$43,$fa
        dc.b    $01,$8e,$23,$48,$00,$04,$70,$01
        dc.b    $61,$00,$01,$8c,$43,$fa,$00,$0c
        dc.b    $22,$88,$4e,$75
_exit:
        dc.b    $61,$00,$00,$18,$4e,$75,$00,$00
        dc.b    $00,$00
_play:
        dc.b    $48,$e7,$ff,$fe,$22,$7a,$ff,$f6
        ...

There should be an "end of header". So there is clearly something bad with the file.

Yeah. :-)

@frno7
Copy link
Owner

frno7 commented Feb 20, 2023

By the way, the SNDH archive v4.8 release contains approximately 439 tag errors and 3113 tag warnings, of which 1486 relate to the missing HDNS tag:

% find . -iname '*'.sndh | sort | parallel psgplay -i 2>&1 | grep error: | wc -l
439
% find . -iname '*'.sndh | sort | parallel psgplay -i 2>&1 | grep warning: | wc -l
3113
% find . -iname '*'.sndh | sort | parallel psgplay -i 2>&1 | grep "missing HDNS tag" | wc -l
1486

@Gunstick
Copy link
Author

I think old SNDH format did not have an HDNS trailer. The address of init was the end.
I think it's a good idea to make my python tool understand broken files and publish it so people can update all the files to the newest format.

@frno7
Copy link
Owner

frno7 commented Feb 21, 2023

That’d be good. Here’s a summary of tag warnings, ordered by frequency by find . -iname '*'.sndh | sort | parallel psgplay -i 2>&1 | grep warning: | sed 's/^.*sndh: //' | sort | uniq -c | sort -rn:

   1486 missing HDNS tag
    786 tag YEAR empty
    341 tag RIPP malformed whitespace
    221 tag RIPP empty
    155 tag TITL malformed whitespace
     97 tag ## missing NUL termination
      7 tag !#SN empty
      5 tag COMM malformed whitespace
      4 tag !# malformed number: ST
      4 tag CONV empty
      2 tag !#SN missing NUL termination
      2 tag !#SN contains nonprintable characters: ^G
      1 tag !#SN malformed whitespace
      1 tag FLAG missing NUL termination
      1 tag CONV malformed whitespace

Likewise for tag errors:

    438 unrecognised data
      1 tag TIME too short

Listing all tag warnings and errors per file by find . -iname '*'.sndh -printf '%P\n' | sort | parallel psgplay -i 2>&1 | grep -E 'warning|error:':

psgplay: warning: 4-Mat/Beastbusters.sndh: tag YEAR empty
psgplay: warning: 4-Mat/Bubble_Dizzy.sndh: tag RIPP malformed whitespace
psgplay: warning: 4-Mat/Bubble_Dizzy.sndh: tag TITL malformed whitespace
psgplay: warning: 4-Mat/Bubble_Dizzy.sndh: missing HDNS tag
psgplay: warning: 4-Mat/Captain_Dynamo.sndh: tag RIPP malformed whitespace
psgplay: warning: 4-Mat/Chuck_Rock.sndh: tag RIPP malformed whitespace
psgplay: error: 4-Mat/Chuck_Rock.sndh: unrecognised data in 1 bytes at offset 85
psgplay: warning: 4-Mat/Dizzy-Prince_Of_Yolkfolk.sndh: tag TITL malformed whitespace
psgplay: warning: 4-Mat/Dizzy-Prince_Of_Yolkfolk.sndh: tag RIPP malformed whitespace
psgplay: warning: 4-Mat/G-Loc.sndh: tag RIPP malformed whitespace
psgplay: warning: 4-Mat/G-Loc.sndh: missing HDNS tag
psgplay: warning: 4-Mat/Magicland_Dizzy.sndh: tag RIPP malformed whitespace
psgplay: warning: 4-Mat/Magicland_Dizzy.sndh: tag TITL malformed whitespace
psgplay: error: 4-Mat/Magicland_Dizzy.sndh: unrecognised data in 1 bytes at offset 87
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants