player.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Adplug - Replayer for many OPL2/OPL3 audio file formats.
  3. * Copyright (C) 1999 - 2007 Simon Peter, <dn.tlp@gmx.net>, et al.
  4. *
  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.
  9. *
  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.
  14. *
  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
  18. *
  19. * player.h - Replayer base class, by Simon Peter <dn.tlp@gmx.net>
  20. */
  21. #ifndef H_ADPLUG_PLAYER
  22. #define H_ADPLUG_PLAYER
  23. #include <string>
  24. #include "fprovide.h"
  25. #include "opl.h"
  26. class CPlayer {
  27. public:
  28. CPlayer(Copl *newopl);
  29. virtual ~CPlayer();
  30. /***** Operational methods *****/
  31. void seek(unsigned long ms);
  32. virtual bool load(const std::string &filename, // loads file
  33. const CFileProvider &fp = CProvider_Filesystem()) = 0;
  34. virtual bool update() = 0; // executes replay code for 1 tick
  35. virtual void rewind(int subsong = -1) = 0; // rewinds to specified subsong
  36. virtual float getrefresh() = 0; // returns needed timer refresh rate
  37. /***** Informational methods *****/
  38. unsigned long songlength(int subsong = -1);
  39. virtual std::string gettype() = 0; // returns file type
  40. virtual std::string gettitle() { // returns song title
  41. return std::string();
  42. }
  43. virtual std::string getauthor() { // returns song author name
  44. return std::string();
  45. }
  46. virtual std::string getdesc() { // returns song description
  47. return std::string();
  48. }
  49. virtual unsigned int getpatterns() { // returns number of patterns
  50. return 0;
  51. }
  52. virtual unsigned int getpattern() { // returns currently playing pattern
  53. return 0;
  54. }
  55. virtual unsigned int getorders() { // returns size of orderlist
  56. return 0;
  57. }
  58. virtual unsigned int getorder() { // returns currently playing song position
  59. return 0;
  60. }
  61. virtual unsigned int getrow() { // returns currently playing row
  62. return 0;
  63. }
  64. virtual unsigned int getspeed() { // returns current song speed
  65. return 0;
  66. }
  67. virtual unsigned int getsubsongs() { // returns number of subsongs
  68. return 1;
  69. }
  70. virtual unsigned int getinstruments() { // returns number of instruments
  71. return 0;
  72. }
  73. virtual std::string getinstrument(unsigned int n) { // returns n-th instrument name
  74. return std::string();
  75. }
  76. protected:
  77. Copl *opl; // our OPL chip
  78. static const unsigned short note_table[12]; // standard adlib note table
  79. static const unsigned char op_table[9]; // the 9 operators as expected by the OPL
  80. };
  81. #endif