Index: NetworkEditor/src/Qt4Configurator.hxx
===================================================================
--- NetworkEditor/src/Qt4Configurator.hxx	(revision 9990)
+++ NetworkEditor/src/Qt4Configurator.hxx	(working copy)
@@ -31,9 +31,8 @@
 #include <CLAM/BPF.hxx>
 #include <CLAM/DataTypes.hxx>
 #include <CLAM/DynamicType.hxx>
+#include <CLAM/ConfigurableFile.hxx>
 #include <CLAM/Filename.hxx>
-#include <CLAM/DataTypes.hxx>
-#include <CLAM/AudioFile.hxx>
 // #include <CLAM/QtEnvelopeEditor.hxx> // TODO: Still not Qt4
 
 #include <QtGui/QDialog>
@@ -43,7 +42,6 @@
 #include <QtGui/QSpinBox>
 #include <QtGui/QComboBox>
 #include <QtGui/QFileDialog>
-//Added by qt3to4:
 #include <QtGui/QFrame>
 #include <QtGui/QVBoxLayout>
 #include <QtGui/QHBoxLayout>
@@ -366,16 +364,18 @@
 			value = mInput->text().toStdString();
 		}
 
-		QString audioFilterString(bool read)
+		QString filterString(const char *group,
+				const CLAM::FileFormatFilterList &filters,
+				bool inWrite)
 		{
-			QString qtfilter;
-			typedef const CLAM::EAudioFileFormat::FormatFilterList Filters;
-			Filters & filters = read?
-				CLAM::EAudioFileFormat::ReadableFormats():
-				CLAM::EAudioFileFormat::WritableFormats();
-			QString allfilter;
-			char * separator = "";
-			for (Filters::const_iterator it = filters.begin(); it!=filters.end(); it++)
+			if (!group[0])
+				group = "visible";
+			if (filters.empty())
+				return tr("All %1 files (* *.*)").arg(group);
+			QString qtfilter, allfilter;
+			char *separator = "";
+			CLAM::FileFormatFilterList::const_iterator it;
+			for (it = filters.begin(); it != filters.end(); it++)
 			{
 				qtfilter += QString("%1%2 (%3)")
 					.arg(separator)
@@ -385,45 +385,35 @@
 				separator = ";;";
 				allfilter += (it->second+" ").c_str();
 			}
-			if (read) return tr("Audio files (%1)").arg(allfilter);
-			return qtfilter + tr(";;Audio files (%1)").arg(allfilter);
+			QString allfiles(tr("All %1 files (%2)")
+					.arg(group)
+					.arg(allfilter) );
+			if (inWrite)
+				allfiles = qtfilter + separator + allfiles;
+			return allfiles;
 		}
-		template <typename T>
-		void AddWidget(const char *name, CLAM::AudioFileSource *foo, T& value)
-		{
-			QFileLineEdit * mInput = new QFileLineEdit(this);
-			mInput->setLocation(value.GetLocation().c_str());
-			mInput->setWriteMode(false);
-			mInput->setFilters(audioFilterString(true));
-//			mInput->setFilters(tr("Audio File (*.wav *.ogg *.mp3)"));
-			mInput->setDialogCaption(tr("Select the input audio file"));
-			mInput->setLocation(value.GetLocation().c_str());
 
-			QHBoxLayout * cell = new QHBoxLayout;
-			mLayout->addLayout(cell);
-			cell->addWidget(new QLabel(name));
-			cell->addWidget(mInput);
-			cell->setSpacing(5);
-			PushWidget(name, mInput);
-		}
-
 		template <typename T>
