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.

156 lines
5.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the dRowAudio JUCE module
  4. Copyright 2004-13 by dRowAudio.
  5. ------------------------------------------------------------------------------
  6. dRowAudio is provided under the terms of The MIT License (MIT):
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in all
  14. copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. SOFTWARE.
  22. ==============================================================================
  23. */
  24. #ifndef __DROWAUDIO_AUDIOFILEPLAYEREXT_H__
  25. #define __DROWAUDIO_AUDIOFILEPLAYEREXT_H__
  26. #if DROWAUDIO_USE_SOUNDTOUCH
  27. #include "dRowAudio_SoundTouchAudioSource.h"
  28. #include "dRowAudio_ReversibleAudioSource.h"
  29. #include "dRowAudio_LoopingAudioSource.h"
  30. #include "dRowAudio_FilteringAudioSource.h"
  31. //==============================================================================
  32. /**
  33. This class can be used to load and play an audio file from disk.
  34. This combines the functionality of an AudioTransportSource,
  35. AudioFormatReader and AudioFormatReaderSource.
  36. @see AudioTransportSource
  37. @see AudioFormatReader
  38. @see AudioFormatReaderSource
  39. */
  40. class AudioFilePlayerExt : public AudioFilePlayer
  41. {
  42. public:
  43. //==============================================================================
  44. enum PlayerSettingCode
  45. {
  46. SoundTouchSetting = 0x0001,
  47. LoopBeetweenTimesSetting = 0x0002,
  48. PlayDirectionSetting = 0x0003,
  49. FilterGainSetting = 0x0004
  50. };
  51. //==============================================================================
  52. /** Creates an empty AudioFilePlayerExt.
  53. */
  54. AudioFilePlayerExt();
  55. /** Destructor.
  56. */
  57. ~AudioFilePlayerExt();
  58. //==============================================================================
  59. /** Sets the current library entry.
  60. */
  61. void setLibraryEntry (ValueTree newEntry) { libraryEntry = newEntry; }
  62. /** Returns the currents library entry.
  63. */
  64. ValueTree getLibraryEntry() { return libraryEntry; }
  65. //==============================================================================
  66. /** Sets SoundTouchProcessor settings.
  67. */
  68. void setPlaybackSettings (SoundTouchProcessor::PlaybackSettings newSettings);
  69. /** Returns the current SoundTouchProcessor settings.
  70. */
  71. SoundTouchProcessor::PlaybackSettings getPlaybackSettings();
  72. /** Sets whether the source should play forwards or backwards.
  73. */
  74. void setPlayDirection (bool shouldPlayForwards);
  75. /** Returns true if the source is playing forwards.
  76. */
  77. bool getPlayDirection();
  78. /** Sets the gain of one of the FilteringAudioSource filters.
  79. */
  80. void setFilterGain (FilteringAudioSource::FilterType type, float newGain);
  81. //==============================================================================
  82. /** Sets the start and end times of the loop.
  83. This doesn't actually activate the loop, use setLoopBetweenTimes() to toggle this.
  84. */
  85. void setLoopTimes (double startTime, double endTime);
  86. /** Enables the loop point set.
  87. */
  88. void setLoopBetweenTimes (bool shouldLoop);
  89. /** Returns true if the loop is activated.
  90. */
  91. bool getLoopBetweenTimes();
  92. /** Sets the next play position in seconds disregarding the loop boundries.
  93. */
  94. void setPosition (double newPosition, bool ignoreAnyLoopBounds = false);
  95. //==============================================================================
  96. /** Returns the SoundTouchAudioSource being used.
  97. */
  98. inline SoundTouchAudioSource* getSoundTouchAudioSource() { return soundTouchAudioSource; }
  99. /** Returns the FilteringAudioSource being used.
  100. */
  101. inline FilteringAudioSource* getFilteringAudioSource() { return filteringAudioSource; }
  102. private:
  103. //==============================================================================
  104. ScopedPointer<BufferingAudioSource> bufferingAudioSource;
  105. ScopedPointer<LoopingAudioSource> loopingAudioSource;
  106. ScopedPointer<SoundTouchAudioSource> soundTouchAudioSource;
  107. ScopedPointer<ReversibleAudioSource> reversibleAudioSource;
  108. ScopedPointer<FilteringAudioSource> filteringAudioSource;
  109. SoundTouchProcessor::PlaybackSettings currentSoundtouchSettings;
  110. bool shouldBeLooping;
  111. double currentLoopStartTime, currentLoopEndTime;
  112. ValueTree libraryEntry;
  113. //==============================================================================
  114. bool setSourceWithReader (AudioFormatReader* reader);
  115. void updateLoopTimes();
  116. //==============================================================================
  117. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioFilePlayerExt);
  118. };
  119. #endif
  120. #endif // __DROWAUDIO_AUDIOFILEPLAYEREXT_H__