Re: [hatari-devel] Falcon left-right sound swapper bug?

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


Hi David,

I don't thing the bug is here :

The aim of this code is to separate the sound into a left and a right part.

The sound in the falcon memory is :

LLRRLLRRLLRRLLRR

LL = 1 8 bits or 1 16 bits value
RR = 1 8 bits or 1 16 bits value

The result into the 2 buffers will look like this :

Left_buffer   : LLLLLLLLLLLL
Right_buffer : RRRRRRRRRR


So, if I read the 1st value (the left voice one), I put it into the left buffer If I read the 2nd value, I put it into the right buffer and I've finished for this sound position --> increment the sound buffers (left and right) to the next data.

If you put the dac.writePosition = (dac.writePosition + 1) % (DACBUFFER_SIZE); line after the if, the buffer will look like :

Left_buffer   : LL00LL00LL
Right_buffer : 00RR00RR00

Anyway, I may misendurstand myself. ;)

The thing I find curious into the crossbar sound is that sometimes, the sound is nice and sometimes, it sounds crappy (with the same program). For example, when I launch Racer, the music is sometimes nice to hear and sometimes noisy with cracks...
I haven't found yet why.

But I think that may be that there's a synchro with a VBL or HBL order missing into the crossbar. Actually, when a value into the crossbar changes, I take it into account immedialty (recomputing of the frequency, the 8/16 bits size, ...).
Maybe there's something missing (a buffer, ...)

Another point, into the crossbar (the hardware component, not the emulated code ), there are 2 little buffers (of 32 bytes if I'm right) for the left and the right tracks. These buffers can be emply, full, ... and you can test their state with 0xff893c

/**
 * Write word to CODEC status register (0xff893c).
 *     Bit 1 :  Left Channel Overflow (0/1)
 *     Bit 0 : Right Channel Overflow (0/1)
 */
void Crossbar_CodecStatus_WriteWord(void)
{
LOG_TRACE(TRACE_CROSSBAR, "Crossbar : $ff893c (CODEC status) write: 0x%04x\n", IoMem_ReadWord(0xff893c));
}



I never implemented these 2 buffers (I'm reading directly the sound data from the atari memory.
This could increase the sound quality.
I think Nicolas implemented such buffers into the STE emulation part.

Best regards

Laurent






Le 16/04/2014 02:58, David Savinkoff a écrit :
Hi,

I looked at line 1772 of /hatari/src/falcon/crossbar.c and found a
possible bug:

static void Crossbar_SendDataToDAC(Sint16 value, Uint16 sample_pos)
{
	Uint16 track = crossbar.track_monitored * 2;

	if (sample_pos == track) {
		/* Left channel */
		dac.buffer_left[dac.writePosition] = value;
	}
	else if (sample_pos == track + 1) {
		/* Right channel */
		dac.buffer_right[dac.writePosition] = value;
/*Bug*/		dac.writePosition = (dac.writePosition + 1) % (DACBUFFER_SIZE);
	}
}

Shouldn't the /*Bug*/ line be After the 'if' statement ?

Sincerely,
David Savinkoff







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