MixHelpers.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * MixHelpers.h - helper functions for mixing buffers
  3. *
  4. * Copyright (c) 2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef MIX_HELPERS_H
  25. #define MIX_HELPERS_H
  26. #include "lmms_basics.h"
  27. #include "lmms_export.h"
  28. class ValueBuffer;
  29. namespace MixHelpers
  30. {
  31. bool isSilent( const sampleFrame* src, int frames );
  32. bool useNaNHandler();
  33. LMMS_EXPORT void setNaNHandler( bool use );
  34. void clear(sampleFrame * src, int frames);
  35. #ifndef LMMS_DISABLE_SURROUND
  36. void clear(surroundSampleFrame * src, int frames);
  37. #endif
  38. bool sanitize( sampleFrame * src, int frames );
  39. /*! \brief Add samples from src to dst */
  40. void add( sampleFrame* dst, const sampleFrame* src, int frames );
  41. /*! \brief Add samples from src multiplied by coeffSrc to dst */
  42. void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
  43. /*! \brief Add samples from src multiplied by coeffSrc to dst, swap inputs */
  44. void addSwappedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
  45. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */
  46. void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames );
  47. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */
  48. void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames );
  49. /*! \brief Same as addMultiplied, but sanitize output (strip out infs/nans) */
  50. void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
  51. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst - sanitized version */
  52. void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames );
  53. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst - sanitized version */
  54. void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames );
  55. /*! \brief Add samples from src multiplied by coeffSrcLeft/coeffSrcRight to dst */
  56. void addMultipliedStereo( sampleFrame* dst, const sampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames );
  57. /*! \brief Multiply dst by coeffDst and add samples from src multiplied by coeffSrc */
  58. void multiplyAndAddMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffDst, float coeffSrc, int frames );
  59. /*! \brief Multiply dst by coeffDst and add samples from srcLeft/srcRight multiplied by coeffSrc */
  60. void multiplyAndAddMultipliedJoined( sampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, float coeffDst, float coeffSrc, int frames );
  61. }
  62. #endif