Kega Fusion v3.63

Talk about development tools here

Moderator: BigEvilCorporation

vanfanel
Newbie
Posts: 3
Joined: Fri Oct 30, 2009 10:06 am

Post by vanfanel » Fri Oct 30, 2009 10:13 am

Hello there, Snake! In the first place, I want to say that your emulators have been a ray of light for me since I swithed from Amiga to PC back in 1997. Thanks for all your work and the enjoyment it brings me!

In the other hand, I want to ask for a little feature in Kega Fusion (Linux port is the one I use, as I prefer light systems like my Gentoo minimal system): I would like to have an option for 48000Hz sound output. Why?
Because my sound chip (an HDA variant) has a native audio frenquency output of 48Khz and most HDA sound chips have the same output frequency: hence when using a emulator that outputs at that frequency, no conversion is involved in the ALSA driver code and CPU usage drops down A LOT!

I'm talking about the final sound output, not the genesis opl frequency.

It allows me to use smaller buffer sizes in the ALSA driver , too :)
Maybe I can get 48000Hz output by tweaking some variable in the config file? If it's the case, please tell me.

Thanks!

Flygon
Very interested
Posts: 60
Joined: Mon Sep 28, 2009 11:26 am
Contact:

Post by Flygon » Fri Oct 30, 2009 11:15 am

I too am interested in a 48000Hz option. Partially because I like big numbers. :lol:

Huge
Very interested
Posts: 197
Joined: Sat Dec 13, 2008 11:50 pm

Post by Huge » Fri Oct 30, 2009 4:52 pm

Kega would then need to upsample 44.1khz cd audio to 48khz, which is potentially less flexible, and wastes whatever cpu time you gain at your drivers.
Of course it wouldn't matter for non-cd games, but it would be a huge pain for those. So there's kinda no point at adding higher sampling rates (except maybe 88.2khz, but I'm sure someone will come along and say "that's not how sampling rates work", because, well, that's not how sampling rates work).


Perhaps you could get drivers with more effective driver resampling, or a sound chip that supports 44.1khz native samplingrate (the only hardware I've ever seen that can't do this is the popular E-MU line, also used in the soundblasters from the Live and up).

Also, sound resampling should have unnoticable cpu usage on any modern hardware, compared to accurate Megadrive emulation anyway. If resampling itself shows a noticable spike, then your machine is likely insufficient for running Kega to begin with.

vanfanel
Newbie
Posts: 3
Joined: Fri Oct 30, 2009 10:06 am

Post by vanfanel » Sun Nov 01, 2009 5:35 pm

That's not totally true, Huge: conversion to 48Khz before the final output takes A LOT of CPU in my system. I really need 48Khz in the Linux port, as I've had the same problems with every emulator around: I know what I'm talking about. Please, don't try to avoid Snake adding it: a lot of people with ALSA drivers with 48Khz as their native frequency will be fine with this. My system specs are out of question here: It IS far enough, and I don't have any problems with KEGA as it is, but there's no reason to use a lot of CPU when it can be avoided with souch a little option.

Thanks

LocalH
Very interested
Posts: 152
Joined: Tue Dec 19, 2006 5:04 pm

Post by LocalH » Wed Nov 04, 2009 4:14 pm

Huge wrote:Kega would then need to upsample 44.1khz cd audio to 48khz, which is potentially less flexible, and wastes whatever cpu time you gain at your drivers.
Nothing wrong with the option being there, though. Perhaps Steve could throw a dialog up if the user chooses 48KHz then plays a CD game (to inform them that 48KHz and CD causes CPU usage to increase).

IMO, it has nothing to do with CPU usage for sample rate conversion, but the fact that sample rate conversion is inherently lossy. If one has hardware that natively outputs 48KHz and converts everything else in the driver, then one would get optimal audio output if Kega had a 48KHz option in the first place.

And nowadays there is more and more hardware being released and sold that targets 48KHz and higher, since many modern computers are used to watch DVDs, which are pretty much 48KHz in terms of commercial discs (yes, it's possible to make a DVD with 44.1KHz audio but I can't remember the last commercial DVD I saw with 44.1KHz audio).

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Nov 04, 2009 6:38 pm

vanfanel wrote:That's not totally true, Huge: conversion to 48Khz before the final output takes A LOT of CPU in my system. I really need 48Khz in the Linux port, as I've had the same problems with every emulator around: I know what I'm talking about. Please, don't try to avoid Snake adding it: a lot of people with ALSA drivers with 48Khz as their native frequency will be fine with this. My system specs are out of question here: It IS far enough, and I don't have any problems with KEGA as it is, but there's no reason to use a lot of CPU when it can be avoided with souch a little option.

Thanks
Conversion between two frequencies is slow when you use SDL because SDL only uses the "fast" converter when the two frequencies are easy multiples of each other (like powers of two). If they aren't it defaults to the "slow" converter... which is really slow. On a modern PC, you don't tend to notice how slow the slow routines are since they are normally only used when a sound is loaded. A stream will show how slow they slow converter is. A slow computer will also show how slow it is - versions of Duke Nukem 3D that use SDL will, on a slow computer, given a brief jerk when a sound effect plays (or not so brief depending on how slow the computer is). That is because it uses the slow converter. It was such a bad slow-down that people forced SDL to use the "fast" converter, even though it wouldn't sound right (you wound up with the pitch wrong since the fast converter only converted into/from powers of two).

So I modified my local SDL to have a decent slow converter for when the frequencies aren't related. This made D3D sound right with no jerking.

From SDL/src/audio/SDL_audiocvt.c

Code: Select all

/* Very slow rate conversion routine */
void SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
{
	int ipos, incr;
	int i, clen;

#ifdef DEBUG_CONVERT
	fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0/cvt->rate_incr);
#endif
	incr = (int)(cvt->rate_incr * 512.0f);
	clen = (int)((float)cvt->len_cvt / cvt->rate_incr);
	if ( cvt->rate_incr > 1.0 ) {
		switch (format & 0xFF) {
			case 8: {
				Uint8 *output;

				output = cvt->buf;
				ipos = 0;
				for ( i=clen; i; --i ) {
					*output = cvt->buf[ipos>>9];
					ipos += incr;
					output += 1;
				}
			}
			break;

			case 16: {
				Uint16 *output;

				clen &= ~1;
				output = (Uint16 *)cvt->buf;
				ipos = 0;
				for ( i=clen/2; i; --i ) {
					*output=((Uint16 *)cvt->buf)[ipos>>9];
					ipos += incr;
					output += 1;
				}
			}
			break;
		}
	} else {
		switch (format & 0xFF) {
			case 8: {
				Uint8 *output;

				output = cvt->buf+clen;
				ipos = cvt->len_cvt<<9;
				for ( i=clen; i; --i ) {
					ipos -= incr;
					output -= 1;
					*output = cvt->buf[ipos>>9];
				}
			}
			break;

			case 16: {
				Uint16 *output;

				clen &= ~1;
				output = (Uint16 *)(cvt->buf+clen);
				ipos = cvt->len_cvt<<8;
				for ( i=clen/2; i; --i ) {
					ipos -= incr;
					output -= 1;
					*output=((Uint16 *)cvt->buf)[ipos>>9];
				}
			}
			break;
		}
	}
	cvt->len_cvt = clen;
	if ( cvt->filters[++cvt->filter_index] ) {
		cvt->filters[cvt->filter_index](cvt, format);
	}
}
Notice that (among other changes) the routine uses fixed point math instead of floating point like the original routine did. You also need to enable this in the SDL_BuildAudioCVT() function a little below the above function

