Merge branch 'stable-1.2'

# Conflicts:
#	cmake/modules/BuildPlugin.cmake
#	plugins/CMakeLists.txt
#	plugins/LadspaEffect/swh/CMakeLists.txt
#	plugins/LadspaEffect/tap/CMakeLists.txt
#	plugins/zynaddsubfx/zynaddsubfx
#	plugins/zynaddsubfx/zynaddsubfx/src/Misc/QtXmlWrapper.cpp
#	src/gui/MainWindow.cpp
This commit is contained in:
Lukas W
2018-07-06 12:42:15 +02:00
28 changed files with 216 additions and 115 deletions

View File

@@ -9,7 +9,7 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME)
CMAKE_PARSE_ARGUMENTS(PLUGIN "" "" "MOCFILES;EMBEDDED_RESOURCES;UICFILES;LINK" ${ARGN})
SET(PLUGIN_SOURCES ${PLUGIN_UNPARSED_ARGUMENTS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/include")
ADD_DEFINITIONS(-DPLUGIN_NAME=${PLUGIN_NAME})
@@ -22,7 +22,7 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME)
FILE(GLOB EXPANDED "${ARG}")
LIST(SORT EXPANDED)
FOREACH(ITEM ${EXPANDED})
LIST(APPEND NEW_ARGS ${ITEM})
LIST(APPEND NEW_ARGS "${ITEM}")
ENDFOREACH()
ENDFOREACH()
SET(PLUGIN_EMBEDDED_RESOURCES ${NEW_ARGS})
@@ -38,11 +38,11 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME)
ENDFOREACH(f)
IF(LMMS_BUILD_APPLE)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
LINK_DIRECTORIES("${CMAKE_BINARY_DIR}")
LINK_LIBRARIES(${QT_LIBRARIES})
ENDIF(LMMS_BUILD_APPLE)
IF(LMMS_BUILD_WIN32)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
LINK_DIRECTORIES("${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
LINK_LIBRARIES(${QT_LIBRARIES})
ENDIF(LMMS_BUILD_WIN32)
IF(LMMS_BUILD_MSYS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -65,12 +65,12 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME)
INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION "${PLUGIN_DIR}")
IF(LMMS_BUILD_APPLE)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader ${CMAKE_BINARY_DIR}/lmms")
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader \"${CMAKE_BINARY_DIR}/lmms\"")
ADD_DEPENDENCIES(${PLUGIN_NAME} lmms)
ENDIF(LMMS_BUILD_APPLE)
IF(LMMS_BUILD_WIN32 AND STRIP)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "")
ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} $<TARGET_FILE:${PLUGIN_NAME}>)
ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} "$<TARGET_FILE:${PLUGIN_NAME}>")
ENDIF()
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${RCC_OUT} ${plugin_MOC_out}")

View File

@@ -19,14 +19,16 @@ if(SNDIO_LIBRARY)
get_filename_component(SNDIO_LIBRARY_DIR ${SNDIO_LIBRARY} PATH)
endif(SNDIO_LIBRARY)
check_library_exists(sndio sio_open "${SNDIO_LIBRARY_DIR}" HAVE_SNDIO)
if(HAVE_SNDIO)
message(STATUS "Found sndio: ${SNDIO_LIBRARY}")
else(HAVE_SNDIO)
message(STATUS "sndio not found")
check_library_exists(sndio sio_open "${SNDIO_LIBRARY_DIR}" HAVE_SIO_OPEN)
find_path(SNDIO_INCLUDE_DIR sndio.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SNDIO DEFAULT_MSG SNDIO_LIBRARY SNDIO_INCLUDE_DIR HAVE_SIO_OPEN)
if(SNDIO_FOUND)
set(SNDIO_INCLUDE_DIRS "${SNDIO_INCLUDE_DIR}")
set(SNDIO_LIBRARIES "${SNDIO_LIBRARY}")
endif(HAVE_SNDIO)
set(SNDIO_FOUND ${HAVE_SNDIO})
find_path(SNDIO_INCLUDES sndio.h)
mark_as_advanced(SNDIO_INCLUDES SNDIO_LIBRARY)
mark_as_advanced(SNDIO_INCLUDE_DIR SNDIO_LIBRARY SNDIO_INCLUDE_DIRS SNDIO_LIBRARIES)

View File

@@ -3939,7 +3939,7 @@ Besök https://lmms.io/documentation/ för dokumentation (Engelska).</translatio
</message>
<message>
<source>&amp;View</source>
<translation>%Visa</translation>
<translation>&amp;Visa</translation>
</message>
<message>
<source>Toggle metronome</source>
@@ -9950,4 +9950,4 @@ The LED in the lower right corner of the waveform editor determines whether the
<translation>Utgångsförstärkning</translation>
</message>
</context>
</TS>
</TS>

View File

@@ -56,6 +56,10 @@ protected:
return m_outputFile.isOpen();
}
inline int outputFileHandle() const
{
return m_outputFile.handle();
}
private:
QFile m_outputFile;

View File

@@ -30,22 +30,24 @@
#include <stdint.h>
#include "lmms_basics.h"
class QString;
class DrumSynth {
public:
DrumSynth() {};
int GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels, sample_rate_t Fs);
int GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sample_rate_t Fs);
private:
float LoudestEnv(void);
int LongestEnv(void);
void UpdateEnv(int e, long t);
void GetEnv(int env, const char *sec, const char *key, const char *ini);
void GetEnv(int env, const char *sec, const char *key, QString ini);
float waveform(float ph, int form);
int GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, const char *file);
int GetPrivateProfileInt(const char *sec, const char *key, int def, const char *file);
float GetPrivateProfileFloat(const char *sec, const char *key, float def, const char *file);
int GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, QString file);
int GetPrivateProfileInt(const char *sec, const char *key, int def, QString file);
float GetPrivateProfileFloat(const char *sec, const char *key, float def, QString file);
};

View File

@@ -78,6 +78,11 @@ protected:
return m_file.read( _data, _len );
}
inline QByteArray readAllData()
{
return m_file.readAll();
}
inline void ungetChar( char _ch )
{
m_file.ungetChar( _ch );

72
include/IoHelper.h Normal file
View File

@@ -0,0 +1,72 @@
/*
* IoHelper.h - helper functions for file I/O
*
* Copyright (c) 2018 Hyunjin Song <tteu.ingog/at/gmail.com>
*
* 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.
*
*/
#include "lmmsconfig.h"
#include <cstdio>
#ifdef _WIN32
#include <windows.h>
std::wstring toWString(const std::string& s)
{
std::wstring ret;
int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(),
s.length(), nullptr, 0);
if (len == 0)
{
return ret;
}
ret.resize(len);
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s.length(), &ret[0], len);
return ret;
}
#endif
#ifdef LMMS_BUILD_WIN32
#include <io.h>
#define F_OPEN_UTF8(a, b) _wfopen(toWString(a).data(), L##b)
#else
#ifdef LMMS_HAVE_UNISTD_H
#include <unistd.h>
#endif
#define F_OPEN_UTF8(a, b) fopen((a).data(), b)
#endif
int fileToDescriptor(FILE* f, bool closeFile = true)
{
int fh;
if (f == NULL) {return -1;}
#ifdef LMMS_BUILD_WIN32
fh = _dup(_fileno(f));
#else
fh = dup(fileno(f));
#endif
if (closeFile) {fclose(f);}
return fh;
}

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017-2017 Tres Finocchiaro <tres.finocchiaro/at/gmail.com>
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -270,15 +270,15 @@ private:
void convertIntToFloat ( int_sample_t * & _ibuf, f_cnt_t _frames, int _channels);
void directFloatWrite ( sample_t * & _fbuf, f_cnt_t _frames, int _channels);
f_cnt_t decodeSampleSF( const char * _f, sample_t * & _buf,
f_cnt_t decodeSampleSF( QString _f, sample_t * & _buf,
ch_cnt_t & _channels,
sample_rate_t & _sample_rate );
#ifdef LMMS_HAVE_OGGVORBIS
f_cnt_t decodeSampleOGGVorbis( const char * _f, int_sample_t * & _buf,
f_cnt_t decodeSampleOGGVorbis( QString _f, int_sample_t * & _buf,
ch_cnt_t & _channels,
sample_rate_t & _sample_rate );
#endif
f_cnt_t decodeSampleDS( const char * _f, int_sample_t * & _buf,
f_cnt_t decodeSampleDS( QString _f, int_sample_t * & _buf,
ch_cnt_t & _channels,
sample_rate_t & _sample_rate );

View File

@@ -1,5 +1,5 @@
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_DEBUG_POSTFIX "")
# Enable C++11

View File

@@ -8,13 +8,6 @@ ELSE()
SET(PIC_FLAGS "-fPIC -DPIC")
ENDIF()
# Additional link flags
IF(LMMS_BUILD_WIN32 AND MINGW_PREFIX)
SET(LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined -Wl,-Bsymbolic -lm")
ELSEIF(LMMS_BUILD_APPLE)
SET(LINK_FLAGS "${LINK_FLAGS} -Bsymbolic -lm")
ENDIF()
# Additional compile flags
SET(COMPILE_FLAGS "${COMPILE_FLAGS} -O3 -Wall")
SET(COMPILE_FLAGS "${COMPILE_FLAGS} -fomit-frame-pointer -funroll-loops -ffast-math -c -fno-strict-aliasing")
@@ -44,6 +37,9 @@ FOREACH(_item ${XML_SOURCES})
IF(NOT ("${_plugin}" STREQUAL "vocoder_1337"))
TARGET_LINK_LIBRARIES("${_plugin}" -lfftw3f)
ENDIF()
IF(NOT MSVC)
TARGET_LINK_LIBRARIES("${_plugin}" m)
ENDIF()
SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")

View File

@@ -15,13 +15,8 @@ FOREACH(_item ${PLUGIN_SOURCES})
IF(LMMS_BUILD_WIN32 AND NOT CMAKE_BUILD_TYPE MATCHES "Deb")
ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" \"$<TARGET_FILE:${_plugin}>\")
ENDIF()
IF(LMMS_BUILD_APPLE)
SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES LINK_FLAGS "${LINK_FLAGS} -Bsymbolic -lm")
ELSEIF(NOT LMMS_BUILD_OPENBSD)
SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined -Wl,-Bsymbolic -lm")
ENDIF()
IF(LMMS_BUILD_LINUX OR LMMS_BUILD_HAIKU)
SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
IF(NOT MSVC)
TARGET_LINK_LIBRARIES("${_plugin}" m)
ENDIF()
ENDFOREACH()

View File

@@ -26,9 +26,12 @@
#include <QDomDocument>
#include <QDir>
#include <QApplication>
#include <QFile>
#include <QMessageBox>
#include <QProgressDialog>
#include <sstream>
#include "MidiImport.h"
#include "TrackContainer.h"
#include "InstrumentTrack.h"
@@ -279,8 +282,6 @@ public:
bool MidiImport::readSMF( TrackContainer* tc )
{
QString filename = file().fileName();
closeFile();
const int preTrackSteps = 2;
QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ),
@@ -291,7 +292,11 @@ bool MidiImport::readSMF( TrackContainer* tc )
pd.setValue( 0 );
Alg_seq_ptr seq = new Alg_seq(filename.toLocal8Bit(), true);
std::stringstream stream;
QByteArray arr = readAllData();
stream.str(std::string(arr.constData(), arr.size()));
Alg_seq_ptr seq = new Alg_seq(stream, true);
seq->convert_to_beats();
pd.setMaximum( seq->tracks() + preTrackSteps );

View File

@@ -1,7 +1,7 @@
/*
* ReverbSC.cpp - A native reverb based on an algorithm by Sean Costello
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017 Paul Batchelor
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017 Paul Batchelor
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017 Paul Batchelor
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017 Paul Batchelor
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017 Paul Batchelor
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -620,7 +620,7 @@ malletsSynth::malletsSynth( const StkFloat _pitch,
{
Stk::setSampleRate( _sample_rate );
Stk::setRawwavePath( QDir( ConfigManager::inst()->stkDir() ).absolutePath()
.toLatin1().constData() );
.toLocal8Bit().constData() );
#ifndef LMMS_DEBUG
Stk::showWarnings( false );
#endif
@@ -670,7 +670,7 @@ malletsSynth::malletsSynth( const StkFloat _pitch,
{
Stk::setSampleRate( _sample_rate );
Stk::setRawwavePath( QDir( ConfigManager::inst()->stkDir() ).absolutePath()
.toLatin1().constData() );
.toLocal8Bit().constData() );
#ifndef LMMS_DEBUG
Stk::showWarnings( false );
#endif
@@ -718,7 +718,7 @@ malletsSynth::malletsSynth( const StkFloat _pitch,
{
Stk::setSampleRate( _sample_rate );
Stk::setRawwavePath( QDir( ConfigManager::inst()->stkDir() ).absolutePath()
.toLatin1().constData() );
.toLocal8Bit().constData() );
#ifndef LMMS_DEBUG
Stk::showWarnings( false );
#endif

View File

@@ -88,6 +88,7 @@ struct ERect
#include "lmms_basics.h"
#include "Midi.h"
#include "communication.h"
#include "IoHelper.h"
#include "VstSyncData.h"
@@ -678,9 +679,9 @@ void RemoteVstPlugin::init( const std::string & _plugin_file )
static void close_check( int fd )
static void close_check( FILE* fp )
{
if( close( fd ) )
if( fclose( fp ) )
{
perror( "close" );
}
@@ -790,7 +791,7 @@ void RemoteVstPlugin::destroyEditor()
bool RemoteVstPlugin::load( const std::string & _plugin_file )
{
if( ( m_libInst = LoadLibrary( _plugin_file.c_str() ) ) == NULL )
if( ( m_libInst = LoadLibraryW( toWString(_plugin_file).c_str() ) ) == NULL )
{
// give VstPlugin class a chance to start 32 bit version of RemoteVstPlugin
if( GetLastError() == ERROR_BAD_EXE_FORMAT )
@@ -1072,13 +1073,13 @@ void RemoteVstPlugin::saveChunkToFile( const std::string & _file )
const int len = pluginDispatch( 23, 0, 0, &chunk );
if( len > 0 )
{
int fd = open( _file.c_str(), O_WRONLY | O_BINARY );
if ( ::write( fd, chunk, len ) != len )
FILE* fp = F_OPEN_UTF8( _file, "wb" );
if ( fwrite( chunk, len, 1, fp ) != len )
{
fprintf( stderr,
"Error saving chunk to file.\n" );
}
close_check( fd );
close_check( fp );
}
}
}
@@ -1237,7 +1238,7 @@ void RemoteVstPlugin::savePreset( const std::string & _file )
if (!isPreset &&!chunky) uIntToFile = (unsigned int) m_plugin->numPrograms;
pBank->numPrograms = endian_swap( uIntToFile );
FILE * stream = fopen( _file.c_str(), "w" );
FILE * stream = F_OPEN_UTF8( _file, "w" );
fwrite ( pBank, 1, 28, stream );
fwrite ( progName, 1, isPreset ? 28 : 128, stream );
if ( chunky ) {
@@ -1289,7 +1290,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file )
unsigned int * pLen = new unsigned int[ 1 ];
unsigned int len = 0;
sBank * pBank = (sBank*) new char[ sizeof( sBank ) ];
FILE * stream = fopen( _file.c_str(), "r" );
FILE * stream = F_OPEN_UTF8( _file, "r" );
if ( fread ( pBank, 1, 56, stream ) != 56 )
{
fprintf( stderr, "Error loading preset file.\n" );
@@ -1390,12 +1391,12 @@ void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len )
{
char * chunk = new char[_len];
const int fd = open( _file.c_str(), O_RDONLY | O_BINARY );
if ( ::read( fd, chunk, _len ) != _len )
FILE* fp = F_OPEN_UTF8( _file, "rb" );
if ( fread( chunk, 1, _len, fp ) != _len )
{
fprintf( stderr, "Error loading chunk from file.\n" );
}
close_check( fd );
close_check( fp );
pluginDispatch( effSetChunk, 0, _len, chunk );

View File

@@ -139,7 +139,7 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS}
${SDL2_LIBRARY}
${PORTAUDIO_LIBRARIES}
${SOUNDIO_LIBRARY}
${SNDIO_LIBRARY}
${SNDIO_LIBRARIES}
${PULSEAUDIO_LIBRARIES}
${JACK_LIBRARIES}
${OGGVORBIS_LIBRARIES}

View File

@@ -26,11 +26,13 @@
#include "DrumSynth.h"
#include <fstream>
#include <sstream>
#include <cstring>
#include <math.h> //sin(), exp(), etc.
#include <QFile>
#ifdef LMMS_BUILD_WIN32
#define powf pow
#endif
@@ -117,7 +119,7 @@ void DrumSynth::UpdateEnv(int e, long t)
}
void DrumSynth::GetEnv(int env, const char *sec, const char *key, const char *ini)
void DrumSynth::GetEnv(int env, const char *sec, const char *key, QString ini)
{
char en[256], s[8];
int i=0, o=0, ep=0;
@@ -167,9 +169,9 @@ float DrumSynth::waveform(float ph, int form)
}
int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, const char *file)
int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, QString file)
{
ifstream is;
stringstream is;
bool inSection = false;
char *line;
char *k, *b;
@@ -177,7 +179,12 @@ int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const c
line = (char*)malloc(200);
is.open (file, ifstream::in);
// Use QFile to handle unicode file name on Windows
// Previously we used ifstream directly
QFile f(file);
f.open(QIODevice::ReadOnly);
QByteArray dat = f.readAll().constData();
is.str(string(dat.constData(), dat.size()));
while (is.good()) {
if (!inSection) {
@@ -223,13 +230,12 @@ int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const c
strncpy(buffer, def, size);
}
is.close();
free(line);
return len;
}
int DrumSynth::GetPrivateProfileInt(const char *sec, const char *key, int def, const char *file)
int DrumSynth::GetPrivateProfileInt(const char *sec, const char *key, int def, QString file)
{
char tmp[16];
int i=0;
@@ -240,7 +246,7 @@ int DrumSynth::GetPrivateProfileInt(const char *sec, const char *key, int def, c
return i;
}
float DrumSynth::GetPrivateProfileFloat(const char *sec, const char *key, float def, const char *file)
float DrumSynth::GetPrivateProfileFloat(const char *sec, const char *key, float def, QString file)
{
char tmp[16];
float f=0.f;
@@ -257,7 +263,7 @@ float DrumSynth::GetPrivateProfileFloat(const char *sec, const char *key, float
// an associative array or something once we have a datastructure to load in to.
// llama
int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels, sample_rate_t Fs)
int DrumSynth::GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sample_rate_t Fs)
{
//input file
char sec[32];

View File

@@ -175,11 +175,6 @@ void SampleBuffer::update( bool _keep_settings )
else if( !m_audioFile.isEmpty() )
{
QString file = tryToMakeAbsolute( m_audioFile );
#ifdef LMMS_BUILD_WIN32
char * f = qstrdup( file.toLocal8Bit().constData() );
#else
char * f = qstrdup( file.toUtf8().constData() );
#endif
int_sample_t * buf = NULL;
sample_t * fbuf = NULL;
ch_cnt_t channels = DEFAULT_CHANNELS;
@@ -193,10 +188,13 @@ void SampleBuffer::update( bool _keep_settings )
}
else
{
// Use QFile to handle unicode file names on Windows
QFile f(file);
f.open(QIODevice::ReadOnly);
SNDFILE * snd_file;
SF_INFO sf_info;
sf_info.format = 0;
if( ( snd_file = sf_open( f, SFM_READ, &sf_info ) ) != NULL )
if( ( snd_file = sf_open_fd( f.handle(), SFM_READ, &sf_info, false ) ) != NULL )
{
f_cnt_t frames = sf_info.frames;
int rate = sf_info.samplerate;
@@ -206,6 +204,7 @@ void SampleBuffer::update( bool _keep_settings )
}
sf_close( snd_file );
}
f.close();
}
if( !fileLoadError )
@@ -216,28 +215,26 @@ void SampleBuffer::update( bool _keep_settings )
// decoder first if filename extension matches "ogg"
if( m_frames == 0 && fileInfo.suffix() == "ogg" )
{
m_frames = decodeSampleOGGVorbis( f, buf, channels, samplerate );
m_frames = decodeSampleOGGVorbis( file, buf, channels, samplerate );
}
#endif
if( m_frames == 0 )
{
m_frames = decodeSampleSF( f, fbuf, channels,
m_frames = decodeSampleSF( file, fbuf, channels,
samplerate );
}
#ifdef LMMS_HAVE_OGGVORBIS
if( m_frames == 0 )
{
m_frames = decodeSampleOGGVorbis( f, buf, channels,
m_frames = decodeSampleOGGVorbis( file, buf, channels,
samplerate );
}
#endif
if( m_frames == 0 )
{
m_frames = decodeSampleDS( f, buf, channels,
m_frames = decodeSampleDS( file, buf, channels,
samplerate );
}
delete[] f;
}
if ( m_frames == 0 || fileLoadError ) // if still no frames, bail
@@ -393,7 +390,7 @@ void SampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
f_cnt_t SampleBuffer::decodeSampleSF( const char * _f,
f_cnt_t SampleBuffer::decodeSampleSF(QString _f,
sample_t * & _buf,
ch_cnt_t & _channels,
sample_rate_t & _samplerate )
@@ -404,7 +401,11 @@ f_cnt_t SampleBuffer::decodeSampleSF( const char * _f,
f_cnt_t frames = 0;
bool sf_rr = false;
if( ( snd_file = sf_open( _f, SFM_READ, &sf_info ) ) != NULL )
// Use QFile to handle unicode file names on Windows
QFile f(_f);
f.open(QIODevice::ReadOnly);
if( ( snd_file = sf_open_fd( f.handle(), SFM_READ, &sf_info, false ) ) != NULL )
{
frames = sf_info.frames;
@@ -430,6 +431,8 @@ f_cnt_t SampleBuffer::decodeSampleSF( const char * _f,
"sample %s: %s", _f, sf_strerror( NULL ) );
#endif
}
f.close();
//write down either directly or convert i->f depending on file type
if ( frames > 0 && _buf != NULL )
@@ -495,7 +498,7 @@ long qfileTellCallback( void * _udata )
f_cnt_t SampleBuffer::decodeSampleOGGVorbis( const char * _f,
f_cnt_t SampleBuffer::decodeSampleOGGVorbis( QString _f,
int_sample_t * & _buf,
ch_cnt_t & _channels,
sample_rate_t & _samplerate )
@@ -591,7 +594,7 @@ f_cnt_t SampleBuffer::decodeSampleOGGVorbis( const char * _f,
f_cnt_t SampleBuffer::decodeSampleDS( const char * _f,
f_cnt_t SampleBuffer::decodeSampleDS( QString _f,
int_sample_t * & _buf,
ch_cnt_t & _channels,
sample_rate_t & _samplerate )

View File

@@ -27,6 +27,9 @@
#include "endian_handling.h"
#include "Mixer.h"
#include <QFile>
#include <QDebug>
AudioFileWave::AudioFileWave( OutputSettings const & outputSettings,
const ch_cnt_t channels, bool & successful,
@@ -72,13 +75,15 @@ bool AudioFileWave::startEncoding()
m_si.format |= SF_FORMAT_PCM_16;
break;
}
m_sf = sf_open(
#ifdef LMMS_BUILD_WIN32
outputFile().toLocal8Bit().constData(),
#else
outputFile().toUtf8().constData(),
#endif
SFM_WRITE, &m_si );
// Use file handle to handle unicode file name on Windows
m_sf = sf_open_fd( outputFileHandle(), SFM_WRITE, &m_si, false );
if (!m_sf)
{
qWarning("Error: AudioFileWave::startEncoding: %s", sf_strerror(nullptr));
return false;
}
// Prevent fold overs when encountering clipped data
sf_command(m_sf, SFC_SET_CLIPPING, NULL, SF_TRUE);

View File

@@ -248,9 +248,13 @@ void MidiWinMM::closeDevices()
m_outputSubs.clear();
QMapIterator<HMIDIIN, QString> i( m_inputDevices );
HMIDIIN hInDev;
while( i.hasNext() )
{
midiInClose( i.next().key() );
hInDev = i.next().key();
midiInReset( hInDev );
midiInClose( hInDev );
}
QMapIterator<HMIDIOUT, QString> o( m_outputDevices );

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 2017-2017 Tres Finocchiaro <tres.finocchiaro/at/gmail.com>
*
* This file is part of LMMS - http://lmms.io
* 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

View File

@@ -75,7 +75,7 @@ void disableAutoKeyAccelerators(QWidget* mainWindow)
{
using DisablerFunc = void(*)(QWidget*);
QLibrary kf5WidgetsAddon("KF5WidgetsAddons", 5);
DisablerFunc setNoAccelerators =
DisablerFunc setNoAccelerators =
reinterpret_cast<DisablerFunc>(kf5WidgetsAddon.resolve("_ZN19KAcceleratorManager10setNoAccelEP7QWidget"));
if(setNoAccelerators)
{
@@ -720,7 +720,7 @@ void MainWindow::clearKeyModifiers()
void MainWindow::saveWidgetState( QWidget * _w, QDomElement & _de )
{
// If our widget is the main content of a window (e.g. piano roll, FxMixer, etc),
// If our widget is the main content of a window (e.g. piano roll, FxMixer, etc),
// we really care about the position of the *window* - not the position of the widget within its window
if( _w->parentWidget() != NULL &&
_w->parentWidget()->inherits( "QMdiSubWindow" ) )
@@ -728,7 +728,7 @@ void MainWindow::saveWidgetState( QWidget * _w, QDomElement & _de )
_w = _w->parentWidget();
}
// If the widget is a SubWindow, then we can make use of the getTrueNormalGeometry() method that
// If the widget is a SubWindow, then we can make use of the getTrueNormalGeometry() method that
// performs the same as normalGeometry, but isn't broken on X11 ( see https://bugreports.qt.io/browse/QTBUG-256 )
SubWindow *asSubWindow = qobject_cast<SubWindow*>(_w);
QRect normalGeom = asSubWindow != nullptr ? asSubWindow->getTrueNormalGeometry() : _w->normalGeometry();
@@ -757,7 +757,7 @@ void MainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
qMax( _w->minimumHeight(), _de.attribute( "height" ).toInt() ) );
if( _de.hasAttribute( "visible" ) && !r.isNull() )
{
// If our widget is the main content of a window (e.g. piano roll, FxMixer, etc),
// If our widget is the main content of a window (e.g. piano roll, FxMixer, etc),
// we really care about the position of the *window* - not the position of the widget within its window
if ( _w->parentWidget() != NULL &&
_w->parentWidget()->inherits( "QMdiSubWindow" ) )
@@ -856,7 +856,7 @@ void MainWindow::updateRecentlyOpenedProjectsMenu()
for( QStringList::iterator it = rup.begin(); it != rup.end(); ++it )
{
QFileInfo recentFile( *it );
if ( recentFile.exists() &&
if ( recentFile.exists() &&
*it != ConfigManager::inst()->recoveryFile() )
{
if( recentFile.suffix().toLower() == "mpt" )
@@ -901,15 +901,15 @@ bool MainWindow::saveProject()
{
return( saveProjectAs() );
}
else
else if( this->guiSaveProject() )
{
this->guiSaveProject();
if( getSession() == Recover )
{
sessionCleanup();
}
return true;
}
return( true );
return false;
}
@@ -955,14 +955,16 @@ bool MainWindow::saveProjectAs()
}
}
}
this->guiSaveProjectAs( fname );
if( getSession() == Recover )
if( this->guiSaveProjectAs( fname ) )
{
sessionCleanup();
if( getSession() == Recover )
{
sessionCleanup();
}
return true;
}
return( true );
}
return( false );
return false;
}
@@ -980,8 +982,7 @@ bool MainWindow::saveProjectAsNewVersion()
do VersionedSaveDialog::changeFileNameVersion( fileName, true );
while ( QFile( fileName ).exists() );
this->guiSaveProjectAs( fileName );
return true;
return this->guiSaveProjectAs( fileName );
}
}