NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
thru.h
Go to the documentation of this file.
1/*
2 * NiCMidi - A C++ Class Library for MIDI
3 *
4 * Copyright (C) 2004 J.D. Koftinoff Software, Ltd.
5 * www.jdkoftinoff.com jeffk@jdkoftinoff.com
6 * Copyright (C) 2021, 2022 Nicola Cassetta
7 * https://github.com/ncassetta/NiCMidi
8 *
9 * This file is part of NiCMidi.
10 *
11 * NiCMidi is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as
13 * published by the Free Software Foundation, either version 3 of
14 * the License, or (at your option) any later version.
15 *
16 * NiCMidi is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with NiCMidi. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25
28
29
30#ifndef _NICMIDI_THRU_H
31#define _NICMIDI_THRU_H
32
33#include "driver.h"
34#include "tick.h"
35
36
45 public:
51 virtual ~MIDIThru();
58 virtual void Reset();
59
61 unsigned int GetInPort() const { return in_port; }
63 unsigned int GetOutPort() const { return out_port; }
65 MIDIProcessor* GetProcessor() { return processor; }
67 const MIDIProcessor* GetProcessor() const { return processor; }
69 int GetInChannel() const { return (int)in_channel; }
71 int GetOutChannel() const { return (int)out_channel; }
75 virtual bool SetInPort(unsigned int port);
79 virtual bool SetOutPort(unsigned int port);
84 virtual void SetProcessor(MIDIProcessor* proc);
89 virtual bool SetInChannel(int chan);
94 virtual bool SetOutChannel(int chan);
96 virtual void Start();
98 virtual void Stop();
99
100 protected:
103 static void StaticTickProc(tMsecs sys_time, void* pt);
105 virtual void TickProc(tMsecs sys_time);
106
107
109 unsigned int in_port; // The in port id
110 unsigned int out_port; // The out port id
111 signed char in_channel; // The in channel (0 .. 15, -1 for any channel)
112 signed char out_channel; // The out channel (0 .. 15, -1 for any channel)
113
114 MIDIProcessor* processor; // The MIDIProcessor you can plug to the thru
116
117 private:
118 void SilentOut(); // Internal use
119
120};
121
122
123#endif // THRU_H_INCLUDED
A pure virtual class implementing an object that can manipulate a MIDI message, inspecting or changin...
Definition: processor.h:47
A MIDITickComponent which immediately echoes to an out MIDI port all messages incoming from an in MID...
Definition: thru.h:44
const MIDIProcessor * GetProcessor() const
Returns a pointer to the MIDIProcessor attached to the thru (see SetProcessor()).
Definition: thru.h:67
virtual void Stop()
Stops the MIDI thru.
unsigned int GetOutPort() const
Returns a pointer to the MIDIOutDriver to whom messages are actually being sent.
Definition: thru.h:63
virtual void SetProcessor(MIDIProcessor *proc)
Sets the out processor, which can manipulate messages arrived to the in port before they are sent to ...
virtual void Reset()
Resets the class to initial status:
unsigned int GetInPort() const
Returns the number of the MIDI in port from which messages are actually being received.
Definition: thru.h:61
virtual bool SetOutChannel(int chan)
Sets the channel for outgoing thru messages.
MIDIThru()
The constructor.
virtual bool SetOutPort(unsigned int port)
Selects the hardware out port to whom messages will be sent.
int GetOutChannel() const
Returns the thru out channel (see SetOutChannel())
Definition: thru.h:71
MIDIProcessor * GetProcessor()
Returns a pointer to the MIDIProcessor attached to the thru (see SetProcessor()).
Definition: thru.h:65
virtual bool SetInPort(unsigned int port)
Selects the hardware in port from which messages will be received.
virtual void Start()
Starts the MIDI thru.
int GetInChannel() const
Returns the thru in channel (see SetInChannel())
Definition: thru.h:69
static void StaticTickProc(tMsecs sys_time, void *pt)
Implements the static method inherited from MIDITickComponent and called at every timer tick.
virtual ~MIDIThru()
The destructor.
virtual bool SetInChannel(int chan)
Sets the channel for incoming thru messages.
virtual void TickProc(tMsecs sys_time)
Implements the pure virtual method inherited from MIDITickComponent (you must not call it directly).
A pure virtual class implementing an object which has a callback procedure to be called at every tick...
Definition: tick.h:65
Contains the definition of the classes MIDIOutDriver and MIDIInDriver, used by the library to communi...
unsigned long long tMsecs
The type of a variable which can hold the elapsed time in milliseconds.
Definition: timer.h:44
Contains the definition of the pure virtual class MIDITickComponent.