haiku/headers/os/midi/MidiStore.h
mahlzeit f9b2179cb2 Instruments (patches) are now correctly recognized.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7573 a95241bf-73f2-0310-859d-f6bbb57e9c96
2004-05-14 07:46:19 +00:00

135 lines
2.9 KiB
C++

#ifndef _MIDI_STORE_H
#define _MIDI_STORE_H
#include <BeBuild.h>
#include <Midi.h>
#include <MidiSynthFile.h>
struct entry_ref;
class BFile;
class BList;
class BMidiEvent;
class BMidiStore : public BMidi
{
public:
BMidiStore();
virtual ~BMidiStore();
virtual void NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time = B_NOW);
virtual void ProgramChange(
uchar channel, uchar programNumber, uint32 time = B_NOW);
virtual void ChannelPressure(
uchar channel, uchar pressure, uint32 time = B_NOW);
virtual void PitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void SystemExclusive(
void* data, size_t length, uint32 time = B_NOW);
virtual void SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
status_t Import(const entry_ref* ref);
status_t Export(const entry_ref* ref, int32 format);
void SortEvents(bool force = false);
uint32 CountEvents() const;
uint32 CurrentEvent() const;
void SetCurrentEvent(uint32 eventNumber);
uint32 DeltaOfEvent(uint32 eventNumber) const;
uint32 EventAtDelta(uint32 time) const;
uint32 BeginTime() const;
void SetTempo(int32 beatsPerMinute);
int32 Tempo() const;
private:
friend class BMidiSynthFile;
virtual void _ReservedMidiStore1();
virtual void _ReservedMidiStore2();
virtual void _ReservedMidiStore3();
virtual void Run();
void AddEvent(BMidiEvent* event);
void SprayEvent(const BMidiEvent* event, uint32 time);
BMidiEvent* EventAt(int32 index) const;
uint32 GetEventTime(const BMidiEvent* event) const;
uint32 TicksToMilliseconds(uint32 ticks) const;
uint32 MillisecondsToTicks(uint32 ms) const;
BList* events;
int32 currentEvent;
uint32 startTime;
int32 beatsPerMinute;
int16 ticksPerBeat;
bool needsSorting;
void ReadFourCC(char* fourcc);
uint32 Read32Bit();
uint16 Read16Bit();
uint8 PeekByte();
uint8 NextByte();
void SkipBytes(uint32 length);
uint32 ReadVarLength();
void ReadChunk();
void ReadTrack();
void ReadSystemExclusive();
void ReadMetaEvent();
void WriteFourCC(char a, char b, char c, char d);
void Write32Bit(uint32 val);
void Write16Bit(uint16 val);
void WriteByte(uint8 val);
void WriteVarLength(uint32 val);
void WriteTrack();
void WriteMetaEvent(BMidiEvent* event);
BFile* file;
uint32 byteCount;
uint32 totalTicks;
uint16 numTracks;
uint16 currTrack;
uint16 format;
uint16 _reserved1[1];
bool* instruments;
synth_file_hook hookFunc;
int32 hookArg;
bool looping;
bool paused;
bool finished;
uint32 _reserved2[12];
};
#endif // _MIDI_STORE_H