/[svn]/linuxsampler/trunk/src/mididriver/MidiInputDevice.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/mididriver/MidiInputDevice.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 64 - (show annotations) (download)
Thu May 6 20:06:20 2004 UTC (19 years, 11 months ago) by schoenebeck
File size: 3788 byte(s)
* src/Sampler.cpp: fixed 3 stupid but fatal bugs that left in the rush (in
  method SamplerChannels(), CreateAudioOutputDevice() and
  CreateMidiInputDevice())
* src/network/lscpserver.cpp: implemented LSCP command
  'SET CHANNEL MIDI_INPUT_CHANNEL'
* src/Sampler.h: moved enums 'audio_output_type_t', 'midi_input_type_t'
  and 'engine_type_t' into the respective base classes
  ('AudioOutputDevice', 'MidiInputDevice', 'Engine')

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #include "MidiInputDevice.h"
24
25 namespace LinuxSampler {
26
27 MidiInputDevice::MidiInputDevice(type_t Type) {
28 MidiInputType = Type;
29 }
30
31 void MidiInputDevice::DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel) {
32 std::set<Engine*>::iterator engineiter = MidiChannelMap[MidiChannel].begin();
33 std::set<Engine*>::iterator end = MidiChannelMap[MidiChannel].end();
34 for (; engineiter != end; engineiter++) (*engineiter)->SendNoteOn(Key, Velocity);
35 }
36
37 void MidiInputDevice::DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel) {
38 std::set<Engine*>::iterator engineiter = MidiChannelMap[MidiChannel].begin();
39 std::set<Engine*>::iterator end = MidiChannelMap[MidiChannel].end();
40 for (; engineiter != end; engineiter++) (*engineiter)->SendNoteOff(Key, Velocity);
41 }
42
43 void MidiInputDevice::DispatchPitchbend(int Pitch, uint MidiChannel) {
44 std::set<Engine*>::iterator engineiter = MidiChannelMap[MidiChannel].begin();
45 std::set<Engine*>::iterator end = MidiChannelMap[MidiChannel].end();
46 for (; engineiter != end; engineiter++) (*engineiter)->SendPitchbend(Pitch);
47 }
48
49 void MidiInputDevice::DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel) {
50 std::set<Engine*>::iterator engineiter = MidiChannelMap[MidiChannel].begin();
51 std::set<Engine*>::iterator end = MidiChannelMap[MidiChannel].end();
52 for (; engineiter != end; engineiter++) (*engineiter)->SendControlChange(Controller, Value);
53 }
54
55 void MidiInputDevice::Connect(Engine* pEngine, midi_chan_t MidiChannel) {
56 if (MidiChannel < 0 || MidiChannel > 16)
57 throw MidiInputException("MIDI channel index out of bounds");
58 Disconnect(pEngine);
59 MidiChannelMap[MidiChannel].insert(pEngine);
60 }
61
62 void MidiInputDevice::Disconnect(Engine* pEngine) {
63 try { for (int i = 0; i <= 16; i++) MidiChannelMap[i].erase(pEngine); }
64 catch(...) { /* NOOP */ }
65 }
66
67 MidiInputDevice::type_t MidiInputDevice::Type() {
68 return MidiInputType;
69 }
70
71 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC