Buffer.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright 2025, Ableton AG, Berlin. All rights reserved.
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. * If you would like to incorporate Link into a proprietary software application,
  17. * please contact <link-devs@ableton.com>.
  18. */
  19. #pragma once
  20. #include <ableton/link/Beats.hpp>
  21. #include <ableton/link/Tempo.hpp>
  22. #include <ableton/link_audio/Id.hpp>
  23. #include <vector>
  24. namespace ableton
  25. {
  26. namespace link_audio
  27. {
  28. template <typename SampleFormat>
  29. struct Buffer
  30. {
  31. using SampleFormatType = SampleFormat;
  32. using Samples = std::vector<SampleFormat>;
  33. Buffer(uint32_t numSamples)
  34. : mSamples(numSamples)
  35. {
  36. }
  37. uint32_t mSampleRate;
  38. uint32_t mNumChannels;
  39. uint32_t mNumFrames;
  40. Samples mSamples;
  41. link::Beats mBeginBeats;
  42. link::Tempo mTempo;
  43. uint64_t mCount;
  44. Id mSessionId;
  45. };
  46. template <typename Buffer>
  47. struct BufferCallbackHandle
  48. {
  49. BufferCallbackHandle(const Buffer& buffer, typename Buffer::SampleFormatType* pSamples)
  50. : mBuffer(buffer)
  51. , mpSamples(pSamples)
  52. {
  53. }
  54. const Buffer& mBuffer;
  55. typename Buffer::SampleFormatType* mpSamples;
  56. };
  57. } // namespace link_audio
  58. } // namespace ableton