-		void RetrieveValue(const char *name, CLAM::AudioFileSource *foo, T& value) {
-			QFileLineEdit * mInput = dynamic_cast<QFileLineEdit*>(GetWidget(name));
-			CLAM_ASSERT(mInput,"Configurator: Retrieving a value/type pair not present");
-			value.OpenExisting(mInput->location().toStdString());
-		}
-		template <typename T>
-		void AddWidget(const char *name, CLAM::AudioFileTarget *foo, T& value) {
+		void AddWidget(const char *name, CLAM::ConfigurableFile *foo, T& value)
+		{
+			const char *groupStr = value.GetGroupName();
+			bool writeMode = value.GetWriteMode();
+			QString filters(filterString(groupStr,
+				  value.GetFormatFilterList(), writeMode) );
 			
 			QFileLineEdit * mInput = new QFileLineEdit(this);
+			mInput->setWriteMode(writeMode);
+			mInput->setFilters(filters);
 			mInput->setLocation(value.GetLocation().c_str());
-			mInput->setWriteMode(true);
-			mInput->setFilters(audioFilterString(false));
-//			mInput->setFilters(tr("Audio File (*.wav *.ogg *.mp3)"));
-			mInput->setDialogCaption(tr("Select the output audio file"));
-			mInput->setLocation(value.GetLocation().c_str());
 
+			const char *modeStr = writeMode ? "output" : "input";
+			const char *sep = groupStr[0] ? " " : "";
+			mInput->setDialogCaption(
+				tr("Select an %1%2%3 file")
+					.arg(modeStr)
+					.arg(sep)
+					.arg(groupStr) );
+
 			QHBoxLayout * cell = new QHBoxLayout;
 			mLayout->addLayout(cell);
 			cell->addWidget(new QLabel(name));
@@ -433,14 +423,10 @@
 		}
 
 		template <typename T>
-		void RetrieveValue(const char *name, CLAM::AudioFileTarget *foo, T& value) {
+		void RetrieveValue(const char *name, CLAM::ConfigurableFile *foo, T& value) {
 			QFileLineEdit * mInput = dynamic_cast<QFileLineEdit*>(GetWidget(name));
 			CLAM_ASSERT(mInput,"Configurator: Retrieving a value/type pair not present");
-
-			std::string location = mInput->location().toStdString();
-			CLAM::AudioFileHeader header;
-			header.SetValues(44100, 1, CLAM::EAudioFileFormat::FormatFromFilename(location));
-			value.CreateNew( location, header );
+			value.SetLocation(mInput->location().toStdString());
 		}
 	public slots:
 
Index: Annotator/src/ClamExtractorExample.cxx
===================================================================
--- Annotator/src/ClamExtractorExample.cxx	(revision 9990)
+++ Annotator/src/ClamExtractorExample.cxx	(working copy)
@@ -34,7 +34,6 @@
 #include <CLAM/Segment.hxx>
 #include <CLAM/SegmentDescriptors.hxx>
 #include <CLAM/DescriptorComputation.hxx>
-#include <CLAM/AudioFile.hxx>
 #include <CLAM/MultiChannelAudioFileReader.hxx>
 #include <CLAM/MultiChannelAudioFileReaderConfig.hxx>
 #include <CLAM/FFT.hxx>
@@ -496,7 +495,7 @@
 
 CLAM::TData GetDurationInSeconds(const std::string& fileName)
 {
-	CLAM::AudioFile file;
+	CLAM::AudioFileSource file;
 	file.OpenExisting(fileName);
 	return file.GetHeader().GetLength()/1000;
 }
Index: CLAM/test/UnitTests/ToolsTests/AudioFileTest.cxx
===================================================================
--- CLAM/test/UnitTests/ToolsTests/AudioFileTest.cxx	(revision 9990)
+++ CLAM/test/UnitTests/ToolsTests/AudioFileTest.cxx	(working copy)
@@ -74,7 +74,7 @@
 
 		void testIsReadable_with_strangeThings()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			
 			file.OpenExisting( std::string( mPathToTestData + "Image.jpg" ) );
 
@@ -86,7 +86,7 @@
 
 		void testIsWritable_ReturnsTrue_PCM_WithReasonableHeader()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 
 			CLAM::AudioFileHeader header;
@@ -105,7 +105,7 @@
 
 		void testIsWritable_ReturnsFalse_PCM_TooManyChannels()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 
 			CLAM::AudioFileHeader header;
@@ -125,7 +125,7 @@
 
 		void testIsWritable_ReturnsFalse_PCM_TooFewChannels()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			
 			CLAM::AudioFileHeader header;
@@ -148,7 +148,7 @@
 
 		void testOpenExisting_FileExists_and_Is_PCM()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string("Elvis.wav") );
 
 			CPPUNIT_ASSERT_EQUAL( std::string("PCM"),
@@ -157,7 +157,7 @@
 
 		void testOpenExisting_FileExists_and_Is_OggVorbis()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "Elvis.ogg" ) );
 
 			CPPUNIT_ASSERT_EQUAL( std::string("Ogg/Vorbis"),
@@ -166,7 +166,7 @@
 
 		void testOpenExisting_FileDoesNotExist_UnrecognizedFormat()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string("nikora") );
 
 			CPPUNIT_ASSERT_EQUAL( std::string( "Unknown" ),
@@ -175,7 +175,7 @@
 
 		void testGetHeader_HeaderIsRight_PCM()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "Elvis.wav" ) );
 
 			const CLAM::AudioFileHeader& header = file.GetHeader();
@@ -202,7 +202,7 @@
 
 		void testGetHeader_HeaderIsRight_OggVorbis()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "Elvis.ogg" ) );
 
 			const CLAM::AudioFileHeader& header = file.GetHeader();
@@ -224,7 +224,7 @@
 
 		void testGetHeader_NoHeaderWhenFileIsUnreadable()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( "momonga" );
 			
 			const CLAM::AudioFileHeader& header = file.GetHeader();
@@ -235,7 +235,7 @@
 
 		void testGetHeader_NoHeaderWhenFileIsUnreadable_AfterOneSuccessful()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "Elvis.wav" ) );
 	
 			file.OpenExisting( "Momonga" );
@@ -248,7 +248,7 @@
 
 		void testCreateNew_UserDefinesHeaderForWriting_PCM_RightCodecIsDeduced()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 			
 			CLAM::AudioFileHeader fileHeader;
 
@@ -268,7 +268,7 @@
 
 		void testCreateNew_UserDefinesHeaderForWriting_Ogg_RightCodecIsDeduced()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 			
 
 			CLAM::AudioFileHeader fileHeader;
@@ -290,7 +290,7 @@
 
 		void testCreateNew_WithoutSampleRate_Fails()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 			
 
 			CLAM::AudioFileHeader fileHeader;
@@ -312,7 +312,7 @@
 
 		void testCreateNew_WithoutChannels_IsOK()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 			
 			CLAM::AudioFileHeader fileHeader;
 
@@ -331,7 +331,7 @@
 
 		void testCreateNew_WithoutFormat_Fails()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 			
 			CLAM::AudioFileHeader fileHeader;
 
@@ -347,7 +347,7 @@
 
 		void testCreateNew_SetValues_WAV()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			CLAM::AudioFileHeader fileHeader;
 			
@@ -358,7 +358,7 @@
 
 		void testCreateNew_SetValues_AIFF()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			CLAM::AudioFileHeader fileHeader;
 			
@@ -369,7 +369,7 @@
 
 		void testCreateNew_SetValues_OggVorbis()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			CLAM::AudioFileHeader fileHeader;
 			
@@ -380,7 +380,7 @@
 
 		void testCreateNew_SetValues_WAV_AreWritable()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			CLAM::AudioFileHeader fileHeader;
 			
@@ -394,7 +394,7 @@
 
 		void testCreateNew_SetValues_AIFF_AreWritable()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			CLAM::AudioFileHeader fileHeader;
 			
@@ -408,7 +408,7 @@
 
 		void testCreateNew_SetValues_OggVorbis_AreWritable()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileTarget file;
 
 			CLAM::AudioFileHeader fileHeader;
 			
@@ -422,7 +422,7 @@
 
 		void testOpenExisting_FileExists_and_Is_Mpeg()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "trumpet.mp3" ) );
 
 			CPPUNIT_ASSERT_EQUAL( std::string("Mpeg Audio"),
@@ -433,7 +433,7 @@
 
 		void testOpenExisting_FileExists_NotSpurious_Mpeg()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "ElvisStereo.wav" ) );
 
 			CPPUNIT_ASSERT( std::string("Mpeg Audio") != file.GetKind().GetString() );						
@@ -441,7 +441,7 @@
 
 		void testGetHeader_HeaderIsRight_Mpeg()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "trumpet.mp3" ) );
 
 			const CLAM::AudioFileHeader& header = file.GetHeader();
@@ -476,7 +476,7 @@
 
 		void testTextDescriptorsExtraction_From_OggVorbis()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + std::string( "Elvis.ogg" ) );
 
 			const CLAM::AudioTextDescriptors& txtDesc = file.GetTextDescriptors();
