2010-08-16 04:10:50 +00:00
|
|
|
#include "xaudio2.hpp"
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
#undef interface
|
2010-08-16 04:10:50 +00:00
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
struct AudioXAudio2 : AudioDriver, public IXAudio2VoiceCallback {
|
2018-08-09 04:15:56 +00:00
|
|
|
enum : uint { Buffers = 32 };
|
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
AudioXAudio2& self = *this;
|
2018-08-09 04:15:56 +00:00
|
|
|
AudioXAudio2(Audio& super) : AudioDriver(super) { construct(); }
|
|
|
|
~AudioXAudio2() { destruct(); }
|
2017-07-24 05:23:40 +00:00
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
auto create() -> bool override {
|
2018-08-09 04:15:56 +00:00
|
|
|
super.setDevice(hasDevices().first());
|
2018-08-06 07:46:00 +00:00
|
|
|
super.setChannels(2);
|
2018-08-05 09:00:15 +00:00
|
|
|
super.setFrequency(48000);
|
|
|
|
super.setLatency(40);
|
|
|
|
return initialize();
|
|
|
|
}
|
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
auto driver() -> string override { return "XAudio 2.1"; }
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
auto ready() -> bool override { return self.isReady; }
|
Update to 20180729 release.
byuu wrote:
Sigh ...
asio.hpp needs #include <nall/windows/registry.hpp>
[Since the last WIP, byuu also posted the following message. -Ed.]
ruby drivers have all been updated (but not tested outside of BSD), and
I redesigned the settings window. The driver functionality all exists on
a new "Drivers" panel, the emulator/hack settings go to a
"Configuration" panel, and the video/audio panels lose driver settings.
As does the settings menu and its synchronize options.
I want to start pushing toward a v107 release. Critically, I will need
DirectSound and ALSA to support dynamic rate control. I'd also like to
eliminate the other system manifest.bml files. I need to update the
cheat code database format, and bundle at least a few quark shaders --
although I still need to default to Direct3D on Windows.
Turbo keys would be nice, if it's not too much effort. Aside from
netplay, it's the last significant feature I'm missing.
I think for v107, higan is going to be a bit rough around the edges
compared to bsnes. And I don't think it's practical to finish the bsnes
localization support.
I'm thinking we probably want another WIP to iron out any critical
issues, but this time there should be a feature freeze with the next
WIP.
2018-07-29 13:24:38 +00:00
|
|
|
|
|
|
|
auto hasBlocking() -> bool override { return true; }
|
Update to bsnes v107 release.
[This is specifically a release of bsnes, not the whole higan suite, even though
it contains all the higan source. -Ed.]
byuu says:
Today I am posting the first release of the new bsnes emulator.
bsnes is designed to be a revival of the classic bsnes design, focusing
specifically on performance and ease of use for SNES emulation.
In addition to all of the features of higan, bsnes supports the following
features:
- 300% faster (than higan) scanline-based, multi-threaded graphics renderer
- option to disable sprite limits in games
- option to enable hires mode 7 graphics
- option to enable more accurate pixel-based graphics renderer
- option to overclock SuperFX games by up to 800%
- periodic auto-saving of game save RAM
- save state manager with state screenshots
- several new save state hotkeys such as increment/decrement slot#
- option to auto-save states when unloading a game or closing the emulator
- option to auto-load aforementioned states when loading games
- save state undo and redo support (with associated hotkeys)
- speed override modes (50%, 75%, 100%, 150%, 200%)
- recent games list
- frame advance mode
- screenshot hotkey
- path selection for games, patches, saves, cheats, states, and screenshots
- dynamic video, audio, input driver changes
- direct loading and playing of games without the use of the higan library
- ZIP archive and multiple file extension support for games
- firmware folder for unappended coprocessor firmware (see documentation for
more)
- compatibility with sd2snes and Snes9X MSU1 game file naming
- compatibility with higan gamepaks (game folders)
- soft-patching support for both BPS and IPS patches
- menubar that does not pause emulation when entered
- video pixel shaders (requires OpenGL 3.2)
- built-in game database with over 1,200 games to ensure perfect memory
mapping
- (Linux, BSD only:) audio dynamic rate control to eliminate stuttering
- and much more!
The one feature I regret not being able to support in this release is Windows
dynamic rate control. I put in my best attempt, but XAudio2's API is simply not
fine-grained enough, and the WASAPI driver is not mature enough. I hope that DRC
support can be added to the Windows port in the near future, and I would like to
offer a large cash bounty to anyone who can help me make this happen.
2019-02-22 06:46:53 +00:00
|
|
|
auto hasDynamic() -> bool override { return false; }
|
2018-08-09 04:15:56 +00:00
|
|
|
|
|
|
|
auto hasDevices() -> vector<string> override {
|
|
|
|
vector<string> devices;
|
|
|
|
for(auto& device : self.devices) devices.append(device.name);
|
|
|
|
return devices;
|
|
|
|
}
|
Update to v104r06 release.
byuu says:
Changelog:
- gba,ws: removed Thread::step() override¹
- processor/m68k: move.b (a7)+ and move.b (a7)- adjust a7 by two, not
by one²
- tomoko: created new initialize(Video,Audio,Input)Driver() functions³
- ruby/audio: split Audio::information into
Audio::available(Devices,Frequencies,Latencies,Channels)³
- ws: added Model::(WonderSwan,WonderSwanColor,SwanCrystal)()
functions for consistency with other cores
¹: this should hopefully fix GBA Pokemon Pinball. Thanks to
SuperMikeMan for pointing out the underlying cause.
²: this fixes A Ressaha de Ikou, Mega Bomberman, and probably more
games.
³: this is the big change: so there was a problem with WASAPI where
you might change your device under the audio settings panel. And your
new device may not support the frequency that your old device used. This
would end up not updating the frequency, and the pitch would be
distorted.
The old Audio::information() couldn't tell you what frequencies,
latencies, or channels were available for all devices simultaneously, so
I had to split them up. The new initializeAudioDriver() function
validates you have a correct driver, or it defaults to none. Then it
validates a correct device name, or it defaults to the first entry in
the list. Then it validates a correct frequency, or defaults to the
first in the list. Then finally it validates a correct latency, or
defaults to the first in the list.
In this way ... we have a clear path now with no API changes required to
select default devices, frequencies, latencies, channel counts: they
need to be the first items in their respective lists.
So, what we need to do now is go through and for every audio driver that
enumerates devices, we need to make sure the default device gets added
to the top of the list. I'm ... not really sure how to do this with most
drivers, so this is definitely going to take some time.
Also, when you change a device, initializeAudioDriver() is called again,
so if it's a bad device, it will disable the audio driver instead of
continuing to send samples at it and hoping that the driver blocked
those API calls when it failed to initialize properly.
Now then ... since it was a decently-sized API change, it's possible
I've broken compilation of the Linux drivers, so please report any
compilation errors so that I can fix them.
2017-08-26 01:15:49 +00:00
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
auto hasFrequencies() -> vector<uint> override {
|
|
|
|
return {44100, 48000, 96000};
|
Update to v104r06 release.
byuu says:
Changelog:
- gba,ws: removed Thread::step() override¹
- processor/m68k: move.b (a7)+ and move.b (a7)- adjust a7 by two, not
by one²
- tomoko: created new initialize(Video,Audio,Input)Driver() functions³
- ruby/audio: split Audio::information into
Audio::available(Devices,Frequencies,Latencies,Channels)³
- ws: added Model::(WonderSwan,WonderSwanColor,SwanCrystal)()
functions for consistency with other cores
¹: this should hopefully fix GBA Pokemon Pinball. Thanks to
SuperMikeMan for pointing out the underlying cause.
²: this fixes A Ressaha de Ikou, Mega Bomberman, and probably more
games.
³: this is the big change: so there was a problem with WASAPI where
you might change your device under the audio settings panel. And your
new device may not support the frequency that your old device used. This
would end up not updating the frequency, and the pitch would be
distorted.
The old Audio::information() couldn't tell you what frequencies,
latencies, or channels were available for all devices simultaneously, so
I had to split them up. The new initializeAudioDriver() function
validates you have a correct driver, or it defaults to none. Then it
validates a correct device name, or it defaults to the first entry in
the list. Then it validates a correct frequency, or defaults to the
first in the list. Then finally it validates a correct latency, or
defaults to the first in the list.
In this way ... we have a clear path now with no API changes required to
select default devices, frequencies, latencies, channel counts: they
need to be the first items in their respective lists.
So, what we need to do now is go through and for every audio driver that
enumerates devices, we need to make sure the default device gets added
to the top of the list. I'm ... not really sure how to do this with most
drivers, so this is definitely going to take some time.
Also, when you change a device, initializeAudioDriver() is called again,
so if it's a bad device, it will disable the audio driver instead of
continuing to send samples at it and hoping that the driver blocked
those API calls when it failed to initialize properly.
Now then ... since it was a decently-sized API change, it's possible
I've broken compilation of the Linux drivers, so please report any
compilation errors so that I can fix them.
2017-08-26 01:15:49 +00:00
|
|
|
}
|
2017-07-24 05:23:40 +00:00
|
|
|
|
2018-08-05 09:00:15 +00:00
|
|
|
auto hasLatencies() -> vector<uint> override {
|
Update to v104r06 release.
byuu says:
Changelog:
- gba,ws: removed Thread::step() override¹
- processor/m68k: move.b (a7)+ and move.b (a7)- adjust a7 by two, not
by one²
- tomoko: created new initialize(Video,Audio,Input)Driver() functions³
- ruby/audio: split Audio::information into
Audio::available(Devices,Frequencies,Latencies,Channels)³
- ws: added Model::(WonderSwan,WonderSwanColor,SwanCrystal)()
functions for consistency with other cores
¹: this should hopefully fix GBA Pokemon Pinball. Thanks to
SuperMikeMan for pointing out the underlying cause.
²: this fixes A Ressaha de Ikou, Mega Bomberman, and probably more
games.
³: this is the big change: so there was a problem with WASAPI where
you might change your device under the audio settings panel. And your
new device may not support the frequency that your old device used. This
would end up not updating the frequency, and the pitch would be
distorted.
The old Audio::information() couldn't tell you what frequencies,
latencies, or channels were available for all devices simultaneously, so
I had to split them up. The new initializeAudioDriver() function
validates you have a correct driver, or it defaults to none. Then it
validates a correct device name, or it defaults to the first entry in
the list. Then it validates a correct frequency, or defaults to the
first in the list. Then finally it validates a correct latency, or
defaults to the first in the list.
In this way ... we have a clear path now with no API changes required to
select default devices, frequencies, latencies, channel counts: they
need to be the first items in their respective lists.
So, what we need to do now is go through and for every audio driver that
enumerates devices, we need to make sure the default device gets added
to the top of the list. I'm ... not really sure how to do this with most
drivers, so this is definitely going to take some time.
Also, when you change a device, initializeAudioDriver() is called again,
so if it's a bad device, it will disable the audio driver instead of
continuing to send samples at it and hoping that the driver blocked
those API calls when it failed to initialize properly.
Now then ... since it was a decently-sized API change, it's possible
I've broken compilation of the Linux drivers, so please report any
compilation errors so that I can fix them.
2017-08-26 01:15:49 +00:00
|
|
|
return {20, 40, 60, 80, 100};
|
2017-07-24 05:23:40 +00:00
|
|
|
}
|
2010-08-16 04:10:50 +00:00
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
auto setDevice(string device) -> bool override { return initialize(); }
|
2018-08-05 09:00:15 +00:00
|
|
|
auto setBlocking(bool blocking) -> bool override { return true; }
|
|
|
|
auto setFrequency(uint frequency) -> bool override { return initialize(); }
|
|
|
|
auto setLatency(uint latency) -> bool override { return initialize(); }
|
2010-08-16 04:10:50 +00:00
|
|
|
|
Update to 20180729 release.
byuu wrote:
Sigh ...
asio.hpp needs #include <nall/windows/registry.hpp>
[Since the last WIP, byuu also posted the following message. -Ed.]
ruby drivers have all been updated (but not tested outside of BSD), and
I redesigned the settings window. The driver functionality all exists on
a new "Drivers" panel, the emulator/hack settings go to a
"Configuration" panel, and the video/audio panels lose driver settings.
As does the settings menu and its synchronize options.
I want to start pushing toward a v107 release. Critically, I will need
DirectSound and ALSA to support dynamic rate control. I'd also like to
eliminate the other system manifest.bml files. I need to update the
cheat code database format, and bundle at least a few quark shaders --
although I still need to default to Direct3D on Windows.
Turbo keys would be nice, if it's not too much effort. Aside from
netplay, it's the last significant feature I'm missing.
I think for v107, higan is going to be a bit rough around the edges
compared to bsnes. And I don't think it's practical to finish the bsnes
localization support.
I'm thinking we probably want another WIP to iron out any critical
issues, but this time there should be a feature freeze with the next
WIP.
2018-07-29 13:24:38 +00:00
|
|
|
auto clear() -> void override {
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
self.sourceVoice->Stop(0);
|
|
|
|
self.sourceVoice->FlushSourceBuffers(); //calls OnBufferEnd for all currently submitted buffers
|
2010-08-16 04:10:50 +00:00
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
self.index = 0;
|
|
|
|
self.queue = 0;
|
|
|
|
for(uint n : range(Buffers)) self.buffers[n].fill();
|
2013-05-02 11:25:45 +00:00
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
self.sourceVoice->Start(0);
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
|
|
|
|
Update to bsnes v107 release.
[This is specifically a release of bsnes, not the whole higan suite, even though
it contains all the higan source. -Ed.]
byuu says:
Today I am posting the first release of the new bsnes emulator.
bsnes is designed to be a revival of the classic bsnes design, focusing
specifically on performance and ease of use for SNES emulation.
In addition to all of the features of higan, bsnes supports the following
features:
- 300% faster (than higan) scanline-based, multi-threaded graphics renderer
- option to disable sprite limits in games
- option to enable hires mode 7 graphics
- option to enable more accurate pixel-based graphics renderer
- option to overclock SuperFX games by up to 800%
- periodic auto-saving of game save RAM
- save state manager with state screenshots
- several new save state hotkeys such as increment/decrement slot#
- option to auto-save states when unloading a game or closing the emulator
- option to auto-load aforementioned states when loading games
- save state undo and redo support (with associated hotkeys)
- speed override modes (50%, 75%, 100%, 150%, 200%)
- recent games list
- frame advance mode
- screenshot hotkey
- path selection for games, patches, saves, cheats, states, and screenshots
- dynamic video, audio, input driver changes
- direct loading and playing of games without the use of the higan library
- ZIP archive and multiple file extension support for games
- firmware folder for unappended coprocessor firmware (see documentation for
more)
- compatibility with sd2snes and Snes9X MSU1 game file naming
- compatibility with higan gamepaks (game folders)
- soft-patching support for both BPS and IPS patches
- menubar that does not pause emulation when entered
- video pixel shaders (requires OpenGL 3.2)
- built-in game database with over 1,200 games to ensure perfect memory
mapping
- (Linux, BSD only:) audio dynamic rate control to eliminate stuttering
- and much more!
The one feature I regret not being able to support in this release is Windows
dynamic rate control. I put in my best attempt, but XAudio2's API is simply not
fine-grained enough, and the WASAPI driver is not mature enough. I hope that DRC
support can be added to the Windows port in the near future, and I would like to
offer a large cash bounty to anyone who can help me make this happen.
2019-02-22 06:46:53 +00:00
|
|
|
/*auto level() -> double override {
|
2018-08-09 04:15:56 +00:00
|
|
|
XAUDIO2_VOICE_STATE state{};
|
|
|
|
self.sourceVoice->GetState(&state);
|
|
|
|
uint level = state.BuffersQueued * self.period - state.SamplesPlayed % self.period;
|
|
|
|
uint limit = Buffers * self.period;
|
|
|
|
return (double)(limit - level) / limit;
|
Update to bsnes v107 release.
[This is specifically a release of bsnes, not the whole higan suite, even though
it contains all the higan source. -Ed.]
byuu says:
Today I am posting the first release of the new bsnes emulator.
bsnes is designed to be a revival of the classic bsnes design, focusing
specifically on performance and ease of use for SNES emulation.
In addition to all of the features of higan, bsnes supports the following
features:
- 300% faster (than higan) scanline-based, multi-threaded graphics renderer
- option to disable sprite limits in games
- option to enable hires mode 7 graphics
- option to enable more accurate pixel-based graphics renderer
- option to overclock SuperFX games by up to 800%
- periodic auto-saving of game save RAM
- save state manager with state screenshots
- several new save state hotkeys such as increment/decrement slot#
- option to auto-save states when unloading a game or closing the emulator
- option to auto-load aforementioned states when loading games
- save state undo and redo support (with associated hotkeys)
- speed override modes (50%, 75%, 100%, 150%, 200%)
- recent games list
- frame advance mode
- screenshot hotkey
- path selection for games, patches, saves, cheats, states, and screenshots
- dynamic video, audio, input driver changes
- direct loading and playing of games without the use of the higan library
- ZIP archive and multiple file extension support for games
- firmware folder for unappended coprocessor firmware (see documentation for
more)
- compatibility with sd2snes and Snes9X MSU1 game file naming
- compatibility with higan gamepaks (game folders)
- soft-patching support for both BPS and IPS patches
- menubar that does not pause emulation when entered
- video pixel shaders (requires OpenGL 3.2)
- built-in game database with over 1,200 games to ensure perfect memory
mapping
- (Linux, BSD only:) audio dynamic rate control to eliminate stuttering
- and much more!
The one feature I regret not being able to support in this release is Windows
dynamic rate control. I put in my best attempt, but XAudio2's API is simply not
fine-grained enough, and the WASAPI driver is not mature enough. I hope that DRC
support can be added to the Windows port in the near future, and I would like to
offer a large cash bounty to anyone who can help me make this happen.
2019-02-22 06:46:53 +00:00
|
|
|
}*/
|
2018-08-09 04:15:56 +00:00
|
|
|
|
Update to 20180729 release.
byuu wrote:
Sigh ...
asio.hpp needs #include <nall/windows/registry.hpp>
[Since the last WIP, byuu also posted the following message. -Ed.]
ruby drivers have all been updated (but not tested outside of BSD), and
I redesigned the settings window. The driver functionality all exists on
a new "Drivers" panel, the emulator/hack settings go to a
"Configuration" panel, and the video/audio panels lose driver settings.
As does the settings menu and its synchronize options.
I want to start pushing toward a v107 release. Critically, I will need
DirectSound and ALSA to support dynamic rate control. I'd also like to
eliminate the other system manifest.bml files. I need to update the
cheat code database format, and bundle at least a few quark shaders --
although I still need to default to Direct3D on Windows.
Turbo keys would be nice, if it's not too much effort. Aside from
netplay, it's the last significant feature I'm missing.
I think for v107, higan is going to be a bit rough around the edges
compared to bsnes. And I don't think it's practical to finish the bsnes
localization support.
I'm thinking we probably want another WIP to iron out any critical
issues, but this time there should be a feature freeze with the next
WIP.
2018-07-29 13:24:38 +00:00
|
|
|
auto output(const double samples[]) -> void override {
|
2018-08-09 04:15:56 +00:00
|
|
|
uint32_t frame = 0;
|
|
|
|
frame |= (uint16_t)sclamp<16>(samples[0] * 32767.0) << 0;
|
|
|
|
frame |= (uint16_t)sclamp<16>(samples[1] * 32767.0) << 16;
|
|
|
|
|
|
|
|
auto& buffer = self.buffers[self.index];
|
|
|
|
buffer.write(frame);
|
|
|
|
if(!buffer.full()) return;
|
2010-08-16 04:10:50 +00:00
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
buffer.flush();
|
|
|
|
if(self.queue == Buffers - 1) {
|
2018-08-05 09:00:15 +00:00
|
|
|
if(self.blocking) {
|
2010-08-16 04:10:50 +00:00
|
|
|
//wait until there is at least one other free buffer for the next sample
|
2018-08-09 04:15:56 +00:00
|
|
|
while(self.queue == Buffers - 1);
|
|
|
|
} else {
|
|
|
|
//there is no free buffer for the next block, so ignore the current contents
|
2010-08-16 04:10:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
write(buffer.data(), buffer.capacity<uint8_t>());
|
|
|
|
self.index = (self.index + 1) % Buffers;
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 05:23:40 +00:00
|
|
|
private:
|
2018-08-09 04:15:56 +00:00
|
|
|
struct Device {
|
|
|
|
uint id = 0;
|
|
|
|
uint channels = 0;
|
|
|
|
uint frequency = 0;
|
|
|
|
Format format = Format::none;
|
|
|
|
string name;
|
|
|
|
};
|
|
|
|
vector<Device> devices;
|
|
|
|
|
|
|
|
auto construct() -> void {
|
|
|
|
XAudio2Create(&self.interface, 0 , XAUDIO2_DEFAULT_PROCESSOR);
|
2010-08-16 04:10:50 +00:00
|
|
|
|
2017-07-24 05:23:40 +00:00
|
|
|
uint deviceCount = 0;
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
self.interface->GetDeviceCount(&deviceCount);
|
2017-07-24 05:23:40 +00:00
|
|
|
for(uint deviceIndex : range(deviceCount)) {
|
2018-08-09 04:15:56 +00:00
|
|
|
XAUDIO2_DEVICE_DETAILS deviceDetails{};
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
self.interface->GetDeviceDetails(deviceIndex, &deviceDetails);
|
2018-08-09 04:15:56 +00:00
|
|
|
auto format = deviceDetails.OutputFormat.Format.wFormatTag;
|
|
|
|
auto bits = deviceDetails.OutputFormat.Format.wBitsPerSample;
|
|
|
|
|
|
|
|
Device device;
|
|
|
|
device.id = deviceIndex;
|
|
|
|
device.name = (const char*)utf8_t(deviceDetails.DisplayName);
|
|
|
|
device.channels = deviceDetails.OutputFormat.Format.nChannels;
|
|
|
|
device.frequency = deviceDetails.OutputFormat.Format.nSamplesPerSec;
|
|
|
|
if(format == WAVE_FORMAT_PCM) {
|
|
|
|
if(bits == 16) device.format = Format::int16;
|
|
|
|
if(bits == 32) device.format = Format::int32;
|
|
|
|
} else if(format == WAVE_FORMAT_IEEE_FLOAT) {
|
|
|
|
if(bits == 32) device.format = Format::float32;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ensure devices.first() is the default device
|
|
|
|
if(deviceDetails.Role & DefaultGameDevice) {
|
|
|
|
devices.prepend(device);
|
|
|
|
} else {
|
|
|
|
devices.append(device);
|
|
|
|
}
|
2014-01-28 10:04:58 +00:00
|
|
|
}
|
2018-08-09 04:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto destruct() -> void {
|
|
|
|
terminate();
|
|
|
|
|
|
|
|
if(self.interface) {
|
|
|
|
self.interface->Release();
|
|
|
|
self.interface = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto initialize() -> bool {
|
|
|
|
terminate();
|
|
|
|
if(!self.interface) return false;
|
|
|
|
|
|
|
|
self.period = self.frequency * self.latency / Buffers / 1000.0 + 0.5;
|
|
|
|
for(uint n : range(Buffers)) buffers[n].resize(self.period);
|
|
|
|
self.index = 0;
|
|
|
|
self.queue = 0;
|
|
|
|
|
|
|
|
if(!hasDevices().find(self.device)) self.device = hasDevices().first();
|
|
|
|
uint deviceID = devices[hasDevices().find(self.device)()].id;
|
2014-01-28 10:04:58 +00:00
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
if(FAILED(self.interface->CreateMasteringVoice(&self.masterVoice, self.channels, self.frequency, 0, deviceID, nullptr))) return terminate(), false;
|
2010-08-16 04:10:50 +00:00
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
WAVEFORMATEX waveFormat{};
|
2017-07-24 05:23:40 +00:00
|
|
|
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
|
2018-08-06 07:46:00 +00:00
|
|
|
waveFormat.nChannels = self.channels;
|
2018-08-05 09:00:15 +00:00
|
|
|
waveFormat.nSamplesPerSec = self.frequency;
|
2017-07-24 05:23:40 +00:00
|
|
|
waveFormat.nBlockAlign = 4;
|
|
|
|
waveFormat.wBitsPerSample = 16;
|
|
|
|
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
|
|
|
|
waveFormat.cbSize = 0;
|
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
if(FAILED(self.interface->CreateSourceVoice(&self.sourceVoice, (WAVEFORMATEX*)&waveFormat, XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, this, nullptr, nullptr))) return terminate(), false;
|
2010-08-16 04:10:50 +00:00
|
|
|
|
|
|
|
clear();
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
return self.isReady = true;
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
|
|
|
|
2017-07-24 05:23:40 +00:00
|
|
|
auto terminate() -> void {
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
self.isReady = false;
|
2017-07-24 05:23:40 +00:00
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
if(self.sourceVoice) {
|
|
|
|
self.sourceVoice->Stop(0);
|
|
|
|
self.sourceVoice->DestroyVoice();
|
|
|
|
self.sourceVoice = nullptr;
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
2017-07-24 05:23:40 +00:00
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
if(self.masterVoice) {
|
|
|
|
self.masterVoice->DestroyVoice();
|
|
|
|
self.masterVoice = nullptr;
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
2017-07-24 05:23:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
auto write(const uint32_t* audioData, uint bytes) -> void {
|
|
|
|
XAUDIO2_BUFFER buffer{};
|
2017-07-24 05:23:40 +00:00
|
|
|
buffer.AudioBytes = bytes;
|
2018-08-09 04:15:56 +00:00
|
|
|
buffer.pAudioData = (const BYTE*)audioData;
|
|
|
|
buffer.pContext = nullptr;
|
|
|
|
InterlockedIncrement(&self.queue);
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
self.sourceVoice->SubmitSourceBuffer(&buffer);
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
2013-05-02 11:25:45 +00:00
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
bool isReady = false;
|
2017-07-24 05:23:40 +00:00
|
|
|
|
2018-08-09 04:15:56 +00:00
|
|
|
queue<uint32_t> buffers[Buffers];
|
|
|
|
uint period = 0; //amount (in 32-bit frames) of samples per buffer
|
|
|
|
uint index = 0; //current buffer for writing samples to
|
|
|
|
volatile long queue = 0; //how many buffers are queued and ready for playback
|
2017-07-24 05:23:40 +00:00
|
|
|
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
IXAudio2* interface = nullptr;
|
|
|
|
IXAudio2MasteringVoice* masterVoice = nullptr;
|
|
|
|
IXAudio2SourceVoice* sourceVoice = nullptr;
|
2017-07-24 05:23:40 +00:00
|
|
|
|
|
|
|
//inherited from IXAudio2VoiceCallback
|
|
|
|
STDMETHODIMP_(void) OnBufferStart(void* pBufferContext){}
|
|
|
|
STDMETHODIMP_(void) OnLoopEnd(void* pBufferContext){}
|
|
|
|
STDMETHODIMP_(void) OnStreamEnd() {}
|
|
|
|
STDMETHODIMP_(void) OnVoiceError(void* pBufferContext, HRESULT Error) {}
|
|
|
|
STDMETHODIMP_(void) OnVoiceProcessingPassEnd() {}
|
|
|
|
STDMETHODIMP_(void) OnVoiceProcessingPassStart(UINT32 BytesRequired) {}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
STDMETHODIMP_(void) OnBufferEnd(void* pBufferContext) {
|
2018-08-09 04:15:56 +00:00
|
|
|
InterlockedDecrement(&self.queue);
|
2010-08-16 04:10:50 +00:00
|
|
|
}
|
|
|
|
};
|