Planeshift
songstream.h
Go to the documentation of this file.
1 /*
2  * songstream.h, Author: Andrea Rizzi <88whacko@gmail.com>
3  *
4  * Copyright (C) 2001-2011 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program 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
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef SONGSTREAM_H
21 #define SONGSTREAM_H
22 
23 
24 //====================================================================================
25 // Crystal Space Includes
26 //====================================================================================
27 #include <cssysdef.h>
28 #include <csutil/ref.h>
29 #include <csutil/randomgen.h>
30 #include <csplugincommon/sndsys/sndstream.h>
31 
32 //------------------------------------------------------------------------------------
33 // Forward Declarations
34 //------------------------------------------------------------------------------------
35 class Instrument;
36 class SndSysSongData;
37 struct SongData;
38 struct csSndSysSoundFormat;
39 
40 using namespace CS::SndSys;
41 
43 {
44 public:
45  SndSysSongStream(csRef<SndSysSongData> soundData, SongData* songData, csSndSysSoundFormat* renderFormat, int mode3D);
46  virtual ~SndSysSongStream();
47 
48  // From iSndSysStream
49  //--------------------
50  virtual void AdvancePosition(size_t frameDelta);
51  virtual const char* GetDescription();
52  virtual size_t GetFrameCount();
53 
54  // SndSysBasicStream overriding
55  //------------------------------
56  virtual bool AlwaysStream() const { return true; }
57  virtual bool ResetPosition();
58  virtual bool SetPosition(size_t newPosition) { return false; } // not supported
59  virtual bool SetLoopBoundaries(size_t startPosition, size_t endPosition) { return false; } // not supported
60 
61 private:
62  bool isFinished;
63  size_t currentMeasure;
64  size_t currentNote;
65 
66  size_t lastRepeatStart;
67  size_t lastRepeatEnd;
68  int repeatCounter;
69  csArray<uint> repeatsDone;
70  char* copyNoteBuffer;
71  size_t lastNoteSize;
72 
73  SongData* songData;
74  float timePerDivision;
75  csRef<SndSysSongData> soundData;
76 
77  int conversionFactor;
78  bool conversionNeeded;
79 
86  bool CheckPlaybackReadComplete();
87 
97  bool GetNextChord(char* &noteBuffer, size_t &noteBufferSize);
98 
108  void AdjustAlteration(char pitch, int &alter);
109 
118  void CopyNoteIntoBuffer(char* noteBuffer, size_t noteBufferSize);
119 };
120 
121 #endif /* SONGSTREAM_H */
virtual bool SetPosition(size_t newPosition)
Definition: songstream.h:58
This implements a data class that can be used for the CS sound system to play a song from a musical s...
Definition: songdata.h:78
This struct keeps the data about the instrument and the musical sheet.
Definition: songdata.h:48
virtual bool AlwaysStream() const
Definition: songstream.h:56
virtual bool SetLoopBoundaries(size_t startPosition, size_t endPosition)
Definition: songstream.h:59
This class represent a musical instrument.
Definition: instrument.h:68