DhrBaksteen / ArduinoOPL2

Arduino library for use with the OPL2 board (YM3812) and OPL3Duo (YMF262)
MIT License
198 stars 39 forks source link

Speed issues with complex songs #13

Closed mills32 closed 6 years ago

mills32 commented 6 years ago

Hi!

The board is working perfect!, I started to rip a lot of dro and imf to test and I found this issue. I tested this in imf player (because it was a bit simpler than dro).

Some complex songs are not playing at constan speed, I think it is because they use variable delays and the playinf is not returning the correct delay.

Removing the "round" from this line seems to (nearly) fix the problem, but still some variable speed. [code] return wait * (1000 / imfSpeed); [/code]

I thought arduino might be too "slow" to play complex songs, but that's not the case, because I used an external constant delay in the loop function, and the speed was constant (but of course the songs play incredibly fast).

Here is a song that has issues, it will play slower when all opl channels are being used. bpast.zip

ghost commented 6 years ago

Just to confirm, are you using PlayIMF.ino?

I'm not the creator of the board or that code, but based on issues I ran into when creating examples/SerialIface, here are some possible causes to investigate:

mills32 commented 6 years ago

Yes, I'm using PlayIMF. The sd speed is way faster than the songs need... So fast you can set a short delay in the loop, and you'll hear a 1 minute song in a few seconds, (and i'm preety sure it is not skipping data because I know the songs very well :) ).

I think the issue is the time resolution, so i'll try using the delayMicroseconds and tell you if that fixes it.

Thanks.

DhrBaksteen commented 6 years ago

The problem is that the IMF and DRO examples are not taking into account the time that was spent on IO so when a lot is happening the delay will be too long. It's just being lazy coding it :). I already have the examples fixed locally and I was saving them up to push with an upcoming update of the library. I can push these separately when I get home in a few hours

mills32 commented 6 years ago

That's cool, thanks.

mills32 commented 6 years ago

I'll then close the issue.