[hatari-devel] Interesting sound problems with Hatari?

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

So apart from the issues already discussed by Laurent/David, I'm having my own world of pain at the moment with another sound issue, and which *seems* to be limited to Hatari based on what I have been able to try so far.

I am doing my best to narrow this down but it is difficult indeed :) So here is what I can tell you.

1) I'm getting distortion while playing back samples in Hatari while emulating F030. (I've been trying to rule out real HW but I'm having other problems with the machine so haven't managed it quite yet). 

2) The distortion seems to be related to double-buffering of the DMA pointers which keep the Codec fed continuously with data (think modplayer here). The distortion seems to have a period which roughly matches the buffer length. I currently use a DMA page size of 246 samples, if that means anything to anyone (12khz @ 50hz period).

3) The values involved in the distortion seem to be random but I am not 100% sure since I'm looking at captures of audio output from the emulator.

4) The distortion does not seem to be present in the memory pages being DMA'd to the Codec - filling a circular buffer with the same data and dumping it out looks *correct* and contiguous.

5) The addressing used to increment through the sample has been fixed at one unit (i.e. a direct 1:1 copy of the sample to the DMA buffers with no skipping/duplication of bytes). I have ruled out the mixer code being faulty also - 3 different variants produce identical results.

6) Recording the individual sample *indexes* to a circular buffer shows the expected pattern of 0,1,2,3... until the loop point, after which it resets to 0 and continues for as long as I let it. No problems there either. Loop point in source sample never varies.

7) I tried decoupling the DMA pages using 8 buffers and reading (codec) / writing (my mixer code) 4 buffers apart to be absolutely sure the DMA'd pages are not being written while in use - no improvement. Not the cause.

Other interesting points:

- A very large noise signature can be obtained by just changing Hatari's 'playback quality'. Setting it to 50khz while playing samples at 12khz via the Falcon's Codec results in... mostly noise and not much signal left (see linked capture below). This might just be due to a lack of filtering but it seems to be really, really bad (!).
- Changing the playback quality does not stop the periodic distortion - it just adds more noise per individual sample event.

I have linked a screengrab of what I get from Hatari in the 2 'quality' modes, playing one looped sample.


The top capture is the original sample @ 22khz.

The middle capture is replay within Hatari @ 12khz codec rate, but 50khz Hatari quality (yikes! look at the noise levels!).

The lower capture is the same, but set to 12khz Hatari quality. This is the most interesting one - notice the spikes/glitches at spaced intervals?

I'm still looking into this and doing what I can to isolate possible causes but I'm running out of things to look at in my code. Can anything strange be going on in Hatari which could cause the glitches on each DMA page change? Could it be related to the host OS sound interface, or must it be within the emulation layer or the emulated code?


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