NetworkPlayer.cxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2007 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #include "NetworkPlayer.hxx"
00023 #include "AudioSource.hxx"
00024 #include "AudioBufferSource.hxx"
00025 #include "AudioSink.hxx"
00026 #include "AudioBufferSink.hxx"
00027 #include "ControlSource.hxx"
00028 #include "ControlSink.hxx"
00029 
00030 namespace CLAM
00031 {
00032 
00033 std::string NetworkPlayer::SourcesAndSinksToString()
00034 {
00035         CacheSourcesAndSinks();
00036         std::string result;
00037         for (unsigned i=0; i<_audioSources.size(); i++)
00038                 result += " * source:\t"+SourceName(i)+"\n";
00039         for (unsigned i=0; i<_audioSinks.size(); i++)
00040                 result += " * sink:\t"+SinkName(i)+"\n";
00041         return result;
00042 }
00043 
00044 void NetworkPlayer::ReadControlSource(unsigned source, const float * data)
00045 {
00046         if (not data) return;
00047         ControlSource * processing =
00048                 (ControlSource*) _controlSources[source].processing;
00049         processing->Do( *data );
00050 }
00051 
00052 void NetworkPlayer::FeedControlSink(unsigned sink, float * data)
00053 {
00054         if (not data) return;
00055         ControlSink * processing =
00056                 (ControlSink*) _controlSinks[sink].processing;
00057         *data = processing->GetControlValue();
00058         
00059 }
00060 
00061 void NetworkPlayer::SetSourceBuffer(unsigned source, const float * data, unsigned nframes)
00062 {
00063         Processing * processing = _audioSources[source].processing;
00064         unsigned port = _audioSources[source].port;
00065         SetExternalBuffer<AudioSource>(processing, data, nframes, port);
00066         SetExternalBuffer<AudioBufferSource>(processing, data, nframes, port);
00067 }
00068 void NetworkPlayer::SetSinkBuffer(unsigned sink, float * data, unsigned nframes)
00069 {
00070         Processing * processing = _audioSinks[sink].processing;
00071         unsigned port = _audioSinks[sink].port;
00072         SetExternalBuffer<AudioSink>(processing, data, nframes, port);
00073         SetExternalBuffer<AudioBufferSink>(processing, data, nframes, port);
00074 }
00075 void NetworkPlayer::SetSinkFrameSize(unsigned sink, unsigned frameSize)
00076 {
00077         unsigned port = _audioSinks[sink].port;
00078         Processing * processing = _audioSinks[sink].processing;
00079         SetFrameAndHopSizeIf<AudioSink>(processing,frameSize,port);
00080         SetFrameAndHopSizeIf<AudioBufferSink>(processing,frameSize,port);
00081 }
00082 void NetworkPlayer::SetSourceFrameSize(unsigned source, unsigned frameSize)
00083 {
00084         unsigned port = _audioSources[source].port;
00085         Processing * processing = _audioSources[source].processing;
00086         SetFrameAndHopSizeIf<AudioSource>(processing,frameSize,port);
00087         SetFrameAndHopSizeIf<AudioBufferSource>(processing,frameSize,port);
00088 }
00089 
00090 } //namespace
00091 
Generated by  doxygen 1.6.3