Just the same patch, without forgotten testing calls to getOrdered... on
NE MainWindow.
El 01/04/2009 03:15 PM, Natanael Olaiz escribió:
Hi,
Here is attached a new patch version. The NetworkEditor updates the
geometries map before the network Start () (on NE MainWindow play
trigger), which calls the (JACKNetwork)player, which ask the network
to calculate the order. Then the map is cleared.
Now I'll try to put it the routines that I added to JACKNetworkPlayer
directly on NetworkPlayer::GetAudioSources and GetAudioSinks, which
are used by the OfflinePlayer (and I think could be used for the
JACK...Player too then).
Pau: what do you think about this new method?
Best regards, and happy new year to all clam developers! :)
Natanael.
El 12/19/2008 09:52 AM, Natanael Olaiz escribió:
On Fri, Dec 19, 2008 at 12:16 AM, Pau Arum'i <[email protected]
<mailto:[email protected]>> wrote:
En/na Natanael Olaiz ha escrit:
Hi!,
Pau suggest me to try to keep some order on sources and sinks
within the players. Now are using a map, so the order is
unpredictable...
The idea is to use the geometry positions on canvas(upper is
first)... but the problem is that actually the only who knows
that is the canvas, and for a while (on loading/pasting) the
network, but not the OfflinePlayer...
So... here is a patch with the actual state of my sandbox.
Still with debug messages, and the players are not using the
new ordered list..
I send to the list to ask if someone have a better idea to
implement it.. If not, later I will commit this (without the
messages), and then I'll use that on the players..
Nice! But I'd like to do more reviewing of the pach (ideally on
monday) before commiting -- unless is very necessary for the
recent ambisonics decoding plugins. I'd basically try to not store
the orderedSources/Sinks but calculate them...
If I don't store the order I would need to store the geometries on
the network to calculate them...
The geometries map used to copy and load the networks is cleared
after get it from the canvas... OfflinePlayer doesn't get(/clear) it
... Maybe I can use that map: directly on OfflinePlayer (is updated
on loading), updating it before a play event from NE MainWindow.... I
will see..
Best regards,
Natanael
Ciao!
P
_______________________________________________
Clam-devel mailing list
[email protected]
<mailto:[email protected]>
https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel
Index: NetworkEditor/src/MainWindow.hxx
===================================================================
--- NetworkEditor/src/MainWindow.hxx (revision 12554)
+++ NetworkEditor/src/MainWindow.hxx (working copy)
@@ -428,7 +428,9 @@
).arg(_network.GetUnconnectedInPorts().c_str()));
return;
}
+ _canvas->updateGeometriesOnXML();
_network.Start();
+ _network.GetAndClearGeometries();
updatePlayStatusIndicator();
}
void on_action_Stop_triggered()
Index: CLAM/src/Flow/Networks/FlattenedNetwork.cxx
===================================================================
--- CLAM/src/Flow/Networks/FlattenedNetwork.cxx (revision 12554)
+++ CLAM/src/Flow/Networks/FlattenedNetwork.cxx (working copy)
@@ -32,7 +32,6 @@
# include "ProcessingFactory.hxx"
#endif
#include "CLAMVersion.hxx"
-
namespace CLAM
{
FlattenedNetwork::FlattenedNetwork() :
@@ -148,6 +147,7 @@
void FlattenedNetwork::LoadFrom( Storage & storage)
{
+std::cout<<"loadfrom"<<std::endl;
typedef std::map <std::string, std::string> NamesMap;
NamesMap namesMap;
if (!_setPasteMode) Clear();
@@ -216,6 +216,7 @@
throw XmlStorageErr(std::string("Unable to connect controls '")+fullOut+"->"+fullIn+".");
}
_setPasteMode=false;
+// OrderSinksAndSources(_processingsGeometries);
}
bool FlattenedNetwork::UpdateSelections (const NamesList & processingsNamesList)
@@ -239,16 +240,94 @@
return true;
}
+ const std::list<std::string> FlattenedNetwork::getOrderedSinks() const
+ {
+ std::list <GeometryWithProcessingName> sinksGeometriesWithNames;
+ std::list<std::string> orderedSinksNames;
+ if (_processingsGeometries.empty())
+ {
+ std::cout<<"The geometries map is empty!! Cannot get ordered sinks."<<std::endl;
+ return orderedSinksNames;
+ }
+ ProcessingsGeometriesMap::const_iterator it;
+ for (it=_processingsGeometries.begin();it!=_processingsGeometries.end();it++)
+ {
+ ProcessingsMap::const_iterator itProcessing=_processings.find(it->first);
+ if (itProcessing==_processings.end())
+ continue;
+ const std::string className=itProcessing->second->GetClassName();
+ if (className!="AudioSink")
+ continue;
+ GeometryWithProcessingName processingWithGeometry;
+ processingWithGeometry.processingName=it->first;
+ processingWithGeometry.geometry=it->second;
+ sinksGeometriesWithNames.push_back(processingWithGeometry);
+ }
+ if (sinksGeometriesWithNames.size()!=0)
+ {
+std::cout<<"ordering sinks..."<<std::endl;
+ sinksGeometriesWithNames.sort(compareGeometriesUpperThan);
+ for (std::list<GeometryWithProcessingName>::const_iterator it=sinksGeometriesWithNames.begin();
+ it!=sinksGeometriesWithNames.end();it++)
+ {
+std::cout<<"\t"<<(*it).processingName<<std::endl;
+ orderedSinksNames.push_back((*it).processingName);
+ }
+
+ }
+ return orderedSinksNames;
+ }
+
+
+
+
+ const std::list<std::string> FlattenedNetwork::getOrderedSources() const
+ {
+ std::list <GeometryWithProcessingName> sourcesGeometriesWithNames;
+ std::list<std::string> orderedSourcesNames;
+ if (_processingsGeometries.empty())
+ {
+ std::cout<<"The geometries map is empty!! Cannot get ordered sources."<<std::endl;
+ return orderedSourcesNames;
+ }
+ ProcessingsGeometriesMap::const_iterator it;
+ for (it=_processingsGeometries.begin();it!=_processingsGeometries.end();it++)
+ {
+ ProcessingsMap::const_iterator itProcessing=_processings.find(it->first);
+ if (itProcessing==_processings.end())
+ continue;
+ const std::string className=itProcessing->second->GetClassName();
+ if (className!="AudioSource")
+ continue;
+ GeometryWithProcessingName processingWithGeometry;
+ processingWithGeometry.processingName=it->first;
+ processingWithGeometry.geometry=it->second;
+ sourcesGeometriesWithNames.push_back(processingWithGeometry);
+ }
+ if (sourcesGeometriesWithNames.size()!=0)
+ {
+std::cout<<"ordering sources..."<<std::endl;
+ sourcesGeometriesWithNames.sort(compareGeometriesUpperThan);
+ for (std::list<GeometryWithProcessingName>::const_iterator it=sourcesGeometriesWithNames.begin();
+ it!=sourcesGeometriesWithNames.end();it++)
+ {
+std::cout<<"\t"<<(*it).processingName<<std::endl;
+ orderedSourcesNames.push_back((*it).processingName);
+ }
+
+ }
+ return orderedSourcesNames;
+ }
+
bool FlattenedNetwork::SetProcessingsGeometries (const ProcessingsGeometriesMap & processingsGeometries)
{
- _processingsGeometries.clear();
+ _processingsGeometries.clear();
if (processingsGeometries.empty())
return true;
_processingsGeometries=processingsGeometries;
return false;
}
-
const FlattenedNetwork::ProcessingsGeometriesMap FlattenedNetwork::GetAndClearGeometries()
{
const ProcessingsGeometriesMap copyProcessingsGeometry(_processingsGeometries);
@@ -256,6 +335,13 @@
return copyProcessingsGeometry;
}
+ const bool FlattenedNetwork::compareGeometriesUpperThan (GeometryWithProcessingName & processingWithGeometry1, GeometryWithProcessingName & processingWithGeometry2)
+ {
+ if (processingWithGeometry1.geometry.y<processingWithGeometry2.geometry.y)
+ return true;
+ return false;
+ }
+
/* // TODO: use individual geometries loadings/storings??:
const FlattenedNetwork::Geometry FlattenedNetwork::GetAndEraseGeometry(std::string name)
{
@@ -540,16 +626,23 @@
void FlattenedNetwork::Start()
{
+std::cout<<"FlattenedNetwork::Start"<<std::endl;
ProcessingsMap::iterator it;
for (it=BeginProcessings(); it!=EndProcessings(); it++)
{
- if (it->second->IsRunning()) continue;
+ if (it->second->IsRunning())
+{
+std::cout<<"\tIS RUNNING!"<<std::endl;
+ continue;
+}
if (it->second->IsConfigured())
{
+std::cout<<"\tIS CONFIGURED!"<<std::endl;
it->second->Start();
}
else
{
+std::cout<<"\tELSE!"<<std::endl;
std::cerr << "Warning: could not start processing for not being Configured: '" << it->first<< "' of class " << it->second->GetClassName() << std::endl;
}
}
Index: CLAM/src/Flow/Networks/FlattenedNetwork.hxx
===================================================================
--- CLAM/src/Flow/Networks/FlattenedNetwork.hxx (revision 12554)
+++ CLAM/src/Flow/Networks/FlattenedNetwork.hxx (working copy)
@@ -21,6 +21,8 @@
+
+
#ifndef _FlattenedNetwork_hxx_
#define _FlattenedNetwork_hxx_
@@ -37,7 +39,6 @@
//#include "Component.hxx"
//#include "Storage.hxx"
#include "BaseNetwork.hxx"
-
namespace CLAM
{
class NetworkPlayer;
@@ -88,6 +89,12 @@
bool SetProcessingsGeometries (const ProcessingsGeometriesMap & processingsGeometries);
const ProcessingsGeometriesMap GetAndClearGeometries();
+ //! sources and sink order
+ const std::list<std::string> getOrderedSinks() const;
+ const std::list<std::string> getOrderedSources() const;
+ static const bool compareGeometriesUpperThan(GeometryWithProcessingName &,GeometryWithProcessingName &);
+
+
/*// TODO: make individual geometries loadings/storings??
const Geometry GetAndEraseGeometry(std::string name);*/
//! methods related to connect/disconnect interface
@@ -185,6 +192,7 @@
void StringPairToInts(const std::string & geometryInString, int & a, int & b);
const std::string IntsToString (const int & a, const int & b) const;
+
};
}// namespace
Index: CLAM/src/Flow/Networks/BaseNetwork.hxx
===================================================================
--- CLAM/src/Flow/Networks/BaseNetwork.hxx (revision 12554)
+++ CLAM/src/Flow/Networks/BaseNetwork.hxx (working copy)
@@ -44,6 +44,7 @@
typedef std::list<InPortBase *> InPortsList;
typedef struct { int x, y, width, height; } Geometry;
+ typedef struct { std::string processingName; Geometry geometry; } GeometryWithProcessingName;
typedef std::map <std::string, Geometry> ProcessingsGeometriesMap;
typedef struct { std::string sourceName, sinkName; } Connection;
typedef std::list<Connection> ConnectionsList;
@@ -136,6 +137,12 @@
// canvas related geometries
virtual bool SetProcessingsGeometries (const ProcessingsGeometriesMap & processingsGeometries) = 0;
virtual const ProcessingsGeometriesMap GetAndClearGeometries() = 0;
+
+ virtual const std::list<std::string> getOrderedSinks() const = 0;
+ virtual const std::list<std::string> getOrderedSources() const = 0;
+
+
+
/*// TODO: make individual geometries loadings/storings??
const Geometry GetAndEraseGeometry(std::string name);*/
Index: CLAM/src/Flow/Networks/BackEnds/JACKNetworkPlayer.cxx
===================================================================
--- CLAM/src/Flow/Networks/BackEnds/JACKNetworkPlayer.cxx (revision 12554)
+++ CLAM/src/Flow/Networks/BackEnds/JACKNetworkPlayer.cxx (working copy)
@@ -83,29 +83,35 @@
void JACKNetworkPlayer::RegisterPorts()
{
+std::cout<<"JACKNetworkPlayer::RegisterPorts"<<std::endl;
RegisterInputPorts( GetNetwork() );
RegisterOutputPorts( GetNetwork() );
}
void JACKNetworkPlayer::RegisterInputPorts(const Network& net)
{
+std::cout<<"JACKNetworkPlayer::RegisterInputPorts"<<std::endl;
+
+std::list<std::string> listOfSourcesNames=net.getOrderedSources();
+std::list<std::string>::const_iterator itSourcesNamesList;
+
CLAM_ASSERT( _sourceJackBindings.empty(),
"JACKNetworkPlayer::RegisterInputPorts() : there are already registered input ports");
-
+ net.getOrderedSources();
+
+
SourceJackBinding pair;
-
+
//Get them from the Network and add it to local list
- for (Network::ProcessingsMap::const_iterator it=net.BeginProcessings(); it!=net.EndProcessings(); it++)
+ for (itSourcesNamesList=listOfSourcesNames.begin();itSourcesNamesList!=listOfSourcesNames.end();itSourcesNamesList++)
{
- std::string processingClass = it->second->GetClassName();
- if (processingClass != "AudioSource") continue;
-
+ std::cout<<"--\t-- "<<(*itSourcesNamesList)<<std::endl;
//Get Processing address
- pair.source=(AudioSource*)it->second;
+ pair.source=(AudioSource*)&net.GetProcessing(*itSourcesNamesList);
pair.source->SetFrameAndHopSize(_jackBufferSize);
//Register port on the JACK server
- const std::string & processingName = it->first;
+ const std::string & processingName = (*itSourcesNamesList);
pair.jackPort=jack_port_register (_jackClient,
processingName.c_str(),
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
@@ -117,23 +123,28 @@
void JACKNetworkPlayer::RegisterOutputPorts(const Network& net)
{
+std::cout<<"JACKNetworkPlayer::RegisterOutputPorts"<<std::endl;
+
+std::list<std::string> listOfSinksNames=net.getOrderedSinks();
+std::list<std::string>::const_iterator itSinksNamesList;
+
+
CLAM_ASSERT( _sinkJackBindings.empty(),
- "JACKNetworkPlayer::RegisterOutputPorts() : there are already registered output ports");
-
+ "JACKNetworkPlayer::RegisterOutputPorts() : there are already registered output ports");
+
SinkJackBinding pair;
-
- //Get them from the Network and add it to local list
- for (Network::ProcessingsMap::const_iterator it=net.BeginProcessings(); it!=net.EndProcessings(); it++)
+
+
+ for (itSinksNamesList=listOfSinksNames.begin();itSinksNamesList!=listOfSinksNames.end();itSinksNamesList++)
{
- std::string processingClass = it->second->GetClassName();
- if (processingClass != "AudioSink") continue;
+ std::cout<<"--\t-- "<<(*itSinksNamesList)<<std::endl;
//Get Processing address
- pair.sink=(AudioSink*)it->second;
+ pair.sink=(AudioSink*)&net.GetProcessing((*itSinksNamesList));
pair.sink->SetFrameAndHopSize(_jackBufferSize);
//Register port on the JACK server
- const std::string & processingName = it->first;
+ const std::string & processingName = (*itSinksNamesList);
pair.jackPort=jack_port_register (_jackClient,
processingName.c_str(),
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
@@ -141,6 +152,7 @@
//Add the pair (jack port, clam jack receiver) to the list
_sinkJackBindings.push_back(pair);
}
+
}
void JACKNetworkPlayer::UnRegisterPorts()
@@ -202,6 +214,7 @@
void JACKNetworkPlayer::Start()
{
+std::cout<<"JACKNetworkPlayer::Start"<<std::endl;
if (IsPlaying()) return;
if (IsPaused())
{
_______________________________________________
Clam-devel mailing list
[email protected]
https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel