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


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

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


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

示例1:

	FMOD::Sound *SoundManager::CreatePlayList(std::string &fileName)
	{
		FMOD_RESULT result;
		FMOD::Sound *playlist;
		std::string fullPathName;
		bool isPlayList = false;
		FMOD_SOUND_TYPE soundType;

		fullPathName = SOUND_DIRECTORY + fileName;
		
		result = system->createSound(fullPathName.c_str(), FMOD_DEFAULT, 0, &playlist);

		if(result != FMOD_OK)
		{
			Ogre::LogManager::getSingleton().logMessage(
				"SoundManager::CreateSound could not load sound '" + fileName + "' (invalid soundType)");
			return NULL;
		}

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

		isPlayList = (soundType == FMOD_SOUND_TYPE_PLAYLIST);

		if(isPlayList)
		{
			return playlist;
		}
		else
		{
			playlist->release();
			return NULL;
		}
	}
开发者ID:Grogist,项目名称:OgreGame,代码行数:33,代码来源:GLSoundManager.cpp

示例2: FMODGMS_Chan_Set_ModRow

// Sets the row position of a channel playing a MOD
GMexport double FMODGMS_Chan_Set_ModRow(double channel, double row)
{
	int c = (int)round(channel);
	int chanListSize = channelList.size();

	if (chanListSize > c && c >= 0)
	{
		// get handle of sound currently playing in channel
		FMOD::Sound *snd;
		channelList[c]->getCurrentSound(&snd);

		// check to see if the sound is a module
		FMOD_SOUND_TYPE type;
		snd->getFormat(&type, 0, 0, 0);

		if (type == FMOD_SOUND_TYPE_MOD ||
			type == FMOD_SOUND_TYPE_S3M ||
			type == FMOD_SOUND_TYPE_XM ||
			type == FMOD_SOUND_TYPE_IT)
		{
			unsigned int r;
			if (row < 0)
				r = 0;
			else
				r = (unsigned int)row;

			channelList[c]->setPosition(r, FMOD_TIMEUNIT_MODROW);
			errorMessage = "No errors.";
			return GMS_true;
		}

		// not a module
		else
		{
			errorMessage = "Not a MOD, S3M, XM, or IT.";
			return GMS_error;
		}
	}

	// index out of bounds
	else
	{
		errorMessage = "Index out of bounds.";
		return GMS_error;
	}
}
开发者ID:mstop4,项目名称:FMODGMS,代码行数:47,代码来源:fmodgms.cpp

示例3: 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

