/[svn]/linuxsampler/trunk/src/audiodriver/AudioOutputDevice.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/audiodriver/AudioOutputDevice.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: 3900 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 "AudioOutputDevice.h"
24
25 namespace LinuxSampler {
26
27 AudioOutputDevice::AudioOutputDevice(type_t Type) {
28 AudioOutputType = Type;
29 }
30
31 void AudioOutputDevice::Connect(Engine* pEngine) {
32 if (Engines.find(pEngine) == Engines.end()) {
33 pEngine->Connect(this);
34 Engines.insert(pEngine);
35 }
36 }
37
38 void AudioOutputDevice::Disconnect(Engine* pEngine) {
39 if (Engines.find(pEngine) != Engines.end()) { // if clause to prevent disconnect loop
40 Engines.erase(pEngine);
41 pEngine->DisconnectAudioOutputDevice();
42 }
43 }
44
45 AudioChannel* AudioOutputDevice::Channel(uint ChannelIndex) {
46 return (ChannelIndex < Channels.size()) ? Channels[ChannelIndex] : NULL;
47 }
48
49 int AudioOutputDevice::RenderAudio(uint Samples) {
50 if (Channels.empty()) return 0;
51
52 // reset all channels with silence
53 {
54 std::vector<AudioChannel*>::iterator iterChannels = Channels.begin();
55 std::vector<AudioChannel*>::iterator end = Channels.end();
56 for (; iterChannels != end; iterChannels++)
57 (*iterChannels)->Clear(); // zero out audio buffer
58 }
59
60 int result = 0;
61
62 // let all connected engines render audio for the current audio fragment cycle
63 {
64 std::set<Engine*>::iterator iterEngine = Engines.begin();
65 std::set<Engine*>::iterator end = Engines.end();
66 for (; iterEngine != end; iterEngine++) {
67 int res = (*iterEngine)->RenderAudio(Samples);
68 if (res != 0) result = res;
69 }
70 }
71
72 return result;
73 }
74
75 int AudioOutputDevice::RenderSilence(uint Samples) {
76 if (Channels.empty()) return 0;
77
78 // reset all channels with silence
79 {
80 std::vector<AudioChannel*>::iterator iterChannels = Channels.begin();
81 std::vector<AudioChannel*>::iterator end = Channels.end();
82 for (; iterChannels != end; iterChannels++)
83 (*iterChannels)->Clear(); // zero out audio buffer
84 }
85
86 return 0;
87 }
88
89 AudioOutputDevice::type_t AudioOutputDevice::Type() {
90 return AudioOutputType;
91 }
92
93 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC