[Clam-devel] networkplayer patch
dirk.griffioen
dirk.griffioen at barcelonamedia.org
Thu Jun 11 08:04:13 PDT 2009
Hi,
Attached a patch that places the AudioSources/Sinks in the
Networkplayer, thus separating them from the actual backend - which have
it's own details, but the loops are all the same.
It passes all tests (unit, functional, back2back) and networks play.
However, I am not happy with two things:
- the timing: the copy is done in SetNetworkBackLink
- it's a copy, so it does not reflect changes in the network
So, second try was with GetAudioSources/Sinks (which gives an up to date
copy). It works, but now it is called a lot in loops in the player -
which I don't think it was meant for. However, this was the case in the
PA backend, so it might be fine.
The question that I have more or less is 'who should own who', I mean
the network has a pointer to a player and the player has a pointer to
the network. This feels a bit circular.
Code example:
void testAnalysisSynthesisInaNetwork()
{
//CLAM::ErrAssertionFailed::breakpointInCLAMAssertEnabled = true;
CLAM::Network net;
CLAM::MonoOfflineNetworkPlayer * player = new
CLAM::MonoOfflineNetworkPlayer;
*net.SetPlayer( player );* // network owns the player memory
(and sets backlink!)
net.AddProcessing( "Source", new CLAM::AudioSource );
net.AddProcessing( "Sink", new CLAM::AudioSink );
net.AddProcessing( "Analysis", new CLAM::SMSAnalysisCore );
net.AddProcessing( "Synthesis", new CLAM::SMSSynthesis );
net.ConnectPorts("Source.1", "Analysis.Input Audio");
net.ConnectPorts("Analysis.Sinusoidal Peaks",
"Synthesis.InputSinPeaks");
net.ConnectPorts("Analysis.Residual Spectrum",
"Synthesis.InputResSpectrum");
net.ConnectPorts("Synthesis.OutputAudio", "Sink.1");
net.ConfigureProcessing("Analysis",
helperAnalysisConfigInstance() );
net.ConfigureProcessing("Synthesis",
helperSynthesisConfigInstance() );
std::string inputFile = GetTestDataDirectory("Elvis.wav");
std::string baseOutputFile =
GetTestDataDirectory("SMSTests/out_sms_net_stream");
player->AddInputFile(inputFile);
player->AddOutputFile(baseOutputFile+"_result.wav");
net.Start();
net.Stop();
Why does not the player start things:
player->AddInputFile(inputFile);
player->AddOutputFile(baseOutputFile+"_result.wav");
player->Start();
player->Stop();
Then the code then becomes
CLAM::Network net;
net.AddProcessing( "Source", new CLAM::AudioSource );
net.AddProcessing( "Sink", new CLAM::AudioSink );
net.AddProcessing( "Analysis", new CLAM::SMSAnalysisCore );
net.AddProcessing( "Synthesis", new CLAM::SMSSynthesis );
net.ConnectPorts("Source.1", "Analysis.Input Audio");
net.ConnectPorts("Analysis.Sinusoidal Peaks",
"Synthesis.InputSinPeaks");
net.ConnectPorts("Analysis.Residual Spectrum",
"Synthesis.InputResSpectrum");
net.ConnectPorts("Synthesis.OutputAudio", "Sink.1");
net.ConfigureProcessing("Analysis",
helperAnalysisConfigInstance() );
net.ConfigureProcessing("Synthesis",
helperSynthesisConfigInstance() );
std::string inputFile = GetTestDataDirectory("Elvis.wav");
std::string baseOutputFile =
GetTestDataDirectory("SMSTests/out_sms_net_stream");
CLAM::MonoOfflineNetworkPlayer player(net); // on the stack and
by reference
player->AddInputFile(inputFile);
player->AddOutputFile(baseOutputFile+"_result.wav");
player->Start();
player->Stop();
And the player could set references to sources/sinks in its constructor
(not shown). But I probably am missing something here.
The second question is 'how to update jack to reflect changes in the
network dynamically'.
This can be solved either way: the network changes so it calls the player:
- if the player owns the net then the net would call into the player
on_change (I would use boost::function (to decouple) but a backlink
would work the same)
- if the net owns the player then it calls registerports on the player
(but you need the networkbacklink in the player)
What would be preferable?
Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20090611/fbe9a8b3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nw.patch
Type: text/x-patch
Size: 23109 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20090611/fbe9a8b3/attachment-0004.bin>
More information about the clam-devel
mailing list