/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInputDevicePlugin.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/drivers/midi/MidiInputDevicePlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2494 - (show annotations) (download)
Wed Jan 1 17:48:01 2014 UTC (5 years, 9 months ago) by schoenebeck
File size: 4579 byte(s)
* Enabled automatic svn "Revision" macro expansion on certain files.
* Bumped version to 1.0.0.svn24.

1 /***************************************************************************
2 * *
3 * Copyright (C) 2008 - 2012 Andreas Persson *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
18 * MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "MidiInputDevicePlugin.h"
22 #include "../../common/global_private.h"
23
24 namespace LinuxSampler {
25
26 // *************** MidiInputPortPlugin ***************
27 // *
28
29 MidiInputDevicePlugin::MidiInputPortPlugin::MidiInputPortPlugin(MidiInputDevicePlugin* pDevice,
30 int portNumber) :
31 MidiInputPort(pDevice, portNumber) {
32 }
33
34
35
36 // *************** ParameterPortsPlugin ***************
37 // *
38
39 void MidiInputDevicePlugin::ParameterPortsPlugin::ForceSetValue(int ports) {
40 OnSetValue(ports);
41 iVal = ports;
42 }
43
44
45 // *************** MidiInputDevicePlugin ***************
46 // *
47
48 MidiInputDevicePlugin::MidiInputDevicePlugin(std::map<String, DeviceCreationParameter*> Parameters,
49 void* pSampler) :
50 MidiInputDevice(Parameters, pSampler) {
51 AcquirePorts(((DeviceCreationParameterInt*)Parameters["PORTS"])->ValueAsInt());
52 }
53
54 MidiInputDevicePlugin::~MidiInputDevicePlugin() {
55 for (std::map<int, MidiInputPort*>::iterator iter =
56 Ports.begin() ; iter != Ports.end() ; iter++) {
57 delete dynamic_cast<MidiInputPortPlugin*>(iter->second);
58 }
59 Ports.clear();
60 }
61
62 void MidiInputDevicePlugin::Listen() {
63 }
64
65 void MidiInputDevicePlugin::StopListen() {
66 }
67
68 String MidiInputDevicePlugin::Driver() {
69 return Name();
70 }
71
72 String MidiInputDevicePlugin::Name() {
73 return "Plugin";
74 }
75
76 String MidiInputDevicePlugin::Version() {
77 String s = "$Revision$";
78 return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
79 }
80
81 String MidiInputDevicePlugin::Description() {
82 return Name();
83 }
84
85 MidiInputPort* MidiInputDevicePlugin::CreateMidiPort() {
86 return new MidiInputPortPlugin(this, Ports.size());
87 }
88
89 void MidiInputDevicePlugin::AddMidiPort() {
90 static_cast<ParameterPortsPlugin*>(
91 Parameters["PORTS"])->ForceSetValue(Ports.size() + 1);
92 }
93
94 void MidiInputDevicePlugin::RemoveMidiPort(MidiInputPort* pPort) {
95 // reorder map so pPort is last
96 int portNumber = 0;
97 std::map<int, MidiInputPort*>::iterator i = Ports.begin();
98 for ( ; i != Ports.end(); ++i, portNumber++) {
99 if (i->second == pPort) break;
100 }
101 std::map<int, MidiInputPort*>::iterator previ = i;
102 for (++i ; i != Ports.end(); ++i, portNumber++) {
103 previ->second = i->second;
104 static_cast<MidiInputPortPlugin*>(previ->second)->portNumber = portNumber;
105 previ->second->PortParameters()["NAME"]->SetValue("Port " + ToString(portNumber));
106 previ = i;
107 }
108 previ->second = pPort;
109
110 // delete the last port
111 static_cast<ParameterPortsPlugin*>(
112 Parameters["PORTS"])->ForceSetValue(Ports.size() - 1);
113 }
114
115 bool MidiInputDevicePlugin::isAutonomousDevice() {
116 return false;
117 }
118
119 bool MidiInputDevicePlugin::isAutonomousDriver() {
120 return false;
121 }
122 }

Properties

Name Value
svn:keywords Revision

  ViewVC Help
Powered by ViewVC