Example #1
0
bool SoundBuffer::SaveToFile(const std::string& filename) const
{
    // Create the sound file in write mode
    priv::SoundFile file;
    if (file.OpenWrite(filename, GetChannelsCount(), GetSampleRate()))
    {
        // Write the samples to the opened file
        file.Write(&mySamples[0], mySamples.size());

        return true;
    }
    else
    {
        return false;
    }
}
Example #2
0
////////////////////////////////////////////////////////////
/// Save the sound buffer to a file
////////////////////////////////////////////////////////////
bool SoundBuffer::SaveToFile(const std::string& Filename) const
{
    // Create the sound file in write mode
    std::auto_ptr<priv::SoundFile> File(priv::SoundFile::CreateWrite(Filename, GetChannelsCount(), GetSampleRate()));
    if (File.get())
    {
        // Write the samples to the opened file
        File->Write(&mySamples[0], mySamples.size());

        return true;
    }
    else
    {
        // Error...
        std::cerr << "Failed to save sound buffer to file \"" << Filename << "\"" << std::endl;

        return false;
    }
}
Example #3
0
////////////////////////////////////////////////////////////
/// Return the number of channels of a music (1 = mono, 2 = stereo)
////////////////////////////////////////////////////////////
unsigned int sfMusic_GetChannelsCount(sfMusic* Music)
{
    CSFML_CALL_RETURN(Music, GetChannelsCount(), 0);
}
	std::vector<std::shared_ptr<KeyFrameAnimation>> FBXConverter::LoadCurve(FbxAnimLayer* fbxAnimLayer, FbxNode* fbxNode, int32_t frameCount)
	{
		std::vector<std::shared_ptr<KeyFrameAnimation>> ret;
		auto boneName = fbxNode->GetName();
		auto transXCurve = fbxNode->LclTranslation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
		auto transYCurve = fbxNode->LclTranslation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
		auto transZCurve = fbxNode->LclTranslation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);

		auto rotXCurve = fbxNode->LclRotation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
		auto rotYCurve = fbxNode->LclRotation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
		auto rotZCurve = fbxNode->LclRotation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);

		auto rot = fbxNode->LclRotation.GetCurveNode(fbxAnimLayer);
		auto lclR = fbxNode->LclRotation.Get();
		auto defRotX = lclR[0];
		auto defRotY = lclR[1];
		auto defRotZ = lclR[2];
		if (rot != nullptr)
		{
			for (size_t i = 0; i < rot->GetChannelsCount(); i++)
			{
				auto name = rot->GetChannelName(i);
				if (name == "X")
				{
					defRotX = rot->GetChannelValue(name, defRotX);
				}
				if (name == "Y")
				{
					defRotY = rot->GetChannelValue(name, defRotY);
				}
				if (name == "Z")
				{
					defRotZ = rot->GetChannelValue(name, defRotZ);
				}
			}

		}

		auto sclXCurve = fbxNode->LclScaling.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
		auto sclYCurve = fbxNode->LclScaling.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
		auto sclZCurve = fbxNode->LclScaling.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);

		if (transXCurve != nullptr)
		{
			auto c = LoadCurve(transXCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::TX;
			ret.push_back(c);
		}

		if (transYCurve != nullptr)
		{
			auto c = LoadCurve(transYCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::TY;
			ret.push_back(c);
		}

		if (transZCurve != nullptr)
		{
			auto c = LoadCurve(transZCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::TZ;
			ret.push_back(c);
		}

		if (rotXCurve != nullptr)
		{
			auto c = LoadCurve(rotXCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::RX;
			ret.push_back(c);
		}

		if (rotYCurve != nullptr)
		{
			auto c = LoadCurve(rotYCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::RY;
			ret.push_back(c);
		}

		if (rotZCurve != nullptr)
		{
			auto c = LoadCurve(rotZCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::RZ;
			ret.push_back(c);
		}

		if (sclXCurve != nullptr)
		{
			auto c = LoadCurve(sclXCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::SX;
			ret.push_back(c);
		}

		if (sclYCurve != nullptr)
		{
			auto c = LoadCurve(sclYCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::SY;
			ret.push_back(c);
		}

		if (sclZCurve != nullptr)
		{
			auto c = LoadCurve(sclZCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::SZ;
			ret.push_back(c);
		}

		for (auto i = 0; i< fbxNode->GetChildCount(); i++)
		{
			auto kfas = LoadCurve(fbxAnimLayer, fbxNode->GetChild(i), frameCount);

			for (auto a : kfas)
			{
				ret.push_back(a);
			}
		}

		return ret;
	}