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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3054 - (hide annotations) (download)
Thu Dec 15 12:47:45 2016 UTC (7 years, 4 months ago) by schoenebeck
File size: 4671 byte(s)
* Fixed numerous compiler warnings.
* Bumped version (2.0.0.svn32).

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

Properties

Name Value
svn:keywords Revision

  ViewVC Help
Powered by ViewVC