The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. #if JUCE_USE_CDREADER
  16. int AudioCDReader::getNumTracks() const
  17. {
  18. return trackStartSamples.size() - 1;
  19. }
  20. int AudioCDReader::getPositionOfTrackStart (int trackNum) const
  21. {
  22. return trackStartSamples [trackNum];
  23. }
  24. const Array<int>& AudioCDReader::getTrackOffsets() const
  25. {
  26. return trackStartSamples;
  27. }
  28. int AudioCDReader::getCDDBId()
  29. {
  30. int checksum = 0;
  31. const int numTracks = getNumTracks();
  32. for (int i = 0; i < numTracks; ++i)
  33. for (int offset = (trackStartSamples.getUnchecked(i) + 88200) / 44100; offset > 0; offset /= 10)
  34. checksum += offset % 10;
  35. const int length = (trackStartSamples.getLast() - trackStartSamples.getFirst()) / 44100;
  36. // CCLLLLTT: checksum, length, tracks
  37. return ((checksum & 0xff) << 24) | (length << 8) | numTracks;
  38. }
  39. #endif
  40. } // namespace juce