MixHelpers.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. class ValueBuffer;
  28. namespace MixHelpers
  29. {
  30. bool isSilent( const sampleFrame* src, int frames );
  31. bool useNaNHandler();
  32. void setNaNHandler( bool use );
  33. bool sanitize( sampleFrame * src, int frames );
  34. /*! \brief Add samples from src to dst */
  35. void add( sampleFrame* dst, const sampleFrame* src, int frames );
  36. /*! \brief Add samples from src multiplied by coeffSrc to dst */
  37. void addMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
  38. /*! \brief Add samples from src multiplied by coeffSrc to dst, swap inputs */
  39. void addSwappedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
  40. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */
  41. void addMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames );
  42. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst */
  43. void addMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames );
  44. /*! \brief Same as addMultiplied, but sanitize output (strip out infs/nans) */
  45. void addSanitizedMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffSrc, int frames );
  46. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst - sanitized version */
  47. void addSanitizedMultipliedByBuffer( sampleFrame* dst, const sampleFrame* src, float coeffSrc, ValueBuffer * coeffSrcBuf, int frames );
  48. /*! \brief Add samples from src multiplied by coeffSrc and coeffSrcBuf to dst - sanitized version */
  49. void addSanitizedMultipliedByBuffers( sampleFrame* dst, const sampleFrame* src, ValueBuffer * coeffSrcBuf1, ValueBuffer * coeffSrcBuf2, int frames );
  50. /*! \brief Add samples from src multiplied by coeffSrcLeft/coeffSrcRight to dst */
  51. void addMultipliedStereo( sampleFrame* dst, const sampleFrame* src, float coeffSrcLeft, float coeffSrcRight, int frames );
  52. /*! \brief Multiply dst by coeffDst and add samples from src multiplied by coeffSrc */
  53. void multiplyAndAddMultiplied( sampleFrame* dst, const sampleFrame* src, float coeffDst, float coeffSrc, int frames );
  54. /*! \brief Multiply dst by coeffDst and add samples from srcLeft/srcRight multiplied by coeffSrc */
  55. void multiplyAndAddMultipliedJoined( sampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, float coeffDst, float coeffSrc, int frames );
  56. }
  57. #endif