@@ -514,12 +514,12 @@
 		
 		void testTextDescriptorsExtraction_From_Mpeg()
 		{
-			CLAM::AudioFile file;
+			CLAM::AudioFileSource file;
 			file.OpenExisting( mPathToTestData + CLAM::Text( "trumpet.mp3" ) );
 
-			CLAM::XMLStorage::Dump( file, "AudioFile", "AudioFile_0001.xml" );
+			CLAM::XMLStorage::Dump( file, "AudioFileSource", "AudioFile_0001.xml" );
 
-			CLAM::AudioFile file2;
+			CLAM::AudioFileSource file2;
 
 			CLAM::XMLStorage::Restore( file2, "AudioFile_0001.xml" );
 
Index: CLAM/test/FunctionalTests/ProcessingTests/TestMultiChannelAudioFileReader.cxx
===================================================================
--- CLAM/test/FunctionalTests/ProcessingTests/TestMultiChannelAudioFileReader.cxx	(revision 9990)
+++ CLAM/test/FunctionalTests/ProcessingTests/TestMultiChannelAudioFileReader.cxx	(working copy)
@@ -1316,15 +1316,13 @@
 			CLAM::AudioFileSource inputFile;
 			inputFile.OpenExisting( mPathToTestData + std::string( "test-stereo-decoding-HighVBR_44.mp3" ) );
 
-			CLAM::AudioFileTarget outputFile;
-			outputFile.OpenExisting( "test-mp3-HighVBR-44.wav" );			
 
 			CLAM::AudioFileHeader outputFileHeader;
-					
 			outputFileHeader.SetValues( inputFile.GetHeader().GetSampleRate(),
 						    inputFile.GetHeader().GetChannels(),
 						    "WAV" );
 	
+			CLAM::AudioFileTarget outputFile;
 			outputFile.CreateNew( "test-mp3-HighVBR-44.wav", outputFileHeader );			
 
 			CLAM::MultiChannelAudioFileReaderConfig cfgReader;
Index: CLAM/src/Standard/ConfigurableFile.cxx
===================================================================
--- CLAM/src/Standard/ConfigurableFile.cxx	(revision 0)
+++ CLAM/src/Standard/ConfigurableFile.cxx	(revision 0)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
+ *                         UNIVERSITAT POMPEU FABRA
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include "ConfigurableFile.hxx"
+#include "XMLAdapter.hxx"
+
+namespace CLAM {
+
+ConfigurableFile::ConfigurableFile()
+{
+}
+ConfigurableFile::ConfigurableFile(const ConfigurableFile &file)
+	: mLocation(file.mLocation)
+{
+}
+const ConfigurableFile& ConfigurableFile::operator=( const ConfigurableFile& rhs )
+{
+	mLocation = rhs.mLocation;
+	return *this;
+}
+ConfigurableFile::~ConfigurableFile()
+{
+}
+
+const std::string &ConfigurableFile::GetLocation() const {
+	return mLocation;
+}
+void ConfigurableFile::SetLocation(const std::string& uri)
+{
+	mLocation = uri;
+	LocationUpdated();
+}
+
+void ConfigurableFile::LoadFrom( Storage& storage )
+{
+	CLAM::XMLAdapter< Filename > xmlLocation( mLocation, "URI", true );
+	storage.Load( xmlLocation );
+	LocationUpdated();
+}
+
+void ConfigurableFile::StoreOn( Storage& storage ) const
+{
+	CLAM::XMLAdapter< Filename > xmlLocation( mLocation, "URI", true );
+	storage.Store( xmlLocation );
+}
+
+void ConfigurableFile::LocationUpdated()
+{
+	// this is an empty default implementation
+}
+
+const FileFormatFilterList &ConfigurableFile::GetFormatFilterList() const
+{
+	static FileFormatFilterList filters;
+	return filters;
+}
+
+}
Index: CLAM/src/Standard/ConfigurableFile.hxx
===================================================================
--- CLAM/src/Standard/ConfigurableFile.hxx	(revision 0)
+++ CLAM/src/Standard/ConfigurableFile.hxx	(revision 0)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
+ *                         UNIVERSITAT POMPEU FABRA
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef CLAM_FILE_HXX
+#define CLAM_FILE_HXX
+
+#include "Component.hxx"
+#include "Filename.hxx"
+#include <list>
+#include <string>
+#include <utility>
+
+namespace CLAM
+{
+
+typedef std::pair<std::string, std::string> FileFormatFilter;
+typedef std::list<FileFormatFilter> FileFormatFilterList;
+
+/**
+ * The ConfigurableFile class provides an abstract interface for CLAM 
+ * file management, providing methods that permit a generic user interface 
+ * to work with different classes of files.  In contrast, the Filename 
+ * class may be preferred to handle names of internal files, which the user 
+ * does not directly see or configure.
+ *
+ * See the AudioFile, AudioFileTarget, and AudioFileSource classes for 
+ * examples that show how to handle a new class of files.
+ */
+class ConfigurableFile : public Component
+{
+public:
+	ConfigurableFile();
+	ConfigurableFile( const ConfigurableFile& );
+	const ConfigurableFile& operator=( const ConfigurableFile& );
+	virtual ~ConfigurableFile();
+
+	const std::string &GetLocation() const;
+	void SetLocation(const std::string& uri);
+
+	virtual void LoadFrom( Storage& storage);
+	virtual void StoreOn( Storage& storage ) const;
+
+	virtual const char* GetClassName() const = 0;
+
+	/**
+	 * The group name defines the class of files (e.g. "audio", "video",
+	 * etc.).  The returned string may be used to prompt the user.
+	 */
+	virtual const char *GetGroupName() const = 0;
+
+	/**
+	 * This method returns the file direction for the given instance. 
+	 * Individual instances are restricted to be either in input or output
+	 * mode at any one time; two subclasses (or instances) must be created 
+	 * to support simultaneous input and output.
+	 */
+	virtual bool GetWriteMode() = 0;
+
+	/**
+	 * The GetFormatFilterList() interface allows subclasses to return a 
+	 * FileFormatFilterList that can be used to restrict a user interface
+	 * to display a subset of file name extensions (e.g. *.txt or *.wav).
+	 *
+	 * While this method is pure virtual, a default implementation is 
+	 * available * to call when an empty filter list is required.
+	 * This signfies that no reasonable filtering can be performed, and
+	 * all files should be presented to the user.
+	 */
+	virtual const FileFormatFilterList &GetFormatFilterList() const = 0;
+
+protected:
+	/// subclasses may override this method
+	virtual void LocationUpdated();
+
+private:
+	Filename mLocation;
+};
+
+}
+
+#endif // CLAM_FILE_HXX
Index: CLAM/src/Tools/AudioFileIO/AudioFileFormats.cxx
===================================================================
--- CLAM/src/Tools/AudioFileIO/AudioFileFormats.cxx	(revision 9990)
+++ CLAM/src/Tools/AudioFileIO/AudioFileFormats.cxx	(working copy)
@@ -89,22 +89,22 @@
 		{false, 0,0}
 	};
 
