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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1887 - (hide annotations) (download)
Sat Apr 18 08:17:16 2009 UTC (15 years, 1 month ago) by persson
File size: 5854 byte(s)
* bugfix: pitch bend wasn't working with JackMidi, VST, LV2, Mme,
  CoreMidi or AU
* theoretical fix: made SynchronizedConfig follow C++0x memory model
  more strictly

1 schoenebeck 201 /***************************************************************************
2     * *
3 schoenebeck 551 * Copyright (C) 2004, 2005 Grame *
4 persson 1887 * Copyright (C) 2005 - 2009 Christian Schoenebeck *
5 schoenebeck 201 * *
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., 59 Temple Place, Suite 330, Boston, *
19     * MA 02111-1307 USA *
20     ***************************************************************************/
21    
22     #include "MidiInputDeviceCoreMidi.h"
23 letz 362 #include "MidiInputDeviceFactory.h"
24 schoenebeck 201
25     namespace LinuxSampler {
26    
27 letz 362 int MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::pPortID = 0;
28    
29 schoenebeck 1149 MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterName::ParameterName(MidiInputPort* pPort) throw (Exception) : MidiInputPort::ParameterName(pPort, "Port " + ToString(pPort->GetPortNumber())) {
30 letz 362 OnSetValue(ValueAsString()); // initialize port name
31     }
32    
33 schoenebeck 1149 void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterName::OnSetValue(String s) throw (Exception) {
34 schoenebeck 551
35     }
36    
37 letz 362 // *************** ParameterCoreMidiBindings ***************
38     // *
39    
40     MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterCoreMidiBindings::ParameterCoreMidiBindings(MidiInputPortCoreMidi* pPort) : DeviceRuntimeParameterStrings( std::vector<String>() ) {
41     this->pPort = pPort;
42 schoenebeck 201 }
43    
44 letz 362 String MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterCoreMidiBindings::Description() {
45     return "Bindings to other CoreMidi clients";
46 schoenebeck 201 }
47 letz 362 bool MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterCoreMidiBindings::Fix() {
48     return false;
49     }
50 schoenebeck 201
51 letz 362 std::vector<String> MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterCoreMidiBindings::PossibilitiesAsString() {
52     std::vector<String> res;
53     // Connections
54     return res;
55     }
56    
57 schoenebeck 1149 void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ParameterCoreMidiBindings::OnSetValue(std::vector<String> vS) throw (Exception) {
58 letz 362 // to finish
59     }
60    
61    
62     // *************** MidiInputPortCoreMidi ***************
63     // *
64    
65     MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::MidiInputPortCoreMidi(MidiInputDeviceCoreMidi* pDevice) throw (MidiInputException) : MidiInputPort(pDevice, -1) {
66     // create CoreMidi virtual destination
67 schoenebeck 551
68 nagata 1642 /* 20080105 Toshi Nagata */
69     char buf[32];
70     CFStringRef str;
71     snprintf(buf, sizeof buf, "LinuxSampler_in_%d", pPortID);
72     str = CFStringCreateWithCString(NULL, buf, kCFStringEncodingUTF8);
73     MIDIDestinationCreate(pDevice->hCoreMidiClient, str, ReadProc, this, &pDestination);
74     /* */
75    
76 letz 362 if (!pDestination) throw MidiInputException("Error creating CoreMidi virtual destination");
77     this->portNumber = pPortID++;
78 schoenebeck 551
79 letz 362 Parameters["NAME"] = new ParameterName(this);
80     Parameters["CORE_MIDI_BINDINGS"] = new ParameterCoreMidiBindings(this);
81 schoenebeck 201 }
82    
83 letz 362 MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::~MidiInputPortCoreMidi() {
84     MIDIEndpointDispose(pDestination);
85     }
86 schoenebeck 551
87 letz 362 void MidiInputDeviceCoreMidi::MidiInputPortCoreMidi::ReadProc(const MIDIPacketList* pktlist, void* refCon, void* connRefCon)
88 schoenebeck 201 {
89 letz 362 MidiInputPortCoreMidi* port = (MidiInputPortCoreMidi*)refCon;
90 schoenebeck 551 MIDIPacket *packet = (MIDIPacket *)pktlist->packet;
91 letz 362
92     for (unsigned int i = 0; i < pktlist->numPackets; ++i) {
93 schoenebeck 551
94 schoenebeck 201 // To be checked : several events per packet
95 schoenebeck 551
96 persson 1887 port->DispatchRaw(packet->data);
97 schoenebeck 551
98 schoenebeck 201 packet = MIDIPacketNext(packet);
99 schoenebeck 551 }
100 letz 362 }
101    
102 schoenebeck 551
103     // *************** MidiInputDeviceCoreMidi ***************
104     // *
105    
106     MidiInputDeviceCoreMidi::MidiInputDeviceCoreMidi(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler) : MidiInputDevice(Parameters, pSampler)
107 letz 362 {
108     MIDIClientCreate(CFSTR("LinuxSampler"), NotifyProc, NULL, &hCoreMidiClient);
109     if (!hCoreMidiClient) throw MidiInputException("Error opening CoreMidi client");
110     AcquirePorts(((DeviceCreationParameterInt*)Parameters["PORTS"])->ValueAsInt());
111     }
112    
113 schoenebeck 551 MidiInputDeviceCoreMidi::~MidiInputDeviceCoreMidi()
114 letz 362 {
115     if (hCoreMidiClient) {
116     MIDIClientDispose(hCoreMidiClient);
117 schoenebeck 201 }
118 letz 362 }
119 schoenebeck 551
120 letz 362 MidiInputDeviceCoreMidi::MidiInputPortCoreMidi* MidiInputDeviceCoreMidi::CreateMidiPort() {
121     return new MidiInputPortCoreMidi(this);
122     }
123 schoenebeck 551
124 letz 362 String MidiInputDeviceCoreMidi::Name() {
125 letz 509 return "COREMIDI";
126 letz 362 }
127    
128     String MidiInputDeviceCoreMidi::Driver() {
129     return Name();
130     }
131 schoenebeck 551
132 letz 362 String MidiInputDeviceCoreMidi::Description() {
133     return "Apple CoreMidi";
134     }
135    
136     String MidiInputDeviceCoreMidi::Version() {
137 persson 1887 String s = "$Revision: 1.12 $";
138 letz 362 return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
139     }
140    
141     void MidiInputDeviceCoreMidi::NotifyProc(const MIDINotification* message, void* refCon)
142     {
143     // to be finished
144     if (message->messageID == kMIDIMsgSetupChanged) {
145     printf("kMIDIMsgSetupChanged\n");
146     }
147 schoenebeck 201 }
148    
149 schoenebeck 551
150 schoenebeck 201 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC