当前位置: 首页>>代码示例>>C++>>正文


C++ taglib::AudioProperties类代码示例

本文整理汇总了C++中taglib::AudioProperties的典型用法代码示例。如果您正苦于以下问题:C++ AudioProperties类的具体用法?C++ AudioProperties怎么用?C++ AudioProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AudioProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

bool TagReader::read()
{
    // TagLib functions are not reentrant
    QMutexLocker locker(&m_mutex);

    QByteArray encodedFileName = QFile::encodeName(m_fileName);
	TagLib::FileRef file(encodedFileName.constData(), true);
	if (file.isNull()) {
		return false;
    }

	TagLib::Tag *tags = file.tag();	
	TagLib::AudioProperties *props = file.audioProperties();
	if (!tags || !props) {
        return false;
    }

	m_length = props->length();
    m_bitrate = props->bitrate();
	m_mbid = extractMusicBrainzTrackID(file.file());
	if (!m_length || m_mbid.size() != 36) {
		return false;
    }

    return true;
}
开发者ID:nemesit,项目名称:acoustid-fingerprinter,代码行数:26,代码来源:tagreader.cpp

示例2: f

AlbumTrack::AlbumTrack(Album* album, QString trackPath)
{
    this->path = trackPath;
    this->number = 0;
    this->artist = "Unknown Artist";
    this->album = album;
    this->genre = "Unknown Genre";

    TagLib::FileRef f(trackPath.toStdString().c_str());
    if(!f.isNull() && f.tag())
    {
        TagLib::Tag *tag = f.tag();
        title = QString(tag->title().toCString());
        number = tag->track();
        artist = QString(tag->artist().toCString());
        albumName = QString(tag->album().toCString());
        genre = QString(tag->genre().toCString());
    }
    if(!f.isNull() && f.audioProperties())
    {
        TagLib::AudioProperties *properties = f.audioProperties();
        duration = properties->length() * 1000;
        //Weil Fmod die gerne in Millisekunden hätte
    }
}
开发者ID:HaHeho,项目名称:SoMu-Player,代码行数:25,代码来源:AlbumTrack.cpp

示例3: main

int main(int argc, char *argv[])
{
  for(int i = 1; i < argc; i++) {

    cout << "path:" << argv[i] << endl;

    TagLib::FileRef f(argv[i]);

    if(!f.isNull() && f.tag()) {

      TagLib::Tag *tag = f.tag();

      cout << "title:" << (tag->title()).toCString(true)   << endl;
      cout << "artist:" << (tag->artist()).toCString(true) << endl;
      cout << "album:" << (tag->album()).toCString(true)   << endl;
      cout << "albumartist:" << (tag->albumArtist()).toCString(true) << endl;
      cout << "track:" << tag->track() << endl;
      cout << "disc:"  << tag->cdNr() << endl;
    }

    if(!f.isNull() && f.audioProperties()) {

      TagLib::AudioProperties *properties = f.audioProperties();

      cout << "bitrate:" << properties->bitrate() << endl;
      cout << "length:" << properties->length()  << endl;
    }
  if(i!=argc-1)
    cout << "---" << endl;
  }
  return 0;
}
开发者ID:GunioRobot,项目名称:amp,代码行数:32,代码来源:tagreader.cpp

示例4: tuneFromFile

Tune* tuneFromFile(const QString& file)
{
	Tune* tune = new Tune(false);
	tune->file = file;

	TagLib::FileRef ref = fileName2TaglibRef(file);
	if(!ref.isNull()) {
		if(ref.tag()) {
			TagLib::Tag* tag = ref.tag();
			tune->artist = safeTagLibString2QString( tag->artist() );
			tune->album = safeTagLibString2QString( tag->album() );
			tune->title = safeTagLibString2QString( tag->title() );
			tune->trackNumber = QString::number( tag->track() );
			tune->genre = safeTagLibString2QString( tag->genre() );
		}

		Qomp::loadCover(tune, ref.file());

		if(ref.audioProperties()) {
			TagLib::AudioProperties *prop = ref.audioProperties();
			tune->duration = Qomp::durationSecondsToString( prop->length() );
			tune->bitRate = QString::number( prop->bitrate() );
		}

		tune->setMetadataResolved(true);
	}

	return tune;
}
开发者ID:qomp,项目名称:qomp,代码行数:29,代码来源:taghelpers.cpp

示例5: handle_file

int handle_file(const char* filepath, const char* filekey, AudioFileRecordStore& record_store)
{
    bool record_exists = record_store.find_record(filekey) != NULL;

    // Scanning a file for tags is expensive, so only do it if required.
    if(record_exists
            && !record_store.record_update_required(filekey))
    {
        // no update reqquired so has been handled.
        return 1;
    }

    TagLib::FileRef f(filepath);
    if (!f.isNull() && f.tag())
    {
        AudioFileRecord &record = record_store.get_record(filekey);
        record.update_start();

        if (verbose)
        {
            TagLib::Tag *tag = f.tag();
            std::cout << filepath << endl;
            std::cout << filekey << endl;
            std::cout << "-- TAG (basic) --" << endl;
            std::cout << "title   - \"" << tag->title()   << "\"" << endl;
            std::cout << "artist  - \"" << tag->artist()  << "\"" << endl;
            std::cout << "album   - \"" << tag->album()   << "\"" << endl;
            std::cout << "year    - \"" << tag->year()    << "\"" << endl;
            std::cout << "comment - \"" << tag->comment() << "\"" << endl;
            std::cout << "track   - \"" << tag->track()   << "\"" << endl;
            std::cout << "genre   - \"" << tag->genre()   << "\"" << endl;
        }

        TagLib::PropertyMap tags = f.file()->properties();

        for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i)
        {
            for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) 
            {
                record.update(i->first.toCString(true), j->toCString(true));
            }
        }

        if (f.audioProperties())
        {
            TagLib::AudioProperties *properties = f.audioProperties();
            record.update(audio_tags::BITRATE, properties->bitrate());
            record.update(audio_tags::LENGTH, properties->length());
            record.update(audio_tags::SAMPLERATE, properties->sampleRate());
            record.update(audio_tags::CHANNELS, properties->channels());
        }

        record.update_complete();
        return 1;
    }

    return 0;
}
开发者ID:blaisedias,项目名称:sqzbsrv,代码行数:58,代码来源:audio_file_tags.cpp

示例6: ReadTag

bool ReadTag(const musik::Core::String& fn, musik::Core::SongInfo& target)
{
    bool ret = true;

    musik::Core::Filename mfn(fn);

    target.SetFilename(fn);
    target.SetFormat("Ogg Vorbis");

    try
    {
#if defined (WIN32)
        TagLib::FileRef tag_file(fn.c_str());
#else    
        TagLib::FileRef tag_file(utf16to8(fn, true).c_str());
#endif
        if (!tag_file.isNull())
        {
            if (tag_file.tag())
            {
                TagLib::Tag *tag = tag_file.tag();        

                target.SetArtist(musik::Core::utf8to16(tag->artist().to8Bit(true)));
                target.SetAlbum(musik::Core::utf8to16(tag->album().to8Bit(true)));
                target.SetTitle(musik::Core::utf8to16(tag->title().to8Bit(true)));
                target.SetGenre(musik::Core::utf8to16(tag->genre().to8Bit(true)));
                target.SetNotes(musik::Core::utf8to16(tag->comment().to8Bit(true)));

                target.SetYear(musik::Core::IntToString(tag->year()));
                target.SetTrackNum(musik::Core::IntToString(tag->track()));
            }

            if (tag_file.audioProperties())
            {
                TagLib::AudioProperties *properties = tag_file.audioProperties();
                int duration = properties->length() * 1000;
                target.SetBitrate(musik::Core::IntToString(properties->bitrate()));
                target.SetDuration(musik::Core::IntToString(duration));
            }
        }

        // if the title is empty, then use the
        // filename...
        if (target.GetTitle().IsEmpty())
        {
            musik::Core::Filename MFN(fn);
            target.SetTitle(MFN.GetJustFilename());
        }
    }
    catch (...)
    {
        ret = false;
        cout << "taglib crashed reading: " << fn.c_str() << endl;
    }

    return ret;
}
开发者ID:stephen-hill,项目名称:musicCube,代码行数:57,代码来源:musikPlugin.cpp

示例7: MetaData

bool MetaData(const char* filepath, cFields& fields, cRow& props)
{
#define ADD(x, t) do { if (t) { fields.push_back(x); props.push_back(t); } } while(0)
#define ADDSTRING(x, t) do { if (!t.empty()) { fields.push_back(x); props.push_back(t); } } while(0)
#define ADDINT(x, t) do { std::string c = *itoa(t); if (!c.empty()){ fields.push_back(x); props.push_back(c);} } while(0)
    
    TagLib::FileRef f(filepath);

    fields.clear();
    props.clear();

    //cTag t;
    //const char* tmp = NULL;
    std::string tmp;
    
    if (f.isNull()) 
    {
        std::cerr<< "Taglib failed on " << filepath << std::endl;
        ADD("metadata_needs_update", "2"); // failure
        return false;
    }
   
    TagLib::Tag *tag = f.tag();
    
    if (tag) 
    {
#if 0
      tmp   = toString(tag->title()).c_str();   ADD("title",   tmp);
      tmp   = toString(tag->artist()).c_str();  ADD("artist",  tmp);
      tmp   = toString(tag->album()).c_str();   ADD("album",   tmp);
      tmp   = toString(tag->comment()).c_str(); ADD("comment", tmp);
      tmp   = toString(tag->genre()).c_str();   ADD("genre",   tmp);
#else
        tmp   = toString(tag->title());   ADDSTRING("title",   tmp);
        tmp   = toString(tag->artist());  ADDSTRING("artist",  tmp);
        tmp   = toString(tag->album());   ADDSTRING("album",   tmp);
        tmp   = toString(tag->comment()); ADDSTRING("comment", tmp);
        tmp   = toString(tag->genre());   ADDSTRING("genre",   tmp);
#endif
      
      //ADDINT("track", tag->track());
      ADDINT("year",  tag->year());
    }
    
    TagLib::AudioProperties *prop = f.audioProperties();
    if (prop) 
    {
        ADDINT("bitrate",    prop->bitrate());
        ADDINT("samplerate", prop->sampleRate());
      //  ADDINT("channels",   prop->channels());
        ADDINT("length" ,    prop->length());
    }
 
    ADD("metadata_needs_update", "0");
    return true;
}
开发者ID:suborb,项目名称:reelvdr,代码行数:56,代码来源:analyzer.c

示例8: getAudioInfo

bool getAudioInfo(const QString& file, qint64* durationMiliSecs, int* bitrate)
{
	TagLib::FileRef ref = Qomp::fileName2TaglibRef(file);
	if(!ref.isNull() && ref.audioProperties()) {
		TagLib::AudioProperties *prop = ref.audioProperties();

		*bitrate = prop->bitrate();
		*durationMiliSecs = prop->length() * 1000;

		return true;
	}

	return false;
}
开发者ID:qomp,项目名称:qomp,代码行数:14,代码来源:taghelpers.cpp

示例9: getFiles

