flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.36k stars 167 forks source link

Track 02 cannot be played at the correct length in the music player #1386

Closed kihato closed 7 months ago

kihato commented 7 months ago

Windows11 / i7-10700F / GTX 1660 SUPER

Github hash: c146a92

Currently, when I play track 02, it is cut off or there is continuous silence.

This is because the readout start sector is fixed at 13085. Therefore, it is necessary to vary the readout start sector depending on the file size of track 02.

I tested it in my environment as follows and it worked fine.

Also, the reason why I added 75 sectors to the end of the single-density readout FAD calculation formula is because it felt strange when I listened to it when I transitioned from the end of track 02 to the beginning of track 04. (I don't know the reason for this.)

https://github.com/flyinghead/flycast/assets/14366233/874686e5-d460-40c0-9fb9-de34c3f46932

gdi.cpp

...
struct _stat buf;
...
t.file = new RawTrackFile(file, OFFSET, t.StartFAD, SSIZE);
if (i == 1 && _stat(path.c_str(), &buf) == 0)
        tr02.size = buf.st_size;
...

common.h


...
struct Track02
{
u32 size;
};

extern Track02 tr02;


>common.cpp

```C++
...
Track02 tr02;
...
if (disc->type == GdRom && area == SingleDensity)
{
    // use smaller LEADOUT
    //to[101] = createTrackInfo(disc->LeadOut, 13085);
    u32 LeadOut0 = disc->tracks[1].StartFAD + tr02.size / 2352 + 75;
    to[101] = createTrackInfo(disc->LeadOut, LeadOut0);
}
...
flyinghead commented 7 months ago

This should be fixed in the latest dev build. I used the actual size of track 2 to set the single density area lead-out but didn't add 75 frames based on this video: https://www.youtube.com/watch?v=aljBDyC3Ues It's true that Shenmue's track 2 ends abruptly, but adding a one-second delay makes the time counter reach 0:05 with this gd-rom (Re-Volt US), which doesn't seem to happen on this video.

kihato commented 7 months ago

Apparently an uncounted delay is inserted just before the actual track 04 is played. You can check the basis for this by playing the video below frame by frame.

US Shenmue (Disc3)

Keyboard shortcuts

k - Pause/Play in player. . (period) - While the video is paused, skip to the next frame. , (comma) - While the video is paused, go back to the previous frame.

https://youtu.be/FFzMoxEL3hc?t=120

Start of track 04 (00:00) (The woman on the label is pointing her head downwards) The sound of track 04 is heard (with the woman on the label facing upwards) After about 40 frames or more (on YouTube) 106 frames (number of frames it took for the count to reach 00:01) This video has 60 frames per second, so you can see that there is 46 frames of silence.

You can also check the Revolt video, but this video has 30 frames per second, so the numbers will change slightly. In any case, it seems that something is being done, but I don't know what it is, so I'll close this issue for now. Thanks!