-	const EAudioFileFormat::FormatFilterList& EAudioFileFormat::ReadableFormats( )
+	const FileFormatFilterList& EAudioFileFormat::ReadableFormats( )
 	{
-		static FormatFilterList mReadableFormatsList;
+		static FileFormatFilterList mReadableFormatsList;
 		
 		if ( mReadableFormatsList.empty() )
 		{
 			for (unsigned i=0; filters[i].description; i++)
 				mReadableFormatsList.push_back(
-					FormatFilter( filters[i].description, filters[i].extensions));
+					FileFormatFilter( filters[i].description, filters[i].extensions));
 		}
 		return mReadableFormatsList;
 	}
 
-	const EAudioFileFormat::FormatFilterList& EAudioFileFormat::WritableFormats( )
+	const FileFormatFilterList& EAudioFileFormat::WritableFormats( )
 	{
-		static FormatFilterList mWritableFormatsList;
+		static FileFormatFilterList mWritableFormatsList;
 		
 		if ( mWritableFormatsList.empty() )
 		{
@@ -112,7 +112,7 @@
 			{
 				if (! filters[i].writeable) continue;
 				mWritableFormatsList.push_back(
-					FormatFilter( filters[i].description, filters[i].extensions));
+					FileFormatFilter( filters[i].description, filters[i].extensions));
 			}
 		}
 		return mWritableFormatsList;
Index: CLAM/src/Tools/AudioFileIO/AudioFileFormats.hxx
===================================================================
--- CLAM/src/Tools/AudioFileIO/AudioFileFormats.hxx	(revision 9990)
+++ CLAM/src/Tools/AudioFileIO/AudioFileFormats.hxx	(working copy)
@@ -28,6 +28,7 @@
 
 #include <sndfile.h>
 #include "Enum.hxx"
+#include <CLAM/ConfigurableFile.hxx>
 #include <string>
 #include <list>
 #include <utility>
@@ -124,13 +125,10 @@
 
 		static  EAudioFileFormat FormatFromFilename( std::string filename );
 
-		typedef std::pair< std::string, std::string >              FormatFilter;
-		typedef std::list< FormatFilter >                          FormatFilterList;
+		static  const FileFormatFilterList& ReadableFormats( );
+		static  const FileFormatFilterList& WritableFormats( );
 
-		static  const FormatFilterList& ReadableFormats( );
-		static  const FormatFilterList& WritableFormats( );
 
-
 	};
 
 	/** @ingroup AudioFileIO */