示例4:

	SPtr<Resource> FMODImporter::import(const Path& filePath, SPtr<const ImportOptions> importOptions)
	{
		WString extension = filePath.getWExtension();
		StringUtil::toLowerCase(extension);

		AudioFileInfo info;

		FMOD::Sound* sound;
		String pathStr = filePath.toString();
		if(gFMODAudio()._getFMOD()->createSound(pathStr.c_str(), FMOD_CREATESAMPLE, nullptr, &sound) != FMOD_OK)
		{
			LOGERR("Failed importing audio file: " + pathStr);
			return nullptr;
		}

		FMOD_SOUND_FORMAT format;
		INT32 numChannels = 0;
		INT32 numBits = 0;

		sound->getFormat(nullptr, &format, &numChannels, &numBits);

		if(format != FMOD_SOUND_FORMAT_PCM8 && format != FMOD_SOUND_FORMAT_PCM16 && format != FMOD_SOUND_FORMAT_PCM24 
			&& format != FMOD_SOUND_FORMAT_PCM32 && format != FMOD_SOUND_FORMAT_PCMFLOAT)
		{
			LOGERR("Failed importing audio file, invalid imported format: " + pathStr);
			return nullptr;
		}

		float frequency = 0.0f;
		sound->getDefaults(&frequency, nullptr);

		UINT32 size;
		sound->getLength(&size, FMOD_TIMEUNIT_PCMBYTES);
		
		info.bitDepth = numBits;
		info.numChannels = numChannels;
		info.sampleRate = (UINT32)frequency;
		info.numSamples = size / (info.bitDepth / 8);

		UINT32 bytesPerSample = info.bitDepth / 8;
		UINT32 bufferSize = info.numSamples * bytesPerSample;
		UINT8* sampleBuffer = (UINT8*)bs_alloc(bufferSize);
		assert(bufferSize == size);
		
		UINT8* startData = nullptr;
		UINT8* endData = nullptr;
		UINT32 startSize = 0;
		UINT32 endSize = 0;
		sound->lock(0, size, (void**)&startData, (void**)&endData, &startSize, &endSize);

		if(format == FMOD_SOUND_FORMAT_PCMFLOAT)
		{
			assert(info.bitDepth == 32);

			UINT32* output = (UINT32*)sampleBuffer;
			for(UINT32 i = 0; i < info.numSamples; i++)
			{
				float value = *(((float*)startData) + i);
				*output = (UINT32)(value * 2147483647.0f);
				output++;
			}
		}
		else
		{
			memcpy(sampleBuffer, startData, bufferSize);
		}

		sound->unlock((void**)&startData, (void**)&endData, startSize, endSize);
		sound->release();

		SPtr<const AudioClipImportOptions> clipIO = std::static_pointer_cast<const AudioClipImportOptions>(importOptions);

		// If 3D, convert to mono
		if (clipIO->getIs3D() && info.numChannels > 1)
		{
			UINT32 numSamplesPerChannel = info.numSamples / info.numChannels;

			UINT32 monoBufferSize = numSamplesPerChannel * bytesPerSample;
			UINT8* monoBuffer = (UINT8*)bs_alloc(monoBufferSize);

			AudioUtility::convertToMono(sampleBuffer, monoBuffer, info.bitDepth, numSamplesPerChannel, info.numChannels);

			info.numSamples = numSamplesPerChannel;
			info.numChannels = 1;

			bs_free(sampleBuffer);

			sampleBuffer = monoBuffer;
			bufferSize = monoBufferSize;
		}

		// Convert bit depth if needed
		if (clipIO->getBitDepth() != info.bitDepth)
		{
			UINT32 outBufferSize = info.numSamples * (clipIO->getBitDepth() / 8);
			UINT8* outBuffer = (UINT8*)bs_alloc(outBufferSize);

			AudioUtility::convertBitDepth(sampleBuffer, info.bitDepth, outBuffer, clipIO->getBitDepth(), info.numSamples);

			info.bitDepth = clipIO->getBitDepth();
//.........这里部分代码省略.........
开发者ID:maximwreznikov,项目名称:BansheeEngine,代码行数:101,代码来源:BsFMODImporter.cpp

示例5: main


//.........这里部分代码省略.........
                        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);
            if (result != FMOD_OK || !playing)
            {
                sound->release();
                sound = 0;               
                channel = 0;
            }
            else
            {
                unsigned int    ms = 0, percent = 0;
开发者ID:Guitaroz,项目名称:Arcade-Space-Shooter,代码行数:67,代码来源:main.cpp

示例6: FMOD_Main

int FMOD_Main()
{
    void *extradriverdata = 0;    
    Common_Init(&extradriverdata);

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

    unsigned int version;
    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(32, FMOD_INIT_NORMAL, extradriverdata);
    ERRCHECK(result);
        

    /*
        Create a new channel group to hold the convolution DSP unit
    */
    FMOD::ChannelGroup* reverbGroup;
    result = system->createChannelGroup("reverb", &reverbGroup);
    ERRCHECK(result);

    
    /*
        Create a new channel group to hold all the channels and process the dry path
    */
    FMOD::ChannelGroup* mainGroup;
    result = system->createChannelGroup("main", &mainGroup);
    ERRCHECK(result);

    /*
        Create the convultion DSP unit and set it as the tail of the channel group
    */
    FMOD::DSP* reverbUnit;    
    result = system->createDSPByType(FMOD_DSP_TYPE_CONVOLUTIONREVERB, &reverbUnit);
    ERRCHECK(result);
    result = reverbGroup->addDSP(FMOD_CHANNELCONTROL_DSP_TAIL, reverbUnit);
    ERRCHECK(result);

    /*
        Open the impulse response wav file, but use FMOD_OPENONLY as we want
        to read the data into a seperate buffer
    */
    FMOD::Sound* irSound;
    result = system->createSound(Common_MediaPath("standrews.wav"), FMOD_DEFAULT | FMOD_OPENONLY, NULL, &irSound);
    ERRCHECK(result);

    /*
        Retrieve the sound information for the Impulse Response input file
    */
    FMOD_SOUND_FORMAT irSoundFormat;
    FMOD_SOUND_TYPE irSoundType;
    int irSoundBits, irSoundChannels;
    result = irSound->getFormat(&irSoundType, &irSoundFormat, &irSoundChannels, &irSoundBits);
    ERRCHECK(result);
    unsigned int irSoundLength;
    result = irSound->getLength(&irSoundLength, FMOD_TIMEUNIT_PCM);
    ERRCHECK(result);

    
    if (irSoundFormat != FMOD_SOUND_FORMAT_PCM16)
    {
        /*
            For simplicity of the example, if the impulse response is the wrong format just display an error
        */        
        Common_Fatal("Impulse Response file is the wrong audio format");
    }

    /*
        The reverb unit expects a block of data containing a single 16 bit int containing
        the number of channels in the impulse response, followed by PCM 16 data
    */
    unsigned int irDataLength = sizeof(short) * (irSoundLength * irSoundChannels + 1);
    short* irData = (short*)malloc(irDataLength);
    irData[0] = irSoundChannels;
    unsigned int irDataRead;
    result = irSound->readData(&irData[1], irDataLength - sizeof(short), &irDataRead);
    ERRCHECK(result);
    result = reverbUnit->setParameterData(FMOD_DSP_CONVOLUTION_REVERB_PARAM_IR, irData, irDataLength);
    ERRCHECK(result);

    /*
        Don't pass any dry signal from the reverb unit, instead take the dry part
        of the mix from the main signal path
    */
    result = reverbUnit->setParameterFloat(FMOD_DSP_CONVOLUTION_REVERB_PARAM_DRY, -80.0f);    
    ERRCHECK(result);

    /*
//.........这里部分代码省略.........
开发者ID:Athlos,项目名称:Circuit-Collector,代码行数:101,代码来源:convolution_reverb.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::getFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。