modsmp_ctrl.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * modsmp_ctrl.h
  3. * -------------
  4. * Purpose: Basic sample editing code
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include "Snd_defs.h"
  12. OPENMPT_NAMESPACE_BEGIN
  13. class CSoundFile;
  14. struct ModSample;
  15. struct ModChannel;
  16. namespace ctrlSmp
  17. {
  18. // Replaces sample in 'smp' with given sample and frees the old sample.
  19. void ReplaceSample(ModSample &smp, void *pNewSample, const SmpLength newLength, CSoundFile &sndFile);
  20. // Propagate loop point changes to player
  21. bool UpdateLoopPoints(const ModSample &smp, CSoundFile &sndFile);
  22. // Reverse sample data
  23. bool ReverseSample(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile);
  24. // Invert sample data (flip by 180 degrees)
  25. bool InvertSample(ModSample &smp, SmpLength start, SmpLength end, CSoundFile &sndFile);
  26. // Crossfade sample data to create smooth loops
  27. bool XFadeSample(ModSample &smp, SmpLength fadeLength, int fadeLaw, bool afterloopFade, bool useSustainLoop, CSoundFile &sndFile);
  28. enum StereoToMonoMode
  29. {
  30. mixChannels,
  31. onlyLeft,
  32. onlyRight,
  33. splitSample,
  34. };
  35. // Convert a sample with any number of channels to mono
  36. bool ConvertToMono(ModSample &smp, CSoundFile &sndFile, StereoToMonoMode conversionMode);
  37. // Converts a stereo sample into two mono samples. Source sample will not be deleted.
  38. // Either of the two target samples may be identical to the source sample.
  39. bool SplitStereo(const ModSample &source, ModSample &left, ModSample &right, CSoundFile &sndFile);
  40. // Convert a mono sample to stereo
  41. bool ConvertToStereo(ModSample &smp, CSoundFile &sndFile);
  42. } // Namespace ctrlSmp
  43. namespace ctrlChn
  44. {
  45. // Replaces sample from sound channels by given sample.
  46. void ReplaceSample( CSoundFile &sndFile,
  47. const ModSample &sample,
  48. const void * const pNewSample,
  49. const SmpLength newLength,
  50. FlagSet<ChannelFlags> setFlags,
  51. FlagSet<ChannelFlags> resetFlags);
  52. } // namespace ctrlChn
  53. OPENMPT_NAMESPACE_END