Index: CLAM/src/Tools/AudioFileIO/AudioFile.cxx
===================================================================
--- CLAM/src/Tools/AudioFileIO/AudioFile.cxx	(revision 9990)
+++ CLAM/src/Tools/AudioFileIO/AudioFile.cxx	(working copy)
@@ -33,13 +33,13 @@
 namespace CLAM
 {
 	AudioFile::AudioFile()
-		: mLocation( "" ), mKind( EAudioFileKind::eUnknown ), mActiveCodec( NULL )
+		: mKind( EAudioFileKind::eUnknown )
+		, mActiveCodec( NULL )
 	{
 	}
 
-	AudioFile::AudioFile( const AudioFile& obj )
+	AudioFile::AudioFile( const AudioFile& obj ) : ConfigurableFile(obj)
 	{
-		mLocation = obj.mLocation;
 		mActiveCodec = obj.mActiveCodec;
 		mKind = obj.mKind;
 		mHeaderData = obj.mHeaderData;
@@ -48,12 +48,11 @@
 
 	const AudioFile& AudioFile::operator=( const AudioFile& obj )
 	{
-		mLocation = obj.mLocation;
+		this->ConfigurableFile::operator=(obj);
 		mActiveCodec = obj.mActiveCodec;
 		mKind = obj.mKind;
 		mHeaderData = obj.mHeaderData;
 		mTextDescriptors = obj.mTextDescriptors;
-
 		return *this;
 	}
 
@@ -61,89 +60,45 @@
 	{
 	}
 	
-	void AudioFile::OpenExisting( const std::string& uri )
-	{
-		mLocation = uri;
-		VerifyLocation();
-
-	}
-
-	bool AudioFile::CreateNew( const std::string& uri, const AudioFileHeader& header ) 
-	{
-		mLocation = uri;
-		return SetHeader( header );
-	}
-
 	void AudioFile::ResolveCodec()
 	{
 		mActiveCodec = NULL;
 
-		if ( AudioCodecs::Codec::FileExists( mLocation ) )
+		const std::string &location = GetLocation();
+		if ( !AudioCodecs::Codec::FileExists( location ) )
 		{		
-			if ( AudioCodecs::PCMCodec::Instantiate().IsReadable( mLocation ) )
-			{
-				SetKind( EAudioFileKind::ePCM );
-				mActiveCodec = & AudioCodecs::PCMCodec::Instantiate();
-			}
-// TODO ov_open crashes when opening from MSWindows			
-//#ifndef WIN32
-#if USE_OGGVORBIS == 1
-			else if ( AudioCodecs::OggVorbisCodec::Instantiate().IsReadable( mLocation ) )
-			{
-				SetKind( EAudioFileKind::eOggVorbis );
-				mActiveCodec = & AudioCodecs::OggVorbisCodec::Instantiate();		
-				
-			}
-#endif		
-//#endif		
-#if USE_MAD == 1
-			else if ( AudioCodecs::MpegCodec::Instantiate().IsReadable( mLocation ) )
-			{
-				SetKind( EAudioFileKind::eMpeg );
-				mActiveCodec = &AudioCodecs::MpegCodec::Instantiate();
-			}
-#endif
-			else
-				SetKind( EAudioFileKind::eUnknown );		
+			SetKind( EAudioFileKind::eUnknown );
+			return;
 		}
-		else
-			SetKind( EAudioFileKind::eUnknown );
-	}
 
-	void AudioFile::VerifyLocation()
-	{
-		ResolveCodec();			
-		
-		if ( mActiveCodec != NULL )
+		if ( AudioCodecs::PCMCodec::Instantiate().IsReadable( location ) )
 		{
-			mActiveCodec->RetrieveHeaderData( mLocation, mHeaderData );
-			
-			if ( GetKind() == EAudioFileKind::eOggVorbis ||
-			     GetKind() == EAudioFileKind::eMpeg )
-			{
-				mActiveCodec->RetrieveTextDescriptors( mLocation, mTextDescriptors );				
-			}
+			SetKind( EAudioFileKind::ePCM );
+			mActiveCodec = &AudioCodecs::PCMCodec::Instantiate();
 		}
-		
-		if ( GetKind() == EAudioFileKind::eUnknown )
+#if USE_OGGVORBIS == 1
+		else if ( AudioCodecs::OggVorbisCodec::Instantiate().IsReadable( location ) )
 		{
-			mHeaderData.RemoveAll();
-			mHeaderData.UpdateData();
+			SetKind( EAudioFileKind::eOggVorbis );
+			mActiveCodec = &AudioCodecs::OggVorbisCodec::Instantiate();		
 		}
-
+#endif		
+#if USE_MAD == 1
+		else if ( AudioCodecs::MpegCodec::Instantiate().IsReadable( location ) )
+		{
+			SetKind( EAudioFileKind::eMpeg );
+			mActiveCodec = &AudioCodecs::MpegCodec::Instantiate();
+		}
+#endif
+		else
+			SetKind( EAudioFileKind::eUnknown );		
 	}
 
-
 	const AudioFileHeader& AudioFile::GetHeader() const
 	{
 		return mHeaderData;
 	}
 
-	const std::string & AudioFile::GetLocation() const
-	{
-		return mLocation;
-	}
-
 	bool AudioFile::SetHeader( const AudioFileHeader& newHeader )
 	{
 		mHeaderData.AddAll();
@@ -161,23 +116,21 @@
 
 		if ( !newHeader.HasFormat() )
 			return false;
-		else
+
+		if ( newHeader.GetFormat() < EAudioFileFormat::eVorbisMk1 )
 		{
-			if ( newHeader.GetFormat() < EAudioFileFormat::eVorbisMk1 )
-			{
-				mKind = EAudioFileKind::ePCM;
-				mActiveCodec = &AudioCodecs::PCMCodec::Instantiate();
-			}
-			else if ( newHeader.GetFormat() == EAudioFileFormat::eVorbisMk1 )
-			{
-				mKind = EAudioFileKind::eOggVorbis;
+			mKind = EAudioFileKind::ePCM;
+			mActiveCodec = &AudioCodecs::PCMCodec::Instantiate();
+		}
+		else if ( newHeader.GetFormat() == EAudioFileFormat::eVorbisMk1 )
+		{
+			mKind = EAudioFileKind::eOggVorbis;
 #if USE_OGGVORBIS==1		
-				mActiveCodec= &AudioCodecs::OggVorbisCodec::Instantiate();
+			mActiveCodec= &AudioCodecs::OggVorbisCodec::Instantiate();
 #endif		
-			}
-			else
-				CLAM_ASSERT( false, "The Enum contained and invalid value!" );
 		}
+		else
+			CLAM_ASSERT( false, "The Enum contained and invalid value!" );
 
 		if ( !newHeader.HasFormat() )
 		{
@@ -223,7 +176,7 @@
 		if (mActiveCodec == NULL )
 			return false;
 		
-		return mActiveCodec->IsReadable(mLocation);
+		return mActiveCodec->IsReadable(GetLocation());
 	}
 
 	bool AudioFile::IsWritable() const
@@ -231,7 +184,7 @@
 		if ( mActiveCodec == NULL )
 			return false;
 
-		return mActiveCodec->IsWritable(mLocation, GetHeader() );
+		return mActiveCodec->IsWritable(GetLocation(), GetHeader() );
 	}
 
 	AudioCodecs::Stream*  AudioFile::GetStream()
@@ -242,18 +195,10 @@
 		return mActiveCodec->GetStreamFor( *this );
 	}
 
-	const char* AudioFile::GetClassName() const
-	{
-		return "AudioFile";
-	}
-
 	void AudioFile::LoadFrom( Storage& storage )
 	{
+		this->ConfigurableFile::LoadFrom(storage);
 
-		CLAM::XMLAdapter< Filename > xmlLocation( mLocation, "URI", true );
-		storage.Load( xmlLocation );
-		VerifyLocation();
-		
 		CLAM::XMLComponentAdapter xmlHeader( mHeaderData, "Header", true );
 		storage.Load( xmlHeader );
 
@@ -263,8 +208,7 @@
 
 	void AudioFile::StoreOn( Storage& storage ) const
 	{
-		CLAM::XMLAdapter< Filename > xmlLocation( mLocation, "URI", true );
-		storage.Store( xmlLocation );
+		this->ConfigurableFile::StoreOn(storage);
 
 		CLAM::XMLComponentAdapter xmlHeader( mHeaderData, "Header", true );
 		storage.Store( xmlHeader );
@@ -274,4 +218,74 @@
 		storage.Store( xmlTxtDescriptors );
 	}
 
+void AudioFile::ActivateCodec()
+{
+	if ( NULL == mActiveCodec )
+		return;
+
+	mActiveCodec->RetrieveHeaderData( GetLocation(), mHeaderData );
+	
+	if ( GetKind() == EAudioFileKind::eOggVorbis ||
+	     GetKind() == EAudioFileKind::eMpeg )
+	{
+		mActiveCodec->RetrieveTextDescriptors( GetLocation(), mTextDescriptors );				
+	}
 }
+	
+void AudioFile::ResetHeaderData()
+{
+	mHeaderData.RemoveAll();
+	mHeaderData.UpdateData();
+}
+
+/* =============================================================== */
+
+void AudioFileSource::OpenExisting(const std::string &location)
+{
+	SetLocation(location);
+}
+
+const char* AudioFileSource::GetClassName() const
+{
+	return "AudioFileSource";
+}
+void AudioFileSource::LocationUpdated()
+{
+	ResolveCodec();			
+	ActivateCodec();
+	if ( GetKind() == EAudioFileKind::eUnknown )
+		ResetHeaderData();
+}
+
+const FileFormatFilterList &AudioFileSource::GetFormatFilterList() const
+{
+	return EAudioFileFormat::ReadableFormats();
+}
+
+/* =============================================================== */
+
+bool AudioFileTarget::CreateNew(const std::string &location,
+		const AudioFileHeader &header)
+{
+	SetLocation(location);
+	return SetHeader(header);
+}
+
+const char* AudioFileTarget::GetClassName() const
+{
+	return "AudioFileTarget";
+}
+void AudioFileTarget::LocationUpdated()
+{
+	EAudioFileFormat format(
+			EAudioFileFormat::FormatFromFilename(GetLocation()));
+	AudioFileHeader header;
+	header.SetValues(44100, 1, format);
+	SetHeader(header);
+}
+const FileFormatFilterList &AudioFileTarget::GetFormatFilterList() const
+{
+	return EAudioFileFormat::WritableFormats();
+}
+
+}
Index: CLAM/src/Tools/AudioFileIO/AudioFile.hxx
===================================================================
--- CLAM/src/Tools/AudioFileIO/AudioFile.hxx	(revision 9990)
+++ CLAM/src/Tools/AudioFileIO/AudioFile.hxx	(working copy)
@@ -22,14 +22,11 @@
 #ifndef __AUDIOFILE__
 #define __AUDIOFILE__
 
-#include "Component.hxx"
+#include <CLAM/ConfigurableFile.hxx>
 #include "DataTypes.hxx"
-#include "Filename.hxx"
 #include "AudioFileFormats.hxx"
 #include "AudioFileHeader.hxx"
 #include "AudioTextDescriptors.hxx"
-#include "Filename.hxx"
-#include <string>
 
 namespace CLAM
 {
@@ -40,27 +37,25 @@
 	}
 
 	/** @ingroup AudioFileIO */
-	class AudioFile : public Component
+	class AudioFile : public ConfigurableFile
 	{
 	public:
 
 		AudioFile();
 		AudioFile( const AudioFile& );
 		const AudioFile& operator=( const AudioFile& );
-		~AudioFile();
+		virtual ~AudioFile();
 
+		const char *GetGroupName() const { return "audio"; }
+
 		const AudioFileHeader&        GetHeader() const;
 		
 		void                          SetTextDescriptors( const AudioTextDescriptors& );
 		AudioTextDescriptors&         GetTextDescriptors();
 		const AudioTextDescriptors&   GetTextDescriptors() const;
 
-		const std::string &           GetLocation() const;
 		EAudioFileKind                GetKind() const;
 
-		void                          OpenExisting( const std::string& uri );
-		bool                          CreateNew( const std::string& uri, const AudioFileHeader& );
-
 		bool                          IsValid() const;
 		bool                          IsReadable() const;
 		bool                          IsWritable() const;
@@ -69,17 +64,16 @@
 		void                   LoadFrom( Storage& storage);
 		void                   StoreOn( Storage& storage ) const;
 
-		const char*            GetClassName() const;
-
 	protected:
 		//! Usually the header is set into the file using CreateNew or OpenExistig (public) methods 
 		bool                   SetHeader( const AudioFileHeader& );
 		void                   ResolveCodec();
-		void		       VerifyLocation();
 		void                   SetKind( EAudioFileKind newKind );
 
-	protected:
-		Filename	      mLocation;
+		void ActivateCodec();
+		void ResetHeaderData();
+
+	private:
 		EAudioFileKind        mKind;
 		AudioCodecs::Codec*   mActiveCodec;
 		AudioFileHeader       mHeaderData;
@@ -90,12 +84,24 @@
 	class AudioFileSource : public AudioFile
 	{
 	public:
-		const char* GetClassName() const {return "AudioFileSource";}
+		void OpenExisting(const std::string &location);
+		bool GetWriteMode() { return false; }
+		const char* GetClassName() const;
+		const FileFormatFilterList &GetFormatFilterList() const;
+	protected:
+		void LocationUpdated();
 	};
+
 	class AudioFileTarget : public AudioFile
 	{
 	public:
-		const char* GetClassName() const {return "AudioFileTarget";}
+		bool CreateNew(const std::string &location,
+				const AudioFileHeader &header);
+		bool GetWriteMode() { return true; }
+		const char* GetClassName() const;
+		const FileFormatFilterList &GetFormatFilterList() const;
+	protected:
+		void LocationUpdated();
 	};
 
 
Index: CLAM/src/Processing/AudioFileIO/MultiChannelAudioFileWriter.cxx
===================================================================
--- CLAM/src/Processing/AudioFileIO/MultiChannelAudioFileWriter.cxx	(revision 9990)
+++ CLAM/src/Processing/AudioFileIO/MultiChannelAudioFileWriter.cxx	(working copy)
@@ -172,7 +172,7 @@
 
 		CopyAsConcreteConfig( mConfig, cfg );
 
-		AudioFile& targetFile = mConfig.GetTargetFile();
+		AudioFileTarget& targetFile = mConfig.GetTargetFile();
 		const std::string & location =targetFile.GetLocation();
 		if (location=="")
 		{
@@ -227,7 +227,7 @@
 		mSamplesMatrix.Resize( nChannels );
 		mSamplesMatrix.SetSize( nChannels );
 
-		for ( int i = 0; i < nChannels; i++ )
+		for ( unsigned i = 0; i < nChannels; i++ )
 		{
 			mChannelsToWrite[ i ] = i;
 			mSamplesMatrix[ i ] = NULL;
Index: CLAM/examples/FileInfo_example.cxx
===================================================================
--- CLAM/examples/FileInfo_example.cxx	(revision 9990)
+++ CLAM/examples/FileInfo_example.cxx	(working copy)
@@ -53,7 +53,7 @@
 	// Now we take argv[1] ( the second token in the command used to invoke this
 	// program ) as the 'File Location'
 
-	CLAM::AudioFile  file;
+	CLAM::AudioFileSource  file;
 	file.OpenExisting( argv[1] );
 
 	// Once set the location, the AudioFile object internally does several things:
