audio.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. auto Emulator::audioUpdate() -> void {
  2. if(audioInstance && audioInstance.driver() != settings.audio.driver) {
  3. audioInstance.reset();
  4. }
  5. if(!audioInstance) {
  6. audioInstance.create(settings.audio.driver);
  7. audioInstance.setContext(program.handle());
  8. if(!audioInstance.ready()) {
  9. audioInstance.create(settings.audio.driver = "None");
  10. }
  11. }
  12. if(audioInstance.hasDevice(settings.audio.device)) {
  13. audioInstance.setDevice(settings.audio.device);
  14. } else {
  15. settings.audio.device = audioInstance.device();
  16. }
  17. if(audioInstance.hasFrequency(settings.audio.frequency)) {
  18. audioInstance.setFrequency(settings.audio.frequency);
  19. } else {
  20. settings.audio.frequency = audioInstance.frequency();
  21. }
  22. if(audioInstance.hasLatency(settings.audio.latency)) {
  23. audioInstance.setLatency(settings.audio.latency);
  24. } else {
  25. settings.audio.latency = audioInstance.latency();
  26. }
  27. if(audioInstance.hasExclusive()) {
  28. audioInstance.setExclusive(settings.audio.exclusive);
  29. } else {
  30. settings.audio.exclusive = false;
  31. }
  32. if(audioInstance.hasBlocking()) {
  33. audioInstance.setBlocking(settings.audio.blocking);
  34. } else {
  35. settings.audio.blocking = false;
  36. }
  37. if(audioInstance.hasDynamic()) {
  38. audioInstance.setDynamic(settings.audio.dynamic);
  39. } else {
  40. settings.audio.dynamic = false;
  41. }
  42. }
  43. auto Emulator::audioUpdateEffects() -> void {
  44. if(!interface) return;
  45. for(auto stream : root->find<higan::Node::Stream>()) {
  46. stream->setResamplerFrequency(settings.audio.frequency + settings.audio.skew);
  47. }
  48. }