ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

midiparser_qt.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef AUDIO_MIDIPARSER_QT_H
00024 #define AUDIO_MIDIPARSER_QT_H
00025 
00026 #include "audio/midiparser.h"
00027 #include "common/array.h"
00028 #include "common/hashmap.h"
00029 #include "common/queue.h"
00030 #include "common/quicktime.h"
00031 
00048 class MidiParser_QT : public MidiParser, public Common::QuickTimeParser {
00049 public:
00050     MidiParser_QT() {}
00051     ~MidiParser_QT() {}
00052 
00053     // MidiParser
00054     bool loadMusic(byte *data, uint32 size);
00055     void unloadMusic();
00056 
00060     bool loadFromTune(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
00061 
00065     bool loadFromContainerStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
00066 
00070     bool loadFromContainerFile(const Common::String &fileName);
00071 
00072 protected:
00073     // MidiParser
00074     void parseNextEvent(EventInfo &info);
00075     void resetTracking();
00076 
00077     // QuickTimeParser
00078     SampleDesc *readSampleDesc(Track *track, uint32 format, uint32 descSize);
00079 
00080 private:
00081     struct MIDITrackInfo {
00082         byte *data;
00083         uint32 size;
00084         uint32 timeScale;
00085     };
00086 
00087     struct PartStatus {
00088         uint32 instrument;
00089         byte volume;
00090         byte pan;
00091         uint16 pitchBend;
00092     };
00093 
00094     class MIDISampleDesc : public SampleDesc {
00095     public:
00096         MIDISampleDesc(Common::QuickTimeParser::Track *parentTrack, uint32 codecTag);
00097         ~MIDISampleDesc() {}
00098 
00099         byte *_requestData;
00100         uint32 _requestSize;
00101     };
00102 
00103     uint32 readNextEvent();
00104     void handleGeneralEvent(uint32 control);
00105     void handleControllerEvent(uint32 control, uint32 part, byte intPart, byte fracPart);
00106     void handleNoteEvent(uint32 part, byte pitch, byte velocity, uint32 length);
00107 
00108     void definePart(uint32 part, uint32 instrument);
00109     void setupPart(uint32 part);
00110 
00111     byte getChannel(uint32 part);
00112     bool isChannelAllocated(byte channel) const;
00113     byte findFreeChannel(uint32 part);
00114     void deallocateFreeChannel();
00115     void deallocateChannel(byte channel);
00116     bool allChannelsAllocated() const;
00117 
00118     byte *readWholeTrack(Common::QuickTimeParser::Track *track, uint32 &trackSize);
00119 
00120     Common::Array<MIDITrackInfo> _trackInfo;
00121     Common::Queue<EventInfo> _queuedEvents;
00122 
00123     typedef Common::HashMap<uint, PartStatus> PartMap;
00124     PartMap _partMap;
00125 
00126     typedef Common::HashMap<uint, byte> ChannelMap;
00127     ChannelMap _channelMap;
00128 
00129     void initFromContainerTracks();
00130     void initCommon();
00131     uint32 readUint32();
00132 };
00133 
00134 #endif


Generated on Sat May 18 2019 05:01:09 for ResidualVM by doxygen 1.7.1
curved edge   curved edge