1
//---------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2012 LenMus project
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU General Public License as published by the Free Software Foundation,
7
// either version 3 of the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
10
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
// PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License along with this
14
// program. If not, see <http://www.gnu.org/licenses/>.
16
// For any comment, suggestion or feature request, please contact the manager of
17
// the project at cecilios@users.sourceforge.net
19
//---------------------------------------------------------------------------------------
21
#ifndef __LENMUS_MIDI_SERVER_H__
22
#define __LENMUS_MIDI_SERVER_H__
25
#include "lenmus_standard_header.h"
26
#include "lenmus_injectors.h" //to use wxMidi
27
#include "wxMidi.h" //to use wxMidi
30
#include "lomse_score_player.h"
31
using namespace lomse;
37
//---------------------------------------------------------------------------------------
38
//stores current MIDI configuration and interfaces with the MIDI API
39
class MidiServer : public lomse::MidiServerBase
42
ApplicationScope& m_appScope;
43
wxMidiSystem* m_pMidiSystem; //MIDI system
44
wxMidiInDevice* m_pMidiIn; //in device object
45
wxMidiOutDevice* m_pMidiOut; //out device object
47
//MIDI configuration information
53
int m_nDefaultVoiceChannel;
54
int m_nDefaultVoiceInstr;
65
MidiServer(ApplicationScope& appScope);
68
//set up configuration
69
void SetUpMidiOut(int nOutDevId, int nChannel, int nInstrument);
70
void SetOutDevice(int nOutDevId);
71
void SetInDevice(int nInDevId);
72
void SetUpCurrentConfig();
73
void VoiceChange(int nChannel, int nInstrument);
74
void SetMetronomeTones(int nTone1, int nTone2);
77
//wxMidiSystem* m_pMidiSystem; //MIDI system
78
inline wxMidiInDevice* get_in_device() { return m_pMidiIn; }
79
inline wxMidiOutDevice* get_out_device() { return m_pMidiOut; }
81
//Has user defined the MIDI configuration?
82
bool is_configured() { return m_fMidiSet; }
85
bool is_operative() { return m_fMidiOK; }
87
//Access to MIDI configuration information
88
int InDevId() { return m_nInDevId; }
89
int OutDevId() { return m_nOutDevId; }
90
int VoiceChannel() { return m_nVoiceChannel; }
91
int VoiceInstr() { return m_nVoiceInstr; }
92
int MtrChannel() { return m_nMtrChannel; }
93
int MtrInstr() { return m_nMtrInstr; }
94
int MtrTone1() { return m_nMtrTone1; }
95
int MtrTone2() { return m_nMtrTone2; }
98
void SetConfigured(bool value) { m_fMidiSet = value; }
99
void SaveUserPreferences();
102
//access to methods in midi system
106
int DefaultVoiceChannel() { return m_nDefaultVoiceChannel; }
107
int DefaultVoiceInstr() { return m_nDefaultVoiceInstr; }
109
//mandatory overrides from MidiServerBase
110
virtual void program_change(int channel, int instr) {
111
m_pMidiOut->ProgramChange(channel, instr);
113
virtual void voice_change(int channel, int instr) {
114
VoiceChange(channel, instr);
116
virtual void note_on(int channel, int pitch, int volume) {
117
m_pMidiOut->NoteOn(channel, pitch, volume);
119
virtual void note_off(int channel, int pitch, int volume) {
120
m_pMidiOut->NoteOff(channel, pitch, volume);
122
virtual void all_sounds_off() { m_pMidiOut->AllSoundsOff(); }
127
void LoadUserPreferences();
134
#endif // __LENMUS_MIDI_SERVER_H__