| 1712 | } |
| 1713 | |
| 1714 | bool VSTWrapper::FetchSettings(VSTSettings& vstSettings, bool doFetch) const |
| 1715 | { |
| 1716 | // Get the fallback ID-value parameters |
| 1717 | ForEachParameter |
| 1718 | ( |
| 1719 | [&](const ParameterInfo& pi) |
| 1720 | { |
| 1721 | if (doFetch) |
| 1722 | { |
| 1723 | float val = callGetParameter(pi.mID); |
| 1724 | vstSettings.mParamsMap[pi.mName] = val; |
| 1725 | } |
| 1726 | else |
| 1727 | { |
| 1728 | vstSettings.mParamsMap[pi.mName] = std::nullopt; |
| 1729 | } |
| 1730 | return true; |
| 1731 | } |
| 1732 | ); |
| 1733 | |
| 1734 | // These are here to be checked against for compatibility later |
| 1735 | vstSettings.mVersion = mAEffect->version; |
| 1736 | vstSettings.mUniqueID = mAEffect->uniqueID; |
| 1737 | vstSettings.mNumParams = mAEffect->numParams; |
| 1738 | |
| 1739 | // Get the chunk (if supported) |
| 1740 | vstSettings.mChunk.resize(0); |
| 1741 | |
| 1742 | if (mAEffect->flags & effFlagsProgramChunks) |
| 1743 | { |
| 1744 | void* chunk = nullptr; |
| 1745 | int clen = (int)constCallDispatcher(effGetChunk, 1, 0, &chunk, 0.0); |
| 1746 | if (clen > 0 && chunk) { |
| 1747 | vstSettings.mChunk.resize(clen); |
| 1748 | memcpy(vstSettings.mChunk.data(), chunk, clen); |
| 1749 | } |
| 1750 | |
| 1751 | if (!doFetch) |
| 1752 | { |
| 1753 | // Don't keep the contents, but keep a sufficiently allocated string, |
| 1754 | // with some extra space in case chunk length might vary |
| 1755 | auto size = vstSettings.mChunk.size(); |
| 1756 | vstSettings.mChunk.resize(0); |
| 1757 | vstSettings.mChunk.reserve(2 * size); |
| 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | return true; |
| 1762 | } |
| 1763 | |
| 1764 | bool VSTWrapper::StoreSettings(const VSTSettings& vstSettings) const |
| 1765 | { |
no test coverage detected