void designer::getFiles(QStringList files)
{
    if (files.empty())
        return;

    QString filenames = "";
    int duration = 0;
    foreach(QString filepath, files)
    {
        TagLib::FileRef f(reinterpret_cast<filestr*>(filepath.constData()));
        TagLib::AudioProperties* props = f.audioProperties();
        duration += props->lengthInSeconds();

        QString filename = filepath.split("/").last();
        filename.remove(QRegExp("\\.(mp3|flac|m4a)"));
        filenames += filename + "\n";
    }
开发者ID:n00levoy,项目名称:mu-designer,代码行数:17,代码来源:designer_files.cpp

示例10: scan_file

string scan_file(const char* path)
{
    TagLib::FileRef f(path);
    if (!f.isNull() && f.tag()) {
        TagLib::Tag *tag = f.tag();
        int filesize = boost::filesystem::file_size(path);
        int bitrate = 0;
        int duration = 0;
        if (f.audioProperties()) {
            TagLib::AudioProperties *properties = f.audioProperties();
            duration = properties->length();
            bitrate = properties->bitrate();
        }
        string artist = tag->artist().toCString(true);
        string album  = tag->album().toCString(true);
        string track  = tag->title().toCString(true);
        boost::trim(artist);
        boost::trim(album);
        boost::trim(track);
        if (artist.length()==0 || track.length()==0) {
            return "{\"error\" : \"no tags\"}\n";
        }
        string ext(toUtf8(boost::filesystem::extension(path)));
        string mimetype = ext2mime(boost::to_lower_copy(ext));
        // turn it into a url by prepending file://
        // because we pass all urls to curl:
        string urlpath = urlify( toUtf8(path) );

        ostringstream os;
        os      <<  "{  \"url\" : \"" << urlpath << "\","
                    "   \"filesize\" : " << filesize << ","
                    "   \"mimetype\" : \"" << mimetype << "\","
                    "   \"artist\" : \"" << tidy(artist) << "\","
                    "   \"album\" : \"" << tidy(album) << "\","
                    "   \"track\" : \"" << tidy(track) << "\","
                    "   \"duration\" : " << duration << ","
                    "   \"bitrate\" : " << bitrate << ","
                    "   \"trackno\" : " << tag->track()

                <<  "}\n";
        return os.str();
    }
    return "{\"error\" : \"no tags\"}\n";
}
开发者ID:dougma,项目名称:playdar-core,代码行数:44,代码来源:taglib_json_reader.cpp

示例11: scan_file

string scan_file(const char* path)
{
    TagLib::FileRef f(path);
    if (!f.isNull() && f.tag()) {
        TagLib::Tag *tag = f.tag();
        int bitrate = 0;
        int duration = 0;
        if (f.audioProperties()) {
            TagLib::AudioProperties *properties = f.audioProperties();
            duration = properties->length();
            bitrate = properties->bitrate();
        }
        string artist = tag->artist().toCString(true);
        string album  = tag->album().toCString(true);
        string track  = tag->title().toCString(true);
        trim(artist);
        trim(album);
        trim(track);
        if (artist.length()==0 || track.length()==0) {
            return "{\"error\" : \"no tags\"}";
        }
        string pathstr(path);
        string ext = pathstr.substr(pathstr.length()-4);
        std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
        string mimetype = ext2mime(ext);
        // turn it into a url by prepending file://
        // because we pass all urls to curl:
        string urlpath = urlify( path );

        ostringstream os;
        os      <<  "{  \"url\" : \"" << esc(urlpath) << "\","
                    "   \"mimetype\" : \"" << mimetype << "\","
                    "   \"artist\" : \"" << tidy(artist) << "\","
                    "   \"album\" : \"" << tidy(album) << "\","
                    "   \"track\" : \"" << tidy(track) << "\","
                    "   \"duration\" : " << duration << ","
                    "   \"bitrate\" : " << bitrate << ","
                    "   \"trackno\" : " << tag->track()
                <<  "}";
        return os.str();
    }
    return "{\"error\" : \"no tags\"}";
}
开发者ID:Brijen,项目名称:playdar-core,代码行数:43,代码来源:taglib_json_reader.cpp

示例12: getMp3Info

void getMp3Info(const WCHAR* fileName, MP3Info &info)
{
    TagLib::FileRef f(fileName);

    if (!f.isNull() && f.tag())
    {
        TagLib::Tag *tag = f.tag();

        info.tag[0] = tag->title().toWString();
        info.tag[1] = tag->artist().toWString();
        info.tag[2] = tag->album().toWString();
        info.tag[3] = tag->comment().toWString();
        info.tag[4] = tag->genre().toWString();
        info.year = tag->year();
        info.track = tag->track();

        TagLib::PropertyMap tags = f.file()->properties();

        if (!f.isNull() && f.audioProperties()) 
        {
            TagLib::AudioProperties *properties = f.audioProperties();

            int seconds = properties->length() % 60;
            int minutes = (properties->length() - seconds) / 60;

            info.bitrate = properties->bitrate();
            info.sample_rate = properties->sampleRate();
            info.channels = properties->channels();
            info.length_minutes = minutes;
            info.length_seconds = seconds;
        }
    }
}
开发者ID:neptune46,项目名称:ShuffleMP3,代码行数:33,代码来源:MP3Info.cpp

示例13: AddFromFile_Taglib

// Use Taglib to parse tags from file and add entried to wxListCtrl
void AddFromFile_Taglib(wxListCtrl *listctrl, const std::map< wxString, long > &mapping, const wxString &filename)
{
    TagLib::FileRef f = TagLib::FileRef(filename.c_str(), TagLib::String::UTF8 ); //TODO: is c_str() safe?

    if ( f.isNull() )
    {
        wxLogError(wxT("Error: TagLib could not read ") + filename + wxT("."));
        return;
    }

    if ( ! f.tag() )
    {
        wxLogError(wxT("Error: TagLib could not read the tags of file ") + filename + wxT("."));
        return;
    }

    TagLib::Tag *tag = f.tag();
    auto idx = listctrl->GetItemCount();
    auto row_idx = listctrl->InsertItem(idx, wxString::Format(wxT("%d"), idx) );

    // TODO: check return values
    listctrl->SetItem(row_idx, mapping.find("Artist")->second, wxString(tag->artist().to8Bit(true)) );
    listctrl->SetItem(row_idx, mapping.find("Trackname")->second, wxString(tag->title().to8Bit(true)));
    listctrl->SetItem(row_idx, mapping.find("Album")->second, wxString(tag->album().to8Bit(true)));

    if ( f.audioProperties() )
    {
      TagLib::AudioProperties *properties = f.audioProperties();
      int seconds = properties->length() % 60;
      int minutes = (properties->length() - seconds) / 60;

      wxString timestr = wxString::Format("%d:%02d", minutes, seconds);

      listctrl->SetItem(row_idx, mapping.find("Time")->second, timestr);
    }

}
开发者ID:sperrholz,项目名称:lfmt,代码行数:38,代码来源:lfmt_util.cpp

示例14: ReadTags

bool ReadTags(const string &filename, bool ignore_missing_mbid)
{
	TagLib::FileRef file(filename.c_str(), true);
	if (file.isNull())
		return false;
	TagLib::Tag *tags = file.tag();	
	TagLib::AudioProperties *props = file.audioProperties();
	if (!tags || !props)
		return false;
	//cout << "ARTIST=" << tags->artist().to8Bit(true) << "\n";
	//cout << "TITLE=" << tags->title().to8Bit(true) << "\n";
	//cout << "ALBUM=" << tags->album().to8Bit(true) << "\n";
	int length = props->length();
	if (!length)
		return false;
	string mbid = ExtractMusicBrainzTrackID(file.file());
	if (mbid.size() != 36 && !ignore_missing_mbid)
		return false;
	if (mbid.size() == 36)
		cout << "MBID=" << mbid << "\n";
	cout << "LENGTH=" << length << "\n";
	cout << "BITRATE=" << props->bitrate() << "\n";
	return true;
}
开发者ID:nemesit,项目名称:chromaprint,代码行数:24,代码来源:fpcollect.cpp

示例15: main

int main(int argc, char *argv[])
{
  for(int i = 1; i < argc; i++) {

    cout << "******************** \"" << argv[i] << "\" ********************" << endl;

    TagLib::FileRef f(argv[i]);

    if(!f.isNull() && f.tag()) {

      TagLib::Tag *tag = f.tag();

      cout << "-- TAG (basic) --" << endl;
      cout << "title   - \"" << tag->title()   << "\"" << endl;
      cout << "artist  - \"" << tag->artist()  << "\"" << endl;
      cout << "album   - \"" << tag->album()   << "\"" << endl;
      cout << "year    - \"" << tag->year()    << "\"" << endl;
      cout << "comment - \"" << tag->comment() << "\"" << endl;
      cout << "track   - \"" << tag->track()   << "\"" << endl;
      cout << "genre   - \"" << tag->genre()   << "\"" << endl;

      TagLib::PropertyMap tags = f.file()->properties();

      unsigned int longest = 0;
      for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
        if (i->first.size() > longest) {
          longest = i->first.size();
        }
      }

      cout << "-- TAG (properties) --" << endl;
      for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
        for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) {
          cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl;
        }
      }

    }

    if(!f.isNull() && f.audioProperties()) {

      TagLib::AudioProperties *properties = f.audioProperties();

      int seconds = properties->length() % 60;
      int minutes = (properties->length() - seconds) / 60;

      cout << "-- AUDIO --" << endl;
      cout << "bitrate     - " << properties->bitrate() << endl;
      cout << "sample rate - " << properties->sampleRate() << endl;
      cout << "channels    - " << properties->channels() << endl;
      cout << "length      - " << minutes << ":" << setfill('0') << setw(2) << seconds << endl;
    }
  }
  return 0;
}
开发者ID:ArnaudBienner,项目名称:taglib,代码行数:55,代码来源:tagreader.cpp


注:本文中的taglib::AudioProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。