AudioFileMP3.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * AudioFileMP3.h - Audio-device which encodes a wave stream into
  3. * an MP3 file. This is used for song export.
  4. *
  5. * Copyright (c) 2017 to present Michael Gregorius <michael.gregorius.git/at/arcor[dot]de>
  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_MP3_H
  26. #define AUDIO_FILE_MP3_H
  27. #include "lmmsconfig.h"
  28. #ifdef LMMS_HAVE_MP3LAME
  29. #include "AudioFileDevice.h"
  30. #include "lame/lame.h"
  31. class AudioFileMP3 : public AudioFileDevice
  32. {
  33. public:
  34. AudioFileMP3( OutputSettings const & outputSettings,
  35. const ch_cnt_t _channels,
  36. bool & successful,
  37. const QString & _file,
  38. Mixer* mixer );
  39. virtual ~AudioFileMP3();
  40. static AudioFileDevice * getInst( const QString & outputFilename,
  41. OutputSettings const & outputSettings,
  42. const ch_cnt_t channels,
  43. Mixer* mixer,
  44. bool & successful )
  45. {
  46. return new AudioFileMP3( outputSettings, channels, successful,
  47. outputFilename, mixer );
  48. }
  49. protected:
  50. virtual void writeBuffer( const surroundSampleFrame * /* _buf*/,
  51. const fpp_t /*_frames*/,
  52. const float /*_master_gain*/ );
  53. private:
  54. void flushRemainingBuffers();
  55. bool initEncoder();
  56. void tearDownEncoder();
  57. private:
  58. lame_t m_lame;
  59. };
  60. #endif
  61. #endif