/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDevicePlugin.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/drivers/audio/AudioOutputDevicePlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2354 - (hide annotations) (download)
Sun Jul 8 10:29:07 2012 UTC (11 years, 9 months ago) by persson
File size: 6401 byte(s)
* DSSI bugfix: it wasn't possible to change engine type. The MIDI port
  and audio channel routing for DSSI plugins are now visible.

1 persson 1777 /***************************************************************************
2     * *
3 schoenebeck 1934 * Copyright (C) 2008 - 2009 Andreas Persson *
4 persson 1777 * *
5     * This program is free software; you can redistribute it and/or modify *
6     * it under the terms of the GNU General Public License as published by *
7     * the Free Software Foundation; either version 2 of the License, or *
8     * (at your option) any later version. *
9     * *
10     * This program is distributed in the hope that it will be useful, *
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13     * GNU General Public License for more details. *
14     * *
15     * You should have received a copy of the GNU General Public License *
16     * along with this program; if not, write to the Free Software *
17     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
18     * MA 02110-1301 USA *
19     ***************************************************************************/
20    
21     #include "AudioOutputDevicePlugin.h"
22 persson 2354 #include "../../common/global_private.h"
23     #include <algorithm>
24 persson 1777
25     namespace LinuxSampler {
26    
27     // *************** AudioChannelPlugin ***************
28     // *
29    
30     AudioOutputDevicePlugin::AudioChannelPlugin::AudioChannelPlugin(uint ChannelNr) :
31     AudioChannel(ChannelNr, 0, 0) {
32     }
33    
34    
35 persson 2354 // *************** ParameterChannelsPlugin ***************
36     // *
37    
38     void AudioOutputDevicePlugin::ParameterChannelsPlugin::ForceSetValue(int channels) {
39     OnSetValue(channels);
40     iVal = channels;
41     }
42    
43    
44 persson 1777 // *************** ParameterFragmentSize ***************
45     // *
46    
47     AudioOutputDevicePlugin::ParameterFragmentSize::ParameterFragmentSize() : DeviceCreationParameterInt() {
48     InitWithDefault();
49     }
50    
51     AudioOutputDevicePlugin::ParameterFragmentSize::ParameterFragmentSize(String s) throw (Exception) : DeviceCreationParameterInt(s) {
52     }
53    
54     String AudioOutputDevicePlugin::ParameterFragmentSize::Description() {
55     return "Size of each buffer fragment";
56     }
57    
58     bool AudioOutputDevicePlugin::ParameterFragmentSize::Fix() {
59     return true;
60     }
61    
62     bool AudioOutputDevicePlugin::ParameterFragmentSize::Mandatory() {
63     return true;
64     }
65    
66     std::map<String,DeviceCreationParameter*> AudioOutputDevicePlugin::ParameterFragmentSize::DependsAsParameters() {
67     return std::map<String,DeviceCreationParameter*>(); // no dependencies
68     }
69    
70     optional<int> AudioOutputDevicePlugin::ParameterFragmentSize::DefaultAsInt(std::map<String,String> Parameters) {
71     return optional<int>::nothing;
72     }
73    
74     optional<int> AudioOutputDevicePlugin::ParameterFragmentSize::RangeMinAsInt(std::map<String,String> Parameters) {
75     return optional<int>::nothing;
76     }
77    
78     optional<int> AudioOutputDevicePlugin::ParameterFragmentSize::RangeMaxAsInt(std::map<String,String> Parameters) {
79     return optional<int>::nothing;
80     }
81    
82     std::vector<int> AudioOutputDevicePlugin::ParameterFragmentSize::PossibilitiesAsInt(std::map<String,String> Parameters) {
83     return std::vector<int>();
84     }
85    
86     void AudioOutputDevicePlugin::ParameterFragmentSize::OnSetValue(int i) throw (Exception) {
87     // not posssible, as parameter is fix
88     }
89    
90     String AudioOutputDevicePlugin::ParameterFragmentSize::Name() {
91     return "FRAGMENTSIZE";
92     }
93    
94    
95    
96     // *************** AudioOutputDevicePlugin ***************
97     // *
98    
99     AudioOutputDevicePlugin::AudioOutputDevicePlugin(std::map<String, DeviceCreationParameter*> Parameters) : AudioOutputDevice(Parameters) {
100     uiSampleRate = dynamic_cast<DeviceCreationParameterInt*>(
101     Parameters["SAMPLERATE"])->ValueAsInt();
102     uiMaxSamplesPerCycle = dynamic_cast<DeviceCreationParameterInt*>(
103     Parameters["FRAGMENTSIZE"])->ValueAsInt();
104    
105     // create audio channels
106     AcquireChannels(dynamic_cast<DeviceCreationParameterInt*>(
107     Parameters["CHANNELS"])->ValueAsInt());
108     }
109    
110     void AudioOutputDevicePlugin::Play() {
111     }
112    
113     bool AudioOutputDevicePlugin::IsPlaying() {
114     return true;
115     }
116    
117     void AudioOutputDevicePlugin::Stop() {
118     }
119    
120     uint AudioOutputDevicePlugin::MaxSamplesPerCycle() {
121     return uiMaxSamplesPerCycle;
122     }
123    
124     uint AudioOutputDevicePlugin::SampleRate() {
125     return uiSampleRate;
126     }
127    
128     String AudioOutputDevicePlugin::Driver() {
129     return Name();
130     }
131    
132     String AudioOutputDevicePlugin::Name() {
133     return "Plugin";
134     }
135    
136     String AudioOutputDevicePlugin::Version() {
137 schoenebeck 1934 String s = "$Revision: 1.2 $";
138 persson 1777 return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
139     }
140    
141     String AudioOutputDevicePlugin::Description() {
142     return Name();
143     }
144    
145     AudioChannel* AudioOutputDevicePlugin::CreateChannel(uint ChannelNr) {
146     return new AudioChannelPlugin(ChannelNr);
147     }
148 schoenebeck 1934
149     bool AudioOutputDevicePlugin::isAutonomousDevice() {
150     return false;
151     }
152    
153     bool AudioOutputDevicePlugin::isAutonomousDriver() {
154     return false;
155     }
156 persson 2354
157    
158     void AudioOutputDevicePlugin::AddChannels(int newChannels) {
159     static_cast<ParameterChannelsPlugin*>(
160     Parameters["CHANNELS"])->ForceSetValue(Channels.size() + newChannels);
161     }
162    
163     void AudioOutputDevicePlugin::RemoveChannel(AudioChannel* pChannel) {
164     std::vector<AudioChannel*>::iterator i = find(Channels.begin(), Channels.end(), pChannel);
165     int channelNumber = i - Channels.begin();
166     delete *i;
167     Channels.erase(i);
168    
169     for ( ; channelNumber < Channels.size() ; channelNumber++) {
170     static_cast<AudioChannelPlugin*>(Channels[channelNumber])->ChannelNr = channelNumber;
171     Channels[channelNumber]->ChannelParameters()["NAME"]->SetValue("Channel " + ToString(channelNumber));
172     }
173     static_cast<ParameterChannelsPlugin*>(
174     Parameters["CHANNELS"])->ForceSetValue(Channels.size());
175     }
176 persson 1777 }

  ViewVC Help
Powered by ViewVC