Example #1
0
string ExtractMBIDFromFile(TagLib::MP4::File *file)
{
	string key = "----:com.apple.iTunes:MusicBrainz Track Id";
	TagLib::MP4::Tag *tag = file->tag();
	if (tag && tag->itemListMap().contains(key)) {
		return tag->itemListMap()[key].toStringList().toString().to8Bit(true);
	}
	return string();
}
QString extractMBIDFromFile(TagLib::MP4::File *file)
{
	const char *key = "----:com.apple.iTunes:MusicBrainz Track Id";
	TagLib::MP4::Tag *tag = file->tag();
	if (tag->itemListMap().contains(key)) {
		return QString::fromUtf8(tag->itemListMap()[key].toStringList().toString().toCString(true));
	}
	return QString();
}
Example #3
0
/*
** Extracts cover art embedded in MP4-like files.
**
*/
bool CCover::ExtractMP4(TagLib::MP4::File* file, const std::string& target)
{
    TagLib::MP4::Tag* tag = file->tag();
    if (tag->itemListMap().contains("covr"))
    {
        TagLib::MP4::CoverArtList coverList = tag->itemListMap()["covr"].toCoverArtList();
        if (coverList[0].data().size() > 0)
        {
            return WriteCover(coverList[0].data(), target);
        }
    }

    return false;
}
Example #4
0
/*
** Extracts cover art embedded in MP4-like files.
**
*/
bool QCoverArt::ExtractMP4(TagLib::MP4::File* file)
{
    TagLib::MP4::Tag* tag = file->tag();
    if (tag->itemListMap().contains("covr"))
    {
        TagLib::MP4::CoverArtList coverList = tag->itemListMap()["covr"].toCoverArtList();

        if (coverList[0].data().size() > 0)
        {
            img.loadFromData((const unsigned char*)coverList[0].data().data(), coverList[0].data().size());
            return true;
        }
    }

    return false;
}
Example #5
0
bool CoverUtils::coverFromMP4(QString filename, Album *album) {

    TagLib::MP4::File f((TagLib::FileName)filename.toUtf8());
    if (!f.isValid()) return false;

    TagLib::MP4::Tag *tag = static_cast<TagLib::MP4::Tag *>(f.tag());
    if (!tag) return false;

    TagLib::MP4::ItemListMap itemsListMap = tag->itemListMap();
    TagLib::MP4::Item coverItem = itemsListMap["covr"];
    TagLib::MP4::CoverArtList coverArtList = coverItem.toCoverArtList();
    TagLib::MP4::CoverArt coverArt = coverArtList.front();

    QImage image;
    image.loadFromData((const uchar *) coverArt.data().data(), coverArt.data().size());
    if (!isAcceptableImage(image)) return false;

    qDebug() << "Cover from MP4!";

    return saveImage(image, album);
}
Example #6
0
QByteArray TagReader::LoadEmbeddedArt(const QString& filename) const {
  if (filename.isEmpty()) return QByteArray();

  qLog(Debug) << "Loading art from" << filename;

#ifdef Q_OS_WIN32
  TagLib::FileRef ref(filename.toStdWString().c_str());
#else
  TagLib::FileRef ref(QFile::encodeName(filename).constData());
#endif

  if (ref.isNull() || !ref.file()) return QByteArray();

  // MP3
  TagLib::MPEG::File* file = dynamic_cast<TagLib::MPEG::File*>(ref.file());
  if (file && file->ID3v2Tag()) {
    TagLib::ID3v2::FrameList apic_frames =
        file->ID3v2Tag()->frameListMap()["APIC"];
    if (apic_frames.isEmpty()) return QByteArray();

    TagLib::ID3v2::AttachedPictureFrame* pic =
        static_cast<TagLib::ID3v2::AttachedPictureFrame*>(apic_frames.front());

    return QByteArray((const char*)pic->picture().data(),
                      pic->picture().size());
  }

  // Ogg vorbis/speex
  TagLib::Ogg::XiphComment* xiph_comment =
      dynamic_cast<TagLib::Ogg::XiphComment*>(ref.file()->tag());

  if (xiph_comment) {
    TagLib::Ogg::FieldListMap map = xiph_comment->fieldListMap();

    // Other than the below mentioned non-standard COVERART,
    // METADATA_BLOCK_PICTURE
    // is the proposed tag for cover pictures.
    // (see http://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE)
    if (map.contains("METADATA_BLOCK_PICTURE")) {
      TagLib::StringList pict_list = map["METADATA_BLOCK_PICTURE"];
      for (std::list<TagLib::String>::iterator it = pict_list.begin();
           it != pict_list.end(); ++it) {
        QByteArray data(QByteArray::fromBase64(it->toCString()));
        TagLib::ByteVector tdata(data.data(), data.size());
        TagLib::FLAC::Picture p(tdata);
        if (p.type() == TagLib::FLAC::Picture::FrontCover)
          return QByteArray(p.data().data(), p.data().size());
      }
      // If there was no specific front cover, just take the first picture
      QByteArray data(QByteArray::fromBase64(
          map["METADATA_BLOCK_PICTURE"].front().toCString()));
      TagLib::ByteVector tdata(data.data(), data.size());
      TagLib::FLAC::Picture p(tdata);
      return QByteArray(p.data().data(), p.data().size());
    }

    // Ogg lacks a definitive standard for embedding cover art, but it seems
    // b64 encoding a field called COVERART is the general convention
    if (!map.contains("COVERART")) return QByteArray();

    return QByteArray::fromBase64(map["COVERART"].toString().toCString());
  }

#ifdef TAGLIB_HAS_FLAC_PICTURELIST
  // Flac
  TagLib::FLAC::File* flac_file = dynamic_cast<TagLib::FLAC::File*>(ref.file());
  if (flac_file && flac_file->xiphComment()) {
    TagLib::List<TagLib::FLAC::Picture*> pics = flac_file->pictureList();
    if (!pics.isEmpty()) {
      // Use the first picture in the file - this could be made cleverer and
      // pick the front cover if it's present.

      std::list<TagLib::FLAC::Picture*>::iterator it = pics.begin();
      TagLib::FLAC::Picture* picture = *it;

      return QByteArray(picture->data().data(), picture->data().size());
    }
  }
#endif

  // MP4/AAC
  TagLib::MP4::File* aac_file = dynamic_cast<TagLib::MP4::File*>(ref.file());
  if (aac_file) {
    TagLib::MP4::Tag* tag = aac_file->tag();
    const TagLib::MP4::ItemListMap& items = tag->itemListMap();
    TagLib::MP4::ItemListMap::ConstIterator it = items.find("covr");
    if (it != items.end()) {
      const TagLib::MP4::CoverArtList& art_list = it->second.toCoverArtList();

      if (!art_list.isEmpty()) {
        // Just take the first one for now
        const TagLib::MP4::CoverArt& art = art_list.front();
        return QByteArray(art.data().data(), art.data().size());
      }
    }
  }

  return QByteArray();
}
Example #7
0
bool TagReader::SaveSongRatingToFile(
    const QString& filename, const pb::tagreader::SongMetadata& song) const {
  if (filename.isNull()) return false;

  qLog(Debug) << "Saving song rating tags to" << filename;
  if (song.rating() < 0) {
    // The FMPS spec says unrated == "tag not present". For us, no rating
    // results in rating being -1, so don't write anything in that case.
    // Actually, we should also remove tag set in this case, but in
    // Clementine it is not possible to unset rating i.e. make a song "unrated".
    qLog(Debug) << "Unrated: do nothing";
    return true;
  }

  std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));

  if (!fileref || fileref->isNull())  // The file probably doesn't exist
    return false;

  if (TagLib::MPEG::File* file =
          dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
    TagLib::ID3v2::Tag* tag = file->ID3v2Tag(true);

    // Save as FMPS
    SetUserTextFrame("FMPS_Rating", QString::number(song.rating()), tag);

    // Also save as POPM
    TagLib::ID3v2::PopularimeterFrame* frame = GetPOPMFrameFromTag(tag);
    frame->setRating(ConvertToPOPMRating(song.rating()));

  } else if (TagLib::FLAC::File* file =
                 dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
    TagLib::Ogg::XiphComment* vorbis_comments = file->xiphComment(true);
    SetFMPSRatingVorbisComments(vorbis_comments, song);
  } else if (TagLib::Ogg::XiphComment* tag =
                 dynamic_cast<TagLib::Ogg::XiphComment*>(
                     fileref->file()->tag())) {
    SetFMPSRatingVorbisComments(tag, song);
  }
#ifdef TAGLIB_WITH_ASF
  else if (TagLib::ASF::File* file =
               dynamic_cast<TagLib::ASF::File*>(fileref->file())) {
    TagLib::ASF::Tag* tag = file->tag();
    tag->addAttribute("FMPS/Rating", NumberToASFAttribute(song.rating()));
  }
#endif
  else if (TagLib::MP4::File* file =
               dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
    TagLib::MP4::Tag* tag = file->tag();
    tag->itemListMap()[kMP4_FMPS_Rating_ID] = TagLib::StringList(
        QStringToTaglibString(QString::number(song.rating())));
  } else {
    // Nothing to save: stop now
    return true;
  }

  bool ret = fileref->save();
#ifdef Q_OS_LINUX
  if (ret) {
    // Linux: inotify doesn't seem to notice the change to the file unless we
    // change the timestamps as well. (this is what touch does)
    utimensat(0, QFile::encodeName(filename).constData(), nullptr, 0);
  }
#endif  // Q_OS_LINUX
  return ret;
}
Example #8
0
bool TagReader::SaveSongStatisticsToFile(
    const QString& filename, const pb::tagreader::SongMetadata& song) const {
  if (filename.isNull()) return false;

  qLog(Debug) << "Saving song statistics tags to" << filename;

  std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));

  if (!fileref || fileref->isNull())  // The file probably doesn't exist
    return false;

  if (TagLib::MPEG::File* file =
          dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
    TagLib::ID3v2::Tag* tag = file->ID3v2Tag(true);

    // Save as FMPS
    SetUserTextFrame("FMPS_PlayCount", QString::number(song.playcount()), tag);
    SetUserTextFrame("FMPS_Rating_Amarok_Score",
                     QString::number(song.score() / 100.0), tag);

    // Also save as POPM
    TagLib::ID3v2::PopularimeterFrame* frame = GetPOPMFrameFromTag(tag);
    frame->setCounter(song.playcount());

  } else if (TagLib::FLAC::File* file =
                 dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
    TagLib::Ogg::XiphComment* vorbis_comments = file->xiphComment(true);
    SetFMPSStatisticsVorbisComments(vorbis_comments, song);
  } else if (TagLib::Ogg::XiphComment* tag =
                 dynamic_cast<TagLib::Ogg::XiphComment*>(
                     fileref->file()->tag())) {
    SetFMPSStatisticsVorbisComments(tag, song);
  }
#ifdef TAGLIB_WITH_ASF
  else if (TagLib::ASF::File* file =
               dynamic_cast<TagLib::ASF::File*>(fileref->file())) {
    TagLib::ASF::Tag* tag = file->tag();
    tag->addAttribute("FMPS/Playcount", NumberToASFAttribute(song.playcount()));
    tag->addAttribute("FMPS/Rating_Amarok_Score",
                      NumberToASFAttribute(song.score() / 100.0));
  }
#endif
  else if (TagLib::MP4::File* file =
               dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
    TagLib::MP4::Tag* tag = file->tag();
    tag->itemListMap()[kMP4_FMPS_Score_ID] = TagLib::StringList(
        QStringToTaglibString(QString::number(song.score() / 100.0)));
    tag->itemListMap()[kMP4_FMPS_Playcount_ID] =
        TagLib::StringList(TagLib::String::number(song.playcount()));
  } else {
    // Nothing to save: stop now
    return true;
  }

  bool ret = fileref->save();
#ifdef Q_OS_LINUX
  if (ret) {
    // Linux: inotify doesn't seem to notice the change to the file unless we
    // change the timestamps as well. (this is what touch does)
    utimensat(0, QFile::encodeName(filename).constData(), nullptr, 0);
  }
#endif  // Q_OS_LINUX
  return ret;
}
Example #9
0
bool TagReader::SaveFile(const QString& filename,
                         const pb::tagreader::SongMetadata& song) const {
  if (filename.isNull()) return false;

  qLog(Debug) << "Saving tags to" << filename;

  std::unique_ptr<TagLib::FileRef> fileref(factory_->GetFileRef(filename));

  if (!fileref || fileref->isNull())  // The file probably doesn't exist
    return false;

  fileref->tag()->setTitle(StdStringToTaglibString(song.title()));
  fileref->tag()->setArtist(StdStringToTaglibString(song.artist()));  // TPE1
  fileref->tag()->setAlbum(StdStringToTaglibString(song.album()));
  fileref->tag()->setGenre(StdStringToTaglibString(song.genre()));
  fileref->tag()->setComment(StdStringToTaglibString(song.comment()));
  fileref->tag()->setYear(song.year());
  fileref->tag()->setTrack(song.track());

  if (TagLib::MPEG::File* file =
          dynamic_cast<TagLib::MPEG::File*>(fileref->file())) {
    TagLib::ID3v2::Tag* tag = file->ID3v2Tag(true);
    SetTextFrame(
        "TPOS", song.disc() <= 0 - 1 ? QString() : QString::number(song.disc()),
        tag);
    SetTextFrame("TBPM",
                 song.bpm() <= 0 - 1 ? QString() : QString::number(song.bpm()),
                 tag);
    SetTextFrame("TCOM", song.composer(), tag);
    SetTextFrame("TIT1", song.grouping(), tag);
    // Skip TPE1 (which is the artist) here because we already set it
    SetTextFrame("TPE2", song.albumartist(), tag);
    SetTextFrame("TCMP", std::string(song.compilation() ? "1" : "0"), tag);
  } else if (TagLib::FLAC::File* file =
                 dynamic_cast<TagLib::FLAC::File*>(fileref->file())) {
    TagLib::Ogg::XiphComment* tag = file->xiphComment();
    SetVorbisComments(tag, song);
  } else if (TagLib::MP4::File* file =
                 dynamic_cast<TagLib::MP4::File*>(fileref->file())) {
    TagLib::MP4::Tag* tag = file->tag();
    tag->itemListMap()["disk"] =
        TagLib::MP4::Item(song.disc() <= 0 - 1 ? 0 : song.disc(), 0);
    tag->itemListMap()["tmpo"] = TagLib::StringList(
        song.bpm() <= 0 - 1 ? "0" : TagLib::String::number(song.bpm()));
    tag->itemListMap()["\251wrt"] = TagLib::StringList(song.composer());
    tag->itemListMap()["\251grp"] = TagLib::StringList(song.grouping());
    tag->itemListMap()["aART"] = TagLib::StringList(song.albumartist());
    tag->itemListMap()["cpil"] =
        TagLib::StringList(song.compilation() ? "1" : "0");
  }

  // Handle all the files which have VorbisComments (Ogg, OPUS, ...) in the same
  // way;
  // apart, so we keep specific behavior for some formats by adding another
  // "else if" block above.
  if (TagLib::Ogg::XiphComment* tag =
          dynamic_cast<TagLib::Ogg::XiphComment*>(fileref->file()->tag())) {
    SetVorbisComments(tag, song);
  }

  bool ret = fileref->save();
#ifdef Q_OS_LINUX
  if (ret) {
    // Linux: inotify doesn't seem to notice the change to the file unless we
    // change the timestamps as well. (this is what touch does)
    utimensat(0, QFile::encodeName(filename).constData(), nullptr, 0);
  }
#endif  // Q_OS_LINUX

  return ret;
}
Example #10
0
bool cMediaInfo::readFromFile(const QString& szFileName)
{
	clear();

	QFileInfo	fileInfo(szFileName);
	if(!fileInfo.exists())
		return(false);

	if(!fileInfo.suffix().compare("APE", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_APE;
	else if(!fileInfo.suffix().compare("WMA", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_ASF;
	else if(!fileInfo.suffix().compare("FLAC", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_FLAC;
	else if(!fileInfo.suffix().compare("AAC", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MP4;
	else if(!fileInfo.suffix().compare("MP4", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MP4;
	else if(!fileInfo.suffix().compare("M4A", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MP4;
	else if(!fileInfo.suffix().compare("MPC", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPC;
	else if(!fileInfo.suffix().compare("MP1", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPEG;
	else if(!fileInfo.suffix().compare("MP2", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPEG;
	else if(!fileInfo.suffix().compare("MP3", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_MPEG;
	else if(!fileInfo.suffix().compare("TTA", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_TRUEAUDIO;
	else if(!fileInfo.suffix().compare("WV", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_WAVPACK;
	else if(!fileInfo.suffix().compare("WAV", Qt::CaseInsensitive))
		m_fileType	= MEDIA_TYPE_WAV;

	if(m_fileType	== MEDIA_TYPE_UNKNOWN)
		return(false);

	m_szFileName					= szFileName;

	ID3v1::Tag*			lpTagV1		= 0;
	ID3v2::Tag*			lpTagV2		= 0;
	APE::Tag*			lpTagAPE	= 0;
	APE::File*			lpApe		= 0;
	ASF::File*			lpASF		= 0;
	FLAC::File*			lpFlac		= 0;
	MP4::File*			lpMP4		= 0;
	MPC::File*			lpMPC		= 0;
	MPEG::File*			lpMPEG		= 0;
	TrueAudio::File*	lpTrueAudio	= 0;
	WavPack::File*		lpWavPack	= 0;
	RIFF::WAV::File*	lpWav		= 0;

	TagLib::PropertyMap	tags;

	QString				szTmp;

	switch(m_fileType)
	{
	case MEDIA_TYPE_APE:
	{
		lpApe	= new APE::File(m_szFileName.toLocal8Bit().data());

		lpTagV1										= lpApe->ID3v1Tag();
		lpTagAPE									= lpApe->APETag();
		tags										= lpApe->properties();

		APE::Properties* lpAudioProperties			= lpApe->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_iVersion								= lpAudioProperties->version();
		}
		break;
	}
	case MEDIA_TYPE_ASF:
	{
		lpASF	= new ASF::File(m_szFileName.toLocal8Bit().data());
		TagLib::ASF::Tag*	lpTag					= lpASF->tag();
		m_szTitle									= QString::fromStdWString(lpTag->title().toWString());
		szTmp										= QString::fromStdWString(lpTag->artist().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szArtistList							= szTmp.split("\n");
		m_szAlbum									= QString::fromStdWString(lpTag->album().toWString());
		m_szComment									= QString::fromStdWString(lpTag->comment().toWString());
		szTmp										= QString::fromStdWString(lpTag->genre().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szGenreList							= szTmp.split("\n");
		m_szRating									= QString::fromStdWString(lpTag->genre().toWString());
		m_szCopyright								= QString::fromStdWString(lpTag->copyright().toWString());
		m_iYear										= lpTag->year();
		m_szTrackNumber								= QString("%1").arg(lpTag->track());

		tags										= lpASF->properties();

		ASF::Properties* lpAudioProperties			= lpASF->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_bIsEncrypted							= lpAudioProperties->isEncrypted();
		}
		break;
	}
	case MEDIA_TYPE_FLAC:
	{
		lpFlac	= new FLAC::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpFlac->ID3v1Tag();
		lpTagV2										= lpFlac->ID3v2Tag();
		tags										= lpFlac->properties();

		FLAC::Properties* lpAudioProperties			= lpFlac->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iSampleWidth							= lpAudioProperties->sampleWidth();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
		}
		break;
	}
	case MEDIA_TYPE_MP4:
	{
		lpMP4	= new MP4::File(m_szFileName.toLocal8Bit().data());
		TagLib::MP4::Tag*	lpTag					= lpMP4->tag();
		m_szTitle									= QString::fromStdWString(lpTag->title().toWString());
		szTmp										= QString::fromStdWString(lpTag->artist().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szArtistList							= szTmp.split("\n");
		m_szAlbum									= QString::fromStdWString(lpTag->album().toWString());
		m_szComment									= QString::fromStdWString(lpTag->comment().toWString());
		szTmp										= QString::fromStdWString(lpTag->genre().toWString());
		if(!szTmp.isEmpty() && m_bID3V1)
			m_szGenreList							= szTmp.split("\n");
		m_iYear										= lpTag->year();
		m_szTrackNumber								= QString("%1").arg(lpTag->track());

		tags										= lpMP4->properties();

		MP4::Properties* lpAudioProperties			= lpMP4->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_bIsEncrypted							= lpAudioProperties->isEncrypted();
		}
		break;
	}
	case MEDIA_TYPE_MPC:
	{
		lpMPC	= new MPC::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpMPC->ID3v1Tag();
		lpTagAPE									= lpMPC->APETag();
		tags										= lpMPC->properties();

		MPC::Properties* lpAudioProperties			= lpMPC->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iVersion								= lpAudioProperties->mpcVersion();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
			m_iTrackGain							= lpAudioProperties->trackGain();
			m_iAlbumGain							= lpAudioProperties->albumGain();
			m_iTrackPeak							= lpAudioProperties->trackPeak();
			m_iAlbumPeak							= lpAudioProperties->albumPeak();
		}
		break;
	}
	case MEDIA_TYPE_MPEG:
	{
		lpMPEG	= new MPEG::File(m_szFileName.toLocal8Bit().data());

		lpTagV1										= lpMPEG->ID3v1Tag();
		lpTagV2										= lpMPEG->ID3v2Tag();
		lpTagAPE									= lpMPEG->APETag();
		tags										= lpMPEG->properties();

		MPEG::Properties*	lpAudioProperties		= lpMPEG->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iLayer								= lpAudioProperties->layer();
			switch(lpAudioProperties->version())
			{
			case MPEG::Header::Version1:
				m_iVersion	= 10;
				break;
			case MPEG::Header::Version2:
				m_iVersion	= 20;
				break;
			case MPEG::Header::Version2_5:
				m_iVersion	= 25;
				break;
			}
			m_bProtectionEnabled					= lpAudioProperties->protectionEnabled();
			switch(lpAudioProperties->channelMode())
			{
			case MPEG::Header::Stereo:
				m_channelMode						= CHANNEL_MODE_STEREO;
				break;
			case MPEG::Header::JointStereo:
				m_channelMode						= CHANNEL_MODE_JOINTSTEREO;
				break;
			case MPEG::Header::DualChannel:
				m_channelMode						= CHANNEL_MODE_DUALMONO;
				break;
			case MPEG::Header::SingleChannel:
				m_channelMode						= CHANNEL_MODE_MONO;
				break;
			}
			m_bIsCopyrighted						= lpAudioProperties->isCopyrighted();
			m_bIsOriginal							= lpAudioProperties->isOriginal();
		}
		break;
	}
	case MEDIA_TYPE_TRUEAUDIO:
	{
		lpTrueAudio	= new TrueAudio::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpTrueAudio->ID3v1Tag();
		lpTagV2										= lpTrueAudio->ID3v2Tag();
		tags										= lpTrueAudio->properties();

		TrueAudio::Properties* lpAudioProperties	= lpTrueAudio->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_iVersion								= lpAudioProperties->ttaVersion();
		}
		break;
	}
	case MEDIA_TYPE_WAVPACK:
	{
		lpWavPack	= new WavPack::File(m_szFileName.toLocal8Bit().data());
		lpTagV1										= lpWavPack->ID3v1Tag();
		lpTagAPE									= lpWavPack->APETag();
		tags										= lpWavPack->properties();

		WavPack::Properties* lpAudioProperties		= lpWavPack->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iBitsPerSample						= lpAudioProperties->bitsPerSample();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
			m_iVersion								= lpAudioProperties->version();
		}
		break;
	}
	case MEDIA_TYPE_WAV:
	{
		lpWav	= new RIFF::WAV::File(m_szFileName.toLocal8Bit().data());
		lpTagV2										= lpWav->tag();
		tags										= lpWav->properties();

		RIFF::WAV::Properties* lpAudioProperties	= lpWav->audioProperties();

		if(lpAudioProperties)
		{
			m_iLength								= lpAudioProperties->length();
			m_iBitrate								= lpAudioProperties->bitrate();
			m_iSampleRate							= lpAudioProperties->sampleRate();
			m_iChannels								= lpAudioProperties->channels();
			m_iSampleWidth							= lpAudioProperties->sampleWidth();
			m_ullSampleFrames						= lpAudioProperties->sampleFrames();
		}
		break;
	}
	default:
		break;
	}

	if(lpTagV2 && m_bID3V2)
		readTagV2(lpTagV2);
	if(lpTagV1 && m_bID3V1)
		readTagV1(lpTagV1);
	if(lpTagAPE && m_bAPE)
		readTagAPE(lpTagAPE);
	if(m_bProperties)
		readTagProperties(tags);

	if(lpApe)
		delete lpApe;
	if(lpASF)
		delete lpASF;
	if(lpFlac)
		delete lpFlac;
	if(lpMP4)
		delete lpMP4;
	if(lpMPC)
		delete lpMPC;
	if(lpMPEG)
		delete lpMPEG;
	if(lpTrueAudio)
		delete lpTrueAudio;
	if(lpWavPack)
		delete lpWavPack;
	if(lpWav)
		delete lpWav;

	m_bIsValid	= true;
	return(true);
}