source: cmedia/trunk/Drv16/midistrm.hpp@ 577

Last change on this file since 577 was 553, checked in by rudi, 14 years ago

Adapt sourcecode to OpenWatcom

File size: 4.3 KB
Line 
1/* $Id: midistrm.hpp,v 1.1 2000/04/23 14:55:18 ktk Exp $ */
2
3/* SCCSID = %W% %E% */
4/****************************************************************************
5 * *
6 * Copyright (c) IBM Corporation 1994 - 1997. *
7 * *
8 * The following IBM OS/2 source code is provided to you solely for the *
9 * the purpose of assisting you in your development of OS/2 device drivers. *
10 * You may use this code in accordance with the IBM License Agreement *
11 * provided in the IBM Device Driver Source Kit for OS/2. *
12 * *
13 ****************************************************************************/
14/**@internal %W%
15 * Defines, class definations and prototypes for the MIDISTREAM class
16 * @version %I%
17 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
18 * kernel stack.
19 * @history
20 */
21#ifndef MIDISTREAM_INCLUDED
22#define MIDISTREAM_INCLUDED
23
24#ifndef OS2_INCLUDED
25#define INCL_NOPMAPI
26#include <os2.h>
27#endif
28
29#ifndef OS2ME_INCLUDED
30#include <os2me.h> // prereq to midistrm.hpp
31#endif
32
33#ifndef DDCMD_REG_STREAM // shdd.h can't handle being included twice
34#include <shdd.h> // for PDDCMDREGISTER
35#endif
36
37#include "stream.hpp" // Object definition.
38#include "midimsg.hpp" // Object definition.
39
40// Number of notes in the MIDI definition.
41const USHORT NUM_MidiNotes = 128;
42
43// Number of channels in the MIDI definition.
44const USHORT NUM_MidiChannels = 16;
45
46// The MIDI parser is always in one of the following states.
47enum PARSER_STATE
48{
49 S_Init, // Initial state.
50 S_ChannelMsg, // Channel message in progress.
51 S_SystemCommon, // System Common message in progress.
52 S_SysexSignature, // System Exclusive signature (1st 4 bytes).
53 S_SysexIBM, // IBM Sysex in progress.
54 S_SysexNotIBM // Non-IBM Sysex in progress.
55};
56
57
58class MIDISTREAM : public STREAM {
59
60public:
61 MIDISTREAM( USHORT streamtype, USHORT filesysnum);
62 virtual ~MIDISTREAM() {};
63
64 void Process ( void ); // Called by Timer when it's time to do work.
65 // Process() schedules its next invocation.
66
67 virtual ULONG GetCurrentTime(void);
68 virtual void SetCurrentTime(ULONG time);
69
70// virtual ULONG Register(PDDCMDREGISTER);
71
72 virtual ULONG Read(PSTREAMBUF, unsigned);
73 virtual ULONG StartStream(void);
74 virtual ULONG StopStream(PCONTROL_PARM);
75 virtual ULONG PauseStream(PCONTROL_PARM);
76 virtual ULONG ResumeStream(void);
77
78 virtual BOOL SetProperty(int type, ULONG value, ULONG reserved = 0);
79 virtual ULONG GetCurrentPos(void) { return 0; };
80 virtual ULONG GetCurrentWritePos(void) { return 0; };
81
82private:
83// Members that deal with timing
84 ULONG ulPerClock; // microseconds per 0xF8 timing pulse
85 ULONG _ulLastProcess; // Time on clock when we last processed MIDI messages.
86 long lWait; // microseconds to wait until it's time to
87 // process the next message
88 ULONG ulTempo; // 1/10 beats per minute (beats per 10 minutes)
89 USHORT usCPQN; // last PPQN scalar received from MMPM; is
90 // _not_ the current PPQN value. used by
91 // CalcDelay() to compute ulPerClock.
92 void CalcDelay(void); // calculates ulPerClock (per 0xF8 pulse)
93 void ResetParser(BOOL fFreshStart); // Initialize parser and timing variables
94
95// Members that deal with processing the stream data
96 USHORT _notesOn[ NUM_MidiNotes ];
97 // 128 x 16 bit matrix, each bit represents one
98 // note on one channel. Records whether each note
99 // is currently on or off. Used for "all notes off".
100
101 PARSER_STATE state; // Current state of MIDI parser, as enumerated above.
102 MIDIMSG message; // Current message that we're assembling from the input stream.
103
104 void _allNotesOff( void ); // Shut off all notes that are currently playing.
105 void parse( MIDIBYTE bInput ); // Parse the next byte of the input stream.
106 void dispatch( MIDIMSG& msg ); // Interpret the complete message.
107};
108
109#endif
Note: See TracBrowser for help on using the repository browser.