2003-03-18 01:24:09 +03:00
|
|
|
|
2002-11-01 19:11:03 +03:00
|
|
|
#ifndef _MIDI_STORE_H
|
|
|
|
#define _MIDI_STORE_H
|
|
|
|
|
|
|
|
#include <BeBuild.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <Midi.h>
|
2004-05-13 23:54:00 +04:00
|
|
|
#include <MidiSynthFile.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
struct entry_ref;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-01 23:08:23 +03:00
|
|
|
class BFile;
|
2003-03-18 01:24:09 +03:00
|
|
|
class BList;
|
|
|
|
class BMidiEvent;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
class BMidiStore : public BMidi
|
|
|
|
{
|
2002-11-21 22:23:22 +03:00
|
|
|
public:
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
BMidiStore();
|
|
|
|
virtual ~BMidiStore();
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void NoteOff(
|
|
|
|
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void NoteOn(
|
|
|
|
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void KeyPressure(
|
|
|
|
uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void ControlChange(
|
|
|
|
uchar channel, uchar controlNumber, uchar controlValue,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void ProgramChange(
|
|
|
|
uchar channel, uchar programNumber, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void ChannelPressure(
|
|
|
|
uchar channel, uchar pressure, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void PitchBend(
|
|
|
|
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void SystemExclusive(
|
|
|
|
void* data, size_t length, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void SystemCommon(
|
|
|
|
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
status_t Import(const entry_ref* ref);
|
|
|
|
status_t Export(const entry_ref* ref, int32 format);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
void SortEvents(bool force = false);
|
|
|
|
uint32 CountEvents() const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
uint32 CurrentEvent() const;
|
|
|
|
void SetCurrentEvent(uint32 eventNumber);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
uint32 DeltaOfEvent(uint32 eventNumber) const;
|
|
|
|
uint32 EventAtDelta(uint32 time) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
uint32 BeginTime() const;
|
2002-11-21 22:23:22 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
void SetTempo(int32 beatsPerMinute);
|
|
|
|
int32 Tempo() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
private:
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2004-05-13 23:54:00 +04:00
|
|
|
friend class BMidiSynthFile;
|
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
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];
|
2004-05-13 23:54:00 +04:00
|
|
|
|
2004-05-14 11:46:19 +04:00
|
|
|
bool* instruments;
|
2004-05-13 23:54:00 +04:00
|
|
|
synth_file_hook hookFunc;
|
|
|
|
int32 hookArg;
|
|
|
|
bool looping;
|
|
|
|
bool paused;
|
|
|
|
bool finished;
|
|
|
|
|
2004-05-14 11:46:19 +04:00
|
|
|
uint32 _reserved2[12];
|
2003-03-18 01:24:09 +03:00
|
|
|
};
|
2002-11-21 22:23:22 +03:00
|
|
|
|
2003-03-18 01:24:09 +03:00
|
|
|
#endif // _MIDI_STORE_H
|