Re: [hatari-devel] Sample frame buffer is incorrectly restarted

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Le 01/02/2024 à 21:06, Miro Kropáček a écrit :
Hi,

I have a pretty simple test prg: https://pastebin.com/YgVzqwfc <https://pastebin.com/YgVzqwfc> (attached). It takes "en.raw" as input by default or any other file if specified as argv[1]. It's a raw sample (preferably quite long) 24585 Hz / 16-bit / stereo.

It may look strange at the first sight but it's supposed to emulate one specific behaviour: direct-from-disk sample playback which occasionally (in my case always) doesn't make it, i.e. the playback repeat doesn't play a fresh part from the disk but the same one already present in the buffer.

The idea is to detect this behaviour and if so, disable playback so instead of the stuttering there will be only silence. And as soon as there's an opportunity, start the playback again.

This works on real hardware (Falcon030/060). However in Hatari, it behaves like this:

  * sample is played back
  * there's a pause for 500 VBLs
  * after the pause a new buffer is loaded, playback continues
  * but the buffer is played twice (???)

It's best audible with some real song as the sample so one can hear repeated sentences. If you are struggling with generating such a sample, just let me know, I'll upload it somewhere.

Also, if I'm doing something stupid and it works only by chance on Falcon, I'm also all ears.

Hi

the low level docs for Falcon are rather hard to find ; for STE or TT atari published some docs with all new registers, but I was not able to find similar Atari's docs for falcon.

So, Hatari is based on reg listing such as this one http://ftp.lip6.fr/pub/atari/Docs/hardware.txt + reports/research from other users.

Maybe these docs are wrong when they say timer A is triggered at the end of the buffer ? Because on STE/TT timer A is triggered when the new address is loaded into internal DMA register, ie when the sample starts playing, not at the end.

Could you add some printf's to your program to check on a real Falcon when Timer A is called ?

2 printfs after Setbuffer, 1 printf at the end of timerA routine


line 68 :  Setbuffer(SR_PLAY, phys, phys + sampleBufferSize);
add after : printf ( "setbuffer init %p %d\n" , phys , (volatile unsigned long *)0x454) );

line 82 : Setbuffer(SR_PLAY, phys, phys + sampleBufferSize);
add after : printf ( "setbuffer loop %p %d\n" , phys , (volatile unsigned long *)0x454) );

line 31, before the end of timerA(void) function, add :

printf ( "timerA %p %d\n" , frameAddr , (volatile unsigned long *)0x454) );


This should show the order / delay for timer A relative to each new sample address, which will be easier to compare with Hatari


Nicolas




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/