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


C++ Sound::getTag方法代码示例

本文整理汇总了C++中fmod::Sound::getTag方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::getTag方法的具体用法?C++ Sound::getTag怎么用?C++ Sound::getTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fmod::Sound的用法示例。


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

示例1: loadPlaylist

void SoundManager::loadPlaylist(std::string filename)
{
	FMOD::Sound* playlist;
	mSystem->createSound(filename.c_str(), FMOD_DEFAULT, 0, &playlist);
	FMOD_SOUND_TYPE type;
	playlist->getFormat(&type, 0, 0, 0);
	if(type != FMOD_SOUND_TYPE_PLAYLIST)
	{
		printf("%s, wasn't a playlist!  Make sure it exists and it's in .m3u format.\n", filename.c_str());
		return;
	}
	printf("loading playlist %s\n", filename.c_str());
	int count = 0;
	FMOD_TAG tag;
	result = FMOD_OK;
	//go through the m3u file and extract the playlist info
	result = playlist->getTag("FILE", count, &tag);
	while(result == FMOD_OK)
	{

		unsigned int trackTime = 0;
		FMOD::Sound* music;		//attempt to load the song
		result = mSystem->createSound((char*)tag.data, FMOD_CREATESTREAM | FMOD_SOFTWARE | FMOD_2D, 0, &music); 
		//if we successfully found the file, get its length and close it
		if(result == FMOD_OK)
		{
			music->getLength(&trackTime, FMOD_TIMEUNIT_MS);
			music->release();
			PlayListEntry p(std::string((char*)tag.data), 0.001 * trackTime + 2.f);
			mPlayList.push_back(p);
//			printf("our file is...%s at %f seconds\n", p.filename.c_str(), p.trackTime);
		}
		else printf("%s not found, but is listed in the playlist\n", (char*)tag.data);
		
				count++;
		//check to see if we have another file in the playlist
		result = playlist->getTag("FILE", count, &tag);
	}
	mUsePlayList = true;
}
开发者ID:thoney,项目名称:MIRAGEvisApp,代码行数:40,代码来源:SoundManager.cpp

示例2: main


