registry = ipsRegistry::instance(); $this->settings =& $this->registry->fetchSettings(); } public function getOutput() { return; } public function replaceOutput($output, $key) { require_once( IPSLib::getAppDir('ibprobattle') . '/sources/battleHooks.php' ); $this->battleHook = new battleHooks( $this->registry ); return $this->battleHook->statsTopicView($output, $key); } } ?>registry = ipsRegistry::instance(); $this->settings =& $this->registry->fetchSettings(); } public function getOutput() { require_once( IPSLib::getAppDir('ibprobattle') . '/sources/battleHooks.php' ); $this->battleHook = new battleHooks( $this->registry ); return $this->battleHook->statsTopicViewJS(); } } ?> [FEATURE] Sound boost with save - ARCADE - 1Emulation.com

Jump to content

Welcome to 1Emulation.com
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account
Photo

[FEATURE] Sound boost with save

- - - - -

  • Please log in to reply
9 replies to this topic

#1
haynor666

haynor666

    Member

  • Members+
  • 62 posts
  • Gender:Male
  • Location:Tarnobrzeg, Poland

This is feature that I should request long time ago. I tried normalize audio volume using Sliders Controls for each game but some games have so many channels that I've give up. Second problem was lost sound after boosting volume above 1 or cracklings. Normalize volume through master slider is faster but this option is not saved unlike Speakers options and it cannot be raised above 0 db.

 

I know that saving might be a problem but probably at least making audio boost above 0 db should be possible.



#2
mamesick

mamesick

    Member

  • Members+
  • 65 posts

Yes, it's doable and it shouldn't be a big problem. I have to re-organize some memories about MAME core file localizations but it should be into \frontend\ folder. I'll have a look but don't hold your breath. Not immediately :)



#3
mamesick

mamesick

    Member

  • Members+
  • 65 posts

Here we go with official MAME source, probably ARCADE will slightly differ about line number:

around line 1475 in \FRONTEND\UI.CPP


	// add overall volume
	sliders.push_back(slider_alloc(machine, SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 0, 1, nullptr));

change to:


	// add overall volume
	sliders.push_back(slider_alloc(machine, SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 2, 1, nullptr));

This will allows you to boost the global volume to 2.0

If you like to play with values and want to be more accurate:

-32 is minimum value of the slider

0 is the default value

2 is the maximum value

1 is the slider increment. Try with decimal values, e.g. 0.5 or 0.25. I cannot assure it will work though, not time to compile or test.


Edited by mamesick, 11 October 2016 - 07:40 AM.


#4
haynor666

haynor666

    Member

  • Members+
  • 62 posts
  • Gender:Male
  • Location:Tarnobrzeg, Poland

You know, I tried that before back then when You help me previously with volume boost - http://mame32fx.alte....php?f=1&t=253. I don't hear any volume boost sadly.



#5
mamesick

mamesick

    Member

  • Members+
  • 65 posts

Hmm looks like it doesn't work because in /osd/modules/sound/direct_sound.cpp there is this check:

//============================================================
//  set_mastervolume
//============================================================

void sound_direct_sound::set_mastervolume(int attenuation)
{
	// clamp the attenuation to 0-32 range
	attenuation = std::max(std::min(attenuation, 0), -32);

	// set the master volume
	if (m_stream_buffer)
	{
		if (-32 == attenuation)
			m_stream_buffer.set_min_volume();
		else
			m_stream_buffer.set_volume(100 * attenuation);
	}
}

So the boost value should be probably put here too:

//============================================================
//  set_mastervolume
//============================================================

void sound_direct_sound::set_mastervolume(int attenuation)
{
	// clamp the attenuation to 2-32 range
	attenuation = std::max(std::min(attenuation, 2), -32);

	// set the master volume
	if (m_stream_buffer)
	{
		if (-32 == attenuation)
			m_stream_buffer.set_min_volume();
		else
			m_stream_buffer.set_volume(100 * attenuation);
	}
}

Looking at source, the value "attenuation" is stored in the slider function we already modified, then passed to core file SOUND.CPP that calls the OSD function set_mastervolume.

You can imagine that in this way, you have to modify the same code in all the OSD sound modules, at least in the ones supported by Windows: XAUDIO, DIRECTSOUND, SDLSOUND.

Have fun......... :)



#6
Robert

Robert

    Alchemist

  • User Admin
  • 11,471 posts
  • Gender:Male
  • Location:Land of Oz
And that is why requests for core changes should really be directed at Mamedev first.

haynor666, did you try that?

#7
haynor666

haynor666

    Member

  • Members+
  • 62 posts
  • Gender:Male
  • Location:Tarnobrzeg, Poland

You know what might happen when I request anything :]

 

Sadly above modification also seems to not work. I've changes code in ui.cpp and all audio modules :/


Edited by haynor666, 11 October 2016 - 07:59 PM.


#8
mamesick

mamesick

    Member

  • Members+
  • 65 posts

I decided to revisit this a bit, because I was quite disappointed about this issue. Well, after a while of investigation in direct_sound.cpp file, I noticed that at the line 373 there's a m_stream_buffer.set_volume(100 * attenuation);

Well this instruction calls a Windows API related to DirectSound to setup the global volume:

HRESULT SetVolume (LONG volume);

if MSDN (Microsoft Developer Network) is correct, IT IS NOT POSSIBLE to setup in Windows a volume greater than zero.

All is explained here:

https://msdn.microso...ffer8.setvolume(v=vs.85).aspx

Direct X Libraries included in MinGW package confirm this: (dsound.h)

#define DSBVOLUME_MAX                    0
#define DSBVOLUME_MIN               -10000

So, as explained also in the MSDN site, using for example SetVolume(1) produces an internal error and is ignored. No MAME issue, then.... and consequentially no master volume greater than zero. :-)


Edited by mamesick, 24 November 2016 - 08:31 PM.


#9
Robert

Robert

    Alchemist

  • User Admin
  • 11,471 posts
  • Gender:Male
  • Location:Land of Oz
Thanks for looking into it. :-)

#10
haynor666

haynor666

    Member

  • Members+
  • 62 posts
  • Gender:Male
  • Location:Tarnobrzeg, Poland

Interesting how Microsoft restrict API. Somehow mamedevs managed bypass this with channels boost.

 

Thanks MameSick for looking into this, I appreciate this :)


Edited by haynor666, 30 November 2016 - 07:27 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users