XFuXMPlayer.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# XFuXMPlayer.h

Go to the documentation of this file.

    00001 /*! \file
    00002  * X-Forge Util <br>
    00003  * Copyright 2000-2003 Fathammer Ltd
    00004  *
    00005  * \brief XM player header file
    00006  *
    00007  * $Id: XFuXMPlayer.h,v 1.20 2003/10/06 11:26:47 toni Exp $
    00008  * $Date: 2003/10/06 11:26:47 $
    00009  * $Revision: 1.20 $
    00010  */
    00011
    00012 #ifndef XFUXMPLAYER_H_INCLUDED
    00013 #define XFUXMPLAYER_H_INCLUDED
    00014
    00015 #include <xfcore/XFcAudioStream.h>
    00016 #include <xfutil/XFuXMPlayer_internal.h>
    00017 #include <xfutil/XFuXMPlayerEventHandler.h>
    00018
    00019
    00020 template<class T> class XFcLinkedList;
    00021
    00022
    00023 class XFuXMPlayerEventHandlerSlot
    00024 {
    00025 public:
    00026     XFuXMPlayerEvent mEvent;
    00027     XFuXMPlayerEventHandler *mHandler;
    00028
    00029     INT operator != (const XFuXMPlayerEventHandlerSlot &aRef) const
    00030     {
    00031         return !(mHandler == aRef.mHandler);
    00032     }
    00033
    00034     INT operator == (const XFuXMPlayerEventHandlerSlot &aRef) const
    00035     {
    00036         return (mHandler == aRef.mHandler);
    00037     }
    00038 };
    00039
    00040
    00041 //! Plays XM music files.
    00042 class XFuXMPlayer : public XFcAudioStream
    00043 {
    00044 protected:
    00045     FLOAT32 mSamplingRate;              //!< Sampling rate.
    00046     UINT32 mFlags;                      //!< Format flags.
    00047     INT32 mTgtXor;                      //!< Signed/unsigned xor value.
    00048
    00049     XFuXMFormatHeader mXMHeader;        //!< XM file header.
    00050     XFuXMSong mSong;                    //!< Module.
    00051
    00052     XFuXMFormatPatternHeader *mXMPatternHeaders;    //!< XM pattern headers.
    00053     XFuXMPattern *mPatternData;                     //!< Pattern data.
    00054
    00055     XFuXMInstrument *mInstruments;      //!< Instruments.
    00056
    00057     XFuXMChannel *mChannels;            //!< Channels.
    00058
    00059     INT16 mSineWaveTable[XMFORMAT_SIZEOF_WAVEFORM];
    00060     INT16 mSquareWaveTable[XMFORMAT_SIZEOF_WAVEFORM];
    00061     INT16 mRampUpTable[XMFORMAT_SIZEOF_WAVEFORM];
    00062     INT16 mRampDownTable[XMFORMAT_SIZEOF_WAVEFORM];
    00063
    00064     UINT32 mPpoint;                     //!< Pattern data index.
    00065     INT16 mCurrentOrder;                //!< Order index.
    00066     INT16 mPatternNb;                   //!< Pattern index.
    00067     INT16 mCurrentRow;                  //!< Row index.
    00068     INT32 mSamplesPerTick;              //!< Amount of samples in one tick.
    00069     INT32 mSamplePointer;               //!< Counter.
    00070     FLOAT32 mTickRate;                  //!< Tick speed in Hz.
    00071     INT32 mRamp;
    00072
    00073     UINT8 mPatternDelayCounter;         //!< Pattern delay counter.
    00074     UINT8 mPatternDelayCounterTemp;     //!< Temporary pattern delay counter.
    00075     UINT8 mPatternDelaySkip;            //!< Flag for skipping pattern delay commands.
    00076
    00077     UINT8 mIsRead;                      //!< Flag indicating whether pattern data should be read.
    00078     UINT8 mJumpFlag;                    //!< Flag for pattern jump and pattern break commands.
    00079
    00080     UINT8 mCurrentTick;                 //!< Tick index (0..tempo-1).
    00081     UINT32 mTotalTicks;                 //!< Test tick counter.
    00082
    00083     REAL mVolumeRampDivOpt;             //!< For volume ramping.
    00084
    00085     //! List of event handlers interested in events of this player.
    00086     XFcLinkedList<XFuXMPlayerEventHandlerSlot> *mEventHandlers;
    00087
    00088
    00089     INT loadXM(const CHAR *aFilename, XFcFile *aTextout);
    00090
    00091
    00092     XFuXMFormatAtom getAtom();
    00093
    00094     void dumpSongParameters(XFcFile *aTextout);
    00095
    00096
    00097     UINT32 getPeriod(INT8 aNote, INT8 aFinetune);
    00098
    00099     UINT32 getSpeed(UINT32 aPeriod, FLOAT32 aSamplingRate);
    00100
    00101     void initChannel(XFuXMChannel &aCh);
    00102
    00103     void initSound(XFuXMChannel &aCh);
    00104
    00105
    00106     //! Notify handlers of events.
    00107     void notifyHandlers(XFuXMChannel &aCh);
    00108
    00109     void debugPrint(XFcFile *aTextout, char *aFmt, ...);
    00110
    00111
    00112     XFuXMPlayer(FLOAT32 aSamplingRate, UINT32 aFlags);
    00113
    00114 public:
    00115     //! Initializes the playhead to the beginning of a certain pattern.
    00116     void initSong(INT16 aStartOrder);
    00117
    00118     //! Returns the player's internal tick.
    00119     INT32 getTick();
    00120
    00121     //! Returns the current order being played.
    00122     INT16 getCurrentOrder();
    00123
    00124
    00125     //! Adds a new event handler to this player.
    00126     void addHandler(XFuXMPlayerEvent aEvent, XFuXMPlayerEventHandler *aHandler);
    00127
    00128     //! Removes a specific event handler from this player.
    00129     INT removeHandler(XFuXMPlayerEventHandler *aHandler);
    00130
    00131     //! Removes all event handlers from this player.
    00132     void removeHandlers();
    00133
    00134
    00135     virtual void stop();
    00136
    00137     virtual UINT32 stream(void *aBuffer, INT32 aTargetSamples, INT32 aOffset,
    00138                           INT32 aSamples);
    00139
    00140     //! Creates an XM-Player.
    00141     /*!
    00142      * Creates an XM-Player with the given module name, sampling rate and audio format.
    00143      */
    00144     static XFuXMPlayer * create(const CHAR *aFilename, FLOAT32 aSamplingRate,
    00145                                 UINT32 aFlags);
    00146
    00147     virtual ~XFuXMPlayer();
    00148 };
    00149
    00150
    00151 #endif // !XFUXMPLAYER_H_INCLUDED
    00152

|  | X-Forge Documentation Confidential Copyright © 2002-2003 Fathammer |  | Documentation generated with doxygen by Dimitri van Heesch