-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement #2000 ("Add mp3 encoding and/or decoding support") #3615
Changes from all commits
2c091aa
ed011e7
969ade2
a28a7cf
0e94912
4dd25fb
12578d5
0cc4406
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# - Try to find LAME | ||
# Once done this will define | ||
# | ||
# LAME_FOUND - system has liblame | ||
# LAME_INCLUDE_DIRS - the liblame include directory | ||
# LAME_LIBRARIES - The liblame libraries | ||
|
||
find_path(LAME_INCLUDE_DIRS lame/lame.h) | ||
find_library(LAME_LIBRARIES mp3lame) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Lame DEFAULT_MSG LAME_INCLUDE_DIRS LAME_LIBRARIES) | ||
|
||
list(APPEND LAME_DEFINITIONS -DHAVE_LIBMP3LAME=1) | ||
|
||
mark_as_advanced(LAME_INCLUDE_DIRS LAME_LIBRARIES LAME_DEFINITIONS) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* AudioFileMP3.h - Audio-device which encodes a wave stream into | ||
* an MP3 file. This is used for song export. | ||
* | ||
* Copyright (c) 2017 to present Michael Gregorius <michael.gregorius.git/at/arcor[dot]de> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#ifndef AUDIO_FILE_MP3_H | ||
#define AUDIO_FILE_MP3_H | ||
|
||
#include "lmmsconfig.h" | ||
|
||
#ifdef LMMS_HAVE_MP3LAME | ||
|
||
#include "AudioFileDevice.h" | ||
|
||
#include "lame/lame.h" | ||
|
||
|
||
class AudioFileMP3 : public AudioFileDevice | ||
{ | ||
public: | ||
AudioFileMP3( OutputSettings const & outputSettings, | ||
const ch_cnt_t _channels, | ||
bool & successful, | ||
const QString & _file, | ||
Mixer* mixer ); | ||
virtual ~AudioFileMP3(); | ||
|
||
static AudioFileDevice * getInst( const QString & outputFilename, | ||
OutputSettings const & outputSettings, | ||
const ch_cnt_t channels, | ||
Mixer* mixer, | ||
bool & successful ) | ||
{ | ||
return new AudioFileMP3( outputSettings, channels, successful, | ||
outputFilename, mixer ); | ||
} | ||
|
||
protected: | ||
virtual void writeBuffer( const surroundSampleFrame * /* _buf*/, | ||
const fpp_t /*_frames*/, | ||
const float /*_master_gain*/ ); | ||
|
||
private: | ||
void flushRemainingBuffers(); | ||
bool initEncoder(); | ||
void tearDownEncoder(); | ||
|
||
private: | ||
lame_t m_lame; | ||
}; | ||
|
||
#endif | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1316,7 +1316,8 @@ void Song::exportProject( bool multiExport ) | |
efd.setFileMode( FileDialog::AnyFile ); | ||
int idx = 0; | ||
QStringList types; | ||
while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats ) | ||
while( ProjectRenderer::fileEncodeDevices[idx].m_fileFormat != ProjectRenderer::NumFileFormats && | ||
ProjectRenderer::fileEncodeDevices[idx].isAvailable()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelgregorius This logic malfunctions if LMMS is built with WAV + MP3 support (no OGG). I found it while testing #3714. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PhysSong Good catch! For now I have asked @irrenhaus3 whether (s)he can fix it as part of #3713. |
||
{ | ||
types << tr( ProjectRenderer::fileEncodeDevices[idx].m_description ); | ||
++idx; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the way CMake works on all of these libraries, if can't find lame, the
LAME_LIBRARIES
variable will be a value ofLAME_LIBRARIES-NOTFOUND
which will abort the build. This is a problem with our build scripts and not necessarily a problem with this PR, but once merged, people without the proper lame libraries will get build errors, hence this comment about the "trick" mentioned here. #3615 (comment)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So something like this, @tresf?
On the other hand wouldn't it be cleaner to have a structure like the following in
src/CMakeLists.txt
?