#include "xsoundcurve.h"

XSoundCurve::XSoundCurve()
    : XAsset()
    , mFileName(nullptr)
    , mKnotCount(0)
    , mKnots(QVector<QVector<float>>())
{

}

XString *XSoundCurve::GetFileName()
{
    return mFileName;
}

void XSoundCurve::SetFileName(XString *aFileName)
{
    mFileName = aFileName;
}

float XSoundCurve::GetKnotEntry(int aRow, int aColumn)
{
    return mKnots[aRow][aColumn];
}

void XSoundCurve::SetKnotEntry(int aRow, int aColumn, float aValue)
{
    mKnots[aRow][aColumn] = aValue;
}

int XSoundCurve::GetKnotCount()
{
    return mKnotCount;
}

void XSoundCurve::Clear()
{
    if (mFileName != nullptr)
    {
        mFileName->Clear();
    }
    mKnotCount = 0;
    mKnots.clear();
}

void XSoundCurve::ParseData(QDataStream *aStream)
{
    if (mFileName != nullptr)
    {
        mFileName->ParsePtr(aStream, false);
    }

    *aStream
        >> mKnotCount;

    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            float knot;
            *aStream >> knot;

            mKnots[i][j] = knot;
        }
    }
}
