Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into jackdexsync
Browse files Browse the repository at this point in the history
  • Loading branch information
firewall1110 committed Aug 17, 2024
2 parents 96f162c + 58ce9b4 commit 4d26cc9
Show file tree
Hide file tree
Showing 26 changed files with 181 additions and 251 deletions.
27 changes: 2 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,37 +338,14 @@ IF(WANT_SDL)
FIND_PACKAGE(SDL2)
IF(SDL2_FOUND)
SET(LMMS_HAVE_SDL TRUE)
SET(LMMS_HAVE_SDL2 TRUE)
SET(STATUS_SDL "OK, using SDL2")
SET(STATUS_SDL "OK")
SET(SDL2_LIBRARY "SDL2::SDL2")
SET(SDL_INCLUDE_DIR "")
SET(SDL_LIBRARY "")
ELSE()
SET(STATUS_SDL "not found, please install libsdl2-dev (or similar) if you require SDL support")
SET(SDL2_LIBRARY "")
ENDIF()
ENDIF()

# fallback to SDL1
IF(WANT_SDL AND NOT LMMS_HAVE_SDL2)
# Fallback to SDL1.2
SET(SDL_BUILDING_LIBRARY TRUE)
FIND_PACKAGE(SDL)
IF(SDL_FOUND)
SET(LMMS_HAVE_SDL TRUE)
SET(STATUS_SDL "OK, using SDL1.2")
# fix mingw since 53abd65
IF(NOT SDL_INCLUDE_DIR)
SET(SDL_INCLUDE_DIR "${CMAKE_FIND_ROOT_PATH}/include")
ENDIF()

ELSE()
SET(STATUS_SDL "not found, please install libsdl2-dev (or similar) "
"if you require SDL support")
SET(SDL_INCLUDE_DIR "")
SET(SDL_LIBRARY "")
ENDIF()
ENDIF()

# check for Sid
if(WANT_SID)
if(PERL_FOUND)
Expand Down
28 changes: 8 additions & 20 deletions include/AudioSdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@

#ifdef LMMS_HAVE_SDL

#ifdef LMMS_HAVE_SDL2
#include <SDL2/SDL_audio.h>
#else
#include <SDL/SDL.h>
#include <SDL/SDL_audio.h>
#endif

#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"

class QLineEdit;
class QComboBox;

namespace lmms
{
Expand All @@ -64,10 +59,16 @@ class AudioSdl : public AudioDevice
~setupWidget() override = default;

void saveSettings() override;

private:
void populatePlaybackDeviceComboBox();
void populateInputDeviceComboBox();

private:
QLineEdit * m_device;
QComboBox* m_playbackDeviceComboBox = nullptr;
QComboBox* m_inputDeviceComboBox = nullptr;

static QString s_systemDefaultDevice;
} ;


Expand All @@ -78,35 +79,22 @@ class AudioSdl : public AudioDevice
static void sdlAudioCallback( void * _udata, Uint8 * _buf, int _len );
void sdlAudioCallback( Uint8 * _buf, int _len );

#ifdef LMMS_HAVE_SDL2
static void sdlInputAudioCallback( void * _udata, Uint8 * _buf, int _len );
void sdlInputAudioCallback( Uint8 * _buf, int _len );
#endif

SDL_AudioSpec m_audioHandle;

SampleFrame* m_outBuf;

#ifdef LMMS_HAVE_SDL2
size_t m_currentBufferFramePos;
size_t m_currentBufferFramesCount;
#else
Uint8 * m_convertedBuf;
int m_convertedBufPos;
int m_convertedBufSize;
bool m_outConvertEndian;
#endif


bool m_stopped;

#ifdef LMMS_HAVE_SDL2
SDL_AudioDeviceID m_outputDevice;

SDL_AudioSpec m_inputAudioHandle;
SDL_AudioDeviceID m_inputDevice;
#endif

} ;


Expand Down
2 changes: 2 additions & 0 deletions include/EffectRackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private slots:

private:
void modelChanged() override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override { return sizeHint(); }

inline EffectChain* fxChain()
{
Expand Down
2 changes: 2 additions & 0 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#ifndef LMMS_INSTRUMENT_TRACK_H
#define LMMS_INSTRUMENT_TRACK_H

#include <limits>

#include "AudioPort.h"
#include "InstrumentFunctions.h"
#include "InstrumentSoundShaping.h"
Expand Down
2 changes: 2 additions & 0 deletions include/MixerChannelLcdSpinBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class MixerChannelLcdSpinBox : public LcdSpinBox
void contextMenuEvent(QContextMenuEvent* event) override;

private:
void enterValue();

TrackView * m_tv;
};

Expand Down
2 changes: 0 additions & 2 deletions include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ public slots:
protected:
static const int DEFAULT_PIXELS_PER_BAR = 128;

void resizeEvent( QResizeEvent * ) override;

TimePos m_currentPosition;


Expand Down
52 changes: 0 additions & 52 deletions include/lmms_basics.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#define LMMS_TYPES_H

#include <cstddef>
#include <limits>

#include "lmmsconfig.h"

Expand Down Expand Up @@ -55,57 +54,6 @@ using mix_ch_t = uint16_t; // Mixer-channel (0 to MAX_CHANNEL)

using jo_id_t = uint32_t; // (unique) ID of a journalling object

// windows headers define "min" and "max" macros, breaking the methods bwloe
#undef min
#undef max

template<typename T>
struct typeInfo
{
static inline T min()
{
return std::numeric_limits<T>::min();
}

static inline T max()
{
return std::numeric_limits<T>::max();
}

static inline T minEps()
{
return 1;
}

static inline bool isEqual( T x, T y )
{
return x == y;
}

static inline T absVal( T t )
{
return t >= 0 ? t : -t;
}
} ;


template<>
inline float typeInfo<float>::minEps()
{
return 1.0e-10f;
}

template<>
inline bool typeInfo<float>::isEqual( float x, float y )
{
if( x == y )
{
return true;
}
return absVal( x - y ) < minEps();
}



constexpr ch_cnt_t DEFAULT_CHANNELS = 2;

Expand Down
2 changes: 2 additions & 0 deletions include/lmms_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ constexpr float F_E = (float) LD_E;
constexpr float F_E_R = (float) LD_E_R;
constexpr float F_SQRT_2 = (float) LD_SQRT_2;

constexpr float F_EPSILON = 1.0e-10f; // 10^-10

// Microtuner
constexpr unsigned int MaxScaleCount = 10; //!< number of scales per project
constexpr unsigned int MaxKeymapCount = 10; //!< number of keyboard mappings per project
Expand Down
5 changes: 5 additions & 0 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
namespace lmms
{

static inline bool approximatelyEqual(float x, float y)
{
return x == y ? true : std::abs(x - y) < F_EPSILON;
}

#ifdef __INTEL_COMPILER

static inline float absFraction( const float _x )
Expand Down
3 changes: 2 additions & 1 deletion plugins/Eq/EqCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "embed.h"
#include "Engine.h"
#include "lmms_constants.h"
#include "lmms_math.h"


namespace lmms::gui
Expand Down Expand Up @@ -65,7 +66,7 @@ QRectF EqHandle::boundingRect() const

float EqHandle::freqToXPixel( float freq , int w )
{
if (typeInfo<float>::isEqual(freq, 0.0f)) { return 0.0f; }
if (approximatelyEqual(freq, 0.0f)) { return 0.0f; }
float min = log10f( 20 );
float max = log10f( 20000 );
float range = max - min;
Expand Down
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ include_directories(SYSTEM
${FFTW3F_INCLUDE_DIRS}
)

IF(NOT LMMS_HAVE_SDL2 AND NOT ("${SDL_INCLUDE_DIR}" STREQUAL ""))
include_directories(SYSTEM "${SDL_INCLUDE_DIR}")
ENDIF()

IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL ""))
include_directories(SYSTEM "${PULSEAUDIO_INCLUDE_DIR}")
ENDIF()
Expand Down
5 changes: 2 additions & 3 deletions src/core/AutomatableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ float AutomatableModel::inverseScaledValue( float value ) const
template<class T>
void roundAt( T& value, const T& where, const T& step_size )
{
if (std::abs(value - where)
< typeInfo<float>::minEps() * std::abs(step_size))
if (std::abs(value - where) < F_EPSILON * std::abs(step_size))
{
value = where;
}
Expand Down Expand Up @@ -583,7 +582,7 @@ float AutomatableModel::controllerValue( int frameOffset ) const
"lacks implementation for a scale type");
break;
}
if( typeInfo<float>::isEqual( m_step, 1 ) && m_hasStrictStepSize )
if (approximatelyEqual(m_step, 1) && m_hasStrictStepSize)
{
return std::round(v);
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "ConfigManager.h"
#include "SampleFrame.h"
#include "lmms_constants.h"

namespace lmms
{
Expand Down Expand Up @@ -154,7 +155,7 @@ void Effect::checkGate( double _out_sum )

// Check whether we need to continue processing input. Restart the
// counter if the threshold has been exceeded.
if( _out_sum - gate() <= typeInfo<float>::minEps() )
if (_out_sum - gate() <= F_EPSILON)
{
incrementBufferCount();
if( bufferCount() > timeout() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/NotePlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ void NotePlayHandle::processTimePos(const TimePos& time, float pitchValue, bool
else
{
const float v = detuning()->automationClip()->valueAt(time - songGlobalParentOffset() - pos());
if (!typeInfo<float>::isEqual(v, m_baseDetuning->value()))
if (!approximatelyEqual(v, m_baseDetuning->value()))
{
m_baseDetuning->setValue(v);
updateFrequency();
Expand Down
2 changes: 1 addition & 1 deletion src/core/Oscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void Oscillator::updateFM( SampleFrame* _ab, const fpp_t _frames,
// should be called every time phase-offset is changed...
inline void Oscillator::recalcPhase()
{
if( !typeInfo<float>::isEqual( m_phaseOffset, m_ext_phaseOffset ) )
if (!approximatelyEqual(m_phaseOffset, m_ext_phaseOffset))
{
m_phase -= m_phaseOffset;
m_phaseOffset = m_ext_phaseOffset;
Expand Down
2 changes: 1 addition & 1 deletion src/core/PresetPreviewPlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file,
// create note-play-handle for it
m_previewNote = NotePlayHandleManager::acquire(
s_previewTC->previewInstrumentTrack(), 0,
typeInfo<f_cnt_t>::max() / 2,
std::numeric_limits<f_cnt_t>::max() / 2,
Note( 0, 0, DefaultKey, 100 ) );

setAudioPort( s_previewTC->previewInstrumentTrack()->audioPort() );
Expand Down
4 changes: 3 additions & 1 deletion src/core/Sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "Sample.h"

#include "lmms_math.h"

#include <cassert>

namespace lmms {
Expand Down Expand Up @@ -143,7 +145,7 @@ bool Sample::play(SampleFrame* dst, PlaybackState* state, size_t numFrames, floa
const auto outputFrames = static_cast<f_cnt_t>(resampleResult.outputFramesGenerated);
if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, SampleFrame{}); }

if (!typeInfo<float>::isEqual(m_amplification, 1.0f))
if (!approximatelyEqual(m_amplification, 1.0f))
{
for (auto i = std::size_t{0}; i < numFrames; ++i)
{
Expand Down
Loading

0 comments on commit 4d26cc9

Please sign in to comment.