diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/tracklib/SampleEdit.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/tracklib/SampleEdit.h')
-rw-r--r-- | Src/external_dependencies/openmpt-trunk/tracklib/SampleEdit.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/tracklib/SampleEdit.h b/Src/external_dependencies/openmpt-trunk/tracklib/SampleEdit.h new file mode 100644 index 00000000..28c9c4c3 --- /dev/null +++ b/Src/external_dependencies/openmpt-trunk/tracklib/SampleEdit.h @@ -0,0 +1,92 @@ +/* + * SampleEdit.h + * ------------ + * Purpose: Basic sample editing code (resizing, adding silence, normalizing, ...). + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + + +#pragma once + +#include "openmpt/all/BuildSettings.hpp" + +#include "FadeLaws.h" +#include "../soundlib/Snd_defs.h" + +OPENMPT_NAMESPACE_BEGIN + +class CSoundFile; +struct ModSample; +struct ModChannel; + +namespace SampleEdit +{ + +enum ResetFlag +{ + SmpResetCompo, + SmpResetInit, + SmpResetVibrato, +}; + +// Get a reference to all cue and loop points of the sample +std::vector<std::reference_wrapper<SmpLength>> GetCuesAndLoops(ModSample &smp); + + +// Insert silence to given location. +// Note: Is currently implemented only for inserting silence to the beginning and to the end of the sample. +// Return: Length of the new sample. +SmpLength InsertSilence(ModSample &smp, const SmpLength silenceLength, const SmpLength startFrom, CSoundFile &sndFile); + +// Remove part of a sample [selStart, selEnd[. +// Note: Removed memory is not freed. +// Return: Length of the new sample. +SmpLength RemoveRange(ModSample &smp, SmpLength selStart, SmpLength selEnd, CSoundFile &sndFile); + +// Change sample size. +// Note: If resized sample is bigger, silence will be added to the sample's tail. +// Return: Length of the new sample. +SmpLength ResizeSample(ModSample &smp, const SmpLength newLength, CSoundFile &sndFile); + +// Resets samples. +void ResetSamples(CSoundFile &sndFile, ResetFlag resetflag, SAMPLEINDEX minSample = SAMPLEINDEX_INVALID, SAMPLEINDEX maxSample = SAMPLEINDEX_INVALID); + +// Remove DC offset and normalize. +// Return: If DC offset was removed, returns original offset value, zero otherwise. +double RemoveDCOffset(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile); + +// Amplify / fade sample data +bool AmplifySample(ModSample &smp, SmpLength start, SmpLength end, double amplifyStart, double amplifyEnd, bool isFadeIn, Fade::Law fadeLaw, CSoundFile &sndFile); + +// Reverse sample data +bool ReverseSample(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile); + +// Virtually unsign sample data +bool UnsignSample(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile); + +// Invert sample data (flip by 180 degrees) +bool InvertSample(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile); + +// Crossfade sample data to create smooth loops +bool XFadeSample(ModSample &smp, SmpLength fadeLength, int fadeLaw, bool afterloopFade, bool useSustainLoop, CSoundFile &sndFile); + +// Silence parts of the sample data +bool SilenceSample(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile); + +// Modify stereo separation of the sample data. separation is in range [-200, 200] +bool StereoSepSample(ModSample &smp, SmpLength start, SmpLength end, double separation, CSoundFile &sndFile); + +// Convert 16-bit sample to 8-bit +bool ConvertTo8Bit(ModSample &smp, CSoundFile &sndFile); + +// Convert 8-bit sample to 16-bit +bool ConvertTo16Bit(ModSample &smp, CSoundFile &sndFile); + +// Convert ping-pong loops to regular loops +bool ConvertPingPongLoop(ModSample &smp, CSoundFile &sndFile, bool sustainLoop); + +} // namespace SampleEdit + +OPENMPT_NAMESPACE_END |