Spectrum analyzer update (#5160)

* advanced config: expose hidden constants to user screen
* advanced config: add support for FFT window overlapping
* waterfall: display at native resolution on high-DPI screens
* waterfall: add cursor and improve label density
* FFT: fix normalization so that 0 dBFS matches full-scale sinewave
* FFT: decouple data acquisition from processing and display
* FFT: separate lock for reallocation (to avoid some needless waiting)
* moved ranges and other constants to a separate file
* debug: better performance measurements
* minor fixes
* build the ringbuffer library as part of LMMS core
This commit is contained in:
Martin Pavelek
2019-11-21 14:44:18 +01:00
committed by Johannes Lorenz
parent 2f0010270e
commit da73ddd242
26 changed files with 1867 additions and 364 deletions

View File

@@ -10,3 +10,22 @@ ENDIF()
ADD_SUBDIRECTORY(rpmalloc)
ADD_SUBDIRECTORY(weakjack)
# The lockless ring buffer library is compiled as part of the core
SET(RINGBUFFER_DIR "${CMAKE_SOURCE_DIR}/src/3rdparty/ringbuffer/")
SET(RINGBUFFER_DIR ${RINGBUFFER_DIR} PARENT_SCOPE)
# Create a dummy ringbuffer_export.h, since ringbuffer is not compiled as a library
FILE(WRITE ${CMAKE_BINARY_DIR}/src/ringbuffer_export.h
"#include \"${CMAKE_BINARY_DIR}/src/lmms_export.h\"\n
#define RINGBUFFER_EXPORT LMMS_EXPORT")
# Enable MLOCK support for ringbuffer if available
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/mman.h HAVE_SYS_MMAN)
IF(HAVE_SYS_MMAN)
SET(USE_MLOCK ON)
ELSE()
SET(USE_MLOCK OFF)
ENDIF()
# Generate ringbuffer configuration headers
CONFIGURE_FILE(${RINGBUFFER_DIR}/src/ringbuffer-config.h.in ${CMAKE_BINARY_DIR}/src/ringbuffer-config.h)
CONFIGURE_FILE(${RINGBUFFER_DIR}/src/ringbuffer-version.h.in ${CMAKE_BINARY_DIR}/src/ringbuffer-version.h)

1
src/3rdparty/ringbuffer vendored Submodule

Submodule src/3rdparty/ringbuffer added at 82ed7cfb9a

View File

@@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES(
"${CMAKE_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/include"
"${RINGBUFFER_DIR}/include"
)
IF(WIN32 AND MSVC)
@@ -89,6 +90,8 @@ IF(NOT ("${LAME_INCLUDE_DIRS}" STREQUAL ""))
INCLUDE_DIRECTORIES("${LAME_INCLUDE_DIRS}")
ENDIF()
LIST(APPEND LMMS_SRCS "${RINGBUFFER_DIR}/src/lib/ringbuffer.cpp")
# Use libraries in non-standard directories (e.g., another version of Qt)
IF(LMMS_BUILD_LINUX)
LINK_LIBRARIES(-Wl,--enable-new-dtags)

View File

@@ -1,5 +1,6 @@
set(LMMS_SRCS
${LMMS_SRCS}
core/AutomatableModel.cpp
core/AutomationPattern.cpp
core/BandLimitedWave.cpp

View File

@@ -66,6 +66,7 @@ int normalize(const float *abs_spectrum, float *norm_spectrum, unsigned int bin_
if (abs_spectrum == NULL || norm_spectrum == NULL) {return -1;}
if (bin_count == 0 || block_size == 0) {return -1;}
block_size /= 2;
for (i = 0; i < bin_count; i++)
{
norm_spectrum[i] = abs_spectrum[i] / block_size;