CLAM-Development  1.4.0
MIDIIn.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
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, MA 02111-1307 USA
19  *
20  */
21 
22 #include "MIDIIn.hxx"
23 #include "MIDIManager.hxx"
24 
25 namespace CLAM {
26 
28  throw(ErrProcessingObj)
29 {
30  CopyAsConcreteConfig(mConfig, c);
31 
35  if (mpDevice)
36  mpDevice->Unregister(*this);
37 
38  MIDIManager *m;
39 
42  try {
43  m = &MIDIManager::Current();
44  }
45  catch (Err &e) {
46  ErrProcessingObj ne("MIDIIn::ConcreteConfigure(): No MIDIManager found.",this);
47  ne.Embed(e);
48  throw(ne);
49  }
50 
53  bool res;
54  try {
55  res = m->Register(*this);
56  }
57  catch (Err &e) {
58  ErrProcessingObj ne("MIDIIn::ConcreteConfigure(): Failed to register in MIDIManager.",this);
59  ne.Embed(e);
60  throw(ne);
61  }
62 
63  if (res == false)
64  throw ErrProcessingObj("MIDIIn::ConcreteConfigure(): "
65  "Failed to register in MIDIManager.",this);
66 
67  return true;
68 }
69 
71 {
72  if (!mpDevice)
73  throw(Err("MIDIIn::ConcreteStart(): No Device found!"));
75  mpDevice->Start();
76  return true;
77 }
78 
80 {
81  if (mpDevice)
82  mpDevice->GetInfo(info);
83  else
84  info.Reset();
85 }
86 
87 } // namespace CLAM
88