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

Adapt to OPL3DUO (serial control OPL3 actual hardware) #89

Open
denjhang opened this issue Oct 25, 2022 · 8 comments
Open

Adapt to OPL3DUO (serial control OPL3 actual hardware) #89

denjhang opened this issue Oct 25, 2022 · 8 comments

Comments

@denjhang
Copy link

https://github.com/DhrBaksteen/ArduinoOPL2
Arduino OPL2 allows to use serial port to control YM3812 or YMF262, I hope vgmplay can adapt to this function.
I made a USB-OPL3 based on Arduino OPL2, and currently I can use Dosbox-X+sbvgm to play music from OPL1/2/3.

@ValleyBell
Copy link
Contributor

I see lots of Arduino-code in that repo. But VGMPlay doesn't run on an Arduino.,

Is there a way to access the OPL3Duo from the PC side? And if so, please describe (or link) how it is done.
If it should be a serial connection via COM port, then I need information about the baud rate, stop bits, etc.

@denjhang
Copy link
Author

https://github.com/DhrBaksteen/ArduinoOPL2/blob/master/examples/OPL3Duo/SerialPassthrough/SerialPassthrough.ino
https://github.com/DhrBaksteen/ArduinoOPL2/blob/master/examples/OPL2AudioBoard/SerialPassthrough/SerialPassthrough.ino

Currently I use SerialPassthrough.ino of OPL3DUO, compile these codes with arduino and upload them to arduino nano.
After that I use dosbox-x and specify the port number (like com3) and I can use the actual opl3 hardware.

sshot-20221025-123536

@denjhang
Copy link
Author

In addition to using dosbox-x to access opl3duo, you can also use opl3bankeditor
https://github.com/Wohlstand/OPL3BankEditor

and an immature vgm player made by my friend.
https://github.com/zhblue/OPL3USB/tree/main/vgmplay2usb

@denjhang
Copy link
Author

sshot-20221025-124005

@denjhang
Copy link
Author

By the way, the vgmplay2usb made by my friend has been tested and found that the playback speed is very unstable, fast and slow. And it plays very slowly when it encounters VGM with many notes. This doesn't happen when I use dosbox-x+sbvgm.

@ValleyBell
Copy link
Contributor

vgmplay2usb's timing code just uses Sleep(wait/speed); to perform timing.
In practise this guarantees you that timing will be inaccurate, because any sort of "wait" command waits at least the specified time. Sleep(4) may return after 4 ms ... or after 300 ms if the OS is busy with other stuff.

VGMPlay uses a separate time counter that is advanced by the VGM wait commands. It does Sleep(1) in a loop until the system time reaches the target time. When waiting takes too long for one delay, it will wait a shorter time for the next command. Thus the overall timing will be stable. (And it has been for hardware OPL passthrough when I used it.)

(Also, vgmplay2usb calling _kbhit() between every VGM command will probably slow down VGM parsing. I'd check for key input only when actively waiting.)

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

No branches or pull requests

2 participants