-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
padreEnvelopeProcessor: fixes/tweaks
take LFO generator: - allow for generating more envelope points (use envUtil::GetEnvelopeStateChunkBig() instead of PadreGetEnvelopeState()) #1158 (partly) padreUtils: - remove GetEnvelopeState() +add files: envelope.hpp/.cpp (place for general envelope utility functions), #include in stdafx.h, update CMakeLists.txt +Snapshots: - TrackSends: use envUtil::GetEnvelopeStateChunkBig() (instead of GetEnvelopeStateChunk())
- Loading branch information
1 parent
629a566
commit 05e6486
Showing
10 changed files
with
196 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/****************************************************************************** | ||
/ envelope.cpp | ||
/ | ||
/ Copyright (c) 2019 | ||
/ | ||
/ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
/ of this software and associated documentation files (the "Software"), to deal | ||
/ in the Software without restriction, including without limitation the rights to | ||
/ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
/ of the Software, and to permit persons to whom the Software is furnished to | ||
/ do so, subject to the following conditions: | ||
/ | ||
/ The above copyright notice and this permission notice shall be included in all | ||
/ copies or substantial portions of the Software. | ||
/ | ||
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
/ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
/ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
/ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
/ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
/ OTHER DEALINGS IN THE SOFTWARE. | ||
/ | ||
******************************************************************************/ | ||
|
||
#include "stdafx.h" | ||
#include "envelope.hpp" | ||
|
||
namespace envUtil | ||
{ | ||
// wraps GetEnvelopeStateChunk() to make it more save | ||
// until maybe it gets enhanced one day | ||
// https://forum.cockos.com/showthread.php?p=2142245#post2142245 | ||
// throws envUtil::bad_get_env_chunk_big on failure | ||
std::string GetEnvelopeStateChunkBig(TrackEnvelope* envelope, bool isUndo /*= false*/) | ||
{ | ||
std::string buffer(1024, '\0'); | ||
|
||
while (true) { | ||
// can't use std::string::front (C++11) as we're targeting OSX 10.5 (as of September 2019) | ||
// though &operator[0] should be ok: | ||
// https://github.com/reaper-oss/sws/pull/1202#issuecomment-532476783 | ||
// if (!GetEnvelopeStateChunk(envelope, &buffer.front(), buffer.size() + 1, isUndo)) | ||
if (!GetEnvelopeStateChunk(envelope, &buffer[0], buffer.size() + 1, isUndo)) | ||
break; | ||
|
||
const size_t endpos = buffer.find('\0'); | ||
|
||
if (endpos != std::string::npos) { | ||
buffer.resize(endpos); | ||
return buffer; | ||
} | ||
|
||
if (buffer.size() > 100 << 20) { // 100 MiB | ||
throw envUtil::bad_get_env_chunk_big("The envelope chunk size exceeded the 100 MiB limit."); | ||
break; | ||
} | ||
|
||
try { | ||
buffer.resize(buffer.size() * 2); | ||
} | ||
catch (const std::bad_alloc) { | ||
throw envUtil::bad_get_env_chunk_big("std::bad_alloc thrown"); | ||
} | ||
} | ||
|
||
return {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/****************************************************************************** | ||
/ envelope.hpp | ||
/ | ||
/ Copyright (c) 2019 | ||
/ | ||
/ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
/ of this software and associated documentation files (the "Software"), to deal | ||
/ in the Software without restriction, including without limitation the rights to | ||
/ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
/ of the Software, and to permit persons to whom the Software is furnished to | ||
/ do so, subject to the following conditions: | ||
/ | ||
/ The above copyright notice and this permission notice shall be included in all | ||
/ copies or substantial portions of the Software. | ||
/ | ||
/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
/ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
/ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
/ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
/ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
/ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
/ OTHER DEALINGS IN THE SOFTWARE. | ||
/ | ||
******************************************************************************/ | ||
|
||
#pragma once | ||
#include <stdexcept> | ||
|
||
namespace envUtil | ||
{ | ||
std::string GetEnvelopeStateChunkBig(TrackEnvelope* envelope, bool isUndo = false); | ||
|
||
class bad_get_env_chunk_big : public std::runtime_error { | ||
public: | ||
using runtime_error::runtime_error; | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters