Go Back   Project64 Forums > General Discussion > Open Discussion

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 22nd April 2013, 05:00 PM
shunyuan's Avatar
shunyuan shunyuan is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Apr 2013
Posts: 491
Default Shunyuan's HLE audio plugin v1.8.2u1

---------------------------------
HLE audio plugin v1.8.2u1
---------------------------------
HLE audio plugin is written by Shunyuan with features:

* Zilmar's audio plugin spec #1.2 for pj64-2.0, spec #1.1 for other emulators
* XAudio2, DirectSound8 and No Sound driver support.
* XAudio2 upmix to 5.1 ~ 7.1
* prebuffer stream audio
* HLE interface
* LLE interface
* audio thread to update sound buffer
* tested with pj64 1.6, pj64 1.7, pj64 2.x,
1964 svn r146, 1964_ultrafast 3.0, and mupen64 5.1.
* auto sync game to audio
* dynamic plugin interface
* Lua interface to tweak per game settings


Special thanks:

Zilmar for the great Project64 emulator and his plugin system design.

nintendo1889 for testing and push me to improve the audio quality of this plugin every time.

CXD4 for his LLE RSP module, source of rsp_interface here.

--------
Note:
--------
From 2013/04/23 to 2013/05/17

I have implemented all the features that I need, so there won't be a new release in short time.
Thanks for people that help me to develop and debug this plugin.


------------
Lua script to tweak per game settings
---------------

view the Lua script here:

------------
Bug Report
------------

Please post your bug report with following information:

(1) OS & System spec
Windows 7 - 32 bit, 4 GB RAM

(2) emulator spec
Project64 2.1

(3) Plugin version
HleAudio 1.7.1

(4) Game and setting
RR64 (USA)
Sound Driver=XAudio2
Playback Rate=48000
Fixed Audio Timing=0
Sync To Audio=0
VI Refresh Rate=2200
AI couter per byte=500

(5) bug description
audio speep-up (too fast)
....

(6) Did this bug exist in previous version of HleAudio?


(7) Audio Record (optional, but very useful)
download link

--------
Then I will try to fix the bug if possible.


--------
History:
--------

v1.8.2u1
* fixed sometimes mupen64 and 1964 failed to initialize XAudio2 driver.
* Lua script fixed World Driver Championship no audio

v1.8.2
* Fixed Excitebike 64 sound crackling
(Counter Factor=1, Fixed Audio Timing=0, Sync using Audio=0)
* add new settings for Lua script

v1.8.1
* Fixed syntax errors for Lua script
* Fixed official pj64 1.6; can't use the Lua script to tweak per game settings.
(no more need for the pj64 1.6 HleAudio Fixed version)
* Fixed missing audio for Top Gear Rally

v1.8
* Open Lua interface implemented to tweak per game settings
(official pj64 1.6 doesn't support this feature because it won't call the audio plugin 'RomOpen' function, use the pj64 1.6 HleAudio Fixed version instead)

v1.7.1u9
* Fixed audio slow down for A Bug's Life.
* Add DirectSound hardware acceleration option in the UI
(default is off, for Vista and Win7 you need ALchemy, 3D SoundBack or Xear3D EX to take advantage of this feature)

v1.7.1u8
* Fixed Super Smash Bros sound delay for PJ64 2.x
* Fixed Super Smash Bros sound crackling for PJ64 1.6

v1.7.1u7
* Fixed Paper Mario sound crackling
(Counter Factor=1, VI refresh rate=2200, AI count Per byte=500,Fixed Audio Timing=0, Sync using Audio=0)

v1.7.1u6
* work around implemented for the project64 SP DMA read error

v1.7.1u5
* added UI to select output device
(useful if you have multiple sound cards or install DSP plugin such as a DFX audio enhancer)

v1.7.1u4
* playback rate support up to 192 KHz
* playback bits support up to 24 bits (now support 16 ~ 24 bit playback)
* Fixed no audio bug for Top Gear Rally (USA)
(AI Count Per Byte=500, Fixed Audio Timing=1, Sync To Audio=0)

v1.7.1u3
* Fixed no audio for Killer Instinct Gold (USA) 1.2

v1.7.1u2
* support for XAudio2 upmix (surround)
(tested with SRS Audio SandBox)

v1.7.1u1
* Fixed XAudio2 crash for pj64 1.7.0.50b23
* Fixed audio speed up issue reported by nintendo1889
* Fixed pj64 1.7.0.50b23 compatibility error reported by Goldlink11

v1.7.1
* Fixed no audio after restore game state
* Fixed audo speed up of Mystical Ninja Starring Goemon
* Fixed cannot change sound driver after end emulation
* Fixed compatibility issue of pj64 1.7.x

v1.7
* dynamic interface for project64 2.x and other emulators, now HleAudio will provide an interface from 1.2 to pj64-2.0,
and provide interface 1.1 to other emulators.
* added XAudio2 driver support
* added No Sound driver support
* removed the redundent initialization and checking from HLE emulation

v1.6.2
* improved the audio quality when "Fixed Audio Timing" and "Sync to Audio" options off
* improved the frame rate of N64 games that use 32 KHz audio
* released the source code for the rsp_interface

v1.6.1
* added OSD to show the plugin's internal data in real time
(need RivaTuner Statistics Server to display OSD)
* implemented auto sync game to audio feature for other emulators. Now N64 games with 32 KHz audio
such as Zelda OOT, Bomberman 64, F-Zero X should sound better without crackling on 1964, mupen64 and pj64 1.6.

v1.6
* changed interface to Zilmar's Common Audio plugin spec, version #1.2,
because currently only project64 2.x CPU core supports "Sync using Audio" feature
* integrated with Project64's setting manager.

v1.5
* integrated with project64 2.0 "Fixed Audio Timing" & "Sync using Audio" options,
now Bomberman 64, Zelda OOT, Resident Evil 2 sound crackling should Fixed when
these two options are enabled
* Fixed the bug where no was audio playing when loading more than one rom
* Fixed the noises when the plugin dialog was loaded
* Fixed the sound crackling for RR64

v1.4
* Fixed the slow down caused by streaming audio flow control (Bomberman64 back to 60 fps)
* Fixed audio plugin crashes caused by intenal multi thread errors

v1.3
* enhanced code to handle audio data underrun and overrun, Fixed the sound crackling of Zelda OOT and F-Zero X.

v1.2
* tweak for 1964 a little bit
* add UI for DirectSound settings

v1.1
* Fixed the the sound crackling of Mario64 (sound blocks 1024x4 are too small)
* added code to round the sound frequency to 32027 => 32000, 22057 => 22050 (thank CXD4's suggestion)
* added code to show debug messages when unknown system types are detected

v1.0
* the first release.

----------
Preview:
----------
Mystical Ninja Starring Goemon
San Francisco Rush 2049
Zelda OOT
Bomberman 64
Resident Evil 2
Ridge Racer 64

-----------------
my other plugins:
-----------------
ShunyuanDI: Shunyuan's DirectInput8 plugin
SoftGraphic: graphics plugin use mess rdp software rendering
GfxWrapper: to use Jabo's Direct3D8 v1.7.0.57-ver5 with Project64 1.6

Last edited by Melchior; 26th March 2019 at 07:57 PM.
  #2  
Old 22nd April 2013, 06:14 PM
ash_mohak ash_mohak is offline
Junior Member
 
Join Date: Aug 2010
Posts: 12
Default

Hello, very impressive plugin!
Tested it with 1964 and works really good

Just one question, source doesn't seem complete, any plans on releasing it?
  #3  
Old 22nd April 2013, 06:38 PM
Scootaloo's Avatar
Scootaloo Scootaloo is offline
Junior Member
 
Join Date: Apr 2013
Posts: 25
Default

It seems nice, but I've never had an issue with sound before so I don't think I'll swap yet.
__________________
http://i.imgur.com/dHvvv9j.gif
  #4  
Old 22nd April 2013, 09:19 PM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,236
Default

Been catching up on posts, just still trying to move so cannot participate fully.

A small fragment within the audio.cpp
Code:
    switch (SystemType) 
    {
        case SYSTEM_NTSC:
            g_DxSoundContext.Frequency = 48681812 / g_DxSoundContext.Dacrate; 
            break;

        case SYSTEM_PAL:  
            g_DxSoundContext.Frequency = 49656530 / g_DxSoundContext.Dacrate; 
            break;

        case SYSTEM_MPAL: 
            g_DxSoundContext.Frequency = 48628316 / g_DxSoundContext.Dacrate; 
            break;

        default:
            g_DxSoundContext.Frequency = 48681812 / g_DxSoundContext.Dacrate; 
            break;
    }
NTSC is sort of like the default, but if a ROM hard-set an invalid audio system (SystemType > 0x00000002) then I would personally want to debug it with a warning alert notifying that the game is weird and could prove useful for research.

Code:
const long int FreqTable[3] = {
    48681812, /* SYSTEM_NTSC */
    49656530, /* SYSTEM_PAL */
    48628316  /* SYSTEM_MPAL */
};

/* ... stuff in-between */
EXPORT void CALL AiDacrateChanged(int SystemType)
{
/* ... more stuff */
    if (SystemType > 2)
    {
        DebugPrintf("Invalid SystemType\n");
        SystemType = SYSTEM_NTSC; /* default value? (Suanyuan) */
    }
    g_DxSoundContext.Frequency = FreqTable[SystemType] / g_DxSoundContext.Dacrate;
/* ... */
}
But yeah, not really that important.
The DAC rate and the SystemType audio clocks are what causes the un-rounded audio frequencies (~32,006 Hz instead of exactly 32 KHz for Mario64, etc.) in Jabo's and everyone else's audio plugins. I wrote a sort of "fix" for this but it could just be a hack.
  #5  
Old 22nd April 2013, 11:12 PM
the_randomizer's Avatar
the_randomizer the_randomizer is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Sep 2008
Location: USA
Posts: 1,136
Default

Wow, it's nice to have more people work on plugins to help give people more choices to tinker around with
__________________
My rig:
CPU: Intel Core i7 4470 3.4 GHz to 3.9 GHz
Video card:: MSI nVidia GTX 970 4 GB GDDR5
OS: Windows 7 Professional 64-bit
RAM: 16 GB DDR3 SDRAM 10600
HDD: 2 x Western Digital 1 TB HDDs
Monitor: 23" Asus Full HD LED

Oh, and Snes9x > Zsnes in every way
  #6  
Old 22nd April 2013, 11:59 PM
shunyuan's Avatar
shunyuan shunyuan is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Apr 2013
Posts: 491
Default

Quote:
Originally Posted by FatCat View Post
Been catching up on posts, just still trying to move so cannot participate fully.

NTSC is sort of like the default, but if a ROM hard-set an invalid audio system (SystemType > 0x00000002) then I would personally want to debug it with a warning alert notifying that the game is weird and could prove useful for research.

Code:
const long int FreqTable[3] = {
    48681812, /* SYSTEM_NTSC */
    49656530, /* SYSTEM_PAL */
    48628316  /* SYSTEM_MPAL */
};

/* ... stuff in-between */
EXPORT void CALL AiDacrateChanged(int SystemType)
{
/* ... more stuff */
    if (SystemType > 2)
    {
        DebugPrintf("Invalid SystemType\n");
        SystemType = SYSTEM_NTSC; /* default value? (Suanyuan) */
    }
    g_DxSoundContext.Frequency = FreqTable[SystemType] / g_DxSoundContext.Dacrate;
/* ... */
}
The DAC rate and the SystemType audio clocks are what causes the un-rounded audio frequencies (~32,006 Hz instead of exactly 32 KHz for Mario64, etc.) in Jabo's and everyone else's audio plugins. I wrote a sort of "fix" for this but it could just be a hack.
Thanks for your suggestions, I always can learn some things of N64 emulation from your comments.

(1) fixed the Mario64 sound crackles (sound blocks 1024x4 is too small for Mario64)
(2) add code to round the sound frequency.
(3) add code to output debug message for unknown system type

Last edited by shunyuan; 1st May 2013 at 08:55 AM.
  #7  
Old 23rd April 2013, 12:50 AM
the_randomizer's Avatar
the_randomizer the_randomizer is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Sep 2008
Location: USA
Posts: 1,136
Default

Awesome work on the plugin, so I took the liberty to test some games that have emulator core issues (like Bomberman 64). I can safely say that the audio issues aren't related to any plugin, but an issue in the emulator itself.

Games like Goemon's Great Adventure sound flawless
http://filetrip.net/view?SMdn59ij1G

Same with Killer Instinct Gold - (Note, the audio needed to be amplified since I paused the game to remove sound effects)
http://filetrip.net/view?d8V5xynmDk


Games like Bombeman 64 have nasty emulator issues (resulting in crackling audio) and no known plugin can fix it, so rest assured, your plugin is not at fault. Keep up the good work! I'll continue to test.
__________________
My rig:
CPU: Intel Core i7 4470 3.4 GHz to 3.9 GHz
Video card:: MSI nVidia GTX 970 4 GB GDDR5
OS: Windows 7 Professional 64-bit
RAM: 16 GB DDR3 SDRAM 10600
HDD: 2 x Western Digital 1 TB HDDs
Monitor: 23" Asus Full HD LED

Oh, and Snes9x > Zsnes in every way

Last edited by the_randomizer; 23rd April 2013 at 12:56 AM.
  #8  
Old 23rd April 2013, 01:11 AM
Scootaloo's Avatar
Scootaloo Scootaloo is offline
Junior Member
 
Join Date: Apr 2013
Posts: 25
Default

I can only imagine how ignorant I must sound, but here I go: what is wrong with the sound as it is? why should we use this plug-in. 99% of the games I play have no audio issues whatsoever.
__________________
http://i.imgur.com/dHvvv9j.gif
  #9  
Old 23rd April 2013, 01:41 AM
the_randomizer's Avatar
the_randomizer the_randomizer is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Sep 2008
Location: USA
Posts: 1,136
Default

Quote:
Originally Posted by Scootaloo View Post
I can only imagine how ignorant I must sound, but here I go: what is wrong with the sound as it is? why should we use this plug-in. 99% of the games I play have no audio issues whatsoever.
It's an alternate choice, it requires no configuration whatsoever so it's easy to use. Some games still have audio issues, like Bomberman 64, which is related to the emulator and not the plugin it seems. Plus, perhaps the programmer wanted to challenge himself to see if he could make a good plugin, which he has.
__________________
My rig:
CPU: Intel Core i7 4470 3.4 GHz to 3.9 GHz
Video card:: MSI nVidia GTX 970 4 GB GDDR5
OS: Windows 7 Professional 64-bit
RAM: 16 GB DDR3 SDRAM 10600
HDD: 2 x Western Digital 1 TB HDDs
Monitor: 23" Asus Full HD LED

Oh, and Snes9x > Zsnes in every way
  #10  
Old 23rd April 2013, 02:08 AM
HatCat's Avatar
HatCat HatCat is offline
Alpha Tester
Project Supporter
Senior Member
 
Join Date: Feb 2007
Location: In my hat.
Posts: 16,236
Default

nintendo: Could you test World Driver Championship using his audio dll? It might not give any sound, but the hope is that it doesn't immediately crash the game on startup/boot which is a known issue with every open-source audio plugin.

This would then be the very first open-source sound plugin to not crash that game.


By the way, if I can remember right.
The exact enumeration of the system types was PAL, NTSC, then MPAL.
Obviously nobody can control this from within the plugin; it's just another fault of zilmar's plugin interface design.
The macro names were also made up (SYSTEM_x); there were some official names in the functions reference but I forget which.

This allowed the video clock integers corresponding to the various "system types" to go in descending order, making the exact video clock integer to be fetched a little more calculable than relying on a look-up table of constants (as far as efficiency measures go).

So, Hell, I left it at that.

Quote:
Originally Posted by Scootaloo View Post
I can only imagine how ignorant I must sound, but here I go: what is wrong with the sound as it is? why should we use this plug-in. 99% of the games I play have no audio issues whatsoever.
I agree that the sound plugin made by Jabo is already perfect essentially, barring the limitation's of zilmar's spec and the oddball frequencies for audio recording.

We need an open-source audio plugin to help with some things.

I was going to start from scratch but got distracted by the RSP.

LaC's nemu audio, Jabo's DirectSound, and zilmar's No Sound have always been the only plugins to not fault certain timing or thread management circumstances in games using special audio setups.
Only one of them however is open-source (the No Sound plugin).

The objective is to fund efforts into a rudimentary, portable code base, into something as optimized and functioning as Jabo's DirectSound, so that we can use non-DirectX / non-Microsoft solutions later.

The source to Azimer's versions of the audio I think was waveOut, which would also be a better alternative to scattering DirectSound all the time I think.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 01:45 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.