Code: Select all

		/* We may need a slow conversion here to finish up */
		if ( (lo_rate/100) != (hi_rate/100) ) {
#if 0
			/* The problem with this is that if the input buffer is
			   say 1K, and the conversion rate is say 1.1, then the
			   output buffer is 1.1K, which may not be an acceptable
			   buffer size for the audio driver (not a power of 2)
			*/
			/* For now, punt and hope the rate distortion isn't great.
			*/
#else
			if ( src_rate < dst_rate ) {
				cvt->rate_incr = (float)lo_rate/hi_rate;
				cvt->len_mult *= 2;
				cvt->len_ratio /= cvt->rate_incr;
			} else {
				cvt->rate_incr = (float)hi_rate/lo_rate;
				cvt->len_ratio *= cvt->rate_incr;
			}
			cvt->filters[cvt->filter_index++] = SDL_RateSLOW;
#endif
		}
In the original code, the "#if 0" will be an "#if 1". Their "punt and hope the rate distortion isn't great" was quick, but sounded bad for games like D3D.

King Of Chaos
Very interested
Posts: 273
Joined: Fri Feb 29, 2008 8:12 pm
Location: United States

Post by King Of Chaos » Sun Nov 08, 2009 6:03 pm

Eidolon's Inn is back up guys. :)

vanfanel
Newbie
Posts: 3
Joined: Fri Oct 30, 2009 10:06 am

Post by vanfanel » Tue Nov 10, 2009 10:11 am

Tha's great news! Thanks, King!

LocalH
Very interested
Posts: 152
Joined: Tue Dec 19, 2006 5:04 pm

Post by LocalH » Tue Nov 17, 2009 1:19 am

Ok, I'm having a minor problem that I am having problems trying to wrap my head around.

I have an older Duron box (sub-1GHz) that I threw WinME on. Fusion itself runs fine on this machine (frameskips in windowed but fullspeed in fullscreen, so I'm happy there). The issue is that I can't seem to get RPI plugins to appear in the menu. I've tried using a Plugins subdir, I've tried plopping the RPIs straight in Fusion's folder, and I've tried starting over with a virgin copy of Fusion, but the submenu will not appear. Is this a known issue with the 9x series of kernels and Fusion 3.63, or have I just discovered an obscure bug? =P

I was mainly interested in running the NTSC filter on this machine, but I can't see any of them. I have not tried any other filters by themselves, so it is possible that it might be an incompatibility between the NTSC filter and WinME.

Alternately, if this is just due to the fact that I'm running 3.63 on ME instead of 2k/XP, is there an earlier version of Fusion that might work for what I want to do? I mainly plan on using this machine for a bit of gaming as well as coding, so I'd really like to be able to see the NTSC artifacts without having to load a ROM to my Genesis every single time (my general workflow is to primarily do emulator testing, followed by hardware testing at key points in development).

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Nov 17, 2009 10:25 am

You should use a 98SE with AutoPatcher, ServicePack3.4, KernelEx, Revolutions Pack9 and Maximum Decim's USB Stack 3.3 instead of the puny MegaError :P

I need to get some RPIs and see if I get same problem.... I do recall having no problems with those.... we'll see soon.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

LocalH
Very interested
Posts: 152
Joined: Tue Dec 19, 2006 5:04 pm

Post by LocalH » Tue Nov 17, 2009 4:57 pm

TmEE co.(TM) wrote:You should use a 98SE with AutoPatcher, ServicePack3.4, KernelEx, Revolutions Pack9 and Maximum Decim's USB Stack 3.3 instead of the puny MegaError :P

I need to get some RPIs and see if I get same problem.... I do recall having no problems with those.... we'll see soon.
I had problems getting 98SE set up on this machine, I think there are some hardware problems (bad RAM perhaps). I also had problems installing 2k and XP as well.

Post Reply