2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2007 Simon Peter, <dn.tlp@gmx.net>, et al.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * player.cpp - Replayer base class, by Simon Peter <dn.tlp@gmx.net>
24 #include "silentopl.h"
28 const unsigned short CPlayer::note_table[12] =
29 {363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647, 686};
31 const unsigned char CPlayer::op_table[9] =
32 {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12};
34 CPlayer::CPlayer(Copl *newopl)
35 : opl(newopl), db(CAdPlug::database)
43 unsigned long CPlayer::songlength(int subsong)
49 // save original OPL from being overwritten
54 while(update() && slength < 600000) // song length limit: 10 minutes
55 slength += 1000.0f / getrefresh();
58 // restore original OPL and return
60 return (unsigned long)slength;
63 void CPlayer::seek(unsigned long ms)
68 while(pos < ms && update()) // seek to new position
69 pos += 1000/getrefresh();