sfizz/vst/SfizzVstState.cpp

78 lines
1.6 KiB
C++
Raw Normal View History

2020-03-05 11:16:47 +01:00
// SPDX-License-Identifier: BSD-2-Clause
// This code is part of the sfizz library and is licensed under a BSD 2-clause
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
#include "SfizzVstState.h"
#include <mutex>
#include <cstring>
tresult SfizzVstState::load(IBStream* state)
{
IBStreamer s(state, kLittleEndian);
uint64 version = 0;
if (!s.readInt64u(version))
return kResultFalse;
2020-03-05 18:21:46 +01:00
if (const char* str = s.readStr8())
sfzFile = str;
else
return kResultFalse;
if (!s.readFloat(volume))
return kResultFalse;
2020-03-05 11:16:47 +01:00
2020-03-06 11:46:49 +01:00
if (!s.readInt32(numVoices))
return kResultFalse;
2020-03-05 11:16:47 +01:00
return kResultTrue;
}
tresult SfizzVstState::store(IBStream* state) const
{
IBStreamer s(state, kLittleEndian);
if (!s.writeInt64u(currentStateVersion))
return kResultFalse;
2020-03-05 18:21:46 +01:00
if (!s.writeStr8(sfzFile.c_str()))
return kResultFalse;
if (!s.writeFloat(volume))
return kResultFalse;
2020-03-06 11:46:49 +01:00
if (!s.writeInt32(numVoices))
return kResultFalse;
2020-03-05 18:21:46 +01:00
return kResultTrue;
}
tresult SfizzUiState::load(IBStream* state)
{
IBStreamer s(state, kLittleEndian);
uint64 version = 0;
if (!s.readInt64u(version))
return kResultFalse;
if (!s.readInt32u(activePanel))
return kResultFalse;
return kResultTrue;
}
tresult SfizzUiState::store(IBStream* state) const
{
IBStreamer s(state, kLittleEndian);
if (!s.writeInt64u(currentStateVersion))
return kResultFalse;
if (!s.writeInt32u(activePanel))
2020-03-05 11:16:47 +01:00
return kResultFalse;
return kResultTrue;
}