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


C++ SoundData类代码示例

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


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

示例1: draw

void CWaveFormDrawer::draw(void *data,CRect r, CDC *pDC, int begin, int end)
{
	SoundData<short> *ptr = (SoundData<short> *)data;
	if(end < 0)
		end = ptr->getSamples();
	int numSamples = end - begin;
	CSize s;
	s.cx = r.Width();
	s.cy = r.Height();
	pDC->SetBkColor(RGB(0,0,0));
	pDC->SetBkMode(OPAQUE);
	if((int)ptr->getStereoMode() == 1)
	{
		drawMonoAxis(pDC,pDC->GetWindowExt());
		drawMonoWaveForm(data,pDC,s,begin,end);
	}
	else if((int)ptr->getStereoMode() == 2)
	{
		drawStereoAxis(pDC,pDC->GetWindowExt());
		drawStereoWaveForm(data,pDC,s,begin,end);
	}

//	SampleData<short> *pdat = data;

	
}
开发者ID:kobayosi,项目名称:WaveAnalyzer,代码行数:26,代码来源:WaveFormDrawer.cpp

示例2: w_SoundData_getSample

int w_SoundData_getSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int)lua_tointeger(L, 2);
	lua_pushnumber(L, sd->getSample(i));
	return 1;
}
开发者ID:joedrago,项目名称:love,代码行数:7,代码来源:wrap_SoundData.cpp

示例3: w_SoundData_setSample

int w_SoundData_setSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int) luaL_checkinteger(L, 2);
	float sample = (float) luaL_checknumber(L, 3);

	EXCEPT_GUARD(sd->setSample(i, sample);)
	return 0;
开发者ID:Ghor,项目名称:LoveEngineCore,代码行数:8,代码来源:wrap_SoundData.cpp

示例4: SoundData

	bool SE::load(uint uID, int max_moment)
	{
		bool bResult = true;

		SoundData * soundd = new SoundData();
		bResult = soundd->load(uID);
		if (bResult == false) return false;

		bResult = set_sound_data(*soundd, max_moment);

		ownership = true;

		return bResult;
	}
开发者ID:yuni-net,项目名称:simplect3D,代码行数:14,代码来源:se.cpp

示例5: w_SoundData_setSample

int w_SoundData_setSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int)lua_tointeger(L, 2);
	float sample = (float)lua_tonumber(L, 3);
	sd->setSample(i, sample);
	return 0;
}
开发者ID:joedrago,项目名称:love,代码行数:8,代码来源:wrap_SoundData.cpp

示例6: w_SoundData_clone

int w_SoundData_clone(lua_State *L)
{
	SoundData *t = luax_checksounddata(L, 1), *c = nullptr;
	luax_catchexcept(L, [&](){ c = t->clone(); });
	luax_pushtype(L, c);
	c->release();
	return 1;
}
开发者ID:MikuAuahDark,项目名称:livesim4,代码行数:8,代码来源:wrap_SoundData.cpp

示例7: assert

void Emitter::SetSoundData(sound::ISoundData* data)  {
	//FIXME error occurs in this function!
	SoundData* SFMLData = static_cast<SoundData*>(data);
	assert(pSFMLSoundSource == 0);
	delete pSFMLSoundSource; //FIXME error occurs at this deletion (virtual destructor used)
	pSFMLSoundSource = SFMLData->GetSFMLSoundData()->CreateSFMLSoundSource();

	soundData.Reset(SFMLData);
}
开发者ID:swordlegend,项目名称:ExcessiveTeam,代码行数:9,代码来源:Emitter.cpp

示例8: findChunk

/**
 * Play sound repeatedly.
 * @param name sound name
 * @return the channel the sample is played on. On any errors, -1 is returned.
 */
int SDLSound::playSoundRepeatedly(const char* name)
{
    int channel = -1;
    SoundData *sdata = findChunk(name);
    if (sdata) {
        if ((channel = Mix_PlayChannel(-1, sdata->getData(), -1)) == -1) {
            LOG (("Couldn't play sound '%s': %s", name, Mix_GetError()));
        }
    }

    return channel;
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:17,代码来源:SDLSound.cpp

示例9: w_SoundData_getSample

int w_SoundData_getSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int) luaL_checkinteger(L, 2);

	if (lua_gettop(L) > 2)
	{
		int channel = luaL_checkinteger(L, 3);
		luax_catchexcept(L, [&](){ lua_pushnumber(L, sd->getSample(i, channel)); });
	}
	else
		luax_catchexcept(L, [&](){ lua_pushnumber(L, sd->getSample(i)); });
	return 1;
}
开发者ID:MikuAuahDark,项目名称:livesim4,代码行数:14,代码来源:wrap_SoundData.cpp

示例10: Stop

	ErrorType SoundSource::Load(const String &fileName,
		SoundCollection *collection)
	{
		Stop();
		Bind(collection, collection->GetIDByName(fileName));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, load the sound data
		SoundData soundData;
		ErrorType error = soundData.Load(fileName);
		if (error)
			return Error::Throw(error, String("[%s(\"%s\")]",
				FastFunctionName, fileName.GetCString()));
		return LoadResource(fileName, soundData, collection);
	}
开发者ID:JSandrew4,项目名称:FastGdk,代码行数:15,代码来源:SoundSource.cpp

示例11: w_SoundData_setSample

int w_SoundData_setSample(lua_State *L)
{
	SoundData *sd = luax_checksounddata(L, 1);
	int i = (int) luaL_checkinteger(L, 2);

	if (lua_gettop(L) > 3)
	{
		int channel = luaL_checkinteger(L, 3);
		float sample = (float) luaL_checknumber(L, 4);
		luax_catchexcept(L, [&](){ sd->setSample(i, channel, sample); });
	}
	else
	{
		float sample = (float) luaL_checknumber(L, 3);
		luax_catchexcept(L, [&](){ sd->setSample(i, sample); });
	}

	return 0;
}
开发者ID:MikuAuahDark,项目名称:livesim4,代码行数:19,代码来源:wrap_SoundData.cpp

示例12: Load

	ErrorType SoundSource::Load(const SoundData &soundData,
		SoundCollection *collection)
	{
		String name = soundData.GetName();
		Stop();
		Bind(collection, collection->GetIDByName(name));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, load the sound data
		return LoadResource(name, soundData, collection);
	}
开发者ID:JSandrew4,项目名称:FastGdk,代码行数:11,代码来源:SoundSource.cpp

示例13: addSound

void SoundManager::addSound(const char* fileName, SOUND_TYPE type, bool isLoop)
{
    if (_dicSounds.at(fileName)) return;
    
    SoundData* data = new SoundData;
    data->setSoundKey(fileName);
    data->setSoundType(type);
    data->setIsLoop(isLoop);
    
    _dicSounds.insert(fileName, data);
    
    if (type == BGM)
    {
        SimpleAudioEngine::getInstance()->preloadBackgroundMusic(fileName);
    }
    else if (type == EFFECT)
    {
        SimpleAudioEngine::getInstance()->preloadEffect(fileName);
    }
    
    
}
开发者ID:devYongJun,项目名称:Wizard,代码行数:22,代码来源:SoundManager.cpp

示例14: LoadResource

	ErrorType SoundSource::LoadResource(const String &name,
		const SoundData &soundData, SoundCollection *collection)
	{
		// Check for existing sound with matching checksum
		Checksum checksum(soundData.GetSamples().GetData(),
			soundData.GetSamples().GetElementCount());
		Bind(collection, collection->GetIDByChecksum(checksum));
		if (-1 < mID)
			return kErrorNone;
		// No sound was found, generate new buffer
		UInt openALID;
		alGenBuffers(1, &openALID);
		if (!openALID)
			return Error::Throw(kErrorOpenALGenBuffersFailure,
				String("[%s(\"%s\", %p)]", FastFunctionName,
				name.GetCString(), &soundData));
		SoundResource soundResource;
		soundResource.SetName(name);
		soundResource.SetChecksum(checksum);
		soundResource.GetProperties()->SetFormat(soundData.GetProperties().GetFormat());
		soundResource.GetProperties()->SetFrequency(soundData.GetProperties().GetFrequency());
		soundResource.GetProperties()->SetSampleCount(soundData.GetProperties().GetSampleCount());
		soundResource.SetOpenALBufferID(openALID);
		soundResource.SetActive(true);
		mID = collection->AddResource(soundResource, this);
		mCollection = collection;
		{
			alBufferData(GetResource().GetOpenALBufferID(),
				GetResource().GetProperties().GetFormat(),
				soundData.GetSamples().GetData(),
				soundData.GetSamples().GetElementCount(),
				GetResource().GetProperties().GetFrequency());
			ALint alErr = alGetError();
			switch (alErr)
			{
			case AL_OUT_OF_MEMORY:
				Unbind();
				return Error::Throw(kErrorOutOfMemory,
					String("[%s(\"%s\", %p)]", FastFunctionName,
					name.GetCString(), &soundData));
			case AL_INVALID_ENUM:
			case AL_INVALID_VALUE:
				Unbind();
				return Error::Throw(kErrorInvalidValue,
					String("[%s(\"%s\", %p)]", FastFunctionName,
					name.GetCString(), &soundData));
			}
		}
		return kErrorNone;
	}
开发者ID:JSandrew4,项目名称:FastGdk,代码行数:50,代码来源:SoundSource.cpp

示例15: SD_PlayDigitized

int SD_PlayDigitized(const SoundData &which,int leftpos,int rightpos,SoundChannel chan)
{
    if (!DigiMode)
        return 0;

    // If this sound has been played too recently, don't play it again.
    // (Fix for extremely loud sounds when one plays over itself too much.)
    uint32_t currentTick = SDL_GetTicks();
    if (currentTick - SoundInfo.GetLastPlayTick(which) < MIN_TICKS_BETWEEN_DIGI_REPEATS)
        return 0;

    SoundInfo.SetLastPlayTick(which, currentTick);

    int channel = chan;
    if(chan == SD_GENERIC)
    {
        channel = Mix_GroupAvailable(1);
        if(channel == -1) channel = Mix_GroupOldest(1);
        if(channel == -1)           // All sounds stopped in the meantime?
            channel = Mix_GroupAvailable(1);
    }
    SD_SetPosition(channel, leftpos,rightpos);

    DigiPlaying = true;

    Mix_Chunk *sample = reinterpret_cast<Mix_Chunk*> (which.GetData(SoundData::DIGITAL));
    if(sample == NULL)
        return 0;

    Mix_Volume(channel, static_cast<int> (ceil(128.0*MULTIPLY_VOLUME(SoundVolume))));
    if(Mix_PlayChannel(channel, sample, 0) == -1)
    {
        printf("Unable to play sound: %s\n", Mix_GetError());
        return 0;
    }

    // Return channel + 1 because zero is a valid channel.
    return channel + 1;
}
开发者ID:JohnnyonFlame,项目名称:ecwolf,代码行数:39,代码来源:id_sd.cpp


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