AudioFileDevice.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * AudioFileDevice.h - base-class for audio-device-classes which write
  3. * their output into a file
  4. *
  5. * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef AUDIO_FILE_DEVICE_H
  26. #define AUDIO_FILE_DEVICE_H
  27. #include <QtCore/QFile>
  28. #include "AudioDevice.h"
  29. #include "OutputSettings.h"
  30. class AudioFileDevice : public AudioDevice
  31. {
  32. public:
  33. AudioFileDevice(OutputSettings const & outputSettings,
  34. const ch_cnt_t _channels, const QString & _file,
  35. AudioEngine* audioEngine );
  36. virtual ~AudioFileDevice();
  37. QString outputFile() const
  38. {
  39. return m_outputFile.fileName();
  40. }
  41. OutputSettings const & getOutputSettings() const { return m_outputSettings; }
  42. protected:
  43. int writeData( const void* data, int len );
  44. inline bool outputFileOpened() const
  45. {
  46. return m_outputFile.isOpen();
  47. }
  48. inline int outputFileHandle() const
  49. {
  50. return m_outputFile.handle();
  51. }
  52. private:
  53. QFile m_outputFile;
  54. OutputSettings m_outputSettings;
  55. } ;
  56. typedef AudioFileDevice * ( * AudioFileDeviceInstantiaton )
  57. ( const QString & outputFilename,
  58. OutputSettings const & outputSettings,
  59. const ch_cnt_t channels,
  60. AudioEngine* audioEngine,
  61. bool & successful );
  62. #endif