Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 4-channel output support and fixing 4-op mode edge case bug #21

Merged
merged 2 commits into from
Nov 12, 2022

Conversation

Kagamiin
Copy link
Contributor

@Kagamiin Kagamiin commented Nov 7, 2022

Description

  • OPL3_Generate has been refactored into OPL3_Generate4Ch.
    • OPL3_Generate4Ch contains the original logic for sample generation, but modified to output into 4 channels (2 DACs) like the real chip does
    • Added shims for OPL3_Generate, OPL3_GenerateResampled and OPL3_GenerateStream to maintain compatibility with existing applications that expect 2 channel output
    • Tested on a hacked version of Furnace Tracker, 4 channel output works as expected, 2 channel output still works the same.
  • Fixed bug where setting the 4-op flags would not immediately change the channel connections until a write to base 0xC0 was issued (bug encountered in Adlib Tracker II when previewing instruments, confirmed by ValleyBell to not occur in real hardware)

Notes

  • Added inline attribute to OPL3_Generate4Ch; checked on Compiler Explorer and with -O3 optimizations on GCC this results in OPL3_Generate (and GenerateResampled) being generated with very similar code to the original which should result in almost no performance impact for apps that only use 2 channel output.
    • If -O2 is used, GCC chooses to not inline the code (as if the inline hint wasn't there). Did not check other compilers.

@Kagamiin Kagamiin marked this pull request as draft November 7, 2022 13:11
@Kagamiin
Copy link
Contributor Author

Kagamiin commented Nov 7, 2022

Some of the line endings were mangled in the original file and this caused some trouble for me when generating the commits. I ended up converting the existing CRLF endings to LF, hence the weird changes in comments. Oh well.

@Kagamiin Kagamiin marked this pull request as ready for review November 7, 2022 13:41
@nukeykt nukeykt merged commit f2c9873 into nukeykt:master Nov 12, 2022
@nukeykt
Copy link
Owner

nukeykt commented Nov 12, 2022

Thanks!

@Kagamiin Kagamiin deleted the feature/4ch-output branch November 13, 2022 00:24
@Kagamiin Kagamiin mentioned this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants