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

use Nuked OPL3 emulator #2

Closed
loki666 opened this issue Dec 6, 2016 · 17 comments
Closed

use Nuked OPL3 emulator #2

loki666 opened this issue Dec 6, 2016 · 17 comments

Comments

@loki666
Copy link
Contributor

@loki666 loki666 commented Dec 6, 2016

NukedOPL3 emulator has a very good emulation (close to real OPL3) and is LGPL licensed.
There is a version in adplug (https://github.com/adplug/adplug) which I integrated.
I gave it a quick shot for libADLMIDI, but the result was very bad (crashing sound).

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

I did some experiment with it, but wasn't sent result yet, it seems more accurate, but I still need to optimize something. Also I would have both of them but switch by macro. I need to test it on phones too to be sure it will don't lag on them. (especially SGS III with 1.2 Ghz quad core ARM cpu).
In the Doom banks hi-hats are sounds not fine (especially on libADLMIDI) with Nuked, but mayby some calibration is wrong (in ZDoom hihats sounds fine as on my real SoundBlaster 16, even it uses same Nuked emulator) and again, I think, I'll add it now to have it be switchable via macro.

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

Just small comparison of DOOM hihats generated by DosBox's (current) and by Nuke (register Management still be same):
http://wohlsoft.ru/docs/Music/Misc/drums_hihat_dosbox.ogg
http://wohlsoft.ru/docs/Music/Misc/drums_hihat_nuke.ogg

@loki666
Copy link
Contributor Author

@loki666 loki666 commented Dec 6, 2016

involving @nukeykt
he may have a better opinion on this

@nukeykt
Copy link

@nukeykt nukeykt commented Dec 6, 2016

Doom drums are quite frequency sensitive.
172.00093 seems is slightly wrong here:
https://github.com/Wohlstand/libADLMIDI/blob/master/src/adlmidi.cpp#L1209
Try to replace it with 172.4387 and check.

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

@nukeykt , okay, thanks for hint, much better:
http://wohlsoft.ru/docs/Music/Misc/drums_hihat_nuke_172.4387.ogg

P.S. that coefficient was before I forked original ADLMIDI player

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

Just pushed everything I made, now I will test this on my phone how it will lag it.
Just for comparison: PGE MusPlayer's CPU load while DosBox's emulator: 0%, Nuked: 12~15% in debug and 2% in release builds. (CPU at me is 4x cored Intel Core i5, 3.3 Ghz)

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

Okay, on phone it lags a lot, and sound is choppy. Seems is really need optimize it for best performance as possible to keep accuracy same, even one chip is processed.

On same device is 4 virtual chips of DosBox are processed and sound playing fine.

Used Open SL ES api for wave output.

I'll try to optimize it as possible to look what will happen.

@loki666
Copy link
Contributor Author

@loki666 loki666 commented Dec 6, 2016

I'll give it a try

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

P.S. What you are mean "crashing sound"? Which sample rate you are requesting? Also seems you may requested samples incorrectly. It spawns signed 16bit stereo. In the bottom of adlmidi.cpp (or in the midiplay fodder) you will find SDL Audio playing example which implements tiny console tool to test library.

@loki666
Copy link
Contributor Author

@loki666 loki666 commented Dec 6, 2016

I just updated my MIDI Player using your changes and it works just fine on my Nexus 5X

https://play.google.com/store/apps/details?id=net.volcanomobile.midiplayer

@loki666
Copy link
Contributor Author

@loki666 loki666 commented Dec 6, 2016

go in the Settings and enable ADLMIDI

@loki666
Copy link
Contributor Author

@loki666 loki666 commented Dec 6, 2016

just tested on a Nexus 4, and indeed, sound is choopy.
maybe you could add a settings to select the emulator at runtime

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 6, 2016

Just installed, waiting until it will fetch all my MIDIs (I have a huge and deep folders tree with lots of MIDIs in my collection), and it still think long time... Ok, just fetched, so long... But work have been done. I have CianogenMod 13 (based on Android 6.0) installed on SGS 3 (latest official for my phone 4.3 is fat, slow and glitchy) (1 GB official vs ~300 MB custom firmware).

I though to make at runtime selection, but some notices I have: ... but, wait, I can have polymorphic class for that to don't change code a lot and just swap pointers while toggling emulator type. Anyway I like Nuked synth, but I don't like it's CPU requirement which I want to fix.

P.S. I toggled Duke Nukem bank, and your app still use 0'th when I jumping to another melody.
P.P.S. I don't recommend use 0'th bank, because it has a bit incorrect drums. Use 58'th as default which is compared to Windows 9x's in-driver hardcoded bank.
P.P.P.S. Mayby you will allow to loop music? (even with max time limit or max loops limit) Internally libADLMIDI supports loop tags based on markers "loopStart" and "loopEnd" (but, with protection from mistakes while put those markers, for example, swapped or there are has same tick with no delay between which causes infinite loop inside library which was pain until I fixed that). And also 111'th controller as loop start point which used in RPG Maker.
P.P.P.P.S. I like your app for ability to automatically switch music or even implement a playlists system (my application is able to loop a single song https://github.com/Wohlstand/ADLMIDI-Player-Java).
P.P.P.P.P.S. I think to use mus2mid converter and xmi2mid from your codes to embed into libADLMIDI, because author of original ADLMIDI tried to implement them, but was made so few for that. To implement seek I also need to add the ticks counter with ability to navigate on the track. (Mayby completely rework it, also to sort events by priority (controllers and other stuff at the same position as notes are must be executed before notes!) to resolve some set of troubles caused by this thing)

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 7, 2016

Another P.S. Just trying play Corritor 7's IMF files (which are as every IMF file, a raw sequence of chip commands which targeted to real chip and if emulator doesn't plays them right, seems emulator doesn't correctly processing them), which by unknown reasons had silent melodic part on DosBox's OPL, but playing fine on Nuked OPL, so, that really makes sense! Anyway, by unknown reasons, snare drum on "dukeiia.imf" from Duke Nukem II sounds like is not correct (more like agogo) or I really need play it on my real Sound Blaster 16 card... Or, @nukeykt , what's wrong I made with macros experiment Or is it a one of "artifacts" of resampler (which you noticed on the Vogons before)? Or nothing to worry because real chip plays same? (chip commands which stored in IMF as is as was in original game, and just sequentially passed into emulator)

IMF file itself (I converted it into Wolfensten 3D hz rate): http://wohlsoft.ru/docs/Music/Misc/dukeiia.imf
Record from Nuked: http://wohlsoft.ru/docs/Music/Misc/dukeiia_nuked.ogg (snare like agogo)
Record from DosBox: http://wohlsoft.ru/docs/Music/Misc/dukeiia_dosbox.ogg (snare is fine)

@nukeykt
Copy link

@nukeykt nukeykt commented Dec 8, 2016

Nuked OPL3 sounds exactly like real OPL3:
https://youtu.be/ftV1XLmLHLE

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Dec 8, 2016

Okay, so, agogo-like snare is not problem and that fine, so, thanks for the proof!

@Wohlstand
Copy link
Owner

@Wohlstand Wohlstand commented Feb 22, 2017

Closed because already implemented

@Wohlstand Wohlstand closed this Feb 22, 2017
jpcima added a commit to jpcima/libADLMIDI that referenced this issue May 10, 2018
Wohlstand added a commit that referenced this issue May 10, 2018
pitch bend sensitivity attempt #2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants