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

Added an experimental ALSA sequencer client #274

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NY00123
Copy link

@NY00123 NY00123 commented Dec 11, 2023

For users of Linux and other relevant environments, this can be seen as a (limited) user-level ALSA equivalent of the WinMM driver.

  • The given implementation uses SDL2 for outputting audio.
  • The user has to select an FM bank via a command-line argument.
  • Other options are not configurable (except for cases like SDL2's environment variables), and Nuked OPL3 v1.8 is always used.

I'm not as familiar with MIDI or ALSA as others may be, so good chances are that there's at least one mistake. I originally started with a small example currently found here: http://fundamental-code.com/midi/

This program could be adapted to allow greater configurability, the way the WinMM driver and other software did (like selecting a different OPL emulator or changing the number of chips). But I'm not as familiar again. Also, in this manner, I refrained from using GPLed standalone player code of ADLMIDI as a base, in case there's such code.

It currently uses SDL2 for sound output. Code can be written to use ALSA directly (as done for MIDI) and/or other APIs; I'm just more familiar with SDL2, and also know that it'll allow the use of multiple APIs/drivers via SDL_AUDIODRIVER.

For now I've used this program on my own, at least for a few purposes. Others may experiment with this client as well.

- Essentially a user-level ALSA equivalent of the WinMM driver.
- The given implementation uses SDL2 for outputting audio.
- The user has to select an FM bank via a command-line argument.
- Other options are not configurable
(except for cases like SDL2's environment variables),
and Nuked OPL3 v1.8 is always used.
@Wohlstand
Copy link
Owner

Wohlstand commented Dec 11, 2023

Interesting thing!
Ye, it's better to add more arguments, there are various options including work modes (different volume models, channel allocation modes), and ability to run with an external WOPL bank files, not just with embedded banks. Also, there is an option that builds the library with all embedded banks disabled, so only external bank files can be used in such builds.

Speaking about the sound output, it's would be good to allow setting different sample rates and sample formats (you may take a look into midiplay how it does), and the buffer size (affects the latency).

@NY00123
Copy link
Author

NY00123 commented Dec 11, 2023

I see. I'll currently leave this PR as-is, in order to see if another person may test the patch.

I actually did optionally allow changing the sample rate in the beginning, but I eventually omitted this; adlmidiplay and the VLC plugin are the only components under utils that appear to allow the change (based on calls to adl_init), so this didn't seem to be a great deviation.

As for the various options, hopefully there's a source to adapt/copy from without having to change to a GPL license, albeit it's less of a problem for standalone programs; As an alternative to copying, this is where it looks like common configuration and command-line parsing code (to be used by multiple programs) could potentially help; Especially in case more options would get added in the future, and the existence of some of them depended on compile-time macros.

@Wohlstand
Copy link
Owner

Then, I could extend it by myself after testing. But right now I'm ill, and the rest of time I staying at my bed. I'll take this as soon as I can.

@NY00123
Copy link
Author

NY00123 commented Dec 12, 2023

Then, I could extend it by myself after testing. But right now I'm ill, and the rest of time I staying at my bed. I'll take this as soon as I can.

First of all, get well soon!

Personally, I can make use of the sequencer client separately. libADLMIDI is structured as a library so other programs can use it, after all. I've still thought of adding the ALSA sequencer client to the repository, as it's more general purpose, like the WinMM driver, albeit expected to have a significantly smaller audience.

@NY00123
Copy link
Author

NY00123 commented Dec 15, 2023

btw, this can be used with Windows software that's run via Wine, as Wine may subscribe to an ALSA sequencer client. One test case of mine is the game DemonStar (versions preceding the one recently released on Steam).

@NY00123
Copy link
Author

NY00123 commented Dec 20, 2023

Added a minor modification defining the port as SND_SEQ_PORT_TYPE_MIDI_GENERIC. It was previously defined just as SND_SEQ_PORT_TYPE_APPLICATION, which wasn't sufficient for one program. Other bits might or might not make sense, and SND_SEQ_PORT_TYPE_APPLICATION should maybe be removed.

I've actually uploaded a demonstration of this sequencer with DemonStar last week. As written earlier, this does not hold to the new edition recently released via Steam, since it doesn't use MIDI at all. But other versions (including older shareware ones) should work, as demonstrated here: https://www.youtube.com/watch?v=KeTPOf9S_ks

As previously mentioned, I haven't really added a lot of user-accessible configuration. There might be ways in which the output differs from a single genuine OPL3 chip, like Nuked OPL3's optional extended stereo support accessible from EDuke32-based ports.

Ignoring the changes in output related to Apogee's EMIDI format, this technically allows stereo FM output for DOS executables by using the Apogee Sound System without modifying them, in case it's identified as a General MIDI device for the game. There was originally limited stereo FM support only, disabled in compile-time as of early February 1995, according to the Apogee Sound System's change log.

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