NetworkPlayer.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }
00091