Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
midiadapter.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Midi adapter
22 //=============================================================================
23 
24 #ifndef MIDIADAPTER_H
25 #define MIDIADAPTER_H
26 
27 #include <string>
28 
42 
44 {
45 public:
46 
49 
50  virtual void init() = 0;
51  virtual void exit() = 0;
52 
53  virtual int GetNumberOfPorts () = 0;
54  virtual std::string GetPortName (int i) = 0;
55  virtual std::string GetPortNames ();
56  virtual bool OpenPort (int i, std::string AppName="")=0;
57  virtual bool OpenPort (std::string AppName="") = 0;
58 
59  virtual int getCurrentPort() const = 0;
60 
67 
68  enum MidiEvent
69  {
74  };
75 
76 
87 
88  struct Data
89  {
91  int byte1;
92  int byte2;
93  double deltatime;
94  };
95 
96 public:
97 
98  // The following functions have to be public because of access from iosnativewrapper
99  static MidiEvent byteToEvent (int byte);
100  void send (Data &data);
101 };
102 
103 #endif // MIDIADAPTER_H
double deltatime
Time elapsed since the last MIDI event.
Definition: midiadapter.h:93
MidiEvent event
Midi event, encoded by the enumeration MidiEvent.
Definition: midiadapter.h:90
virtual void init()=0
Initialisation of the implementation.
Midi event when a key is pressed.
Definition: midiadapter.h:71
Midi event for changing voice.
Definition: midiadapter.h:73
MidiAdapter()
Constructor without function.
Definition: midiadapter.h:47
void send(Data &data)
Send new MIDI data to the messaging system.
Definition: midiadapter.cpp:84
~MidiAdapter()
Destructor without function.
Definition: midiadapter.h:48
virtual void exit()=0
Shut down the implementation.
MidiEvent
Enumeration of the possible MIDI events.
Definition: midiadapter.h:68
int byte1
Data byte, usually representing the MIDI key index.
Definition: midiadapter.h:91
virtual std::string GetPortName(int i)=0
Get the name of device number i (starting with zero)
virtual bool OpenPort(int i, std::string AppName="")=0
Open Midi input device number i.
Midi event when a key is released.
Definition: midiadapter.h:72
virtual int getCurrentPort() const =0
Get the current port number.
static MidiEvent byteToEvent(int byte)
Convert MIDI code to MidiEvent.
Definition: midiadapter.cpp:63
virtual int GetNumberOfPorts()=0
Get the number of available input devices.
Adapter class for reading an externally connected MIDI keyboard.
Definition: midiadapter.h:43
virtual std::string GetPortNames()
Get a list of all available input devices.
Definition: midiadapter.cpp:41
int byte2
Data byte, usually representing the keystroke intensity.
Definition: midiadapter.h:92
Midi event undefined.
Definition: midiadapter.h:70
Structure of the data associated with a MIDI event.
Definition: midiadapter.h:88