1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include "player.h"
- #include "opl.h"
- const unsigned short CPlayer::note_table[12] =
- {363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647, 686};
- const unsigned char CPlayer::op_table[9] =
- {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12};
- CPlayer::CPlayer(Copl *newopl)
- : opl(newopl) {
- }
- CPlayer::~CPlayer() {
- }
- unsigned long CPlayer::songlength(int subsong) {
- Copl tempopl;
- Copl *saveopl = opl;
- float slength = 0.0f;
-
- opl = &tempopl;
-
- rewind(subsong);
- while (update() && slength < 600000)
- slength += 1000.0f / getrefresh();
- rewind(subsong);
-
- opl = saveopl;
- return (unsigned long)slength;
- }
- void CPlayer::seek(unsigned long ms) {
- float pos = 0.0f;
- rewind();
- while (pos < ms && update())
- pos += 1000/getrefresh();
- }
|