void TrackInfoObject::parse() { // Log parsing of header information in developer mode. This is useful for // tracking down corrupt files. const QString& canonicalLocation = m_fileInfo.canonicalFilePath(); if (CmdlineArgs::Instance().getDeveloper()) { qDebug() << "TrackInfoObject::parse()" << canonicalLocation; } // Parse the information stored in the sound file. SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken); Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource(); if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) { // Dump the metadata extracted from the file into the track. // TODO(XXX): This involves locking the mutex for every setXXX // method. We should figure out an optimization where there are private // setters that don't lock the mutex. // If Artist, Title and Type fields are not blank, modify them. // Otherwise, keep their current values. // TODO(rryan): Should we re-visit this decision? if (!(pProxiedSoundSource->getArtist().isEmpty())) { setArtist(pProxiedSoundSource->getArtist()); } if (!(pProxiedSoundSource->getTitle().isEmpty())) { setTitle(pProxiedSoundSource->getTitle()); } if (!(pProxiedSoundSource->getType().isEmpty())) { setType(pProxiedSoundSource->getType()); } setAlbum(pProxiedSoundSource->getAlbum()); setAlbumArtist(pProxiedSoundSource->getAlbumArtist()); setYear(pProxiedSoundSource->getYear()); setGenre(pProxiedSoundSource->getGenre()); setComposer(pProxiedSoundSource->getComposer()); setGrouping(pProxiedSoundSource->getGrouping()); setComment(pProxiedSoundSource->getComment()); setTrackNumber(pProxiedSoundSource->getTrackNumber()); setReplayGain(pProxiedSoundSource->getReplayGain()); setBpm(pProxiedSoundSource->getBPM()); setDuration(pProxiedSoundSource->getDuration()); setBitrate(pProxiedSoundSource->getBitrate()); setSampleRate(pProxiedSoundSource->getSampleRate()); setChannels(pProxiedSoundSource->getChannels()); setKeyText(pProxiedSoundSource->getKey(), mixxx::track::io::key::FILE_METADATA); setHeaderParsed(true); } else { qDebug() << "TrackInfoObject::parse() error at file" << canonicalLocation; setHeaderParsed(false); // Add basic information derived from the filename: parseFilename(); } }
void PhononItem::metaStateChanged(Phonon::State newState, Phonon::State oldState) { Q_UNUSED(oldState); // static QObjectWriter writer(this, false); if (newState == Phonon::ErrorState) { qDebug() << "PhononItem: Error Opening File: " << fileName(); emit fetched(false); return; } if (m_metaMedia->currentSource().type() == Phonon::MediaSource::Invalid) { emit fetched(false); qDebug() << "Invalid metadata: " << fileName(); return; } QMap<QString, QString> metaData = m_metaMedia->metaData(); setArtist(metaData.value("ARTIST")); setTrackTitle(metaData.value("TITLE")); setAlbumTitle(metaData.value("ALBUM")); setGenre(metaData.value("GENRE")); QString tn = metaData.value("TRACK-NUMBER"); if (tn == QString()) tn = metaData.value("TRACKNUMBER"); setTrackNumber(tn); extendedComment = QString(); QString comment = metaData.value("COMMENT"); setComment(comment); // http://www.freedesktop.org/wiki/Specifications/free-media-player-specs QString fmpsRating = metaData.value("FMPS_Rating"); // ??? Why does this not work? if (fmpsRating.toDouble() > 0 ) { int stars = fmpsRating.toDouble() * 10; Preference fmpsPref(stars); qDebug() << "FMPS Rating: " << stars; setPreference(fmpsPref); } // Preference can be obtained from various ways. else setPreference(comment); // Check for MusicMatch preference if ((preference().intValue() == 0) && metaData.contains("EXTENDED-COMMENT")) { extendedComment = metaData.value("EXTENDED-COMMENT"); int eqidx = extendedComment.indexOf("="); if (eqidx > 0) extendedComment=extendedComment.mid(eqidx+1); Preference p(extendedComment); if (p.intValue() > 0) { setPreference(p); setComment(p.toString()); } } //start id="notify" m_loaded = true; if (m_timeSet) { emit fetched(); } //end }
bool SoundSource::processTaglibFile(TagLib::File& f) { if (s_bDebugMetadata) qDebug() << "Parsing" << getFilename(); if (f.isValid()) { TagLib::Tag *tag = f.tag(); if (tag) { QString title = TStringToQString(tag->title()); setTitle(title); QString artist = TStringToQString(tag->artist()); setArtist(artist); QString album = TStringToQString(tag->album()); setAlbum(album); QString comment = TStringToQString(tag->comment()); setComment(comment); QString genre = TStringToQString(tag->genre()); setGenre(genre); int iYear = tag->year(); QString year = ""; if (iYear > 0) { year = QString("%1").arg(iYear); setYear(year); } int iTrack = tag->track(); QString trackNumber = ""; if (iTrack > 0) { trackNumber = QString("%1").arg(iTrack); setTrackNumber(trackNumber); } if (s_bDebugMetadata) qDebug() << "TagLib" << "title" << title << "artist" << artist << "album" << album << "comment" << comment << "genre" << genre << "year" << year << "trackNumber" << trackNumber; } TagLib::AudioProperties *properties = f.audioProperties(); if (properties) { int lengthSeconds = properties->length(); int bitrate = properties->bitrate(); int sampleRate = properties->sampleRate(); int channels = properties->channels(); if (s_bDebugMetadata) qDebug() << "TagLib" << "length" << lengthSeconds << "bitrate" << bitrate << "sampleRate" << sampleRate << "channels" << channels; setDuration(lengthSeconds); setBitrate(bitrate); setSampleRate(sampleRate); setChannels(channels); } // If we didn't get any audio properties, this was a failure. return (properties!=NULL); } return false; }
, m_editors( editors ) {} void beginUpdate() { m_batchMode = true; foreach( TrackEditorPtr ec, m_editors ) ec->beginUpdate(); } void endUpdate() { foreach( TrackEditorPtr ec, m_editors ) ec->endUpdate(); m_batchMode = false; QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) ); } void setComment( const QString &newComment ) { FORWARD( setComment( newComment ) ) } void setTrackNumber( int newTrackNumber ) { FORWARD( setTrackNumber( newTrackNumber ) ) } void setDiscNumber( int newDiscNumber ) { FORWARD( setDiscNumber( newDiscNumber ) ) } void setBpm( const qreal newBpm ) { FORWARD( setBpm( newBpm ) ) } void setTitle( const QString &newTitle ) { FORWARD( setTitle( newTitle ) ) } void setArtist( const QString &newArtist ) { FORWARD( setArtist( newArtist ) ) } void setAlbum( const QString &newAlbum ) { FORWARD( setAlbum( newAlbum ) ) } void setAlbumArtist( const QString &newAlbumArtist ) { FORWARD( setAlbumArtist ( newAlbumArtist ) ) } void setGenre( const QString &newGenre ) { FORWARD( setGenre( newGenre ) ) } void setComposer( const QString &newComposer ) { FORWARD( setComposer( newComposer ) ) } void setYear( int newYear ) { FORWARD( setYear( newYear ) ) } private: bool m_batchMode; Collections::AggregateCollection *m_collection; QList<TrackEditorPtr> m_editors; };