//.........这里部分代码省略.........
                    }
                    break;
                }
                case 'm' :
                case 'M' :
                {
                    if (channel)
                    {
                        channel->getMute(&mute);
                        channel->setMute(!mute);
                    }
                    break;
                }
            }
        }

        system->update();

        if (channel)
        {
            bool         playing = false;
            int          tagsupdated = 0;

            sound->getNumTags(0, &tagsupdated);

            if (tagsupdated)
            {
                printf("\n");
                printf("\n");
                for (;;)
                {
                    FMOD_TAG tag;

                    if (sound->getTag(0, -1, &tag) != FMOD_OK)
                    {
                        break;
                    }

                    if (tag.datatype == FMOD_TAGDATATYPE_STRING)
                    {
                        printf("[%-11s] %s (%d bytes)\n", tag.name, tag.data, tag.datalen);
                        
                        sound->getFormat(&gSoundType, 0, 0, 0);
                    
                        if (!strcmp(tag.name, "ARTIST"))
                        {
                            if (strncmp(gCurrentTrackArtist, (const char *)tag.data, 256))
                            {
                                strncpy(gCurrentTrackArtist, (const char *)tag.data, 256);
                                gUpdateFileName = true;
                            }
                        }
                        if (!strcmp(tag.name, "TITLE"))
                        {
                            if (strncmp(gCurrentTrackTitle, (const char *)tag.data, 256))
                            {
                                strncpy(gCurrentTrackTitle, (const char *)tag.data, 256);
                                gUpdateFileName = true;
                            }
                        }
                    }
                }
                printf("\n");
            }

            result = channel->isPlaying(&playing);
开发者ID:Guitaroz,项目名称:Arcade-Space-Shooter,代码行数:67,代码来源:main.cpp

示例3: main

int main(int argc, char *argv[])
{
    FMOD::System    *system;
    FMOD::Sound     *sound;
    FMOD_RESULT      result;
    FMOD_TAG         tag;
    int              numtags, numtagsupdated, count;
    unsigned int     version;

    printf("==================================================================\n");
    printf("ReadTags Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("==================================================================\n\n");

    /*
        Global Settings
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        getch();
        return 0;
    }

    result = system->init(100, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);

    /*
        Open the specified file. Use FMOD_CREATESTREAM and FMOD_OPENONLY so it opens quickly
    */
    result = system->createSound("../media/wave.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_OPENONLY, 0, &sound);
    ERRCHECK(result);

    /*
        Read and display all tags associated with this file
    */
    for (;;)
    {
        /*
            An index of -1 means "get the first tag that's new or updated".
            If no tags are new or updated then getTag will return FMOD_ERR_TAGNOTFOUND.
            This is the first time we've read any tags so they'll all be new but after we've read them, 
            they won't be new any more.
        */
        if (sound->getTag(0, -1, &tag) != FMOD_OK)
        {
            break;
        }
        if (tag.datatype == FMOD_TAGDATATYPE_STRING)
        {
            printf("%s = %s (%d bytes)\n", tag.name, (char *)tag.data, tag.datalen);
        }
        else
        {
            printf("%s = <binary> (%d bytes)\n", tag.name, tag.datalen);
        }
    }
    printf("\n");

    /*
        Read all the tags regardless of whether they're updated or not. Also show the tag type.
    */
    result = sound->getNumTags(&numtags, &numtagsupdated);
    ERRCHECK(result);
    for (count=0; count < numtags; count++)
    {
        result = sound->getTag(0, count, &tag);
        ERRCHECK(result);

        switch (tag.type)
        {
            case FMOD_TAGTYPE_UNKNOWN :
                printf("FMOD_TAGTYPE_UNKNOWN  ");
                break;

            case FMOD_TAGTYPE_ID3V1 :
                printf("FMOD_TAGTYPE_ID3V1  ");
                break;

            case FMOD_TAGTYPE_ID3V2 :
                printf("FMOD_TAGTYPE_ID3V2  ");
                break;

            case FMOD_TAGTYPE_VORBISCOMMENT :
                printf("FMOD_TAGTYPE_VORBISCOMMENT  ");
                break;

            case FMOD_TAGTYPE_SHOUTCAST :
                printf("FMOD_TAGTYPE_SHOUTCAST  ");
                break;

            case FMOD_TAGTYPE_ICECAST :
                printf("FMOD_TAGTYPE_ICECAST  ");
                break;

//.........这里部分代码省略.........
开发者ID:EEmmanuel7,项目名称:leapmotion-irrlicht,代码行数:101,代码来源:main.cpp

示例4: main

int main(int argc, char *argv[])
{
    FMOD::System    *system;
    FMOD::Sound     *cdsound;
    FMOD::Sound     *sound;
    FMOD::Channel   *channel = 0;
    FMOD_RESULT      result;
    int              key, numtracks, currenttrack = 0;
    unsigned int     version;

    if (argc < 2)
    {
        printf("Usage: cdplayer <drivepath>\n");
        printf("Example: cdplayer /dev/cdrom\n");
        exit(-1);
    }

    printf("==================================================================\n");
    printf("CDPlayer Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("==================================================================\n\n");

    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        return 0;
    }

    result = system->init(1, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);

    /*
        Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium.
    */
    result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
    ERRCHECK(result);

    result = system->createStream(argv[1], FMOD_OPENONLY, 0, &cdsound);
    ERRCHECK(result);
    result = cdsound->getNumSubSounds(&numtracks);
    ERRCHECK(result);
    result = cdsound->getSubSound(currenttrack, &sound);
    ERRCHECK(result);

    for (;;)
    {
        FMOD_TAG tag;

        if (cdsound->getTag(0, -1, &tag) != FMOD_OK)
        {
            break;
        }
        if (tag.datatype == FMOD_TAGDATATYPE_CDTOC)
        {
            dump_cddb_query((FMOD_CDTOC *)tag.data);
        }
    }

    printf("\n========================================\n");
    printf("Press SPACE to pause\n");
    printf("      n     to skip to next track\n");
    printf("      ESC   to exit\n");
    printf("========================================\n\n");

    /*
        Print out length of entire CD.  Did you know you can also play 'cdsound' and it will play the whole CD without gaps?
    */
    {
        unsigned int lenms;

        result = cdsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
        ERRCHECK(result);

        printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100);
    }


    /*
        Play a CD track
    */
    result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
    ERRCHECK(result);

    /*
        Main loop
    */
    do
    {
        if (kbhit())
        {
            key = getch();

//.........这里部分代码省略.........
开发者ID:YanisBreton,项目名称:wolf3d,代码行数:101,代码来源:main.cpp

示例5: main

int main(int argc, char *argv[])
{
    FMOD::System    *system;
    FMOD::Sound     *cdsound;
    FMOD::Channel   *channel = 0;
    FMOD_RESULT      result;
    int              key;
    unsigned int     currenttrack = 0, numtracks;
    unsigned int     version;

    printf("==================================================================\n");
    printf("CDPlayer Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("==================================================================\n\n");

    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        return 0;
    }

    result = system->init(1, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);

    /*
        Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium.
    */
    result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
    ERRCHECK(result);

    /*
        Try a few drive letters.
    */
    result = system->createStream("d:", FMOD_OPENONLY, 0, &cdsound);
    if (result != FMOD_OK)
    {
        result = system->createStream("e:", FMOD_OPENONLY, 0, &cdsound);
        if (result != FMOD_OK)
        {
            result = system->createStream("f:", FMOD_OPENONLY, 0, &cdsound);
            ERRCHECK(result);
        }
    }
    result = cdsound->getNumSubSounds((int *)&numtracks);
    ERRCHECK(result);

    for (;;)
    {
        FMOD_TAG tag;

        if (cdsound->getTag(0, -1, &tag) != FMOD_OK)
        {
            break;
        }
        if (tag.datatype == FMOD_TAGDATATYPE_CDTOC)
        {
            dump_cddb_query((FMOD_CDTOC *)tag.data);
        }
    }

    printf("\n========================================\n");
    printf("Press SPACE to pause\n");
    printf("      n     to skip to next track\n");
    printf("      <     re-wind 10 seconds\n");
    printf("      >     fast-forward 10 seconds\n");
    printf("      ESC   to exit\n");
    printf("========================================\n\n");

    /*
        Print out length of entire CD.  Did you know you can also play 'cdsound' and it will play the whole CD without gaps?
    */
    {
        unsigned int lenms;

        result = cdsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
        ERRCHECK(result);

        printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100);
    }

    /*
        Play whole CD
    */
    result = system->playSound(FMOD_CHANNEL_FREE, cdsound, false, &channel);
    ERRCHECK(result);

    /*
        Main loop
    */
    do
    {
        if (_kbhit())
//.........这里部分代码省略.........
开发者ID:InfoSmart,项目名称:InSource-Singleplayer,代码行数:101,代码来源:main.cpp

示例6: FMOD_Main

int FMOD_Main()
{
    FMOD::System    *system = 0;
    FMOD::Sound     *sound = 0;
    FMOD::Channel   *channel = 0;
    FMOD_RESULT      result = FMOD_OK;
    FMOD_OPENSTATE   openstate = FMOD_OPENSTATE_READY;
    unsigned int     version = 0;
    void            *extradriverdata = 0;
    const int        tagcount = 4;
    int              tagindex = 0;
    char             tagstring[tagcount][128] = { 0 };
    
    Common_Init(&extradriverdata);
    
    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
    }

    result = system->init(1, FMOD_INIT_NORMAL, extradriverdata);
    ERRCHECK(result);

    /* Increase the file buffer size a little bit to account for Internet lag. */
    result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
    ERRCHECK(result);

    result = system->createSound("http://shoutmedia.abc.net.au:10426", FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);
    ERRCHECK(result);

    /*
        Main loop
    */
    do
    {
        unsigned int    pos = 0;
        unsigned int    percent = 0;
        bool            playing = false;
        bool            paused = false;
        bool            starving = false;
        const char     *state = "Stopped";
        
        Common_Update();

        if (Common_BtnPress(BTN_ACTION1))
        {
            if (channel)
            {
                bool paused = false;
                
                result = channel->getPaused(&paused);
                ERRCHECK(result);
                result = channel->setPaused(!paused);
                ERRCHECK(result);
            }
        }
        
        result = system->update();
        ERRCHECK(result);
        
        result = sound->getOpenState(&openstate, &percent, &starving, 0);
        ERRCHECK(result);
        
        if (channel)
        {
            FMOD_TAG tag;
        
            /*
                Read any tags that have arrived, this could happen if a radio station switches
                to a new song.
            */
            while (sound->getTag(0, -1, &tag) == FMOD_OK)
            {
                if (tag.datatype == FMOD_TAGDATATYPE_STRING)
                {
                    sprintf(tagstring[tagindex], "%s = '%s' (%d bytes)", tag.name, (char *)tag.data, tag.datalen);
                    tagindex = (tagindex + 1) % tagcount;
                }
                else if (tag.type == FMOD_TAGTYPE_FMOD)
                {
                    /* When a song changes, the sample rate may also change, so compensate here. */
                    if (!strcmp(tag.name, "Sample Rate Change"))
                    {
                        float frequency = *((float *)tag.data);
                        
                        result = channel->setFrequency(frequency);
                        ERRCHECK(result);
                    }
                }
            }
            
//.........这里部分代码省略.........
开发者ID:joyfish,项目名称:GameThirdPartyLibs,代码行数:101,代码来源:net_stream.cpp

示例7: main

int main(int argc, char *argv[])
{
    FMOD::System     *system   = 0;
    FMOD::Sound      *playlist = 0;
    FMOD::Sound      *sound    = 0;
    FMOD::Channel    *channel  = 0;
    FMOD_TAG          tag;
    FMOD_RESULT       result;
    FMOD_SOUND_TYPE   soundtype;
    bool              isplaylist = false;
    char             *title = NULL;
    int               count = 0;
    int               key;
    unsigned int      version;
    char              file[128];
    
    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        return 0;
    }

    result = system->init(32, FMOD_INIT_NORMAL, 0);
    ERRCHECK(result);

    result = system->createSound("../media/playlist.m3u", FMOD_DEFAULT, 0, &playlist);
    ERRCHECK(result);

    result = playlist->getFormat(&soundtype, 0, 0, 0);
    ERRCHECK(result);

    isplaylist = (soundtype == FMOD_SOUND_TYPE_PLAYLIST);

    printf("===================================================================\n");
    printf("PlayList Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("===================================================================\n");
    printf("\n");
    printf("Press 'n'     to play next sound in playlist\n");
    printf("Press 'space' to pause/unpause current sound\n");
    printf("Press 'Esc'   to quit\n");
    printf("\n");

    if (isplaylist)
    {
        printf("PLAYLIST loaded.\n");
        /*
            Get the first song in the playlist, create the sound and then play it.
        */
        result = playlist->getTag("FILE", count, &tag);
        ERRCHECK(result);

        sprintf(file, "../media/%s", (char *)tag.data);

        result = system->createSound(file, FMOD_DEFAULT, 0, &sound);
        ERRCHECK(result);

        result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
        ERRCHECK(result);

        playlist->getTag("TITLE", count, &tag);
        title = (char *)tag.data;

        count++;
    }
    else
    {
        printf("SOUND loaded.\n");

        /*
            This is just a normal sound, so just play it.
        */
        sound = playlist;

        result = sound->setMode(FMOD_LOOP_NORMAL);
        ERRCHECK(result);

        result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
        ERRCHECK(result);
    }

    printf("\n");

    /*
        Main loop.
    */
    do
    {
        bool  isplaying = false;

        if (channel && isplaylist)
        {
//.........这里部分代码省略.........
开发者ID:YanisBreton,项目名称:wolf3d,代码行数:101,代码来源:main.cpp


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