padthv1-0.9.34/PaxHeaders/CMakeLists.txt 0000644 0000000 0000000 00000000132 14554770535 015013 x ustar 00 30 mtime=1706291549.607007126
30 atime=1706291549.607007126
30 ctime=1706291549.607007126
padthv1-0.9.34/CMakeLists.txt 0000644 0001750 0000144 00000027530 14554770535 015012 0 ustar 00rncbc users cmake_minimum_required (VERSION 3.15)
project (padthv1
VERSION 0.9.34
DESCRIPTION "an old-school polyphonic additive synthesizer"
HOMEPAGE_URL "https://padthv1.sourceforge.io"
LANGUAGES C CXX)
set (PROJECT_COPYRIGHT "Copyright (C) 2012-2024, rncbc aka Rui Nuno Capela. All rights reserved.")
set (PROJECT_DOMAIN "rncbc.org")
execute_process (
COMMAND git describe --tags --dirty --abbrev=6
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT
RESULT_VARIABLE GIT_DESCRIBE_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (GIT_DESCRIBE_RESULT EQUAL 0)
set (GIT_VERSION "${GIT_DESCRIBE_OUTPUT}")
string (REGEX REPLACE "^[^0-9]+" "" GIT_VERSION "${GIT_VERSION}")
string (REGEX REPLACE "^1_" "" GIT_VERSION "${GIT_VERSION}")
string (REGEX REPLACE "^[_vV]+" "" GIT_VERSION "${GIT_VERSION}")
string (REGEX REPLACE "-g" "git." GIT_VERSION "${GIT_VERSION}")
string (REGEX REPLACE "[_|-]" "." GIT_VERSION "${GIT_VERSION}")
execute_process (
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVPARSE_OUTPUT
RESULT_VARIABLE GIT_REVPARSE_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (GIT_REVPARSE_RESULT EQUAL 0 AND NOT GIT_REVPARSE_OUTPUT STREQUAL "main")
set (GIT_VERSION "${GIT_VERSION} [${GIT_REVPARSE_OUTPUT}]")
endif ()
set (PROJECT_VERSION "${GIT_VERSION}")
endif ()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set (CONFIG_DEBUG 1)
set (CONFIG_BUILD_TYPE "debug")
else ()
set (CONFIG_DEBUG 0)
set (CONFIG_BUILD_TYPE "release")
set (CMAKE_BUILD_TYPE "Release")
endif ()
set (CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
include (GNUInstallDirs)
set (CONFIG_BINDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set (CONFIG_LIBDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set (CONFIG_DATADIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_DATADIR}")
set (CONFIG_MANDIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_MANDIR}")
# Enable JACK standalone build.
option (CONFIG_JACK "Enable JACK stand-alone build (default=yes)" 1)
# Enable JACK session support.
option (CONFIG_JACK_SESSION "Enable JACK session support (default=yes)" 1)
# Enable JACK MIDI support option.
option (CONFIG_JACK_MIDI "Enable JACK MIDI support (default=yes)" 1)
# Enable ALSA MIDI support option.
option (CONFIG_ALSA_MIDI "Enable ALSA MIDI support (default=yes)" 1)
# Enable LV2 plugin build.
option (CONFIG_LV2 "Enable LV2 plug-in build (default=yes)" 1)
if (WIN32)
option (CONFIG_LV2_UI_WINDOWS "Enable LV2 plug-in Windows UI support (default=yes)" 1)
# Windows install target path.
set (CONFIG_WINDOWS_LV2_PATH "$ENV{SYSTEMDRIVE}/Program Files/Common Files/LV2" CACHE STRING "Specify Windows LV2 install path")
else ()
option (CONFIG_LV2_UI_X11 "Enable LV2 plug-in X11 UI support (default=yes)" 1)
endif ()
option (CONFIG_LV2_UI_EXTERNAL "Enable LV2 plug-in External UI support (default=yes)" 1)
option (CONFIG_LV2_UI_IDLE "Enable LV2 UI Idle interface support (default=yes)" 1)
option (CONFIG_LV2_UI_SHOW "Enable LV2 UI Show interface support (default=yes)" 1)
option (CONFIG_LV2_UI_RESIZE "Enable LV2 UI Resize interface support (default=yes)" 1)
option (CONFIG_LV2_PROGRAMS "Enable LV2 plug-in Programs support (default=yes)" 1)
option (CONFIG_LV2_PATCH "Enable LV2 plug-in Patch support (default=yes)" 1)
option (CONFIG_LV2_PORT_EVENT "Enable LV2 plug-in Port-event support (default=yes)" 1)
option (CONFIG_LV2_PORT_CHANGE_REQUEST "Enable LV2 plug-in Port-change request support (default=yes)" 1)
# Enable liblo availability.
option (CONFIG_LIBLO "Enable liblo interface (default=yes)" 1)
# Enable NSM support.
option (CONFIG_NSM "Enable NSM support (default=yes)" 1)
# Enable Wayland support option.
option (CONFIG_WAYLAND "Enable Wayland support (EXPERIMENTAL) (default=no)" 0)
# Enable Qt6 build preference.
option (CONFIG_QT6 "Enable Qt6 build (default=yes)" 1)
# Fix for new CMAKE_REQUIRED_LIBRARIES policy.
if (POLICY CMP0075)
cmake_policy (SET CMP0075 NEW)
endif ()
# Fix for CXX_VISIBILITY_PRESET policy.
if (POLICY CMP0063)
cmake_policy (SET CMP0063 NEW)
set (CMAKE_CXX_VISIBILITY_PRESET hidden)
set (CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif ()
# Check for Qt...
if (CONFIG_QT6)
find_package (Qt6 QUIET)
if (NOT Qt6_FOUND)
set (CONFIG_QT6 0)
endif ()
endif ()
if (CONFIG_QT6)
find_package (QT QUIET NAMES Qt6)
else ()
find_package (QT QUIET NAMES Qt5)
endif ()
find_package (Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Xml Svg)
#find_package (Qt${QT_VERSION_MAJOR}LinguistTools)
include (CheckIncludeFile)
include (CheckIncludeFiles)
include (CheckIncludeFileCXX)
include (CheckFunctionExists)
include (CheckLibraryExists)
# Make sure we get some subtle optimizations out there...
add_compile_options (-ffast-math)
# Checks for header files.
if (UNIX AND NOT APPLE)
check_include_files ("fcntl.h;unistd.h;signal.h" HAVE_SIGNAL_H)
endif ()
# Find package modules
include (FindPkgConfig)
# Check for FFTW3 libraries.
pkg_check_modules (FFTW3 REQUIRED IMPORTED_TARGET fftw3f)
if (FFTW3_FOUND)
set (CONFIG_FFTW3 1)
else ()
message (FATAL_ERROR "*** FFTW3 library not found.")
set (CONFIG_FFTW3 0)
endif ()
# Check for JACK libraries.
if (CONFIG_JACK)
pkg_check_modules (JACK IMPORTED_TARGET jack>=0.100.0)
if (JACK_FOUND)
find_library (JACK_LIBRARY NAMES ${JACK_LIBRARIES} HINTS ${JACK_LIBDIR})
endif ()
if (JACK_LIBRARY)
set (CONFIG_JACK 1)
set (CMAKE_REQUIRED_LIBRARIES "${JACK_LIBRARY};${CMAKE_REQUIRED_LIBRARIES}")
# Check for JACK MIDI headers availability.
if (CONFIG_JACK_MIDI)
check_include_file (jack/midiport.h HAVE_JACK_MIDIPORT_H)
if (NOT HAVE_JACK_MIDIPORT_H)
set (CONFIG_JACK_MIDI 0)
endif ()
endif ()
# Check for JACK session headers availability.
if (CONFIG_JACK_SESSION)
check_include_file (jack/session.h HAVE_JACK_SESSION_H)
if (NOT HAVE_JACK_SESSION_H)
set (CONFIG_JACK_SESSION 0)
endif ()
endif ()
# Check for JACK session event callback availability.
if (CONFIG_JACK_SESSION)
check_function_exists (jack_set_session_callback CONFIG_JACK_SESSION)
endif ()
# Check for ALSA libraries.
if (CONFIG_ALSA_MIDI)
pkg_check_modules (ALSA IMPORTED_TARGET alsa)
if (ALSA_FOUND)
find_library (ALSA_LIBRARY NAMES ${ALSA_LIBRARIES} HINTS ${ALSA_LIBDIR})
endif ()
if (ALSA_LIBRARY)
set (CONFIG_ALSA_MIDI 1)
#set (CMAKE_REQUIRED_LIBRARIES "${ALSA_LIBRARY};${CMAKE_REQUIRED_LIBRARIES}")
else ()
message (WARNING "*** ALSA library not found.")
endif ()
endif ()
else ()
message (WARNING "*** JACK library not found.")
set (CONFIG_JACK 0)
endif ()
endif ()
if (NOT CONFIG_JACK)
set (CONFIG_JACK_SESSION 0)
set (CONFIG_JACK_MIDI 0)
set (CONFIG_ALSA_MIDI 0)
set (CONFIG_LIBLO 0)
set (CONFIG_NSM 0)
endif ()
# Check for LIBLO libraries.
if (CONFIG_LIBLO)
pkg_check_modules (LIBLO IMPORTED_TARGET liblo)
if (NOT LIBLO_FOUND)
message (WARNING "*** LIBLO library not found.")
set (CONFIG_LIBLO 0)
endif ()
endif ()
# Check for LV2 support.
if (CONFIG_LV2)
pkg_check_modules (LV2 lv2)
if (LV2_FOUND)
include_directories (${LV2_INCLUDE_DIRS})
# Check for LV2 old/new headers style.
check_include_file (lv2/urid/urid.h HAVE_LV2_URID_H)
if (NOT HAVE_LV2_URID_H)
check_include_file (lv2/lv2plug.in/ns/ext/urid/urid.h HAVE_OLD_LV2_URID_H)
if (NOT HAVE_OLD_LV2_URID_H)
set (CONFIG_LV2 0)
else ()
set (CONFIG_LV2_OLD_HEADERS 1)
endif ()
else ()
set (CONFIG_LV2_OLD_HEADERS 0)
endif ()
endif ()
if (NOT CONFIG_LV2)
message (WARNING "*** LV2 SDK not found.")
endif ()
endif ()
if (CONFIG_LV2)
# Check for LV2 Atom support.
if (CONFIG_LV2_OLD_HEADERS)
check_include_file (lv2/lv2plug.in/ns/ext/atom/atom.h HAVE_LV2_ATOM_H)
else ()
check_include_file (lv2/atom/atom.h HAVE_LV2_ATOM_H)
endif ()
if (NOT HAVE_LV2_ATOM_H)
set (CONFIG_LV2_ATOM 0)
else ()
set (CONFIG_LV2_ATOM 1)
endif ()
set (CONFIG_LV2_ATOM_FORGE_OBJECT ${CONFIG_LV2_ATOM})
set (CONFIG_LV2_ATOM_FORGE_KEY ${CONFIG_LV2_ATOM})
# Check for LV2 UI support.
if (CONFIG_LV2_OLD_HEADERS)
check_include_file (lv2/lv2plug.in/ns/extensions/ui/ui.h HAVE_LV2_UI_H)
else ()
check_include_file (lv2/ui/ui.h HAVE_LV2_UI_H)
endif ()
if (NOT HAVE_LV2_UI_H)
set (CONFIG_LV2_UI 0)
else ()
set (CONFIG_LV2_UI 1)
endif ()
if (NOT CONFIG_LV2_UI)
set (CONFIG_LV2_UI_X11 0)
set (CONFIG_LV2_UI_WINDOWS 0)
set (CONFIG_LV2_UI_EXTERNAL 0)
set (CONFIG_LV2_UI_IDLE 0)
set (CONFIG_LV2_UI_SHOW 0)
set (CONFIG_LV2_UI_RESIZE 0)
endif ()
endif ()
# Check for LV2 headers.
if (CONFIG_LV2)
set (LV2_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/src/lv2)
set (CMAKE_REQUIRED_INCLUDES "${LV2_INCLUDES};${CMAKE_REQUIRED_INCLUDES}")
include_directories (${LV2_INCLUDES})
else ()
set (CONFIG_LV2_UI_X11 0)
set (CONFIG_LV2_UI_WINDOWS 0)
set (CONFIG_LV2_UI_EXTERNAL 0)
set (CONFIG_LV2_UI_IDLE 0)
set (CONFIG_LV2_UI_SHOW 0)
set (CONFIG_LV2_UI_RESIZE 0)
set (CONFIG_LV2_PROGRAMS 0)
set (CONFIG_LV2_PATCH 0)
set (CONFIG_LV2_PORT_EVENT 0)
set (CONFIG_LV2_PORT_CHANGE_REQUEST 0)
endif ()
if (CONFIG_LV2_UI_EXTERNAL)
check_include_file (lv2_external_ui.h HAVE_LV2_EXTERNAL_UI_H)
if (NOT HAVE_LV2_EXTERNAL_UI_H)
set (CONFIG_LV2_UI_EXTERNAL 0)
endif ()
endif ()
if (CONFIG_LV2_PROGRAMS)
check_include_file (lv2_programs.h HAVE_LV2_PROGRAMS_H)
if (NOT HAVE_LV2_PROGRAMS_H)
set (CONFIG_LV2_PROGRAMS 0)
endif ()
endif ()
if (CONFIG_LV2_PATCH)
if (CONFIG_LV2_OLD_HEADERS)
check_include_file (lv2/lv2plug.in/ns/ext/patch/patch.h HAVE_LV2_PATCH_H)
else ()
check_include_file (lv2/patch/patch.h HAVE_LV2_PATCH_H)
endif ()
if (NOT HAVE_LV2_PATCH_H)
set (CONFIG_LV2_PATCH 0)
endif ()
endif ()
if (CONFIG_LV2_PORT_CHANGE_REQUEST)
check_include_file (lv2_port_change_request.h HAVE_LV2_PORT_CHANGE_REQUEST_H)
if (NOT HAVE_LV2_PORT_CHANGE_REQUEST_H)
set (CONFIG_LV2_PORT_CHANGE_REQUEST 0)
endif ()
endif ()
add_subdirectory (src)
# Configuration status
macro (SHOW_OPTION text value)
if (${value})
message ("${text}: yes")
else ()
message ("${text}: no")
endif ()
endmacro ()
message ("\n ${PROJECT_NAME} ${PROJECT_VERSION} (Qt ${QT_VERSION})")
message ("\n Build target . . . . . . . . . . . . . . . . . . .: ${CONFIG_BUILD_TYPE}\n")
show_option (" JACK stand-alone build . . . . . . . . . . . . . ." CONFIG_JACK)
show_option (" JACK session support . . . . . . . . . . . . . . ." CONFIG_JACK_SESSION)
show_option (" JACK MIDI support . . . . . . . . . . . . . . . ." CONFIG_JACK_MIDI)
show_option (" ALSA MIDI support . . . . . . . . . . . . . . . ." CONFIG_ALSA_MIDI)
show_option (" LV2 plug-in build . . . . . . . . . . . . . . . ." CONFIG_LV2)
if (WIN32)
show_option (" LV2 plug-in Windows UI support . . . . . . . . ." CONFIG_LV2_UI_WINDOWS)
else ()
show_option (" LV2 plug-in X11 UI support . . . . . . . . . . ." CONFIG_LV2_UI_X11)
endif ()
show_option (" LV2 plug-in External UI support . . . . . . . . ." CONFIG_LV2_UI_EXTERNAL)
show_option (" LV2 plug-in UI Idle interface support . . . . . ." CONFIG_LV2_UI_IDLE)
show_option (" LV2 plug-in UI Show interface support . . . . . ." CONFIG_LV2_UI_SHOW)
show_option (" LV2 plug-in UI Resize interface support . . . . ." CONFIG_LV2_UI_RESIZE)
show_option (" LV2 plug-in Programs support . . . . . . . . . . ." CONFIG_LV2_PROGRAMS)
show_option (" LV2 plug-in Patch support . . . . . . . . . . . ." CONFIG_LV2_PATCH)
show_option (" LV2 plug-in Port-event support . . . . . . . . . ." CONFIG_LV2_PORT_EVENT)
show_option (" LV2 plug-in Port-change request (EXPERIMENTAL) . ." CONFIG_LV2_PORT_CHANGE_REQUEST)
show_option (" OSC service support (liblo) . . . . . . . . . . ." CONFIG_LIBLO)
show_option (" Non/New Session Management (NSM) support . . . . ." CONFIG_NSM)
message ("\n Install prefix . . . . . . . . . . . . . . . . . .: ${CONFIG_PREFIX}\n")
padthv1-0.9.34/PaxHeaders/ChangeLog 0000644 0000000 0000000 00000000132 14554770535 014025 x ustar 00 30 mtime=1706291549.607007126
30 atime=1706291549.607007126
30 ctime=1706291549.607007126
padthv1-0.9.34/ChangeLog 0000644 0001750 0000144 00000026246 14554770535 014027 0 ustar 00rncbc users padthv1 - An old-school additive polyphonic synthesizer
-------------------------------------------------------
ChangeLog
0.9.34 2024-01-26 A Winter'24 Release.
- Added build checks on whether to use old or newer style of LV2
include headers.
- LV2 plugin Control Input Port-change request extension feature
support added.
- Updated copyright headers into the New Year (2024).
0.9.33 2023-12-20 An End-of-Autumn'23 Release.
- Minor optimization to denormal avoidance on some fx's.
- Bumping into next development cycle (Qt >= 6.6)
0.9.32 2023-09-12 An End-of-Summer'23 Release.
- Preppings to next development cycle (Qt >= 6.6)
0.9.31 2023-06-06 A Spring'23 Release.
- Make sure the XCB interface is in use when instantiating the
LV2 plugin on non-Qt hosts, allowing LV2 X11 UI embedding to
work and show up properly.
- Prepping into the next development cycle (with Qt >= 6.5).
0.9.30 2023-03-24 An Early-Spring'23 Release.
- Restrict to existing named presets when adding new or editing
programs; load and restore presets directly when previewing
programs (cf. Configure... > Programs).
- NSM open and save operation failures are now replied with an
error status (was always OK before).
- JACK client watchdog introduced for automatic reactivation and
resilience (standalone only).
- NSM announcement reply/error messages now relegated to debug
builds only.
0.9.29 2023-01-25 A Winter'23 Release.
- Bumping copyright headers to the brand new year.
0.9.28 2022-12-29 An End-of-Year'22 Release.
- Mitigate NSM sending lots of dirty messages on SIGTERM signal.
- Although being deprecated to use, JACK Session support hopefuly
fixed once again.
0.9.27 2022-10-04 An Early-Autumn'22 Release.
- Fixed MIDI Controller... modeless dialog (de)instantiation.
- Custom color/style themes applies only to main widget only.
- Fixed typos and updated some old MIDI GM2 Controller names.
0.9.26 2022-06-07 An End-of-Sping'22 Release.
- Corrected an incredible mistake introduced in the last year's
Glide/portamento protential crash fix.
- Added Qt::Svg module as required at build time.
0.9.25 2022-04-07 A Spring'22 Release.
- Added missing file code to desktop exec entry (standalone only).
- Main application icon is now presented in scalable format (SVG).
- Migrated command line parsing to QCommandLineParser/Option
(Qt >= 5.2)
- Avoid issuing NSM dirty messages as much as possible.
0.9.24 2022-01-09 A Winter'22 Release.
- Dropped autotools (autoconf, automake, etc.) build system.
- Fixed deprecate warnings in preparation for Qt >= 6.2.
0.9.23 2021-07-07 An Early-Summer'21 Release.
- Fixed some ages old Glide/portamento potential crash bug
(as reported by AnClark, while on synthv1).
- Add support for LV2 UI Windows platform (by AnClark, also
while on synthv1).
- Sustenuto pedal controller (MIDI CC#66) is now implemented.
- Fixed old Sustain/Damper/Hold pedal controller (MIDI CC#64)
note-off processing.
- Have some tolerance for buffer-size changes.
- All builds default to Qt6 (Qt >= 6.1) where available.
- CMake is now the official build system.
0.9.22 2021-05-13 A Spring'21 Release.
- All packaging builds switching to CMake.
0.9.21 2021-03-16 An End-of-Winter'21 Release.
- Fixed an old lurker, causing slight differences to voice
on-sets, due to a wrong initial LFO Volume ramping value.
- Slightly improved eye-candyness to all graphic widgets,
most especially on the EG widget handling, curved lines
and gradient fills.
0.9.20 2021-02-10 A Winter'21 Release.
- When under under the NSM auspices, fix SIGTERM handler
on exit and just hide the main-window on close (applies
to the JACK stand-alone only).
0.9.19 20220-12-19 A Winter'20 Release.
- Fixed display of old knob/dial values on status-bar.
- Reduced formant filter coefficient slew rate, aiming
to a tenfold DSP performance gain.
- Get a chance on bringing Wayland into the picture when
dealing Qt static-linked deliverables.
0.9.18 2020-10-27 A Fall'20 Release.
- Upstream package naming for the JACK standalone and LV2
plugin deliverables are suffixed to '-jack' and '-lv2',
respectively.
- White keys on the virtual piano keyboard are now fully
highlighted.
0.9.17 2020-09-08 Late Summer'10 Release.
- Added -n, --client-name to the JACK stand-alone client
application command line option arguments.
- Fixed unitialized number of voices variable; early-bird
adaptations to Qt6 >= 6.0.0 and C++17 standard.
0.9.16 2020-08-06 A Summer'20 Release.
- Fixed deprecated stuff on an early preparation for Qt6.
0.9.15 2020-06-22 An Early-Summer'20 Release.
- A long awaited expedite "Panic" button is now featured.
- Note velocity doesn't affect DCF envelope anymore.
- Avoid glib event-loop upon LV2 plug-in instantiation.
0.9.14 2020-05-05 A Mid-Spring'20 Release.
- Fixed initial DCF1, LFO1 group enablement (GUI).
- Fixed initial window title for the LV2 External UI.
- LV2 Atom/Port-event host notification support has been
implemented (unofficial).
- Prevent execution of duplicate or redundant MIDI bank-
select/program-change commands.
- Early fixing to build for Qt >= 5.15.0.
0.9.13 2020-03-26 A Spring'20 Release.
- Maximum pitch-bend range has been expanded to 0..400%,
allegedly to support some PME driven instruments (as
proposed by sacarlson, to synthv1).
- Make man page compression reproducible (after request
by Jelle van der Waa, thanks).
- Fixed crash when showing the tooltip of a negative note
number that results from dragging over and beyond the
left edge of the virtual piano keyboard.
- Remove -v (verbose) flag from 'strip' post-link command.
- Fixed CMake build by adding missing Custom Color Theme
(palette) form file (.ui).
- Bumped copyright headers into the New Year (2020).
0.9.12 2019-12-26 The Winter'19 Release.
- Custom color (palette) theme editor introduced; color
(palette) theme changes are now effective immediately,
except on default.
- Second attempt to fix the yet non-official though
CMake build configuration.
- Move QApplication construction/destruction from LV2 UI
to plug-in instantiation and cleanup.
0.9.11 2019-10-31 A Halloween'19 Release.
- When using autotools and ./configure --with-qt=...,
it is also necessary to adjust the PKG_CONFIG_PATH
environment variable (after a merge request by plcl
aka. Pedro López-Cabanillas, while on qmidinet).
- Upstream packaging is now split to JACK standalone and
LV2 plugin only: the former shared common core and UI
package is now duplicated but statically linked though.
0.9.10 2019-09-24 An Early-Fall'19 Release.
- Upstream packaging is now split on JACK standalone,
LV2 plugin and common core and UI packages, similar
to recent Debian practice.
- Added alternate yet non-official CMake build option.
- Fix HiDPI display screen effective support (Qt >= 5.6).
- All randomizers now compliant to the standard normal
distribution.
- Make sure compiler flags comply to c++11 as standard.
0.9.9 2019-07-18 A Summer'19 Release.
- Randomization of current parameters and partials is
now available through a new top-level push-button and
the context-menu respectively.
- Updated for the newer Qt5 development tools (>= 5.13).
- Per instance custom tuning (micro-tonal) option has
been added to the previously existing global settings
(cf. Help > Configure... > Tuning > Global, Instance).
- New DCF and LFO Enabled parameters.
- Configure updated to check for qtchooser availability.
0.9.8 2019-06-06 A Spring'19 Release.
- Improved slew-rate to DCF Formant coefficient updates.
- Refactored the LFO Sync for correctness.
- Fixed all LFO Panning and Volume modulation, now being
correctly isolated on a per voice basis.
- Fixed initial DCO and LFO wave shapes on LV2 plug-in UI.
- Minor update to Debian packaging control file.
0.9.7 2019-04-14 A Spring-Break'19 Release.
- All audio input now get through without being processed
by any or whole effects stage anymore.
- Re-defined all JACK stand-alone client application UNIX
signal handling.
0.9.6 2019-03-18 Pre-LAC2019 Release Frenzy.
- A gentlier shutdown for the JACK client standalone client.
0.9.5 2019-03-04 The End of Winter'19 release.
- HiDPI display screen support (Qt >= 5.6).
- A fake/visual piano-keyboard widget is now being introduced
to the status bar.
- Avoid destructing the possibly shared QApplication instance
on LV2 plug-in UI clean-up.
0.9.4 2018-12-12 A Late Autumn'18 release.
- Sample waveform drawing is a bit more keen to precision.
- Old deprecated Qt4 build support is no more.
- Normalized wavetable oscillator phasors.
- Added missing include to shut up some stricter
compilers from build failures.
0.9.3 2018-10-22 An Autumn'18 release.
- For safety reasons, all processing is now suspended while
loading presets or program changes are issued.
- AppStream metadata updated to be the most compliant with
latest freedesktop.org specification and recommendation.
- SIGTERM (and SIGINT) signal handler added to close the JACK
stand-alone client applications properly.
- Make the GUI not to show initially on NSM.
- Make NSM state independent to session display name, keeping
backward compatibility for old sessions.
- Give some more slack to schedule/worker thread ring-buffer.
0.9.2 2018-07-24 A Summer'18 release.
- Add LV2 UI Resize extension data support.
- Process MIDI Controlllers even though the channel filter
is on (DEF Channel is set anything but "Omni").
- AppData/AppStream metadata is now settled under an all
permisssive license (FSFAP).
0.9.1 2018-06-26 An Early Summer'18 release.
- Fixed for some g++ >= 8.1.1 warnings and quietness.
- Added LV2 UI X11 support option.
- Disable reference micro-tuning settings when a Scala
keyboard map override is in effect.
- Added "All files (*.*)" filter to every file requestor
dialog, wherever missing.
0.9.0 2018-03-07 The End of Winter'18 release.
- Introducing Scala micro-tuning classes, borrowed, stirred
and refactored from original Nick Dowell's amsynth code,
all under the GPL umbrella, of course.
- An internal note-key/frequency indirection table is now in
place, as a baseline for any micro-tuning implementations.
- Whether to use native file browser/requester dialogs is
now an effective option when launching under NSM session
management (was once disabled initially).
- Trying to get CC14 MSB+LSB (course+fine) running status on,
no matter whether each pairing event are under 200ms apart.
- A little hardening on the configure (autoconf) macro side.
0.8.6 2017-12-20 The End of Autumn'17 release.
- Set on a minimum attack time of 500usec as much to prevent
audible clicking on low-pitched notes.
0.8.5 2017-10-29 An Autumn'17 release.
- Opening multiple preset files is now possible, populating
the preset drop-down listing, while only the first one is
loaded effectively into the scene as usual.
- Mono(phonic) "Legato" mode option introduced.
- Desktop entry specification file is now finally independent
from all build/configure template chains, whatever.
- Updated target path for freedesktop.org's AppStream metainfo
file (formerly AppData).
0.8.4 2017-08-22 A Late-Summer'17 release.
- First public release.
0.8.3 2017-07-20 Initial change-log entry.
padthv1-0.9.34/PaxHeaders/LICENSE 0000644 0000000 0000000 00000000132 14554770535 013260 x ustar 00 30 mtime=1706291549.607007126
30 atime=1706291549.607007126
30 ctime=1706291549.607007126
padthv1-0.9.34/LICENSE 0000644 0001750 0000144 00000043103 14554770535 013251 0 ustar 00rncbc users GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
padthv1-0.9.34/PaxHeaders/README 0000644 0000000 0000000 00000000132 14554770535 013133 x ustar 00 30 mtime=1706291549.607007126
30 atime=1706291549.607007126
30 ctime=1706291549.607007126
padthv1-0.9.34/README 0000644 0001750 0000144 00000006153 14554770535 013130 0 ustar 00rncbc users padthv1 - an old-school polyphonic additive synthesizer
-------------------------------------------------------
an old-school polyphonic additive synthesizer with stereo fx.
based on the PADsynth algorithm, by Paul Nasca, as a special
variant of additive synthesis.
cf. https://zynaddsubfx.sourceforge.net/doc/PADsynth/PADsynth.htm
Features:
- pure stand-alone JACK [1] client with JACK-session, NSM [3] and both
JACK MIDI and ALSA MIDI [2] input support;
- LV2 [4] instrument plugin.
URI: http://padthv1.sourceforge.net/lv2
License:
padthv1 is free, Linux Audio [5] open-source software, distributed under
the terms of the GNU General Public License (GPL) [6] version 2 or later.
Website:
https://padthv1.sourceforge.io
http://padthv1.sourceforge.net
Project page:
https://sourceforge.net/projects/padthv1
Git repos:
https://git.code.sf.net/p/padthv1/code
https://github.com/rncbc/padthv1.git
https://gitlab.com/rncbc/padthv1.git
https://codeberg.org/rncbc/padthv1.git
Weblog:
https://www.rncbc.org
Requirements:
mandatory,
- Qt framework [7], C++ class library and tools for
cross-platform application and UI development
https://qt.io/
- FFTW3 [9], a C library for computing the discrete
Fourier transform (DFT) in one or more dimensions
http://www.fftw.org
optional (opted-in at build time),
- JACK [1] Audio Connection Kit
https://jackaudio.org/
- ALSA [2], Advanced Linux Sound Architecture
https://www.alsa-project.org/
- LV2 [4], Audio Plugin Standard, the extensible successor of LADSPA
https://lv2plug.in/
- liblo [8], Lightweight OSC implementation
(needed for NSM support [3])
http://liblo.sourceforge.net/
Installation:
- unpack tarball as usual; in the extracted source directory:
cmake [-DCMAKE_INSTALL_PREFIX=] -B build
cmake --build build [--parallel ]
- optionally, as root:
[sudo] cmake --install build
- note that the default installation path () is /usr/local .
Acknowledgements:
drumkv1 logo/icon is an original fine work of Jarle Richard Akselsen.
References:
[1] JACK Audio Connection Kit
https://jackaudio.org/
[2] ALSA, Advanced Linux Sound Architecture
https://www.alsa-project.org/
[3] Non Session Management (NSM) (legacy)
http://non.tuxfamily.org/nsm/
New Session Manager (NSM)
https://new-session-manager.jackaudio.org/
[4] LV2, Audio Plugin Standard, the extensible successor of LADSPA
http://lv2plug.in/
[5] Linux Audio consortium of libre software for audio-related work
https://linuxaudio.org
[6] GNU General Public License
https://www.gnu.org/copyleft/gpl.html
[7] Qt framework, C++ class library and tools for
cross-platform application and UI development
https://qt.io/
[8] liblo [8], Lightweight OSC implementation
(needed for NSM support)
http://liblo.sourceforge.net/
[9] FFTW3, a C library for computing the discrete
Fourier transform (DFT) in one or more dimensions
http://www.fftw.org
Cheers && Enjoy.
--
rncbc aka. Rui Nuno Capela
rncbc at rncbc dot org
https://www.rncbc.org
padthv1-0.9.34/PaxHeaders/src 0000644 0000000 0000000 00000000132 14554770535 012765 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.608007119
30 ctime=1706291549.612007092
padthv1-0.9.34/src/ 0000755 0001750 0000144 00000000000 14554770535 013032 5 ustar 00rncbc users padthv1-0.9.34/src/PaxHeaders/padthv1widget_status.h 0000644 0000000 0000000 00000000132 14554770535 017371 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_status.h 0000644 0001750 0000144 00000003506 14554770535 017365 0 ustar 00rncbc users // padthv1widget_status.h
//
/****************************************************************************
Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1widget_status_h
#define __padthv1widget_status_h
#include
// Forward declarations.
class padthv1widget_keybd;
class QLabel;
class QPixmap;
//-------------------------------------------------------------------------
// padthv1widget_status - Custom status-bar widget.
class padthv1widget_status : public QStatusBar
{
Q_OBJECT
public:
// Constructor.
padthv1widget_status(QWidget *pParent = 0);
// Destructor.
~padthv1widget_status();
// Permanent widgets accessors.
padthv1widget_keybd *keybd() const;
void midiInLed(bool bMidiInLed);
void midiInNote(int iNote, int iVelocity);
void modified(bool bModified);
private:
// Permanent widgets.
QPixmap *m_midiInLed[2];
QLabel *m_pMidiInLedLabel;
QLabel *m_pModifiedLabel;
padthv1widget_keybd *m_pKeybd;
};
#endif // __padthv1widget_status_h
// end of padthv1widget_status.h
padthv1-0.9.34/src/PaxHeaders/padthv1_param.h 0000644 0000000 0000000 00000000132 14554770535 015742 x ustar 00 30 mtime=1706291549.610007106
30 atime=1706291549.610007106
30 ctime=1706291549.610007106
padthv1-0.9.34/src/padthv1_param.h 0000644 0001750 0000144 00000004637 14554770535 015744 0 ustar 00rncbc users // padthv1_param.h
//
/****************************************************************************
Copyright (C) 2012-2024, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1_param_h
#define __padthv1_param_h
#include "padthv1.h"
#include
// forward decl.
class QDomElement;
class QDomDocument;
//-------------------------------------------------------------------------
// padthv1_param - decl.
//
namespace padthv1_param
{
// Preset serialization methods.
bool loadPreset(padthv1 *pSynth,
const QString& sFilename);
bool savePreset(padthv1 *pSynth,
const QString& sFilename,
bool bSymLink = false);
// Sample serialization methods.
void loadSamples(padthv1 *pSynth,
const QDomElement& eSamples);
void saveSamples(padthv1 *pSynth,
QDomDocument& doc, QDomElement& eSamples,
bool bSymLink = false);
// Tuning serialization methods.
void loadTuning(padthv1 *pSynth,
const QDomElement& eTuning);
void saveTuning(padthv1 *pSynth,
QDomDocument& doc, QDomElement& eTuning,
bool bSymLink = false);
// Default parameter name/value helpers.
const char *paramName(padthv1::ParamIndex index);
float paramDefaultValue(padthv1::ParamIndex index);
float paramSafeValue(padthv1::ParamIndex index, float fValue);
float paramValue(padthv1::ParamIndex index, float fScale);
float paramScale(padthv1::ParamIndex index, float fValue);
bool paramFloat(padthv1::ParamIndex index);
// Load/save and convert canonical/absolute filename helpers.
QString loadFilename(const QString& sFilename);
QString saveFilename(const QString& sFilename, bool bSymLink);
};
#endif // __padthv1_param_h
// end of padthv1_param.h
padthv1-0.9.34/src/PaxHeaders/padthv1widget_palette.h 0000644 0000000 0000000 00000000132 14554770535 017504 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_palette.h 0000644 0001750 0000144 00000015662 14554770535 017506 0 ustar 00rncbc users // padthv1widget_palette.h
//
/****************************************************************************
Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1widget_palette_h
#define __padthv1widget_palette_h
#include
#include
#include
#include
#include
#include
// Forward decls.
class QListView;
class QLabel;
class QToolButton;
//-------------------------------------------------------------------------
// padthv1widget_palette
namespace Ui { class padthv1widget_palette; }
class padthv1widget_palette: public QDialog
{
Q_OBJECT
public:
padthv1widget_palette(QWidget *parent = nullptr,
const QPalette& pal = QPalette());
virtual ~padthv1widget_palette();
void setPalette(const QPalette& pal);
const QPalette& palette() const;
void setSettings(QSettings *settings, bool owner = false);
QSettings *settings() const;
void setPaletteName(const QString& name);
QString paletteName() const;
bool isDirty() const;
static QStringList namedPaletteList(QSettings *settings);
static bool namedPalette(QSettings *settings,
const QString& name, QPalette& pal, bool fixup = false);
static QPalette::ColorRole colorRole(const QString& name);
class PaletteModel;
class ColorDelegate;
class ColorButton;
class ColorEditor;
class RoleEditor;
protected slots:
void nameComboChanged(const QString& name);
void saveButtonClicked();
void deleteButtonClicked();
void generateButtonChanged();
void resetButtonClicked();
void detailsCheckClicked();
void importButtonClicked();
void exportButtonClicked();
void paletteChanged(const QPalette& pal);
void accept();
void reject();
protected:
void setPalette(const QPalette& pal, const QPalette& parentPal);
bool namedPalette(const QString& name, QPalette& pal);
void saveNamedPalette(const QString& name, const QPalette& pal);
void deleteNamedPalette(const QString& name);
QStringList namedPaletteList();
void updateNamedPaletteList();
void updateGenerateButton();
void updateDialogButtons();
void setDefaultDir(const QString& dir);
QString defaultDir() const;
void setShowDetails(bool on);
bool isShowDetails() const;
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
private:
Ui::padthv1widget_palette *p_ui;
Ui::padthv1widget_palette& m_ui;
QSettings *m_settings;
bool m_owner;
QPalette m_palette;
QPalette m_parentPalette;
PaletteModel *m_paletteModel;
bool m_modelUpdated;
bool m_paletteUpdated;
int m_dirtyCount;
int m_dirtyTotal;
};
//-------------------------------------------------------------------------
// padthv1widget_palette::PaletteModel
class padthv1widget_palette::PaletteModel : public QAbstractTableModel
{
Q_OBJECT
Q_PROPERTY(QPalette::ColorRole colorRole READ colorRole)
public:
PaletteModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
void setPalette(const QPalette &palette, const QPalette &parentPalette);
const QPalette& palette() const;
void setGenerate(bool on) { m_generate = on; }
QPalette::ColorRole colorRole() const { return QPalette::NoRole; }
signals:
void paletteChanged(const QPalette &palette);
protected:
QPalette::ColorGroup columnToGroup(int index) const;
int groupToColumn(QPalette::ColorGroup group) const;
private:
QPalette m_palette;
QPalette m_parentPalette;
QMap m_roleNames;
int m_nrows;
bool m_generate;
};
//-------------------------------------------------------------------------
// padthv1widget_palette::ColorDelegate
class padthv1widget_palette::ColorDelegate : public QItemDelegate
{
public:
ColorDelegate(QObject *parent = nullptr)
: QItemDelegate(parent) {}
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const;
void setEditorData(QWidget *editor,
const QModelIndex& index) const;
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex& index) const;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem& option,
const QModelIndex &index) const;
virtual void paint(QPainter *painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const;
virtual QSize sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const;
};
//-------------------------------------------------------------------------
// padthv1widget_palette::ColorButton
class padthv1widget_palette::ColorButton : public QPushButton
{
Q_OBJECT
Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
public:
ColorButton (QWidget *parent = nullptr);
const QBrush& brush() const;
void setBrush(const QBrush& b);
signals:
void changed();
protected slots:
void chooseColor();
protected:
void paintEvent(QPaintEvent *event);
private:
QBrush m_brush;
};
//-------------------------------------------------------------------------
// PaleteEditor::ColorEditor
class padthv1widget_palette::ColorEditor : public QWidget
{
Q_OBJECT
public:
ColorEditor(QWidget *parent = nullptr);
void setColor(const QColor &color);
QColor color() const;
bool changed() const;
signals:
void changed(QWidget *widget);
protected slots:
void colorChanged();
private:
padthv1widget_palette::ColorButton *m_button;
bool m_changed;
};
//-------------------------------------------------------------------------
// PaleteEditor::RoleEditor
class padthv1widget_palette::RoleEditor : public QWidget
{
Q_OBJECT
public:
RoleEditor(QWidget *parent = nullptr);
void setLabel(const QString &label);
void setEdited(bool on);
bool edited() const;
signals:
void changed(QWidget *widget);
protected slots:
void resetProperty();
private:
QLabel *m_label;
QToolButton *m_button;
bool m_edited;
};
#endif // __padthv1widget_palette_h
// end of padthv1widget_palette.h
padthv1-0.9.34/src/PaxHeaders/padthv1.cpp 0000644 0000000 0000000 00000000132 14554770535 015115 x ustar 00 30 mtime=1706291549.609007112
30 atime=1706291549.608007119
30 ctime=1706291549.609007112
padthv1-0.9.34/src/padthv1.cpp 0000644 0001750 0000144 00000153401 14554770535 015111 0 ustar 00rncbc users // padthv1.cpp
//
/****************************************************************************
Copyright (C) 2012-2024, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1.h"
#include "padthv1_sample.h"
#include "padthv1_wave.h"
#include "padthv1_ramp.h"
#include "padthv1_list.h"
#include "padthv1_filter.h"
#include "padthv1_formant.h"
#include "padthv1_fx.h"
#include "padthv1_reverb.h"
#include "padthv1_config.h"
#include "padthv1_controls.h"
#include "padthv1_programs.h"
#include "padthv1_tuning.h"
#include "padthv1_sched.h"
#ifdef CONFIG_DEBUG_0
#include
#endif
#include
//-------------------------------------------------------------------------
// padthv1_impl
//
// -- borrowed and revamped from synth.h of synth4
// Copyright (C) 2007 jorgen, linux-vst.com
//
const uint8_t MAX_VOICES = 64; // max polyphony
const uint8_t MAX_NOTES = 128;
const float MIN_ENV_MSECS = 0.5f; // min 500 usec per stage
const float MAX_ENV_MSECS = 5000.0f; // max 5 sec per stage (default)
const float DETUNE_SCALE = 0.5f;
const float PHASE_SCALE = 0.5f;
const float OCTAVE_SCALE = 12.0f;
const float TUNING_SCALE = 1.0f;
const float SWEEP_SCALE = 0.5f;
const float PITCH_SCALE = 0.5f;
const uint8_t MAX_DIRECT_NOTES = (MAX_VOICES >> 2);
// maximum helper
inline float padthv1_max ( float a, float b )
{
return (a > b ? a : b);
}
// hyperbolic-tangent fast approximation
inline float padthv1_tanhf ( const float x )
{
const float x2 = x * x;
return x * (27.0f + x2) / (27.0f + 9.0f * x2);
}
// sigmoids
inline float padthv1_sigmoid ( const float x )
{
// return 2.0f / (1.0f + ::expf(-5.0f * x)) - 1.0f;
return padthv1_tanhf(2.0f * x);
}
inline float padthv1_sigmoid_0 ( const float x, const float t0 )
{
const float t1 = 1.0f - t0;
#if 0
if (x > +t1)
return +t1 + t0 * padthv1_tanhf(+(x - t1) / t0);
else
if (x < -t1)
return -t1 - t0 * padthv1_tanhf(-(x + t1) / t0);
else
return x;
#else
return (x < -1.0f ? -t1 : (x > +1.0f ? t1 : t1 * x * (1.5f - 0.5f * x * x)));
#endif
}
inline float padthv1_sigmoid_1 ( const float x, const float t0 = 0.01f )
{
return 0.5f * (1.0f + padthv1_sigmoid_0(2.0f * x - 1.0f, t0));
}
// velocity hard-split curve
inline float padthv1_velocity ( const float x, const float p = 0.2f )
{
return ::powf(x, (1.0f - p));
}
// pitchbend curve
inline float padthv1_pow2f ( const float x )
{
// simplest power-of-2 straight linearization
// -- x argument valid in [-1, 1] interval
// return 1.0f + (x < 0.0f ? 0.5f : 1.0f) * x;
return ::powf(2.0f, x);
}
// convert note to frequency (hertz)
inline float padthv1_freq2 ( float delta )
{
return ::powf(2.0f, delta / 12.0f);
}
inline float padthv1_freq ( int note )
{
return (440.0f / 32.0f) * padthv1_freq2(float(note - 9));
}
// parameter port (basic)
class padthv1_port
{
public:
padthv1_port() : m_port(nullptr), m_value(0.0f), m_vport(0.0f) {}
virtual ~padthv1_port() {}
void set_port(float *port)
{ m_port = port; }
float *port() const
{ return m_port; }
virtual void set_value(float value)
{ m_value = value; if (m_port) m_vport = *m_port; }
float value() const
{ return m_value; }
float *value_ptr()
{ tick(1); return &m_value; }
virtual float tick(uint32_t /*nstep*/)
{
if (m_port && ::fabsf(*m_port - m_vport) > 0.001f)
set_value(*m_port);
return m_value;
}
float operator *()
{ return tick(1); }
private:
float *m_port;
float m_value;
float m_vport;
};
// parameter port (smoothed)
class padthv1_port2 : public padthv1_port
{
public:
padthv1_port2() : m_vtick(0.0f), m_vstep(0.0f), m_nstep(0) {}
static const uint32_t NSTEP = 32;
void set_value(float value)
{
m_vtick = padthv1_port::value();
m_nstep = NSTEP;
m_vstep = (value - m_vtick) / float(m_nstep);
padthv1_port::set_value(value);
}
float tick(uint32_t nstep)
{
if (m_nstep == 0)
return padthv1_port::tick(nstep);
if (m_nstep >= nstep) {
m_vtick += m_vstep * float(nstep);
m_nstep -= nstep;
} else {
m_vtick += m_vstep * float(m_nstep);
m_nstep = 0;
}
return m_vtick;
}
private:
float m_vtick;
float m_vstep;
uint32_t m_nstep;
};
// envelope
struct padthv1_env
{
// envelope stages
enum Stage { Idle = 0, Attack, Decay, Sustain, Release, End };
// per voice
struct State
{
// ctor.
State() : running(false), stage(Idle),
phase(0.0f), delta(0.0f), value(0.0f),
c1(1.0f), c0(0.0f), frames(0) {}
// process
float tick()
{
if (running && frames > 0) {
phase += delta;
value = c1 * phase * (2.0f - phase) + c0;
--frames;
}
return value;
}
// state
bool running;
Stage stage;
float phase;
float delta;
float value;
float c1, c0;
uint32_t frames;
};
void start(State *p)
{
p->running = true;
p->stage = Attack;
p->frames = uint32_t(*attack * *attack * max_frames);
if (p->frames < min_frames1) // prevent click on too fast attack
p->frames = min_frames1;
p->phase = 0.0f;
p->delta = 1.0f / float(p->frames);
p->value = 0.0f;
p->c1 = 1.0f;
p->c0 = 0.0f;
}
void next(State *p)
{
if (p->stage == Attack) {
p->stage = Decay;
p->frames = uint32_t(*decay * *decay * max_frames);
if (p->frames < min_frames2) // prevent click on too fast decay
p->frames = min_frames2;
p->phase = 0.0f;
p->delta = 1.0f / float(p->frames);
p->c1 = *sustain - 1.0f;
p->c0 = p->value;
}
else if (p->stage == Decay) {
p->running = false; // stay at this stage until note_off received
p->stage = Sustain;
p->frames = 0;
p->phase = 0.0f;
p->delta = 0.0f;
p->c1 = 0.0f;
p->c0 = p->value;
}
else if (p->stage == Release) {
p->running = false;
p->stage = End;
p->frames = 0;
p->phase = 0.0f;
p->delta = 0.0f;
p->value = 0.0f;
p->c1 = 0.0f;
p->c0 = 0.0f;
}
}
void note_off(State *p)
{
p->running = true;
p->stage = Release;
p->frames = uint32_t(*release * *release * max_frames);
if (p->frames < min_frames2) // prevent click on too fast release
p->frames = min_frames2;
p->phase = 0.0f;
p->delta = 1.0f / float(p->frames);
p->c1 = -(p->value);
p->c0 = p->value;
}
void note_off_fast(State *p)
{
p->running = true;
p->stage = Release;
p->frames = min_frames2;
p->phase = 0.0f;
p->delta = 1.0f / float(p->frames);
p->c1 = -(p->value);
p->c0 = p->value;
}
void restart(State *p, bool legato)
{
p->running = true;
if (legato) {
p->stage = Decay;
p->frames = min_frames2;
p->phase = 0.0f;
p->delta = 1.0f / float(p->frames);
p->c1 = *sustain - p->value;
p->c0 = 0.0f;
} else {
p->stage = Attack;
p->frames = uint32_t(*attack * *attack * max_frames);
if (p->frames < min_frames1)
p->frames = min_frames1;
p->phase = 0.0f;
p->delta = 1.0f / float(p->frames);
p->c1 = 1.0f;
p->c0 = 0.0f;
}
}
// parameters
padthv1_port attack;
padthv1_port decay;
padthv1_port sustain;
padthv1_port release;
uint32_t min_frames1;
uint32_t min_frames2;
uint32_t max_frames;
};
// midi control
struct padthv1_ctl
{
padthv1_ctl() { reset(); }
void reset()
{
pressure = 0.0f;
pitchbend = 1.0f;
modwheel = 0.0f;
panning = 0.0f;
volume = 1.0f;
sustain = false;
}
float pressure;
float pitchbend;
float modwheel;
float panning;
float volume;
bool sustain;
};
// dco
struct padthv1_gen
{
padthv1_port sample1;
padthv1_port width1;
padthv1_port scale1;
padthv1_port nh1;
padthv1_port apod1;
padthv1_port detune1;
padthv1_port glide1;
padthv1_port sample2;
padthv1_port width2;
padthv1_port scale2;
padthv1_port nh2;
padthv1_port apod2;
padthv1_port detune2;
padthv1_port glide2;
padthv1_port balance;
padthv1_port phase;
padthv1_port ringmod;
padthv1_port octave;
padthv1_port tuning;
padthv1_port envtime;
float sample1_0, freq1;
float sample2_0, freq2;
float envtime0;
};
// dcf
struct padthv1_dcf
{
padthv1_port enabled;
padthv1_port2 cutoff;
padthv1_port2 reso;
padthv1_port type;
padthv1_port slope;
padthv1_port2 envelope;
padthv1_env env;
};
// lfo
struct padthv1_voice;
struct padthv1_lfo
{
padthv1_port enabled;
padthv1_port shape;
padthv1_port width;
padthv1_port2 bpm;
padthv1_port2 rate;
padthv1_port sync;
padthv1_port2 sweep;
padthv1_port2 pitch;
padthv1_port2 balance;
padthv1_port2 ringmod;
padthv1_port2 cutoff;
padthv1_port2 reso;
padthv1_port2 panning;
padthv1_port2 volume;
padthv1_env env;
padthv1_voice *psync;
};
// dca
struct padthv1_dca
{
padthv1_port volume;
padthv1_env env;
};
// def (ranges)
struct padthv1_def
{
padthv1_port pitchbend;
padthv1_port modwheel;
padthv1_port pressure;
padthv1_port velocity;
padthv1_port channel;
padthv1_port mono;
};
// out (mix)
struct padthv1_out
{
padthv1_port width;
padthv1_port panning;
padthv1_port fxsend;
padthv1_port volume;
};
// chorus (fx)
struct padthv1_cho
{
padthv1_port wet;
padthv1_port delay;
padthv1_port feedb;
padthv1_port rate;
padthv1_port mod;
};
// flanger (fx)
struct padthv1_fla
{
padthv1_port wet;
padthv1_port delay;
padthv1_port feedb;
padthv1_port daft;
};
// phaser (fx)
struct padthv1_pha
{
padthv1_port wet;
padthv1_port rate;
padthv1_port feedb;
padthv1_port depth;
padthv1_port daft;
};
// delay (fx)
struct padthv1_del
{
padthv1_port wet;
padthv1_port delay;
padthv1_port feedb;
padthv1_port bpm;
};
// reverb
struct padthv1_rev
{
padthv1_port wet;
padthv1_port room;
padthv1_port damp;
padthv1_port feedb;
padthv1_port width;
};
// dynamic(compressor/limiter)
struct padthv1_dyn
{
padthv1_port compress;
padthv1_port limiter;
};
// keyboard/note range
struct padthv1_key
{
padthv1_port low;
padthv1_port high;
bool is_note(int key)
{
return (key >= int(*low) && int(*high) >= key);
}
};
// glide (portamento)
struct padthv1_glide
{
padthv1_glide(float& last) : m_last(last) { reset(); }
void reset( uint32_t frames = 0, float freq = 0.0f )
{
m_frames = frames;
if (m_frames > 0) {
m_freq = m_last;
m_step = (m_last - freq) / float(m_frames);
} else {
m_freq = 0.0f;
m_step = 0.0f;
}
m_last = freq;
}
float tick()
{
if (m_frames > 0) {
m_freq -= m_step;
--m_frames;
}
return m_freq;
}
private:
uint32_t m_frames;
float m_step;
float m_freq;
float& m_last;
};
// balancing smoother (1 parameter)
class padthv1_bal : public padthv1_ramp2
{
public:
padthv1_bal() : padthv1_ramp2(2) {}
protected:
float evaluate(uint16_t i)
{
padthv1_ramp2::update();
const float wbal = 0.25f * M_PI
* (1.0f + m_param1_v)
* (1.0f + m_param2_v);
return M_SQRT2 * (i == 0 ? ::cosf(wbal) : ::sinf(wbal));
}
};
// balance smoother (1 parameters)
class padthv1_bal1 : public padthv1_ramp1
{
public:
padthv1_bal1() : padthv1_ramp1(2) {}
protected:
float evaluate(uint16_t i)
{
padthv1_ramp1::update();
const float wbal = 0.25f * M_PI
* (1.0f + m_param1_v);
return M_SQRT2 * (i & 1 ? ::sinf(wbal) : ::cosf(wbal));
}
};
// balance smoother (2 parameters)
class padthv1_bal2 : public padthv1_ramp2
{
public:
padthv1_bal2() : padthv1_ramp2(2) {}
protected:
float evaluate(uint16_t i)
{
padthv1_ramp2::update();
const float wbal = 0.25f * M_PI
* (1.0f + m_param1_v)
* (1.0f + m_param2_v);
return M_SQRT2 * (i & 1 ? ::sinf(wbal) : ::cosf(wbal));
}
};
// pressure smoother (3 parameters)
class padthv1_pre : public padthv1_ramp3
{
public:
padthv1_pre() : padthv1_ramp3() {}
protected:
float evaluate(uint16_t)
{
padthv1_ramp3::update();
return m_param1_v * padthv1_max(m_param2_v, m_param3_v);
}
};
// common phasor (LFO sync)
class padthv1_phasor
{
public:
padthv1_phasor(uint32_t nsize = 1024)
: m_nsize(nsize), m_nframes(0) {}
void process(uint32_t nframes)
{
m_nframes += nframes;
while (m_nframes >= m_nsize)
m_nframes -= m_nsize;
}
float pshift() const
{ return float(m_nframes) / float(m_nsize); }
private:
uint32_t m_nsize;
uint32_t m_nframes;
};
// forward decl.
class padthv1_impl;
// voice
struct padthv1_voice : public padthv1_list
{
padthv1_voice(padthv1_impl *pImpl);
int note; // voice note
float vel; // key velocity
float pre; // key pressure/after-touch
padthv1_generator gen1_osc1, gen1_osc2; // generators aka. oscillators
float gen1_freq1, gen1_sample1; // frequency and phase
float gen1_freq2, gen1_sample2;
padthv1_oscillator lfo1; // low frequency oscilattor
float lfo1_sample;
padthv1_bal gen1_bal; // oscillator balance
float gen1_balance;
padthv1_filter1 dcf11, dcf12; // filters
padthv1_filter2 dcf13, dcf14;
padthv1_filter3 dcf15, dcf16;
padthv1_formant dcf17, dcf18;
padthv1_env::State dca1_env; // envelope states
padthv1_env::State dcf1_env;
padthv1_env::State lfo1_env;
padthv1_glide gen1_glide1, gen1_glide2; // glides (portamento)
padthv1_pre dca1_pre;
float out1_panning;
float out1_volume;
padthv1_bal1 out1_pan; // output panning
padthv1_ramp1 out1_vol; // output volume
bool sustain;
};
// MIDI input asynchronous status notification
class padthv1_midi_in : public padthv1_sched
{
public:
padthv1_midi_in (padthv1 *pSampl)
: padthv1_sched(pSampl, MidiIn),
m_enabled(false), m_count(0) {}
void schedule_event()
{ if (m_enabled && ++m_count < 2) schedule(-1); }
void schedule_note(int key, int vel)
{ if (m_enabled) schedule((vel << 7) | key); }
void process(int) {}
void enabled(bool on)
{ m_enabled = on; m_count = 0; }
uint32_t count()
{
const uint32_t ret = m_count;
m_count = 0;
return ret;
}
private:
bool m_enabled;
uint32_t m_count;
};
// micro-tuning/instance implementation
class padthv1_tun
{
public:
padthv1_tun() : enabled(false), refPitch(440.0f), refNote(69) {}
bool enabled;
float refPitch;
int refNote;
QString scaleFile;
QString keyMapFile;
};
// polyphonic synth implementation
class padthv1_impl
{
public:
padthv1_impl(padthv1 *pSampl, uint16_t nchannels, float srate, uint32_t nsize);
~padthv1_impl();
void setChannels(uint16_t nchannels);
uint16_t channels() const;
void setSampleRate(float srate);
float sampleRate() const;
void setBufferSize(uint32_t nsize);
uint32_t bufferSize() const;
void setTempo(float bpm);
float tempo() const;
void setParamPort(padthv1::ParamIndex index, float *pfParam);
padthv1_port *paramPort(padthv1::ParamIndex index);
void setParamValue(padthv1::ParamIndex index, float fValue);
float paramValue(padthv1::ParamIndex index);
padthv1_controls *controls();
padthv1_programs *programs();
void setTuningEnabled(bool enabled);
bool isTuningEnabled() const;
void setTuningRefPitch(float refPitch);
float tuningRefPitch() const;
void setTuningRefNote(int refNote);
int tuningRefNote() const;
void setTuningScaleFile(const char *pszScaleFile);
const char *tuningScaleFile() const;
void setTuningKeyMapFile(const char *pszKeyMapFile);
const char *tuningKeyMapFile() const;
void resetTuning();
void process_midi(uint8_t *data, uint32_t size);
void process(float **ins, float **outs, uint32_t nframes);
void stabilize();
void reset();
void reset_test()
{
if (m_gen1.sample1_0 != *m_gen1.sample1) {
m_gen1.sample1_0 = *m_gen1.sample1;
m_gen1.freq1 = padthv1_freq(m_gen1.sample1_0);
}
gen1_sample1.reset_test(m_gen1.freq1,
*m_gen1.width1, *m_gen1.scale1, uint16_t(*m_gen1.nh1),
padthv1_sample::Apodizer(*m_gen1.apod1));
if (m_gen1.sample2_0 != *m_gen1.sample2) {
m_gen1.sample2_0 = *m_gen1.sample2;
m_gen1.freq2 = padthv1_freq(m_gen1.sample2_0);
}
gen1_sample2.reset_test(m_gen1.freq2,
*m_gen1.width2, *m_gen1.scale2, uint16_t(*m_gen1.nh2),
padthv1_sample::Apodizer(*m_gen1.apod2));
}
void midiInEnabled(bool on);
uint32_t midiInCount();
void directNoteOn(int note, int vel);
bool running(bool on);
padthv1_sample gen1_sample1, gen1_sample2;
padthv1_wave_lf lfo1_wave;
float gen1_last1, gen1_last2;
padthv1_formant::Impl dcf1_formant;
protected:
void updateEnvTimes();
void allSoundOff();
void allControllersOff();
void allNotesOff();
void allSustainOff();
void allSustainOn();
float get_bpm ( float bpm ) const
{ return (bpm > 0.0f ? bpm : m_bpm); }
padthv1_voice *alloc_voice ()
{
padthv1_voice *pv = m_free_list.next();
if (pv) {
m_free_list.remove(pv);
m_play_list.append(pv);
++m_nvoices;
}
return pv;
}
void free_voice ( padthv1_voice *pv )
{
if (m_lfo1.psync == pv)
m_lfo1.psync = nullptr;
m_play_list.remove(pv);
m_free_list.append(pv);
--m_nvoices;
}
void alloc_sfxs(uint32_t nsize);
private:
padthv1_config m_config;
padthv1_controls m_controls;
padthv1_programs m_programs;
padthv1_midi_in m_midi_in;
padthv1_tun m_tun;
uint16_t m_nchannels;
float m_srate;
float m_bpm;
float m_freqs[MAX_NOTES];
padthv1_ctl m_ctl1;
padthv1_gen m_gen1;
padthv1_dcf m_dcf1;
padthv1_lfo m_lfo1;
padthv1_dca m_dca1;
padthv1_out m_out1;
padthv1_def m_def;
padthv1_cho m_cho;
padthv1_fla m_fla;
padthv1_pha m_pha;
padthv1_del m_del;
padthv1_rev m_rev;
padthv1_dyn m_dyn;
padthv1_key m_key;
padthv1_voice **m_voices;
padthv1_voice *m_notes[MAX_NOTES];
padthv1_list m_free_list;
padthv1_list m_play_list;
padthv1_ramp1 m_wid1;
padthv1_bal2 m_pan1;
padthv1_ramp3 m_vol1;
float **m_sfxs;
uint32_t m_nsize;
padthv1_fx_chorus m_chorus;
padthv1_fx_flanger *m_flanger;
padthv1_fx_phaser *m_phaser;
padthv1_fx_delay *m_delay;
padthv1_fx_comp *m_comp;
padthv1_reverb m_reverb;
// process direct note on/off...
volatile uint16_t m_direct_note;
struct direct_note {
uint8_t status, note, vel;
} m_direct_notes[MAX_DIRECT_NOTES];
volatile int m_nvoices;
volatile bool m_running;
};
// voice constructor
padthv1_voice::padthv1_voice ( padthv1_impl *pImpl ) :
note(-1),
vel(0.0f),
pre(0.0f),
gen1_osc1(&pImpl->gen1_sample1),
gen1_osc2(&pImpl->gen1_sample2),
gen1_freq1(0.0f), gen1_sample1(0.0f),
gen1_freq2(0.0f), gen1_sample2(0.0f),
lfo1(&pImpl->lfo1_wave),
lfo1_sample(0.0f),
dcf17(&pImpl->dcf1_formant),
dcf18(&pImpl->dcf1_formant),
gen1_glide1(pImpl->gen1_last1),
gen1_glide2(pImpl->gen1_last2),
out1_panning(0.0f),
out1_volume(1.0f),
sustain(false)
{
}
// engine constructor
padthv1_impl::padthv1_impl (
padthv1 *pSampl, uint16_t nchannels, float srate, uint32_t nsize )
: gen1_sample1(pSampl, 1), gen1_sample2(pSampl, 2),
m_controls(pSampl), m_programs(pSampl),
m_midi_in(pSampl), m_bpm(180.0f), m_nvoices(0), m_running(false)
{
// null sample freqs.
m_gen1.sample1_0 = m_gen1.sample2_0 = 0.0f;
m_gen1.freq1 = m_gen1.freq2 = 0.0f;
// max env. stage length (default)
m_gen1.envtime0 = 0.0001f * MAX_ENV_MSECS;
// glide note.
gen1_last1 = gen1_last2 = 0.0f;
// allocate voice pool.
m_voices = new padthv1_voice * [MAX_VOICES];
for (int i = 0; i < MAX_VOICES; ++i) {
m_voices[i] = new padthv1_voice(this);
m_free_list.append(m_voices[i]);
}
for (int note = 0; note < MAX_NOTES; ++note)
m_notes[note] = nullptr;
// local buffers none yet
m_sfxs = nullptr;
m_nsize = 0;
// flangers none yet
m_flanger = nullptr;
// phasers none yet
m_phaser = nullptr;
// delays none yet
m_delay = nullptr;
// compressors none yet
m_comp = nullptr;
// Micro-tuning support, if any...
resetTuning();
// load controllers & programs database...
m_config.loadControls(&m_controls);
m_config.loadPrograms(&m_programs);
// number of channels
setChannels(nchannels);
// set default sample rate
setSampleRate(srate);
// set default buffer size
setBufferSize(nsize);
// reset all voices
allControllersOff();
allNotesOff();
running(true);
}
// destructor
padthv1_impl::~padthv1_impl (void)
{
#if 0
// DO NOT save programs database here:
// prevent multi-instance clash...
m_config.savePrograms(&m_programs);
#endif
// deallocate voice pool.
for (int i = 0; i < MAX_VOICES; ++i)
delete m_voices[i];
delete [] m_voices;
// deallocate local buffers
alloc_sfxs(0);
// deallocate channels
setChannels(0);
}
void padthv1_impl::setChannels ( uint16_t nchannels )
{
m_nchannels = nchannels;
// deallocate flangers
if (m_flanger) {
delete [] m_flanger;
m_flanger = nullptr;
}
// deallocate phasers
if (m_phaser) {
delete [] m_phaser;
m_phaser = nullptr;
}
// deallocate delays
if (m_delay) {
delete [] m_delay;
m_delay = nullptr;
}
// deallocate compressors
if (m_comp) {
delete [] m_comp;
m_comp = nullptr;
}
}
uint16_t padthv1_impl::channels (void) const
{
return m_nchannels;
}
void padthv1_impl::setSampleRate ( float srate )
{
// set internal sample rate
m_srate = srate;
// update waves sample rate
gen1_sample1.setSampleRate(m_srate);
gen1_sample2.setSampleRate(m_srate);
lfo1_wave.setSampleRate(m_srate);
updateEnvTimes();
dcf1_formant.setSampleRate(m_srate);
}
float padthv1_impl::sampleRate (void) const
{
return m_srate;
}
void padthv1_impl::setBufferSize ( uint32_t nsize )
{
// set nominal buffer size
if (m_nsize < nsize) alloc_sfxs(nsize);
}
uint32_t padthv1_impl::bufferSize (void) const
{
return m_nsize;
}
void padthv1_impl::setTempo ( float bpm )
{
// set nominal tempo (BPM)
m_bpm = bpm;
}
float padthv1_impl::tempo (void) const
{
return m_bpm;
}
// allocate local buffers
void padthv1_impl::alloc_sfxs ( uint32_t nsize )
{
if (m_sfxs) {
for (uint16_t k = 0; k < m_nchannels; ++k)
delete [] m_sfxs[k];
delete [] m_sfxs;
m_sfxs = nullptr;
m_nsize = 0;
}
if (m_nsize < nsize) {
m_nsize = nsize;
m_sfxs = new float * [m_nchannels];
for (uint16_t k = 0; k < m_nchannels; ++k)
m_sfxs[k] = new float [m_nsize];
}
}
void padthv1_impl::updateEnvTimes (void)
{
// update envelope range times in frames
const float srate_ms = 0.001f * m_srate;
float envtime_msecs = 10000.0f * m_gen1.envtime0;
if (envtime_msecs < MIN_ENV_MSECS)
envtime_msecs = (gen1_sample1.size() >> 1) / srate_ms;
if (envtime_msecs < MIN_ENV_MSECS)
envtime_msecs = (gen1_sample2.size() >> 1) / srate_ms;
if (envtime_msecs < MIN_ENV_MSECS)
envtime_msecs = MIN_ENV_MSECS * 4.0f;
const uint32_t min_frames1 = uint32_t(srate_ms * MIN_ENV_MSECS);
const uint32_t min_frames2 = (min_frames1 << 2);
const uint32_t max_frames = uint32_t(srate_ms * envtime_msecs);
m_dcf1.env.min_frames1 = min_frames1;
m_dcf1.env.min_frames2 = min_frames2;
m_dcf1.env.max_frames = max_frames;
m_lfo1.env.min_frames1 = min_frames1;
m_lfo1.env.min_frames2 = min_frames2;
m_lfo1.env.max_frames = max_frames;
m_dca1.env.min_frames1 = min_frames1;
m_dca1.env.min_frames2 = min_frames2;
m_dca1.env.max_frames = max_frames;
}
void padthv1_impl::setParamPort ( padthv1::ParamIndex index, float *pfParam )
{
static float s_fDummy = 0.0f;
if (pfParam == nullptr)
pfParam = &s_fDummy;
padthv1_port *pParamPort = paramPort(index);
if (pParamPort)
pParamPort->set_port(pfParam);
// check null connections.
if (pfParam == &s_fDummy)
return;
// reset ramps after port (re)connection.
switch (index) {
case padthv1::OUT1_VOLUME:
case padthv1::DCA1_VOLUME:
m_vol1.reset(
m_out1.volume.value_ptr(),
m_dca1.volume.value_ptr(),
&m_ctl1.volume);
break;
case padthv1::OUT1_WIDTH:
m_wid1.reset(
m_out1.width.value_ptr());
break;
case padthv1::OUT1_PANNING:
m_pan1.reset(
m_out1.panning.value_ptr(),
&m_ctl1.panning);
break;
default:
break;
}
}
padthv1_port *padthv1_impl::paramPort ( padthv1::ParamIndex index )
{
padthv1_port *pParamPort = nullptr;
switch (index) {
case padthv1::GEN1_SAMPLE1: pParamPort = &m_gen1.sample1; break;
case padthv1::GEN1_WIDTH1: pParamPort = &m_gen1.width1; break;
case padthv1::GEN1_SCALE1: pParamPort = &m_gen1.scale1; break;
case padthv1::GEN1_NH1: pParamPort = &m_gen1.nh1; break;
case padthv1::GEN1_APOD1: pParamPort = &m_gen1.apod1; break;
case padthv1::GEN1_DETUNE1: pParamPort = &m_gen1.detune1; break;
case padthv1::GEN1_GLIDE1: pParamPort = &m_gen1.glide1; break;
case padthv1::GEN1_SAMPLE2: pParamPort = &m_gen1.sample2; break;
case padthv1::GEN1_WIDTH2: pParamPort = &m_gen1.width2; break;
case padthv1::GEN1_SCALE2: pParamPort = &m_gen1.scale2; break;
case padthv1::GEN1_NH2: pParamPort = &m_gen1.nh2; break;
case padthv1::GEN1_APOD2: pParamPort = &m_gen1.apod2; break;
case padthv1::GEN1_DETUNE2: pParamPort = &m_gen1.detune2; break;
case padthv1::GEN1_GLIDE2: pParamPort = &m_gen1.glide2; break;
case padthv1::GEN1_BALANCE: pParamPort = &m_gen1.balance; break;
case padthv1::GEN1_PHASE: pParamPort = &m_gen1.phase; break;
case padthv1::GEN1_RINGMOD: pParamPort = &m_gen1.ringmod; break;
case padthv1::GEN1_OCTAVE: pParamPort = &m_gen1.octave; break;
case padthv1::GEN1_TUNING: pParamPort = &m_gen1.tuning; break;
case padthv1::GEN1_ENVTIME: pParamPort = &m_gen1.envtime; break;
case padthv1::DCF1_ENABLED: pParamPort = &m_dcf1.enabled; break;
case padthv1::DCF1_CUTOFF: pParamPort = &m_dcf1.cutoff; break;
case padthv1::DCF1_RESO: pParamPort = &m_dcf1.reso; break;
case padthv1::DCF1_TYPE: pParamPort = &m_dcf1.type; break;
case padthv1::DCF1_SLOPE: pParamPort = &m_dcf1.slope; break;
case padthv1::DCF1_ENVELOPE: pParamPort = &m_dcf1.envelope; break;
case padthv1::DCF1_ATTACK: pParamPort = &m_dcf1.env.attack; break;
case padthv1::DCF1_DECAY: pParamPort = &m_dcf1.env.decay; break;
case padthv1::DCF1_SUSTAIN: pParamPort = &m_dcf1.env.sustain; break;
case padthv1::DCF1_RELEASE: pParamPort = &m_dcf1.env.release; break;
case padthv1::LFO1_ENABLED: pParamPort = &m_lfo1.enabled; break;
case padthv1::LFO1_SHAPE: pParamPort = &m_lfo1.shape; break;
case padthv1::LFO1_WIDTH: pParamPort = &m_lfo1.width; break;
case padthv1::LFO1_BPM: pParamPort = &m_lfo1.bpm; break;
case padthv1::LFO1_RATE: pParamPort = &m_lfo1.rate; break;
case padthv1::LFO1_SYNC: pParamPort = &m_lfo1.sync; break;
case padthv1::LFO1_SWEEP: pParamPort = &m_lfo1.sweep; break;
case padthv1::LFO1_PITCH: pParamPort = &m_lfo1.pitch; break;
case padthv1::LFO1_BALANCE: pParamPort = &m_lfo1.balance; break;
case padthv1::LFO1_RINGMOD: pParamPort = &m_lfo1.ringmod; break;
case padthv1::LFO1_CUTOFF: pParamPort = &m_lfo1.cutoff; break;
case padthv1::LFO1_RESO: pParamPort = &m_lfo1.reso; break;
case padthv1::LFO1_PANNING: pParamPort = &m_lfo1.panning; break;
case padthv1::LFO1_VOLUME: pParamPort = &m_lfo1.volume; break;
case padthv1::LFO1_ATTACK: pParamPort = &m_lfo1.env.attack; break;
case padthv1::LFO1_DECAY: pParamPort = &m_lfo1.env.decay; break;
case padthv1::LFO1_SUSTAIN: pParamPort = &m_lfo1.env.sustain; break;
case padthv1::LFO1_RELEASE: pParamPort = &m_lfo1.env.release; break;
case padthv1::DCA1_VOLUME: pParamPort = &m_dca1.volume; break;
case padthv1::DCA1_ATTACK: pParamPort = &m_dca1.env.attack; break;
case padthv1::DCA1_DECAY: pParamPort = &m_dca1.env.decay; break;
case padthv1::DCA1_SUSTAIN: pParamPort = &m_dca1.env.sustain; break;
case padthv1::DCA1_RELEASE: pParamPort = &m_dca1.env.release; break;
case padthv1::OUT1_WIDTH: pParamPort = &m_out1.width; break;
case padthv1::OUT1_PANNING: pParamPort = &m_out1.panning; break;
case padthv1::OUT1_FXSEND: pParamPort = &m_out1.fxsend; break;
case padthv1::OUT1_VOLUME: pParamPort = &m_out1.volume; break;
case padthv1::DEF1_PITCHBEND: pParamPort = &m_def.pitchbend; break;
case padthv1::DEF1_MODWHEEL: pParamPort = &m_def.modwheel; break;
case padthv1::DEF1_PRESSURE: pParamPort = &m_def.pressure; break;
case padthv1::DEF1_VELOCITY: pParamPort = &m_def.velocity; break;
case padthv1::DEF1_CHANNEL: pParamPort = &m_def.channel; break;
case padthv1::DEF1_MONO: pParamPort = &m_def.mono; break;
case padthv1::CHO1_WET: pParamPort = &m_cho.wet; break;
case padthv1::CHO1_DELAY: pParamPort = &m_cho.delay; break;
case padthv1::CHO1_FEEDB: pParamPort = &m_cho.feedb; break;
case padthv1::CHO1_RATE: pParamPort = &m_cho.rate; break;
case padthv1::CHO1_MOD: pParamPort = &m_cho.mod; break;
case padthv1::FLA1_WET: pParamPort = &m_fla.wet; break;
case padthv1::FLA1_DELAY: pParamPort = &m_fla.delay; break;
case padthv1::FLA1_FEEDB: pParamPort = &m_fla.feedb; break;
case padthv1::FLA1_DAFT: pParamPort = &m_fla.daft; break;
case padthv1::PHA1_WET: pParamPort = &m_pha.wet; break;
case padthv1::PHA1_RATE: pParamPort = &m_pha.rate; break;
case padthv1::PHA1_FEEDB: pParamPort = &m_pha.feedb; break;
case padthv1::PHA1_DEPTH: pParamPort = &m_pha.depth; break;
case padthv1::PHA1_DAFT: pParamPort = &m_pha.daft; break;
case padthv1::DEL1_WET: pParamPort = &m_del.wet; break;
case padthv1::DEL1_DELAY: pParamPort = &m_del.delay; break;
case padthv1::DEL1_FEEDB: pParamPort = &m_del.feedb; break;
case padthv1::DEL1_BPM: pParamPort = &m_del.bpm; break;
case padthv1::REV1_WET: pParamPort = &m_rev.wet; break;
case padthv1::REV1_ROOM: pParamPort = &m_rev.room; break;
case padthv1::REV1_DAMP: pParamPort = &m_rev.damp; break;
case padthv1::REV1_FEEDB: pParamPort = &m_rev.feedb; break;
case padthv1::REV1_WIDTH: pParamPort = &m_rev.width; break;
case padthv1::DYN1_COMPRESS: pParamPort = &m_dyn.compress; break;
case padthv1::DYN1_LIMITER: pParamPort = &m_dyn.limiter; break;
case padthv1::KEY1_LOW: pParamPort = &m_key.low; break;
case padthv1::KEY1_HIGH: pParamPort = &m_key.high; break;
default: break;
}
return pParamPort;
}
void padthv1_impl::setParamValue ( padthv1::ParamIndex index, float fValue )
{
padthv1_port *pParamPort = paramPort(index);
if (pParamPort)
pParamPort->set_value(fValue);
}
float padthv1_impl::paramValue ( padthv1::ParamIndex index )
{
padthv1_port *pParamPort = paramPort(index);
return (pParamPort ? pParamPort->value() : 0.0f);
}
// handle midi input
void padthv1_impl::process_midi ( uint8_t *data, uint32_t size )
{
for (uint32_t i = 0; i < size; ++i) {
// channel status
const int channel = (data[i] & 0x0f) + 1;
const int status = (data[i] & 0xf0);
// channel filter
const int ch = int(*m_def.channel);
const int on = (ch == 0 || ch == channel);
// all system common/real-time ignored
if (status == 0xf0)
continue;
// check data size (#1)
if (++i >= size)
break;
const int key = (data[i] & 0x7f);
// program change
if (status == 0xc0) {
if (on) m_programs.prog_change(key);
continue;
}
// channel aftertouch
if (status == 0xd0) {
if (on) m_ctl1.pressure = float(key) / 127.0f;
continue;
}
// check data size (#2)
if (++i >= size)
break;
// channel value
const int value = (data[i] & 0x7f);
// channel/controller filter
if (!on) {
if (status == 0xb0)
m_controls.process_enqueue(channel, key, value);
continue;
}
// note on
if (status == 0x90 && value > 0) {
if (!m_key.is_note(key))
continue;
padthv1_voice *pv;
// mono voice modes
if (*m_def.mono > 0.0f) {
int n = 0;
for (pv = m_play_list.next(); pv; pv = pv->next()) {
if (pv->note >= 0
&& pv->dca1_env.stage != padthv1_env::Release) {
m_dcf1.env.note_off_fast(&pv->dcf1_env);
m_lfo1.env.note_off_fast(&pv->lfo1_env);
m_dca1.env.note_off_fast(&pv->dca1_env);
if (++n > 1) { // there shall be only one
m_notes[pv->note] = nullptr;
pv->note = -1;
}
}
}
}
pv = m_notes[key];
if (pv && pv->note >= 0/* && !m_ctl1.sustain*/) {
// retrigger fast release
m_dcf1.env.note_off_fast(&pv->dcf1_env);
m_lfo1.env.note_off_fast(&pv->lfo1_env);
m_dca1.env.note_off_fast(&pv->dca1_env);
m_notes[pv->note] = nullptr;
pv->note = -1;
}
// find free voice
pv = alloc_voice();
if (pv) {
// waveform
pv->note = key;
// velocity
const float vel = float(value) / 127.0f;
// quadratic velocity law
pv->vel = padthv1_velocity(vel * vel, *m_def.velocity);
// balance
pv->gen1_balance = 0.0f;
pv->gen1_bal.reset(m_gen1.balance.value_ptr(), &pv->gen1_balance);
// pressure/after-touch
pv->pre = 0.0f;
pv->dca1_pre.reset(
m_def.pressure.value_ptr(),
&m_ctl1.pressure, &pv->pre);
// frequencies
const float gen1_tuning
= *m_gen1.octave * OCTAVE_SCALE
+ *m_gen1.tuning * TUNING_SCALE;
const float gen1_detune1
= *m_gen1.detune1 * DETUNE_SCALE;
const float gen1_detune2
= *m_gen1.detune2 * DETUNE_SCALE;
pv->gen1_freq1 = m_freqs[key] * padthv1_freq2(gen1_tuning + gen1_detune1);
pv->gen1_freq2 = m_freqs[key] * padthv1_freq2(gen1_tuning + gen1_detune2);
// phases
const float gen1_phase = *m_gen1.phase * PHASE_SCALE;
pv->gen1_sample1 = pv->gen1_osc1.start( 0.0f, pv->gen1_freq1);
pv->gen1_sample2 = pv->gen1_osc2.start(gen1_phase, pv->gen1_freq2);
// filters
const int dcf1_type = int(*m_dcf1.type);
pv->dcf11.reset(padthv1_filter1::Type(dcf1_type));
pv->dcf12.reset(padthv1_filter1::Type(dcf1_type));
pv->dcf13.reset(padthv1_filter2::Type(dcf1_type));
pv->dcf14.reset(padthv1_filter2::Type(dcf1_type));
pv->dcf15.reset(padthv1_filter3::Type(dcf1_type));
pv->dcf16.reset(padthv1_filter3::Type(dcf1_type));
// formant filters
const float dcf1_cutoff = *m_dcf1.cutoff;
const float dcf1_reso = *m_dcf1.reso;
pv->dcf17.reset_filters(dcf1_cutoff, dcf1_reso);
pv->dcf18.reset_filters(dcf1_cutoff, dcf1_reso);
// envelopes
m_dcf1.env.start(&pv->dcf1_env);
m_lfo1.env.start(&pv->lfo1_env);
m_dca1.env.start(&pv->dca1_env);
// lfos
const float lfo1_pshift
= (m_lfo1.psync ? m_lfo1.psync->lfo1.pshift() : 0.0f);
pv->lfo1_sample = pv->lfo1.start(lfo1_pshift);
if (*m_lfo1.sync > 0.0f && m_lfo1.psync == nullptr)
m_lfo1.psync = pv;
// glides (portamentoa)
const float gen1_frames1
= uint32_t(*m_gen1.glide1 * *m_gen1.glide1 * m_srate);
const float gen1_frames2
= uint32_t(*m_gen1.glide2 * *m_gen1.glide2 * m_srate);
pv->gen1_glide1.reset(gen1_frames1, pv->gen1_freq1);
pv->gen1_glide2.reset(gen1_frames2, pv->gen1_freq2);
// panning
pv->out1_panning = 0.0f;
pv->out1_pan.reset(&pv->out1_panning);
// volume
pv->out1_volume = 1.0f;
pv->out1_vol.reset(&pv->out1_volume);
// sustain
pv->sustain = false;
// allocated
m_notes[key] = pv;
}
m_midi_in.schedule_note(key, value);
}
// note off
else if (status == 0x80 || (status == 0x90 && value == 0)) {
if (!m_key.is_note(key))
continue;
padthv1_voice *pv = m_notes[key];
if (pv && pv->note >= 0) {
if (m_ctl1.sustain)
pv->sustain = true;
else
if (!pv->sustain) {
if (pv->dca1_env.stage != padthv1_env::Release) {
m_dca1.env.note_off(&pv->dca1_env);
m_dcf1.env.note_off(&pv->dcf1_env);
m_lfo1.env.note_off(&pv->lfo1_env);
}
m_notes[pv->note] = nullptr;
pv->note = -1;
// mono legato?
if (*m_def.mono > 0.0f) {
do pv = pv->prev(); while (pv && pv->note < 0);
if (pv && pv->note >= 0) {
const bool legato = (*m_def.mono > 1.0f);
m_dcf1.env.restart(&pv->dcf1_env, legato);
m_lfo1.env.restart(&pv->lfo1_env, legato);
m_dca1.env.restart(&pv->dca1_env, legato);
m_notes[pv->note] = pv;
}
}
}
}
m_midi_in.schedule_note(key, 0);
}
// key pressure/poly.aftertouch
else if (status == 0xa0) {
if (!m_key.is_note(key))
continue;
padthv1_voice *pv = m_notes[key];
if (pv && pv->note >= 0)
pv->pre = *m_def.pressure * float(value) / 127.0f;
}
// control change
else if (status == 0xb0) {
switch (key) {
case 0x00:
// bank-select MSB (cc#0)
m_programs.bank_select_msb(value);
break;
case 0x01:
// modulation wheel (cc#1)
m_ctl1.modwheel = *m_def.modwheel * float(value) / 127.0f;
break;
case 0x07:
// channel volume (cc#7)
m_ctl1.volume = float(value) / 127.0f;
break;
case 0x0a:
// channel panning (cc#10)
m_ctl1.panning = float(value - 64) / 64.0f;
break;
case 0x20:
// bank-select LSB (cc#32)
m_programs.bank_select_lsb(value);
break;
case 0x40:
// sustain/damper pedal (cc#64)
if (m_ctl1.sustain && value < 64)
allSustainOff();
m_ctl1.sustain = bool(value >= 64);
break;
case 0x42:
// sustenuto pedal (cc#66)
if (value < 64)
allSustainOff();
else
allSustainOn();
break;
case 0x78:
// all sound off (cc#120)
allSoundOff();
break;
case 0x79:
// all controllers off (cc#121)
allControllersOff();
break;
case 0x7b:
// all notes off (cc#123)
allNotesOff();
break;
}
// process controllers...
m_controls.process_enqueue(channel, key, value);
}
// pitch bend
else if (status == 0xe0) {
const float pitchbend = float(key + (value << 7) - 0x2000) / 8192.0f;
m_ctl1.pitchbend = padthv1_pow2f(*m_def.pitchbend * pitchbend);
}
}
// process pending controllers...
m_controls.process_dequeue();
// asynchronous event notification...
m_midi_in.schedule_event();
}
// all controllers off
void padthv1_impl::allControllersOff (void)
{
m_ctl1.reset();
}
// all sound off
void padthv1_impl::allSoundOff (void)
{
m_chorus.setSampleRate(m_srate);
m_chorus.reset();
for (uint16_t k = 0; k < m_nchannels; ++k) {
m_phaser[k].setSampleRate(m_srate);
m_delay[k].setSampleRate(m_srate);
m_comp[k].setSampleRate(m_srate);
m_flanger[k].reset();
m_phaser[k].reset();
m_delay[k].reset();
m_comp[k].reset();
}
m_reverb.setSampleRate(m_srate);
m_reverb.reset();
}
// all notes off
void padthv1_impl::allNotesOff (void)
{
padthv1_voice *pv = m_play_list.next();
while (pv) {
if (pv->note >= 0)
m_notes[pv->note] = nullptr;
free_voice(pv);
pv = m_play_list.next();
}
gen1_last1 = gen1_last2 = 0.0f;
m_lfo1.psync = nullptr;
m_direct_note = 0;
}
// all sustained notes off
void padthv1_impl::allSustainOff (void)
{
padthv1_voice *pv = m_play_list.next();
while (pv) {
if (pv->note >= 0 && pv->sustain) {
pv->sustain = false;
if (pv->dca1_env.stage != padthv1_env::Release) {
m_dca1.env.note_off(&pv->dca1_env);
m_dcf1.env.note_off(&pv->dcf1_env);
m_lfo1.env.note_off(&pv->lfo1_env);
m_notes[pv->note] = nullptr;
pv->note = -1;
}
}
pv = pv->next();
}
}
// sustain all notes on (sustenuto)
void padthv1_impl::allSustainOn (void)
{
padthv1_voice *pv = m_play_list.next();
while (pv) {
if (pv->note >= 0 && !pv->sustain)
pv->sustain = true;
pv = pv->next();
}
}
// direct note-on triggered on next cycle...
void padthv1_impl::directNoteOn ( int note, int vel )
{
if (vel > 0 && m_nvoices >= MAX_DIRECT_NOTES)
return;
const uint32_t i = m_direct_note;
if (i < MAX_DIRECT_NOTES) {
const int ch1 = int(*m_def.channel);
const int chan = (ch1 > 0 ? ch1 - 1 : 0) & 0x0f;
direct_note& data = m_direct_notes[i];
data.status = (vel > 0 ? 0x90 : 0x80) | chan;
data.note = note;
data.vel = vel;
++m_direct_note;
}
}
// controllers accessor
padthv1_controls *padthv1_impl::controls (void)
{
return &m_controls;
}
// programs accessor
padthv1_programs *padthv1_impl::programs (void)
{
return &m_programs;
}
// Micro-tuning support
void padthv1_impl::setTuningEnabled ( bool enabled )
{
m_tun.enabled = enabled;
}
bool padthv1_impl::isTuningEnabled (void) const
{
return m_tun.enabled;
}
void padthv1_impl::setTuningRefPitch ( float refPitch )
{
m_tun.refPitch = refPitch;
}
float padthv1_impl::tuningRefPitch (void) const
{
return m_tun.refPitch;
}
void padthv1_impl::setTuningRefNote ( int refNote )
{
m_tun.refNote = refNote;
}
int padthv1_impl::tuningRefNote (void) const
{
return m_tun.refNote;
}
void padthv1_impl::setTuningScaleFile ( const char *pszScaleFile )
{
m_tun.scaleFile = QString::fromUtf8(pszScaleFile);
}
const char *padthv1_impl::tuningScaleFile (void) const
{
return m_tun.scaleFile.toUtf8().constData();
}
void padthv1_impl::setTuningKeyMapFile ( const char *pszKeyMapFile )
{
m_tun.keyMapFile = QString::fromUtf8(pszKeyMapFile);
}
const char *padthv1_impl::tuningKeyMapFile (void) const
{
return m_tun.keyMapFile.toUtf8().constData();
}
void padthv1_impl::resetTuning (void)
{
if (m_tun.enabled) {
// Instance micro-tuning, possibly from Scala keymap and scale files...
padthv1_tuning tuning(
m_tun.refPitch,
m_tun.refNote);
if (m_tun.keyMapFile.isEmpty())
if (!m_tun.keyMapFile.isEmpty())
tuning.loadKeyMapFile(m_tun.keyMapFile);
if (!m_tun.scaleFile.isEmpty())
tuning.loadScaleFile(m_tun.scaleFile);
for (int note = 0; note < MAX_NOTES; ++note)
m_freqs[note] = tuning.noteToPitch(note);
// Done instance tuning.
}
else
if (m_config.bTuningEnabled) {
// Global/config micro-tuning, possibly from Scala keymap and scale files...
padthv1_tuning tuning(
m_config.fTuningRefPitch,
m_config.iTuningRefNote);
if (!m_config.sTuningKeyMapFile.isEmpty())
tuning.loadKeyMapFile(m_config.sTuningKeyMapFile);
if (!m_config.sTuningScaleFile.isEmpty())
tuning.loadScaleFile(m_config.sTuningScaleFile);
for (int note = 0; note < MAX_NOTES; ++note)
m_freqs[note] = tuning.noteToPitch(note);
// Done global/config tuning.
} else {
// Native/default tuning, 12-tone equal temperament western standard...
for (int note = 0; note < MAX_NOTES; ++note)
m_freqs[note] = padthv1_freq(note);
// Done native/default tuning.
}
}
// all stabilize
void padthv1_impl::stabilize (void)
{
for (int i = 0; i < padthv1::NUM_PARAMS; ++i) {
padthv1_port *pParamPort = paramPort(padthv1::ParamIndex(i));
if (pParamPort)
pParamPort->tick(padthv1_port2::NSTEP);
}
}
// all reset clear
void padthv1_impl::reset (void)
{
m_vol1.reset(
m_out1.volume.value_ptr(),
m_dca1.volume.value_ptr(),
&m_ctl1.volume);
m_pan1.reset(
m_out1.panning.value_ptr(),
&m_ctl1.panning);
m_wid1.reset(
m_out1.width.value_ptr());
// flangers
if (m_flanger == nullptr)
m_flanger = new padthv1_fx_flanger [m_nchannels];
// phasers
if (m_phaser == nullptr)
m_phaser = new padthv1_fx_phaser [m_nchannels];
// delays
if (m_delay == nullptr)
m_delay = new padthv1_fx_delay [m_nchannels];
// compressors
if (m_comp == nullptr)
m_comp = new padthv1_fx_comp [m_nchannels];
// reverbs
m_reverb.reset();
// controllers reset.
m_controls.reset();
allSoundOff();
// allControllersOff();
allNotesOff();
}
// MIDI input asynchronous status notification accessors
void padthv1_impl::midiInEnabled ( bool on )
{
m_midi_in.enabled(on);
}
uint32_t padthv1_impl::midiInCount (void)
{
return m_midi_in.count();
}
// synthesize
void padthv1_impl::process ( float **ins, float **outs, uint32_t nframes )
{
if (!m_running) return;
float *v_outs[m_nchannels];
float *v_sfxs[m_nchannels];
// FIXME: fx-send buffer reallocation... seriously?
if (m_nsize < nframes) alloc_sfxs(nframes);
uint16_t k;
for (k = 0; k < m_nchannels; ++k) {
::memset(m_sfxs[k], 0, nframes * sizeof(float));
::memcpy(outs[k], ins[k], nframes * sizeof(float));
}
// process direct note on/off...
while (m_direct_note > 0) {
const direct_note& data
= m_direct_notes[--m_direct_note];
process_midi((uint8_t *) &data, sizeof(data));
}
// controls
const bool lfo1_enabled = (*m_lfo1.enabled > 0.0f);
const float lfo1_freq = (lfo1_enabled
? get_bpm(*m_lfo1.bpm) / (60.01f - *m_lfo1.rate * 60.0f) : 0.0f);
const float modwheel1 = (lfo1_enabled
? m_ctl1.modwheel + PITCH_SCALE * *m_lfo1.pitch : 0.0f);
const bool dcf1_enabled = (*m_dcf1.enabled > 0.0f);
const float fxsend1 = *m_out1.fxsend * *m_out1.fxsend;
reset_test(); // inline...
if (m_gen1.envtime0 != *m_gen1.envtime) {
m_gen1.envtime0 = *m_gen1.envtime;
updateEnvTimes();
}
if (lfo1_enabled) {
lfo1_wave.reset_test(
padthv1_wave::Shape(*m_lfo1.shape), *m_lfo1.width);
}
// per voice
padthv1_voice *pv = m_play_list.next();
while (pv) {
padthv1_voice *pv_next = pv->next();
// output buffers
for (k = 0; k < m_nchannels; ++k) {
v_outs[k] = outs[k];
v_sfxs[k] = m_sfxs[k];
}
uint32_t nblock = nframes;
while (nblock > 0) {
uint32_t ngen = nblock;
// process envelope stages
if (pv->dca1_env.running && pv->dca1_env.frames < ngen)
ngen = pv->dca1_env.frames;
if (pv->dcf1_env.running && pv->dcf1_env.frames < ngen)
ngen = pv->dcf1_env.frames;
if (pv->lfo1_env.running && pv->lfo1_env.frames < ngen)
ngen = pv->lfo1_env.frames;
for (uint32_t j = 0; j < ngen; ++j) {
// velocities
const float vel1
= (pv->vel + (1.0f - pv->vel) * pv->dca1_pre.value(j));
// generators
const float lfo1_env
= (lfo1_enabled ? pv->lfo1_env.tick() : 0.0f);
const float lfo1
= (lfo1_enabled ? pv->lfo1_sample * lfo1_env : 0.0f);
const float gen1 = pv->gen1_sample1 * pv->gen1_bal.value(j, 0);
const float gen2 = pv->gen1_sample2 * pv->gen1_bal.value(j, 1);
pv->gen1_sample1 = pv->gen1_osc1.sample(pv->gen1_freq1
* (m_ctl1.pitchbend + modwheel1 * lfo1)
+ pv->gen1_glide1.tick());
pv->gen1_sample2 = pv->gen1_osc2.sample(pv->gen1_freq2
* (m_ctl1.pitchbend + modwheel1 * lfo1)
+ pv->gen1_glide2.tick());
if (lfo1_enabled) {
pv->lfo1_sample = pv->lfo1.sample(lfo1_freq
* (1.0f + SWEEP_SCALE * *m_lfo1.sweep * lfo1_env));
}
// ring modulators
const float ringmod1 = padthv1_sigmoid_1(
*m_gen1.ringmod * (1.0f + *m_lfo1.ringmod * lfo1));
float mod1 = gen1 * (1.0f - ringmod1) + gen1 * gen2 * ringmod1;
float mod2 = gen2 * (1.0f - ringmod1) + gen2 * gen1 * ringmod1;
// filters
if (dcf1_enabled) {
const float env1 = 0.5f
* (1.0f + *m_dcf1.envelope * pv->dcf1_env.tick());
const float cutoff1 = padthv1_sigmoid_1(*m_dcf1.cutoff
* env1 * (1.0f + *m_lfo1.cutoff * lfo1));
const float reso1 = padthv1_sigmoid_1(*m_dcf1.reso
* env1 * (1.0f + *m_lfo1.reso * lfo1));
switch (int(*m_dcf1.slope)) {
case 3: // Formant
mod1 = pv->dcf17.output(mod1, cutoff1, reso1);
mod2 = pv->dcf18.output(mod2, cutoff1, reso1);
break;
case 2: // Biquad
mod1 = pv->dcf15.output(mod1, cutoff1, reso1);
mod2 = pv->dcf16.output(mod2, cutoff1, reso1);
break;
case 1: // 24db/octave
mod1 = pv->dcf13.output(mod1, cutoff1, reso1);
mod2 = pv->dcf14.output(mod2, cutoff1, reso1);
break;
case 0: // 12db/octave
default:
mod1 = pv->dcf11.output(mod1, cutoff1, reso1);
mod2 = pv->dcf12.output(mod2, cutoff1, reso1);
break;
}
}
// volumes
const float wid1 = m_wid1.value(j);
const float mid1 = 0.5f * (mod1 + mod2);
const float sid1 = 0.5f * (mod1 - mod2);
const float vol1 = vel1 * m_vol1.value(j)
* pv->dca1_env.tick()
* pv->out1_vol.value(j);
// outputs
const float out1 = vol1 * (mid1 + sid1 * wid1)
* pv->out1_pan.value(j, 0)
* m_pan1.value(j, 0);
const float out2 = vol1 * (mid1 - sid1 * wid1)
* pv->out1_pan.value(j, 1)
* m_pan1.value(j, 1);
for (k = 0; k < m_nchannels; ++k) {
const float dry = (k & 1 ? out2 : out1);
const float wet = fxsend1 * dry;
*v_outs[k]++ += dry - wet;
*v_sfxs[k]++ += wet;
}
if (j == 0) {
pv->gen1_balance = lfo1 * *m_lfo1.balance;
pv->out1_panning = lfo1 * *m_lfo1.panning;
pv->out1_volume = lfo1 * *m_lfo1.volume + 1.0f;
}
}
nblock -= ngen;
// voice ramps countdown
pv->gen1_bal.process(ngen);
pv->dca1_pre.process(ngen);
pv->out1_pan.process(ngen);
pv->out1_vol.process(ngen);
// envelope countdowns
if (pv->dca1_env.running && pv->dca1_env.frames == 0)
m_dca1.env.next(&pv->dca1_env);
if (pv->dca1_env.stage == padthv1_env::End) {
if (pv->note < 0)
free_voice(pv);
nblock = 0;
} else {
if (pv->dcf1_env.running && pv->dcf1_env.frames == 0)
m_dcf1.env.next(&pv->dcf1_env);
if (pv->lfo1_env.running && pv->lfo1_env.frames == 0)
m_lfo1.env.next(&pv->lfo1_env);
}
}
// next playing voice
pv = pv_next;
}
// chorus
if (m_nchannels > 1) {
m_chorus.process(m_sfxs[0], m_sfxs[1], nframes, *m_cho.wet,
*m_cho.delay, *m_cho.feedb, *m_cho.rate, *m_cho.mod);
}
// effects
for (k = 0; k < m_nchannels; ++k) {
float *in = m_sfxs[k];
// flanger
m_flanger[k].process(in, nframes, *m_fla.wet,
*m_fla.delay, *m_fla.feedb, *m_fla.daft * float(k));
// phaser
m_phaser[k].process(in, nframes, *m_pha.wet,
*m_pha.rate, *m_pha.feedb, *m_pha.depth, *m_pha.daft * float(k));
// delay
m_delay[k].process(in, nframes, *m_del.wet,
*m_del.delay, *m_del.feedb, get_bpm(*m_del.bpm));
}
// reverb
if (m_nchannels > 1) {
m_reverb.process(m_sfxs[0], m_sfxs[1], nframes, *m_rev.wet,
*m_rev.feedb, *m_rev.room, *m_rev.damp, *m_rev.width);
}
// output mix-down
for (k = 0; k < m_nchannels; ++k) {
uint32_t n;
float *sfx = m_sfxs[k];
// compressor
if (int(*m_dyn.compress) > 0)
m_comp[k].process(sfx, nframes);
// limiter
if (int(*m_dyn.limiter) > 0) {
float *p = sfx;
float *q = sfx;
for (n = 0; n < nframes; ++n)
*q++ = padthv1_sigmoid(*p++);
}
// mix-down
float *out = outs[k];
for (n = 0; n < nframes; ++n)
*out++ += *sfx++;
}
// post-processing
m_dca1.volume.tick(nframes);
m_out1.width.tick(nframes);
m_out1.panning.tick(nframes);
m_out1.volume.tick(nframes);
m_wid1.process(nframes);
m_pan1.process(nframes);
m_vol1.process(nframes);
m_controls.process(nframes);
}
// process running state...
bool padthv1_impl::running ( bool on )
{
const bool running = m_running;
m_running = on;
return running;
}
//-------------------------------------------------------------------------
// padthv1 - decl.
//
padthv1::padthv1 ( uint16_t nchannels, float srate, uint32_t nsize )
{
m_pImpl = new padthv1_impl(this, nchannels, srate, nsize);
}
padthv1::~padthv1 (void)
{
delete m_pImpl;
}
void padthv1::setChannels ( uint16_t nchannels )
{
m_pImpl->setChannels(nchannels);
}
uint16_t padthv1::channels (void) const
{
return m_pImpl->channels();
}
void padthv1::setSampleRate ( float srate )
{
m_pImpl->setSampleRate(srate);
}
float padthv1::sampleRate (void) const
{
return m_pImpl->sampleRate();
}
padthv1_sample *padthv1::sample ( int sid ) const
{
if (sid == 1)
return &(m_pImpl->gen1_sample1);
else
if (sid == 2)
return &(m_pImpl->gen1_sample2);
else
return nullptr;
}
void padthv1::setBufferSize ( uint32_t nsize )
{
m_pImpl->setBufferSize(nsize);
}
uint32_t padthv1::bufferSize (void) const
{
return m_pImpl->bufferSize();
}
void padthv1::setTempo ( float bpm )
{
m_pImpl->setTempo(bpm);
}
float padthv1::tempo (void) const
{
return m_pImpl->tempo();
}
void padthv1::setParamPort ( ParamIndex index, float *pfParam )
{
m_pImpl->setParamPort(index, pfParam);
}
padthv1_port *padthv1::paramPort ( ParamIndex index ) const
{
return m_pImpl->paramPort(index);
}
void padthv1::setParamValue ( ParamIndex index, float fValue )
{
m_pImpl->setParamValue(index, fValue);
}
float padthv1::paramValue ( ParamIndex index ) const
{
return m_pImpl->paramValue(index);
}
void padthv1::process_midi ( uint8_t *data, uint32_t size )
{
#ifdef CONFIG_DEBUG_0
fprintf(stderr, "padthv1[%p]::process_midi(%u)", this, size);
for (uint32_t i = 0; i < size; ++i)
fprintf(stderr, " %02x", data[i]);
fprintf(stderr, "\n");
#endif
m_pImpl->process_midi(data, size);
}
void padthv1::process ( float **ins, float **outs, uint32_t nframes )
{
m_pImpl->process(ins, outs, nframes);
}
// controllers accessor
padthv1_controls *padthv1::controls (void) const
{
return m_pImpl->controls();
}
// programs accessor
padthv1_programs *padthv1::programs (void) const
{
return m_pImpl->programs();
}
// process state
bool padthv1::running ( bool on )
{
return m_pImpl->running(on);
}
// all stabilize
void padthv1::stabilize (void)
{
m_pImpl->stabilize();
}
// all/test reset samples
void padthv1::reset_test (void)
{
m_pImpl->reset_test();
}
// all reset clear
void padthv1::reset (void)
{
m_pImpl->reset();
}
// MIDI input asynchronous status notification accessors
void padthv1::midiInEnabled ( bool on )
{
m_pImpl->midiInEnabled(on);
}
uint32_t padthv1::midiInCount (void)
{
return m_pImpl->midiInCount();
}
// MIDI direct note on/off triggering
void padthv1::directNoteOn ( int note, int vel )
{
m_pImpl->directNoteOn(note, vel);
}
// Micro-tuning support
void padthv1::setTuningEnabled ( bool enabled )
{
m_pImpl->setTuningEnabled(enabled);
}
bool padthv1::isTuningEnabled (void) const
{
return m_pImpl->isTuningEnabled();
}
void padthv1::setTuningRefPitch ( float refPitch )
{
m_pImpl->setTuningRefPitch(refPitch);
}
float padthv1::tuningRefPitch (void) const
{
return m_pImpl->tuningRefPitch();
}
void padthv1::setTuningRefNote ( int refNote )
{
m_pImpl->setTuningRefNote(refNote);
}
int padthv1::tuningRefNote (void) const
{
return m_pImpl->tuningRefNote();
}
void padthv1::setTuningScaleFile ( const char *pszScaleFile )
{
m_pImpl->setTuningScaleFile(pszScaleFile);
}
const char *padthv1::tuningScaleFile (void) const
{
return m_pImpl->tuningScaleFile();
}
void padthv1::setTuningKeyMapFile ( const char *pszKeyMapFile )
{
m_pImpl->setTuningKeyMapFile(pszKeyMapFile);
}
const char *padthv1::tuningKeyMapFile (void) const
{
return m_pImpl->tuningKeyMapFile();
}
void padthv1::resetTuning (void)
{
m_pImpl->resetTuning();
}
// end of padthv1.cpp
padthv1-0.9.34/src/PaxHeaders/appdata 0000644 0000000 0000000 00000000132 14554770535 014377 x ustar 00 30 mtime=1706291549.608007119
30 atime=1706291549.608007119
30 ctime=1706291549.608007119
padthv1-0.9.34/src/appdata/ 0000755 0001750 0000144 00000000000 14554770535 014444 5 ustar 00rncbc users padthv1-0.9.34/src/appdata/PaxHeaders/org.rncbc.padthv1.metainfo.xml 0000644 0000000 0000000 00000000132 14554770535 022222 x ustar 00 30 mtime=1706291549.608007119
30 atime=1706291549.608007119
30 ctime=1706291549.608007119
padthv1-0.9.34/src/appdata/org.rncbc.padthv1.metainfo.xml 0000644 0001750 0000144 00000003065 14554770535 022216 0 ustar 00rncbc users
org.rncbc.padthv1
FSFAP
GPL-2.0+
padthv1
an old-school polyphonic additive synthesizer
padthv1 is an old-school polyphonic additive synthesizer
with stereo fx.
features:
- pure stand-alone JACK client with JACK-session, NSM and both JACK MIDI
and ALSA MIDI input support;
- LV2 instrument plugin.
URI: http\://padthv1.sourceforge.net/lv2
org.rncbc.padthv1.desktop
padthv1_jack
https://padthv1.sourceforge.io/image/padthv1-screenshot9.png
The main window showing the application in action
Audio
MIDI
ALSA
JACK
Synthesizer
LV2
Qt
https://padthv1.sourceforge.io
rncbc.org
rncbc aka. Rui Nuno Capela
rncbc@rncbc.org
padthv1-0.9.34/src/appdata/PaxHeaders/org.rncbc.padthv1.desktop 0000644 0000000 0000000 00000000132 14554770535 021272 x ustar 00 30 mtime=1706291549.608007119
30 atime=1706291549.608007119
30 ctime=1706291549.608007119
padthv1-0.9.34/src/appdata/org.rncbc.padthv1.desktop 0000644 0001750 0000144 00000000750 14554770535 021264 0 ustar 00rncbc users [Desktop Entry]
Name=padthv1
Version=1.0
GenericName=MIDI
Comment=padthv1 is an old school polyphonic additive synthesizer
Comment[fr]=padthv1 est un synthétiseur polyphonique additif à l'ancienne
Exec=padthv1_jack %f
Icon=org.rncbc.padthv1
Categories=Audio;AudioVideo;Midi;X-Alsa;X-Jack;Qt;
MimeType=application/x-padthv1-preset;
Keywords=Audio;MIDI;ALSA;JACK;Synthesizer;LV2;Qt;
Terminal=false
Type=Application
StartupWMClass=padthv1_jack
X-Window-Icon=padthv1
X-SuSE-translate=true
padthv1-0.9.34/src/PaxHeaders/padthv1widget_programs.cpp 0000644 0000000 0000000 00000000132 14554770535 020233 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_programs.cpp 0000644 0001750 0000144 00000036137 14554770535 020235 0 ustar 00rncbc users // padthv1widget_programs.cpp
//
/****************************************************************************
Copyright (C) 2012-2023, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1widget_programs.h"
#include "padthv1_programs.h"
#include "padthv1_config.h"
#include
#include
#include
#include
#include
//----------------------------------------------------------------------------
// padthv1widget_programs::ItemDelegate -- Custom (tree) list item delegate.
class padthv1widget_programs::ItemDelegate : public QItemDelegate
{
public:
// ctor.
ItemDelegate(QObject *pParent = nullptr);
// QItemDelegate interface...
QSize sizeHint(
const QStyleOptionViewItem& option,
const QModelIndex& index) const;
QWidget *createEditor(QWidget *pParent,
const QStyleOptionViewItem& option,
const QModelIndex& index) const;
void setEditorData(QWidget *pEditor,
const QModelIndex& index) const;
void setModelData(QWidget *pEditor,
QAbstractItemModel *pModel,
const QModelIndex& index) const;
};
//----------------------------------------------------------------------------
// padthv1widget_programs_item_delegate -- Custom (tree) list item delegate.
// ctor.
padthv1widget_programs::ItemDelegate::ItemDelegate ( QObject *pParent )
: QItemDelegate(pParent)
{
}
// QItemDelegate interface...
QSize padthv1widget_programs::ItemDelegate::sizeHint (
const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
return QItemDelegate::sizeHint(option, index) + QSize(4, 4);
}
QWidget *padthv1widget_programs::ItemDelegate::createEditor ( QWidget *pParent,
const QStyleOptionViewItem& /*option*/, const QModelIndex& index ) const
{
QWidget *pEditor = nullptr;
switch (index.column()) {
case 0: // Data.
{
QSpinBox *pSpinBox = new QSpinBox(pParent);
pSpinBox->setMinimum(0);
if (index.parent().isValid())
pSpinBox->setMaximum(127);
else
pSpinBox->setMaximum(16383);
pEditor = pSpinBox;
break;
}
case 1: // Text.
{
if (index.parent().isValid()) {
QComboBox *pComboBox = new QComboBox(pParent);
pComboBox->setEditable(false);
padthv1_config *pConfig = padthv1_config::getInstance();
if (pConfig)
pComboBox->addItems(pConfig->presetList());
pEditor = pComboBox;
} else {
QLineEdit *pLineEdit = new QLineEdit(pParent);
pEditor = pLineEdit;
}
break;
}
default:
break;
}
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_programs::ItemDelegate::createEditor(%p, %d, %d) = %p",
pParent, index.row(), index.column(), pEditor);
#endif
return pEditor;
}
void padthv1widget_programs::ItemDelegate::setEditorData (
QWidget *pEditor, const QModelIndex& index ) const
{
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_programs::ItemDelegate::setEditorData(%p, %d, %d)",
pEditor, index.row(), index.column());
#endif
switch (index.column()) {
case 0: // Data.
{
const QString& sData = index.data().toString();
// = index.model()->data(index, Qt::DisplayRole).toString();
QSpinBox *pSpinBox = qobject_cast (pEditor);
if (pSpinBox) {
const int iData = sData.section("=", 0, 0).toInt();
pSpinBox->setValue(iData);
}
break;
}
case 1: // Text.
{
const QString& sText = index.data().toString();
// = index.model()->data(index, Qt::DisplayRole).toString();
if (index.parent().isValid()) {
QComboBox *pComboBox = qobject_cast (pEditor);
if (pComboBox) {
const int iIndex = pComboBox->findText(sText);
if (iIndex >= 0)
pComboBox->setCurrentIndex(iIndex);
}
} else {
QLineEdit *pLineEdit = qobject_cast (pEditor);
if (pLineEdit) pLineEdit->setText(sText);
}
break;
}
default:
break;
}
}
void padthv1widget_programs::ItemDelegate::setModelData ( QWidget *pEditor,
QAbstractItemModel *pModel, const QModelIndex& index ) const
{
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_programs::ItemDelegate::setModelData(%p, %d, %d)",
pEditor, index.row(), index.column());
#endif
switch (index.column()) {
case 0: // Data.
{
QSpinBox *pSpinBox = qobject_cast (pEditor);
if (pSpinBox) {
const int iData = pSpinBox->value();
QString sData = QString::number(iData);
if (index.parent().isValid())
sData += " =";
pModel->setData(index, sData);
}
break;
}
case 1: // Text.
{
if (index.parent().isValid()) {
QComboBox *pComboBox = qobject_cast (pEditor);
if (pComboBox) {
const QString& sText = pComboBox->currentText();
pModel->setData(index, sText);
}
} else {
QLineEdit *pLineEdit = qobject_cast (pEditor);
if (pLineEdit) {
const QString& sText = pLineEdit->text();
pModel->setData(index, sText);
}
}
break;
}
default:
break;
}
// Done.
}
//----------------------------------------------------------------------------
// padthv1widget_programs -- UI wrapper form.
// ctor.
padthv1widget_programs::padthv1widget_programs ( QWidget *pParent )
: QTreeWidget(pParent)
{
QTreeWidget::setColumnCount(2);
QTreeWidget::setRootIsDecorated(true);
QTreeWidget::setAlternatingRowColors(true);
QTreeWidget::setUniformRowHeights(true);
QTreeWidget::setAllColumnsShowFocus(true);
QTreeWidget::setSelectionBehavior(QAbstractItemView::SelectRows);
QTreeWidget::setSelectionMode(QAbstractItemView::SingleSelection);
QHeaderView *pHeaderView = QTreeWidget::header();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
pHeaderView->setResizeMode(QHeaderView::ResizeToContents);
#else
pHeaderView->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
pHeaderView->hide();
QTreeWidget::setItemDelegate(new ItemDelegate(this));
QObject::connect(this,
SIGNAL(itemChanged(QTreeWidgetItem *, int)),
SLOT(itemChangedSlot(QTreeWidgetItem *, int)));
QObject::connect(this,
SIGNAL(itemExpanded(QTreeWidgetItem *)),
SLOT(itemExpandedSlot(QTreeWidgetItem *)));
QObject::connect(this,
SIGNAL(itemCollapsed(QTreeWidgetItem *)),
SLOT(itemCollapsedSlot(QTreeWidgetItem *)));
}
// dtor.
padthv1widget_programs::~padthv1widget_programs (void)
{
}
// utilities.
void padthv1widget_programs::loadPrograms ( padthv1_programs *pPrograms )
{
QTreeWidget::clear();
QList items;
QTreeWidgetItem *pCurrentItem = nullptr;
const padthv1_programs::Banks& banks = pPrograms->banks();
padthv1_programs::Banks::ConstIterator bank_iter = banks.constBegin();
const padthv1_programs::Banks::ConstIterator& bank_end = banks.constEnd();
for ( ; bank_iter != bank_end; ++bank_iter) {
padthv1_programs::Bank *pBank = bank_iter.value();
QTreeWidgetItem *pBankItem = new QTreeWidgetItem(this);
pBankItem->setIcon(0, QIcon(":/images/presetBankOpen.png"));
pBankItem->setText(0, QString::number(pBank->id()));
pBankItem->setText(1, pBank->name());
pBankItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
pBankItem->setData(0, Qt::UserRole, pBank->id());
const padthv1_programs::Progs& progs = pBank->progs();
padthv1_programs::Progs::ConstIterator prog_iter = progs.constBegin();
const padthv1_programs::Progs::ConstIterator& prog_end = progs.constEnd();
for ( ; prog_iter != prog_end; ++prog_iter) {
padthv1_programs::Prog *pProg = prog_iter.value();
QTreeWidgetItem *pProgItem = new QTreeWidgetItem(pBankItem);
pProgItem->setIcon(1, QIcon(":/images/padthv1_preset.png"));
pProgItem->setText(0, QString::number(pProg->id()) + " =");
pProgItem->setText(1, pProg->name());
pProgItem->setFlags(
Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
pProgItem->setData(0, Qt::TextAlignmentRole,
int(Qt::AlignRight | Qt::AlignVCenter));
pProgItem->setData(0, Qt::UserRole, pProg->id());
if (pBank == pPrograms->current_bank() &&
pProg == pPrograms->current_prog())
pCurrentItem = pProgItem;
}
items.append(pBankItem);
}
QTreeWidget::addTopLevelItems(items);
QTreeWidget::expandAll();
QTreeWidget::setCurrentItem(pCurrentItem);
}
void padthv1widget_programs::savePrograms ( padthv1_programs *pPrograms )
{
pPrograms->clear_banks();
const int iBankCount = QTreeWidget::topLevelItemCount();
for (int iBank = 0 ; iBank < iBankCount; ++iBank) {
QTreeWidgetItem *pBankItem = QTreeWidget::topLevelItem(iBank);
uint16_t bank_id = pBankItem->data(0, Qt::UserRole).toInt();
const QString& bank_name = pBankItem->text(1).simplified();
padthv1_programs::Bank *pBank = pPrograms->add_bank(bank_id, bank_name);
const int iProgCount = pBankItem->childCount();
for (int iProg = 0 ; iProg < iProgCount; ++iProg) {
QTreeWidgetItem *pProgItem = pBankItem->child(iProg);
uint16_t prog_id = pProgItem->data(0, Qt::UserRole).toInt();
const QString& prog_name = pProgItem->text(1).simplified();
pBank->add_prog(prog_id, prog_name);
}
}
}
QString padthv1widget_programs::currentProgramName (void) const
{
QString sProgramName;
const QList& selectedItems
= QTreeWidget::selectedItems();
if (!selectedItems.isEmpty()) {
QTreeWidgetItem *pProgItem = selectedItems.first();
sProgramName = pProgItem->text(1).simplified();
}
return sProgramName;
}
// slots.
void padthv1widget_programs::addBankItem (void)
{
QTreeWidget::setFocus();
QTreeWidgetItem *pBankItem = newBankItem();
if (pBankItem) {
QTreeWidget::setCurrentItem(pBankItem);
QTreeWidget::editItem(pBankItem, 1);
}
}
void padthv1widget_programs::addProgramItem (void)
{
QTreeWidget::setFocus();
QTreeWidgetItem *pProgItem = newProgramItem();
if (pProgItem) {
QTreeWidget::setCurrentItem(pProgItem);
QTreeWidget::editItem(pProgItem, 1);
}
}
// factory methods.
QTreeWidgetItem *padthv1widget_programs::newBankItem (void)
{
QTreeWidgetItem *pItem = QTreeWidget::currentItem();
QTreeWidgetItem *pBankItem = (pItem ? pItem->parent() : nullptr);
if (pBankItem == nullptr)
pBankItem = pItem;
int iBank = 0;
int iBankData = 0;
if (pBankItem) {
iBankData = pBankItem->data(0, Qt::UserRole).toInt() + 1;
if (iBankData > 16383)
iBankData = 0;
else
iBank = QTreeWidget::indexOfTopLevelItem(pBankItem) + 1;
}
const int iBankCount = QTreeWidget::topLevelItemCount();
for ( ; iBank < iBankCount; ++iBank) {
pBankItem = QTreeWidget::topLevelItem(iBank);
if (iBankData < pBankItem->data(0, Qt::UserRole).toInt())
break;
if (++iBankData > 16383)
return nullptr;
}
pBankItem = new QTreeWidgetItem(QStringList()
<< QString::number(iBankData) << tr("Bank %1").arg(iBankData));
pBankItem->setIcon(0, QIcon(":/images/presetBank.png"));
pBankItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
pBankItem->setData(0, Qt::UserRole, iBankData);
QTreeWidget::insertTopLevelItem(iBank, pBankItem);
return pBankItem;
}
QTreeWidgetItem *padthv1widget_programs::newProgramItem (void)
{
QTreeWidgetItem *pItem = QTreeWidget::currentItem();
QTreeWidgetItem *pBankItem = (pItem ? pItem->parent() : nullptr);
QTreeWidgetItem *pProgItem = nullptr;
if (pBankItem == nullptr)
pBankItem = pItem;
else
pProgItem = pItem;
if (pBankItem == nullptr)
pBankItem = QTreeWidget::topLevelItem(0);
if (pBankItem == nullptr)
pBankItem = newBankItem();
if (pBankItem == nullptr)
return nullptr;
const int iBankData
= pBankItem->data(0, Qt::UserRole).toInt();
int iProg = 0;
int iProgData = 0;
if (pProgItem) {
iProgData = pProgItem->data(0, Qt::UserRole).toInt() + 1;
if (iProgData > 127)
iProgData = 0;
else
iProg = pBankItem->indexOfChild(pProgItem) + 1;
}
const int iProgCount = pBankItem->childCount();
for ( ; iProg < iProgCount; ++iProg) {
pProgItem = pBankItem->child(iProg);
if (iProgData < pProgItem->data(0, Qt::UserRole).toInt())
break;
if (++iProgData > 127)
return nullptr;
}
QString sProgram = tr("Program %1.%2").arg(iBankData).arg(iProgData);
padthv1_config *pConfig = padthv1_config::getInstance();
if (pConfig) {
const QStringList& presets
= pConfig->presetList();
if (iProgData < presets.count())
sProgram = presets.at(iProgData);
}
pProgItem = new QTreeWidgetItem(QStringList()
<< QString::number(iProgData) + " =" << sProgram);
pProgItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
pProgItem->setData(0, Qt::TextAlignmentRole, int(Qt::AlignRight | Qt::AlignVCenter));
pProgItem->setData(0, Qt::UserRole, iProgData);
pProgItem->setIcon(1, QIcon(":/images/padthv1_preset.png"));
pBankItem->insertChild(iProg, pProgItem);
pBankItem->setExpanded(true);
return pProgItem;
}
void padthv1widget_programs::itemChangedSlot ( QTreeWidgetItem *pItem, int )
{
const int iData = pItem->text(0).section("=", 0, 0).toInt();
if (iData == pItem->data(0, Qt::UserRole).toInt())
return;
const bool bBlockSignals = QTreeWidget::blockSignals(true);
QTreeWidgetItem *pBankItem = pItem->parent();
if (pBankItem) {
int iProg, iProgData = 0;
const int iOldProg = pBankItem->indexOfChild(pItem);
pItem = pBankItem->takeChild(iOldProg);
const int iProgCount = pBankItem->childCount();
for (iProg = 0; iProg < iProgCount; ++iProg) {
QTreeWidgetItem *pProgItem = pBankItem->child(iProg);
iProgData = pProgItem->data(0, Qt::UserRole).toInt();
if (iProgData >= iData)
break;
}
if (iProgData == iData) {
iProg = iOldProg;
iProgData = pItem->data(0, Qt::UserRole).toInt();
pItem->setText(0, QString::number(iProgData) + " =");
}
else pItem->setData(0, Qt::UserRole, iData);
pBankItem->insertChild(iProg, pItem);
} else {
int iBank, iBankData = 0;
const bool bExpanded = pItem->isExpanded();
const int iOldBank = QTreeWidget::indexOfTopLevelItem(pItem);
pItem = QTreeWidget::takeTopLevelItem(iOldBank);
const int iBankCount = QTreeWidget::topLevelItemCount();
for (iBank = 0; iBank < iBankCount; ++iBank) {
pBankItem = QTreeWidget::topLevelItem(iBank);
iBankData = pBankItem->data(0, Qt::UserRole).toInt();
if (iBankData >= iData)
break;
}
if (iBankData == iData) {
iBank = iOldBank;
iBankData = pItem->data(0, Qt::UserRole).toInt();
pItem->setText(0, QString::number(iBankData));
}
else pItem->setData(0, Qt::UserRole, iData);
QTreeWidget::insertTopLevelItem(iBank, pItem);
pItem->setExpanded(bExpanded);
}
QTreeWidget::setCurrentItem(pItem);
QTreeWidget::blockSignals(bBlockSignals);
}
void padthv1widget_programs::itemExpandedSlot ( QTreeWidgetItem *pItem )
{
if (pItem->parent() == nullptr)
pItem->setIcon(0, QIcon(":/images/presetBankOpen.png"));
}
void padthv1widget_programs::itemCollapsedSlot ( QTreeWidgetItem *pItem )
{
if (pItem->parent() == nullptr)
pItem->setIcon(0, QIcon(":/images/presetBank.png"));
}
// end of padthv1widget_programs.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1widget_status.cpp 0000644 0000000 0000000 00000000132 14554770535 017724 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_status.cpp 0000644 0001750 0000144 00000007577 14554770535 017734 0 ustar 00rncbc users // padthv1widget_status.cpp
//
/****************************************************************************
Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1widget_status.h"
#include "padthv1widget_keybd.h"
#include
#include
#include
#include
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define horizontalAdvance width
#endif
//-------------------------------------------------------------------------
// padthv1widget_status - Custom status-bar widget.
//
// Constructor.
padthv1widget_status::padthv1widget_status ( QWidget *pParent )
: QStatusBar (pParent)
{
QIcon icon;
icon.addPixmap(
QPixmap(":/images/ledOff.png"), QIcon::Normal, QIcon::Off);
icon.addPixmap(
QPixmap(":/images/ledOn.png"), QIcon::Normal, QIcon::On);
m_midiInLed[0] = new QPixmap(
icon.pixmap(16, 16, QIcon::Normal, QIcon::Off));
m_midiInLed[1] = new QPixmap(
icon.pixmap(16, 16, QIcon::Normal, QIcon::On));
const QString sMidiIn(tr("MIDI In"));
QWidget *pMidiInWidget = new QWidget();
pMidiInWidget->setToolTip(tr("%1 status").arg(sMidiIn));
QHBoxLayout *pMidiInLayout = new QHBoxLayout();
pMidiInLayout->setContentsMargins(0, 0, 0, 0);
pMidiInLayout->setSpacing(0);
m_pMidiInLedLabel = new QLabel();
m_pMidiInLedLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_pMidiInLedLabel->setPixmap(*m_midiInLed[0]);
m_pMidiInLedLabel->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
m_pMidiInLedLabel->setAutoFillBackground(true);
pMidiInLayout->addWidget(m_pMidiInLedLabel);
QLabel *pMidiInTextLabel = new QLabel(sMidiIn);
pMidiInTextLabel->setMargin(2);
pMidiInTextLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
pMidiInTextLabel->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
pMidiInTextLabel->setAutoFillBackground(true);
pMidiInLayout->addWidget(pMidiInTextLabel);
pMidiInWidget->setLayout(pMidiInLayout);
QStatusBar::addWidget(pMidiInWidget);
m_pKeybd = new padthv1widget_keybd();
m_pKeybd->setMinimumWidth(760);
QStatusBar::addPermanentWidget(m_pKeybd);
const QFontMetrics fm(QStatusBar::font());
m_pModifiedLabel = new QLabel();
m_pModifiedLabel->setAlignment(Qt::AlignHCenter);
m_pModifiedLabel->setMinimumSize(QSize(fm.horizontalAdvance("MOD") + 4, fm.height()));
m_pModifiedLabel->setToolTip(tr("Modification status"));
m_pModifiedLabel->setAutoFillBackground(true);
QStatusBar::addPermanentWidget(m_pModifiedLabel);
}
// Destructor.
padthv1widget_status::~padthv1widget_status (void)
{
delete m_midiInLed[1];
delete m_midiInLed[0];
}
// Permanent widgets accessors.
padthv1widget_keybd *padthv1widget_status::keybd (void) const
{
return m_pKeybd;
}
void padthv1widget_status::midiInLed ( bool bMidiInLed )
{
m_pMidiInLedLabel->setPixmap(*m_midiInLed[bMidiInLed ? 1 : 0]);
}
void padthv1widget_status::midiInNote ( int iNote, int iVelocity )
{
if (iVelocity > 0)
m_pKeybd->noteOn(iNote);
else
m_pKeybd->noteOff(iNote);
}
void padthv1widget_status::modified ( bool bModified )
{
if (bModified)
m_pModifiedLabel->setText(tr("MOD"));
else
m_pModifiedLabel->clear();
}
// end of padthv1widget_status.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1_config.cpp 0000644 0000000 0000000 00000000132 14554770535 016442 x ustar 00 30 mtime=1706291549.609007112
30 atime=1706291549.609007112
30 ctime=1706291549.609007112
padthv1-0.9.34/src/padthv1_config.cpp 0000644 0001750 0000144 00000026203 14554770535 016435 0 ustar 00rncbc users // padthv1_config.cpp
//
/****************************************************************************
Copyright (C) 2012-2024, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1_config.h"
#include "padthv1_programs.h"
#include "padthv1_controls.h"
#include
//-------------------------------------------------------------------------
// padthv1_config - Prototype settings structure (pseudo-singleton).
//
// Singleton instance accessor (static).
padthv1_config *padthv1_config::g_pSettings = nullptr;
padthv1_config *padthv1_config::getInstance (void)
{
return g_pSettings;
}
// Constructor.
padthv1_config::padthv1_config (void)
: QSettings(PROJECT_DOMAIN, PROJECT_NAME)
{
g_pSettings = this;
load();
}
// Default destructor.
padthv1_config::~padthv1_config (void)
{
save();
g_pSettings = nullptr;
}
// Preset utility methods.
QString padthv1_config::presetGroup (void) const
{
return "/Presets/";
}
QString padthv1_config::presetFile ( const QString& sPreset )
{
QSettings::beginGroup(presetGroup());
const QString sPresetFile(QSettings::value(sPreset).toString());
QSettings::endGroup();
return sPresetFile;
}
void padthv1_config::setPresetFile (
const QString& sPreset, const QString& sPresetFile )
{
QSettings::beginGroup(presetGroup());
QSettings::setValue(sPreset, sPresetFile);
QSettings::endGroup();
m_presetList.clear();
}
void padthv1_config::removePreset ( const QString& sPreset )
{
QSettings::beginGroup(presetGroup());
const QString& sPresetFile = QSettings::value(sPreset).toString();
if (QFileInfo(sPresetFile).exists())
QFile(sPresetFile).remove();
QSettings::remove(sPreset);
QSettings::endGroup();
m_presetList.clear();
}
const QStringList& padthv1_config::presetList (void)
{
if (m_presetList.isEmpty()) {
QSettings::beginGroup(presetGroup());
QStringListIterator iter(QSettings::childKeys());
while (iter.hasNext()) {
const QString& sPreset = iter.next();
if (QFileInfo(QSettings::value(sPreset).toString()).exists())
m_presetList.append(sPreset);
}
QSettings::endGroup();
}
return m_presetList;
}
// Programs utility methods.
QString padthv1_config::programsGroup (void) const
{
return "/Programs";
}
QString padthv1_config::bankPrefix (void) const
{
return "/Bank_";
}
void padthv1_config::loadPrograms ( padthv1_programs *pPrograms )
{
pPrograms->clear_banks();
QSettings::beginGroup(programsGroup());
const QStringList& bank_keys = QSettings::childKeys();
QStringListIterator bank_iter(bank_keys);
while (bank_iter.hasNext()) {
const QString& bank_key = bank_iter.next();
uint16_t bank_id = bank_key.toInt();
const QString& bank_name
= QSettings::value(bank_key).toString();
padthv1_programs::Bank *pBank = pPrograms->add_bank(bank_id, bank_name);
QSettings::beginGroup(bankPrefix() + bank_key);
const QStringList& prog_keys = QSettings::childKeys();
QStringListIterator prog_iter(prog_keys);
while (prog_iter.hasNext()) {
const QString& prog_key = prog_iter.next();
uint16_t prog_id = prog_key.toInt();
const QString& prog_name
= QSettings::value(prog_key).toString();
pBank->add_prog(prog_id, prog_name);
}
QSettings::endGroup();
}
QSettings::endGroup();
pPrograms->enabled(bProgramsEnabled);
}
void padthv1_config::savePrograms ( padthv1_programs *pPrograms )
{
bProgramsEnabled = pPrograms->enabled();
clearPrograms();
QSettings::beginGroup(programsGroup());
const padthv1_programs::Banks& banks = pPrograms->banks();
padthv1_programs::Banks::ConstIterator bank_iter = banks.constBegin();
const padthv1_programs::Banks::ConstIterator& bank_end = banks.constEnd();
for ( ; bank_iter != bank_end; ++bank_iter) {
padthv1_programs::Bank *pBank = bank_iter.value();
const QString& bank_key = QString::number(pBank->id());
const QString& bank_name = pBank->name();
QSettings::setValue(bank_key, bank_name);
QSettings::beginGroup(bankPrefix() + bank_key);
const padthv1_programs::Progs& progs = pBank->progs();
padthv1_programs::Progs::ConstIterator prog_iter = progs.constBegin();
const padthv1_programs::Progs::ConstIterator& prog_end = progs.constEnd();
for ( ; prog_iter != prog_end; ++prog_iter) {
padthv1_programs::Prog *pProg = prog_iter.value();
const QString& prog_key = QString::number(pProg->id());
const QString& prog_name = pProg->name();
QSettings::setValue(prog_key, prog_name);
}
QSettings::endGroup();
}
QSettings::endGroup();
QSettings::sync();
}
void padthv1_config::clearPrograms (void)
{
QSettings::beginGroup(programsGroup());
const QStringList& bank_keys = QSettings::childKeys();
QStringListIterator bank_iter(bank_keys);
while (bank_iter.hasNext()) {
const QString& bank_key = bank_iter.next();
QSettings::beginGroup(bankPrefix() + bank_key);
const QStringList& prog_keys = QSettings::childKeys();
QStringListIterator prog_iter(prog_keys);
while (prog_iter.hasNext()) {
const QString& prog_key = prog_iter.next();
QSettings::remove(prog_key);
}
QSettings::endGroup();
QSettings::remove(bank_key);
}
QSettings::endGroup();
}
// Programs utility methods.
QString padthv1_config::controlsGroup (void) const
{
return "/Controllers";
}
QString padthv1_config::controlPrefix (void) const
{
return "/Control";
}
void padthv1_config::loadControls ( padthv1_controls *pControls )
{
pControls->clear();
QSettings::beginGroup(controlsGroup());
const QStringList& keys = QSettings::childKeys();
QStringListIterator iter(keys);
while (iter.hasNext()) {
const QString& sKey = '/' + iter.next();
const QStringList& clist = sKey.split('_');
if (clist.at(0) == controlPrefix()) {
const unsigned short channel
= clist.at(1).toInt();
const padthv1_controls::Type ctype
= padthv1_controls::typeFromText(clist.at(2));
padthv1_controls::Key key;
key.status = ctype | (channel & 0x1f);
key.param = clist.at(3).toInt();
const QStringList& vlist
= QSettings::value(sKey).toStringList();
padthv1_controls::Data data;
data.index = vlist.at(0).toInt();
if (vlist.count() > 1)
data.flags = vlist.at(1).toInt();
pControls->add_control(key, data);
}
}
QSettings::endGroup();
pControls->enabled(bControlsEnabled);
}
void padthv1_config::saveControls ( padthv1_controls *pControls )
{
bControlsEnabled = pControls->enabled();
clearControls();
QSettings::beginGroup(controlsGroup());
const padthv1_controls::Map& map = pControls->map();
padthv1_controls::Map::ConstIterator iter = map.constBegin();
const padthv1_controls::Map::ConstIterator& iter_end = map.constEnd();
for ( ; iter != iter_end; ++iter) {
const padthv1_controls::Key& key = iter.key();
QString sKey = controlPrefix();
sKey += '_' + QString::number(key.channel());
sKey += '_' + padthv1_controls::textFromType(key.type());
sKey += '_' + QString::number(key.param);
const padthv1_controls::Data& data = iter.value();
QStringList vlist;
vlist.append(QString::number(data.index));
vlist.append(QString::number(data.flags));
QSettings::setValue(sKey, vlist);
}
QSettings::endGroup();
QSettings::sync();
}
void padthv1_config::clearControls (void)
{
QSettings::beginGroup(controlsGroup());
const QStringList& keys = QSettings::childKeys();
QStringListIterator iter(keys);
while (iter.hasNext()) {
const QString& key = iter.next();
QSettings::remove(key);
}
QSettings::endGroup();
}
// Explicit I/O methods.
void padthv1_config::load (void)
{
QSettings::beginGroup("/Default");
sPreset = QSettings::value("/Preset").toString();
sPresetDir = QSettings::value("/PresetDir").toString();
sSampleDir = QSettings::value("/SampleDir").toString();
iKnobDialMode = QSettings::value("/KnobDialMode", 0).toInt();
iKnobEditMode = QSettings::value("/KnobEditMode", 0).toInt();
fRandomizePercent = QSettings::value("/RandomizePercent", 20.0f).toFloat();
bControlsEnabled = QSettings::value("/ControlsEnabled", false).toBool();
bProgramsEnabled = QSettings::value("/ProgramsEnabled", false).toBool();
QSettings::endGroup();
QSettings::beginGroup("/Dialogs");
bProgramsPreview = QSettings::value("/ProgramsPreview", false).toBool();
bUseNativeDialogs = QSettings::value("/UseNativeDialogs", false).toBool();
// Run-time special non-persistent options.
bDontUseNativeDialogs = !bUseNativeDialogs;
QSettings::endGroup();
QSettings::beginGroup("/Custom");
sCustomColorTheme = QSettings::value("/ColorTheme").toString();
sCustomStyleTheme = QSettings::value("/StyleTheme").toString();
QSettings::endGroup();
// Micro-tuning options.
QSettings::beginGroup("/Tuning");
bTuningEnabled = QSettings::value("/Enabled", false).toBool();
fTuningRefPitch = float(QSettings::value("/RefPitch", 440.0).toDouble());
iTuningRefNote = QSettings::value("/RefNote", 69).toInt();
sTuningScaleDir = QSettings::value("/ScaleDir").toString();
sTuningScaleFile = QSettings::value("/ScaleFile").toString();
sTuningKeyMapDir = QSettings::value("/KeyMapDir").toString();
sTuningKeyMapFile = QSettings::value("/KeyMapFile").toString();
QSettings::endGroup();
}
void padthv1_config::save (void)
{
QSettings::beginGroup("/Program");
QSettings::setValue("/Version", PROJECT_VERSION);
QSettings::endGroup();
QSettings::beginGroup("/Default");
QSettings::setValue("/Preset", sPreset);
QSettings::setValue("/PresetDir", sPresetDir);
QSettings::setValue("/SampleDir", sSampleDir);
QSettings::setValue("/KnobDialMode", iKnobDialMode);
QSettings::setValue("/KnobEditMode", iKnobEditMode);
QSettings::setValue("/RandomizePercent", fRandomizePercent);
QSettings::setValue("/ControlsEnabled", bControlsEnabled);
QSettings::setValue("/ProgramsEnabled", bProgramsEnabled);
QSettings::endGroup();
QSettings::beginGroup("/Dialogs");
QSettings::setValue("/ProgramsPreview", bProgramsPreview);
QSettings::setValue("/UseNativeDialogs", bUseNativeDialogs);
QSettings::endGroup();
QSettings::beginGroup("/Custom");
QSettings::setValue("/ColorTheme", sCustomColorTheme);
QSettings::setValue("/StyleTheme", sCustomStyleTheme);
QSettings::endGroup();
// Micro-tuning options.
QSettings::beginGroup("/Tuning");
QSettings::setValue("/Enabled", bTuningEnabled);
QSettings::setValue("/RefPitch", double(fTuningRefPitch));
QSettings::setValue("/RefNote", iTuningRefNote);
QSettings::setValue("/ScaleDir", sTuningScaleDir);
QSettings::setValue("/ScaleFile", sTuningScaleFile);
QSettings::setValue("/KeyMapDir", sTuningKeyMapDir);
QSettings::setValue("/KeyMapFile", sTuningKeyMapFile);
QSettings::endGroup();
QSettings::sync();
}
// end of padthv1_config.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1widget_control.cpp 0000644 0000000 0000000 00000000132 14554770535 020061 x ustar 00 30 mtime=1706291549.611007099
30 atime=1706291549.611007099
30 ctime=1706291549.611007099
padthv1-0.9.34/src/padthv1widget_control.cpp 0000644 0001750 0000144 00000037412 14554770535 020060 0 ustar 00rncbc users // padthv1widget_control.cpp
//
/****************************************************************************
Copyright (C) 2012-2022, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1widget_control.h"
#include "padthv1widget_controls.h"
#include "padthv1_config.h"
#include "ui_padthv1widget_control.h"
#include
#include
#include
//----------------------------------------------------------------------------
// padthv1widget_control -- UI wrapper form.
// Kind of singleton reference.
padthv1widget_control *padthv1widget_control::g_pInstance = nullptr;
// Constructor.
padthv1widget_control::padthv1widget_control ( QWidget *pParent )
: QDialog(pParent), p_ui(new Ui::padthv1widget_control), m_ui(*p_ui)
{
// Setup UI struct...
m_ui.setupUi(this);
// Make it auto-modeless dialog...
QDialog::setAttribute(Qt::WA_DeleteOnClose);
// Control types...
m_ui.ControlTypeComboBox->clear();
m_ui.ControlTypeComboBox->addItem(
padthv1_controls::textFromType(padthv1_controls::CC),
int(padthv1_controls::CC));
m_ui.ControlTypeComboBox->addItem(
padthv1_controls::textFromType(padthv1_controls::RPN),
int(padthv1_controls::RPN));
m_ui.ControlTypeComboBox->addItem(
padthv1_controls::textFromType(padthv1_controls::NRPN),
int(padthv1_controls::NRPN));
m_ui.ControlTypeComboBox->addItem(
padthv1_controls::textFromType(padthv1_controls::CC14),
int(padthv1_controls::CC14));
m_ui.ControlParamComboBox->setInsertPolicy(QComboBox::NoInsert);
// Start clean.
m_iControlParamUpdate = 0;
m_iDirtyCount = 0;
m_iDirtySetup = 0;
// Populate param list.
// activateControlType(m_ui.ControlTypeComboBox->currentIndex());
// Try to fix window geometry.
adjustSize();
// UI signal/slot connections...
QObject::connect(m_ui.ControlTypeComboBox,
SIGNAL(activated(int)),
SLOT(activateControlType(int)));
QObject::connect(m_ui.ControlParamComboBox,
SIGNAL(activated(int)),
SLOT(changed()));
QObject::connect(m_ui.ControlChannelSpinBox,
SIGNAL(valueChanged(int)),
SLOT(changed()));
QObject::connect(m_ui.ControlLogarithmicCheckBox,
SIGNAL(toggled(bool)),
SLOT(changed()));
QObject::connect(m_ui.ControlInvertCheckBox,
SIGNAL(toggled(bool)),
SLOT(changed()));
QObject::connect(m_ui.ControlHookCheckBox,
SIGNAL(toggled(bool)),
SLOT(changed()));
QObject::connect(m_ui.DialogButtonBox,
SIGNAL(clicked(QAbstractButton *)),
SLOT(clicked(QAbstractButton *)));
QObject::connect(m_ui.DialogButtonBox,
SIGNAL(accepted()),
SLOT(accept()));
QObject::connect(m_ui.DialogButtonBox,
SIGNAL(rejected()),
SLOT(reject()));
// Pseudo-singleton reference setup.
g_pInstance = this;
}
// Destructor.
padthv1widget_control::~padthv1widget_control (void)
{
delete p_ui;
}
// Pseudo-singleton instance.
padthv1widget_control *padthv1widget_control::getInstance (void)
{
return g_pInstance;
}
// Pseudo-constructor.
void padthv1widget_control::showInstance (
padthv1_controls *pControls, padthv1::ParamIndex index,
const QString& sTitle, QWidget *pParent )
{
padthv1widget_control *pInstance = padthv1widget_control::getInstance();
if (pInstance)
pInstance->close();
pInstance = new padthv1widget_control(pParent);
pInstance->setWindowTitle(sTitle);
pInstance->setControls(pControls, index);
pInstance->show();
}
// Control accessors.
void padthv1widget_control::setControls (
padthv1_controls *pControls, padthv1::ParamIndex index )
{
++m_iDirtySetup;
m_pControls = pControls;
m_index = index;
m_key.status = padthv1_controls::CC;
unsigned int flags = 0;
if (m_pControls) {
const padthv1_controls::Map& map = m_pControls->map();
padthv1_controls::Map::ConstIterator iter = map.constBegin();
const padthv1_controls::Map::ConstIterator& iter_end
= map.constEnd();
for ( ; iter != iter_end; ++iter) {
const padthv1_controls::Data& data = iter.value();
if (padthv1::ParamIndex(data.index) == m_index) {
flags = data.flags;
m_key = iter.key();
break;
}
}
}
setControlKey(m_key);
const bool bFloat = padthv1_param::paramFloat(m_index);
m_ui.ControlLogarithmicCheckBox->setChecked(
(flags & padthv1_controls::Logarithmic) && bFloat);
m_ui.ControlLogarithmicCheckBox->setEnabled(bFloat);
m_ui.ControlInvertCheckBox->setChecked(
(flags & padthv1_controls::Invert));
m_ui.ControlInvertCheckBox->setEnabled(true);
m_ui.ControlHookCheckBox->setChecked(
(flags & padthv1_controls::Hook) || !bFloat);
m_ui.ControlHookCheckBox->setEnabled(bFloat);
--m_iDirtySetup;
m_iDirtyCount = 0;
}
padthv1_controls *padthv1widget_control::controls (void) const
{
return m_pControls;
}
padthv1::ParamIndex padthv1widget_control::controlIndex (void) const
{
return m_index;
}
// Pseudo-destructor.
void padthv1widget_control::cleanup (void)
{
// Aint't dirty no more...
m_iDirtyCount = 0;
// Pseudo-singleton reference cleanup.
g_pInstance = nullptr;
}
void padthv1widget_control::closeEvent ( QCloseEvent *pCloseEvent )
{
cleanup();
// Sure acceptance and probable destruction (cf. WA_DeleteOnClose).
QDialog::closeEvent(pCloseEvent);
}
// Process incoming controller key event.
void padthv1widget_control::setControlKey ( const padthv1_controls::Key& key )
{
setControlType(key.type());
setControlParam(key.param);
m_ui.ControlChannelSpinBox->setValue(key.channel());
QPushButton *pResetButton
= m_ui.DialogButtonBox->button(QDialogButtonBox::Reset);
if (pResetButton && m_pControls)
pResetButton->setEnabled(m_pControls->find_control(key) >= 0);
}
padthv1_controls::Key padthv1widget_control::controlKey (void) const
{
padthv1_controls::Key key;
const padthv1_controls::Type ctype = controlType();
const unsigned short channel = controlChannel();
key.status = ctype | (channel & 0x1f);
key.param = controlParam();
return key;
}
// Change settings (anything else slot).
void padthv1widget_control::changed (void)
{
if (m_iDirtySetup > 0)
return;
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_control::changed()");
#endif
++m_iDirtyCount;
stabilize();
}
// Reset settings (action button slot).
void padthv1widget_control::clicked ( QAbstractButton *pButton )
{
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_control::clicked(%p)", pButton);
#endif
QDialogButtonBox::ButtonRole role
= m_ui.DialogButtonBox->buttonRole(pButton);
if ((role & QDialogButtonBox::ResetRole) == QDialogButtonBox::ResetRole)
reset();
}
// Reset settings (Reset button slot).
void padthv1widget_control::reset (void)
{
if (m_pControls == nullptr)
return;
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_control::reset()");
#endif
const int iIndex = m_pControls->find_control(m_key);
if (iIndex < 0)
return;
// Unmap the existing controller....
m_pControls->remove_control(m_key);
// Save controls...
padthv1_config *pConfig = padthv1_config::getInstance();
if (pConfig)
pConfig->saveControls(m_pControls);
cleanup();
// Bail out...
QDialog::accept();
}
// Accept settings (OK button slot).
void padthv1widget_control::accept (void)
{
if (m_pControls == nullptr)
return;
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_control::accept()");
#endif
// Unmap the existing controller....
int iIndex = m_pControls->find_control(m_key);
if (iIndex >= 0)
m_pControls->remove_control(m_key);
// Get new map settings...
m_key = controlKey();
// Check if already mapped to someone else...
iIndex = m_pControls->find_control(m_key);
if (iIndex >= 0 && padthv1::ParamIndex(iIndex) != m_index) {
if (QMessageBox::warning(this,
QDialog::windowTitle(),
tr("MIDI controller is already assigned.\n\n"
"Do you want to replace the mapping?"),
QMessageBox::Ok |
QMessageBox::Cancel) == QMessageBox::Cancel)
return;
}
// Unmap the existing controller....
if (iIndex >= 0)
m_pControls->remove_control(m_key);
// Reset controller flags all te way...
unsigned int flags = 0;
if (m_ui.ControlLogarithmicCheckBox->isEnabled() &&
m_ui.ControlLogarithmicCheckBox->isChecked())
flags |= padthv1_controls::Logarithmic;
if (m_ui.ControlInvertCheckBox->isEnabled() &&
m_ui.ControlInvertCheckBox->isChecked())
flags |= padthv1_controls::Invert;
if (m_ui.ControlHookCheckBox->isEnabled() &&
m_ui.ControlHookCheckBox->isChecked())
flags |= padthv1_controls::Hook;
// Map the damn controller....
padthv1_controls::Data data;
data.index = m_index;
data.flags = flags;
m_pControls->add_control(m_key, data);
// Save controls...
padthv1_config *pConfig = padthv1_config::getInstance();
if (pConfig)
pConfig->saveControls(m_pControls);
cleanup();
// Just go with dialog acceptance...
QDialog::accept();
}
// Reject settings (Cancel button slot).
void padthv1widget_control::reject (void)
{
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_control::reject()");
#endif
// Check if there's any pending changes...
if (m_iDirtyCount > 0) {
switch (QMessageBox::warning(this,
QDialog::windowTitle(),
tr("Some settings have been changed.\n\n"
"Do you want to apply the changes?"),
QMessageBox::Apply |
QMessageBox::Discard |
QMessageBox::Cancel)) {
case QMessageBox::Discard:
break;
case QMessageBox::Apply:
accept();
default:
return;
}
}
cleanup();
// Just go with dialog rejection...
QDialog::reject();
}
// Perotected slots.
void padthv1widget_control::activateControlType ( int iControlType )
{
#ifdef CONFIG_DEBUG_0
qDebug("padthv1widget_control::activateControlType(%d)", iControlType);
#endif
updateControlType(iControlType);
changed();
}
void padthv1widget_control::editControlParamFinished (void)
{
if (m_iControlParamUpdate > 0)
return;
++m_iControlParamUpdate;
const QString& sControlParam
= m_ui.ControlParamComboBox->currentText();
bool bOk = false;
sControlParam.toInt(&bOk);
if (bOk) changed();
--m_iControlParamUpdate;
}
void padthv1widget_control::stabilize (void)
{
const bool bValid = (m_iDirtyCount > 0);
m_ui.DialogButtonBox->button(QDialogButtonBox::Ok)->setEnabled(bValid);
}
// Control type dependency refresh.
void padthv1widget_control::updateControlType ( int iControlType )
{
if (iControlType < 0)
iControlType = m_ui.ControlTypeComboBox->currentIndex();
const padthv1_controls::Type ctype
= controlTypeFromIndex(iControlType);
const bool bOldEditable
= m_ui.ControlParamComboBox->isEditable();
const int iOldParam
= m_ui.ControlParamComboBox->currentIndex();
const QString sOldParam
= m_ui.ControlParamComboBox->currentText();
m_ui.ControlParamComboBox->clear();
const QString sMask("%1 - %2");
switch (ctype) {
case padthv1_controls::CC: {
if (m_ui.ControlParamTextLabel)
m_ui.ControlParamTextLabel->setEnabled(true);
m_ui.ControlParamComboBox->setEnabled(true);
m_ui.ControlParamComboBox->setEditable(false);
const padthv1widget_controls::Names& controllers
= padthv1widget_controls::controllerNames();
for (unsigned short param = 0; param < 128; ++param) {
m_ui.ControlParamComboBox->addItem(
sMask.arg(param).arg(controllers.value(param)),
int(param));
}
break;
}
case padthv1_controls::RPN: {
if (m_ui.ControlParamTextLabel)
m_ui.ControlParamTextLabel->setEnabled(true);
m_ui.ControlParamComboBox->setEnabled(true);
m_ui.ControlParamComboBox->setEditable(true);
const padthv1widget_controls::Names& rpns
= padthv1widget_controls::rpnNames();
padthv1widget_controls::Names::ConstIterator iter = rpns.constBegin();
const padthv1widget_controls::Names::ConstIterator& iter_end
= rpns.constEnd();
for ( ; iter != iter_end; ++iter) {
const unsigned short param = iter.key();
m_ui.ControlParamComboBox->addItem(
sMask.arg(param).arg(iter.value()),
int(param));
}
break;
}
case padthv1_controls::NRPN: {
if (m_ui.ControlParamTextLabel)
m_ui.ControlParamTextLabel->setEnabled(true);
m_ui.ControlParamComboBox->setEnabled(true);
m_ui.ControlParamComboBox->setEditable(true);
const padthv1widget_controls::Names& nrpns
= padthv1widget_controls::nrpnNames();
padthv1widget_controls::Names::ConstIterator iter = nrpns.constBegin();
const padthv1widget_controls::Names::ConstIterator& iter_end
= nrpns.constEnd();
for ( ; iter != iter_end; ++iter) {
const unsigned short param = iter.key();
m_ui.ControlParamComboBox->addItem(
sMask.arg(param).arg(iter.value()),
int(param));
}
break;
}
case padthv1_controls::CC14: {
if (m_ui.ControlParamTextLabel)
m_ui.ControlParamTextLabel->setEnabled(true);
m_ui.ControlParamComboBox->setEnabled(true);
m_ui.ControlParamComboBox->setEditable(false);
const padthv1widget_controls::Names& control14s
= padthv1widget_controls::control14Names();
for (unsigned short param = 1; param < 32; ++param) {
m_ui.ControlParamComboBox->addItem(
sMask.arg(param).arg(control14s.value(param)),
int(param));
}
break;
}
default:
break;
}
if (iOldParam >= 0 && iOldParam < m_ui.ControlParamComboBox->count())
m_ui.ControlParamComboBox->setCurrentIndex(iOldParam);
if (m_ui.ControlParamComboBox->isEditable()) {
QObject::connect(m_ui.ControlParamComboBox->lineEdit(),
SIGNAL(editingFinished()),
SLOT(editControlParamFinished()));
if (bOldEditable)
m_ui.ControlParamComboBox->setEditText(sOldParam);
}
}
void padthv1widget_control::setControlType ( padthv1_controls::Type ctype )
{
const int iControlType = indexFromControlType(ctype);
m_ui.ControlTypeComboBox->setCurrentIndex(iControlType);
updateControlType(iControlType);
}
padthv1_controls::Type padthv1widget_control::controlType (void) const
{
return controlTypeFromIndex(m_ui.ControlTypeComboBox->currentIndex());
}
void padthv1widget_control::setControlParam ( unsigned short param )
{
const int iControlParam = indexFromControlParam(param);
if (iControlParam >= 0) {
m_ui.ControlParamComboBox->setCurrentIndex(iControlParam);
} else {
const QString& sControlParam = QString::number(param);
m_ui.ControlParamComboBox->setEditText(sControlParam);
}
}
unsigned short padthv1widget_control::controlParam (void) const
{
if (m_ui.ControlParamComboBox->isEditable()) {
unsigned short param = 0;
const QString& sControlParam
= m_ui.ControlParamComboBox->currentText();
bool bOk = false;
param = sControlParam.toInt(&bOk);
if (bOk) return param;
}
return controlParamFromIndex(m_ui.ControlParamComboBox->currentIndex());
}
unsigned short padthv1widget_control::controlChannel (void) const
{
return m_ui.ControlChannelSpinBox->value();
}
padthv1_controls::Type padthv1widget_control::controlTypeFromIndex ( int iIndex ) const
{
if (iIndex >= 0 && iIndex < m_ui.ControlTypeComboBox->count())
return padthv1_controls::Type(
m_ui.ControlTypeComboBox->itemData(iIndex).toInt());
else
return padthv1_controls::CC;
}
int padthv1widget_control::indexFromControlType ( padthv1_controls::Type ctype ) const
{
return m_ui.ControlTypeComboBox->findData(int(ctype));
}
unsigned short padthv1widget_control::controlParamFromIndex ( int iIndex ) const
{
if (iIndex >= 0 && iIndex < m_ui.ControlParamComboBox->count())
return m_ui.ControlParamComboBox->itemData(iIndex).toInt();
else
return 0;
}
int padthv1widget_control::indexFromControlParam ( unsigned short param ) const
{
return m_ui.ControlParamComboBox->findData(int(param));
}
// end of padthv1widget_control.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1_reverb.h 0000644 0000000 0000000 00000000132 14554770535 016127 x ustar 00 30 mtime=1706291549.610007106
30 atime=1706291549.610007106
30 ctime=1706291549.610007106
padthv1-0.9.34/src/padthv1_reverb.h 0000644 0001750 0000144 00000014334 14554770535 016124 0 ustar 00rncbc users // padthv1_reverb.h
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1_reverb_h
#define __padthv1_reverb_h
#include
#include
//-------------------------------------------------------------------------
// padthv1_reverb
//
// -- borrowed, stirred and refactored from original FreeVerb --
// by Jezar at Dreampoint, June 2000 (public domain)
//
class padthv1_reverb
{
public:
padthv1_reverb (float srate = 44100.0f)
: m_srate(srate), m_room(0.5f), m_damp(0.5f), m_feedb(0.5f)
{ reset(); }
void setSampleRate(float srate)
{ m_srate = srate; }
float sampleRate() const
{ return m_srate; }
void reset()
{
static const uint32_t s_comb[NUM_COMBS]
= { 1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617, 1685, 1748 };
static const uint32_t s_allpass[NUM_ALLPASSES]
= { 556, 441, 341, 225, 180, 153 };
const float sr = m_srate / 44100.0f;
uint32_t j;
for (j = 0; j < NUM_ALLPASSES; ++j) {
m_allpass0[j].resize(uint32_t(s_allpass[j] * sr));
m_allpass0[j].reset();
m_allpass1[j].resize(uint32_t((s_allpass[j] + STEREO_SPREAD) * sr));
m_allpass1[j].reset();
}
for (j = 0; j < NUM_COMBS; ++j) {
m_comb0[j].resize(uint32_t(s_comb[j] * sr));
m_comb0[j].reset();
m_comb1[j].resize(uint32_t((s_comb[j] + STEREO_SPREAD) * sr));
m_comb1[j].reset();
}
reset_feedb();
reset_room();
reset_damp();
}
void process(float *in0, float *in1, uint32_t nframes,
float wet, float feedb, float room, float damp, float width)
{
if (wet < 1E-9f)
return;
if (m_feedb != feedb) {
m_feedb = feedb;
reset_feedb();
}
if (m_room != room) {
m_room = room;
reset_room();
}
if (m_damp != damp) {
m_damp = damp;
reset_damp();
}
uint32_t i, j;
for (i = 0; i < nframes; ++i) {
float out0 = *in0 * 0.05f; // 0.015f;
float out1 = *in1 * 0.05f; // 0.015f;
float tmp0 = 0.0f;
float tmp1 = 0.0f;
for (j = 0; j < NUM_COMBS; ++j) {
tmp0 += m_comb0[j].output(out0);
tmp1 += m_comb1[j].output(out1);
}
for (j = 0; j < NUM_ALLPASSES; ++j) {
tmp0 = m_allpass0[j].output(tmp0);
tmp1 = m_allpass1[j].output(tmp1);
}
if (width < 0.0f) {
out0 = tmp0 * (1.0f + width) - tmp1 * width;
out1 = tmp1 * (1.0f + width) - tmp0 * width;
} else {
out0 = tmp0 * width + tmp1 * (1.0f - width);
out1 = tmp1 * width + tmp0 * (1.0f - width);
}
*in0++ += wet * out0;
*in1++ += wet * out1;
}
}
protected:
static const uint32_t NUM_COMBS = 10;
static const uint32_t NUM_ALLPASSES = 6;
static const uint32_t STEREO_SPREAD = 23;
void reset_room()
{
for (uint32_t j = 0; j < NUM_COMBS; ++j) {
m_comb0[j].set_feedb(m_room);
m_comb1[j].set_feedb(m_room);
}
}
void reset_damp()
{
const float damp2 = m_damp * m_damp;
for (uint32_t j = 0; j < NUM_COMBS; ++j) {
m_comb0[j].set_damp(damp2);
m_comb1[j].set_damp(damp2);
}
}
void reset_feedb()
{
const float feedb2 = 2.0f * m_feedb * (2.0f - m_feedb) / 3.0f;
for (uint32_t j = 0; j < NUM_ALLPASSES; ++j) {
m_allpass0[j].set_feedb(feedb2);
m_allpass1[j].set_feedb(feedb2);
}
}
class sample_buffer
{
public:
sample_buffer (uint32_t size = 0)
: m_buffer(0), m_size(0), m_index(0)
{ resize(size); }
virtual ~sample_buffer()
{ delete [] m_buffer; }
void reset()
{ ::memset(m_buffer, 0, m_size * sizeof(float)); m_index = 0; }
void resize(uint32_t size)
{
if (size < 1)
size = 1;
if (m_size != size) {
const uint32_t old_size = m_size;
if (size > old_size) {
float *old_buffer = m_buffer;
m_buffer = new float [size];
m_size = size;
if (old_buffer) {
::memcpy(m_buffer, old_buffer,
old_size * sizeof(float));
delete [] old_buffer;
}
}
}
}
float *tick()
{
float *buf = m_buffer + m_index;
if (++m_index >= m_size)
m_index = 0;
return buf;
}
private:
float *m_buffer;
uint32_t m_size;
uint32_t m_index;
};
class comb_filter : public sample_buffer
{
public:
comb_filter (uint32_t size = 0)
: sample_buffer(size), m_feedb(0.5f), m_damp(0.5f), m_out(0.0f) {}
void set_feedb(float feedb)
{ m_feedb = feedb; }
float feedb() const
{ return m_feedb; }
void set_damp(float damp)
{ m_damp = damp; }
float damp() const
{ return m_damp; }
void reset()
{ sample_buffer::reset(); m_out = 0.0f; }
float output(float in)
{
float *buf = tick();
float out = *buf;
m_out = denormal(out * (1.0f - m_damp) + m_out * m_damp);
*buf = in + (m_out * m_feedb);
return out;
}
private:
float m_feedb;
float m_damp;
float m_out;
};
class allpass_filter : public sample_buffer
{
public:
allpass_filter(uint32_t size = 0)
: sample_buffer(size), m_feedb(0.5f) {}
void set_feedb(float feedb)
{ m_feedb = feedb; }
float feedb () const
{ return m_feedb; }
float output(float in)
{
float *buf = tick();
float out = *buf;
*buf = denormal(in + out * m_feedb);
return out - in;
}
private:
float m_feedb;
};
static float denormal(float v)
{
union { float f; uint32_t w; } u;
u.f = v;
return (u.w & 0x7f800000) ? v : 0.0f;
}
private:
float m_srate;
float m_room;
float m_damp;
float m_feedb;
comb_filter m_comb0[NUM_COMBS];
comb_filter m_comb1[NUM_COMBS];
allpass_filter m_allpass0[NUM_ALLPASSES];
allpass_filter m_allpass1[NUM_ALLPASSES];
};
#endif // __padthv1_reverb_h
padthv1-0.9.34/src/PaxHeaders/padthv1widget_param.h 0000644 0000000 0000000 00000000132 14554770535 017146 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_param.h 0000644 0001750 0000144 00000021507 14554770535 017143 0 ustar 00rncbc users // padthv1widget_param.h
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1widget_param_h
#define __padthv1widget_param_h
#include
#include
#include
#include
#include
// Forward declarations.
class QLabel;
class QComboBox;
class QCheckBox;
//-------------------------------------------------------------------------
// padthv1widget_param - Custom composite widget.
class padthv1widget_param : public QWidget
{
Q_OBJECT
public:
// Constructor.
padthv1widget_param(QWidget *pParent = 0);
// Accessors.
virtual void setText(const QString& sText);
virtual QString text() const;
virtual void setMaximum(float fMaximum);
float maximum() const;
virtual void setMinimum(float fMinimum);
float minimum() const;
void resetDefaultValue();
bool isDefaultValue() const;
void setDefaultValue(float fDefaultValue);
float defaultValue() const;
virtual QString valueText() const;
float value() const;
// Scale multiplier accessors.
void setScale(float fScale);
float scale() const;
public slots:
// Virtual accessor.
virtual void setValue(float fValue);
signals:
// Change signal.
void valueChanged(float);
protected:
// Mouse behavior event handler.
void mousePressEvent(QMouseEvent *pMouseEvent);
// Scale/value converters.
float scaleFromValue(float fValue) const;
float valueFromScale(float fScale) const;
private:
// Current value.
float m_fValue;
// Current value range.
float m_fMinimum;
float m_fMaximum;
// Default value.
float m_fDefaultValue;
int m_iDefaultValue;
// Scale multiplier (default=100).
float m_fScale;
};
//-------------------------------------------------------------------------
// padthv1widget_dial - A better QDial widget.
class padthv1widget_dial : public QDial
{
Q_OBJECT
public:
// Constructor.
padthv1widget_dial(QWidget *pParent = 0);
// Dial mode behavior:
// DefaultMode - default (old) QDial behavior.
// LinearMode - proportionally to distance in one ortogonal axis.
// AngularMode - angularly relative to widget center.
enum DialMode { DefaultMode = 0, LinearMode, AngularMode };
// Set knob dial mode behavior.
static void setDialMode(DialMode dialMode);
static DialMode dialMode();
protected:
// Mouse angle determination.
float mouseAngle(const QPoint& pos);
// Alternate mouse behavior event handlers.
void mousePressEvent(QMouseEvent *pMouseEvent);
void mouseMoveEvent(QMouseEvent *pMouseEvent);
void mouseReleaseEvent(QMouseEvent *pMouseEvent);
private:
// Alternate mouse behavior tracking.
bool m_bMousePressed;
QPoint m_posMouse;
// Just for more precission on the movement
float m_fLastDragValue;
// Knob dial mode behavior.
static DialMode g_dialMode;
};
//-------------------------------------------------------------------------
// padthv1widget_knob - Custom knob/dial widget.
class padthv1widget_knob : public padthv1widget_param
{
Q_OBJECT
public:
// Constructor.
padthv1widget_knob(QWidget *pParent = 0);
// Accessors.
void setText(const QString& sText);
QString text() const;
void setMaximum(float fMaximum);
void setMinimum(float fMinimum);
public slots:
// Virtual accessor.
void setValue(float fValue);
protected slots:
// Dial change slot.
void dialValueChanged(int);
protected:
// Scale-step accessors.
void setSingleStep(float fSingleStep);
float singleStep() const;
private:
// Widget members.
QLabel *m_pLabel;
padthv1widget_dial *m_pDial;
};
//-------------------------------------------------------------------------
// padthv1widget_edit - A better QDoubleSpinBox widget.
class padthv1widget_edit : public QDoubleSpinBox
{
Q_OBJECT
public:
// Constructor.
padthv1widget_edit(QWidget *pParent = 0);
// Edit mode behavior:
// DefaultMode - default (immediate value changes) behavior.
// DeferredMode - deferred value changes (to when editing is finished).
enum EditMode { DefaultMode = 0, DeferredMode };
// Set spin-box edit mode behavior.
static void setEditMode(EditMode editMode);
static EditMode editMode();
protected slots:
// Alternate value change behavior handlers.
void lineEditTextChanged(const QString&);
void spinBoxEditingFinished();
void spinBoxValueChanged(double);
signals:
// Alternate value change signal.
void valueChangedEx(double);
protected:
// Inherited/override methods.
QValidator::State validate(QString& sText, int& iPos) const;
private:
// Alternate edit behavior tracking.
int m_iTextChanged;
// Spin-box edit mode behavior.
static EditMode g_editMode;
};
//-------------------------------------------------------------------------
// padthv1widget_spin - Custom knob/spin-box widget.
class padthv1widget_spin : public padthv1widget_knob
{
Q_OBJECT
public:
// Constructor.
padthv1widget_spin(QWidget *pParent = 0);
// Virtual accessors.
void setMaximum(float fMaximum);
void setMinimum(float fMinimum);
QString valueText() const;
// Specialized accessors.
void setSpecialValueText(const QString& sText);
QString specialValueText() const;
bool isSpecialValue() const;
void setDecimals(int iDecimals);
int decimals() const;
public slots:
// Virtual accessor.
void setValue(float fValue);
protected slots:
// Change slot.
void spinBoxValueChanged(double);
private:
// Widget members.
padthv1widget_edit *m_pSpinBox;
};
//-------------------------------------------------------------------------
// padthv1widget_combo - Custom knob/combo-box widget.
class padthv1widget_combo : public padthv1widget_knob
{
Q_OBJECT
public:
// Constructor.
padthv1widget_combo(QWidget *pParent = 0);
// Virtual accessors.
QString valueText() const;
// Specialized accessors.
void insertItems(int iIndex, const QStringList& items);
void clear();
public slots:
// Virtual accessor.
void setValue(float fValue);
protected slots:
// Change slot.
void comboBoxValueChanged(int);
protected:
// Reimplemented mouse-wheel stepping.
void wheelEvent(QWheelEvent *pWheelEvent);
private:
// Widget members.
QComboBox *m_pComboBox;
};
//-------------------------------------------------------------------------
// padthv1widget_radio - Custom radio-button widget.
class padthv1widget_radio : public padthv1widget_param
{
Q_OBJECT
public:
// Constructor.
padthv1widget_radio(QWidget *pParent = 0);
// Desstructor.
~padthv1widget_radio();
// Virtual accessors.
QString valueText() const;
// Specialized accessors.
void insertItems(int iIndex, const QStringList& items);
void clear();
public slots:
// Virtual accessor.
void setValue(float fValue);
protected slots:
// Change slot.
void radioGroupValueChanged(int);
private:
// Widget members.
QButtonGroup m_group;
};
//-------------------------------------------------------------------------
// padthv1widget_check - Custom check-box widget.
class padthv1widget_check : public padthv1widget_param
{
Q_OBJECT
public:
// Constructor.
padthv1widget_check(QWidget *pParent = 0);
// Desstructor.
~padthv1widget_check();
// Accessors.
void setText(const QString& sText);
QString text() const;
void setAlignment(Qt::Alignment alignment);
Qt::Alignment alignment() const;
public slots:
// Virtual accessor.
void setValue(float fValue);
protected slots:
// Change slot.
void checkBoxValueChanged(bool);
private:
// Widget members.
QCheckBox *m_pCheckBox;
Qt::Alignment m_alignment;
};
//-------------------------------------------------------------------------
// padthv1widget_group - Custom checkable group-box widget.
class padthv1widget_group : public QGroupBox
{
Q_OBJECT
public:
// Constructor.
padthv1widget_group(QWidget *pParent = 0);
// Desstructor.
~padthv1widget_group();
// Accessors.
void setToolTip(const QString& sToolTip);
QString toolTip() const;
padthv1widget_param *param() const;
protected slots:
// Change slot.
void paramValueChanged(float);
void groupBoxValueChanged(bool);
private:
// Widget members.
padthv1widget_param *m_pParam;
};
#endif // __padthv1widget_param_h
// end of padthv1widget_param.h
padthv1-0.9.34/src/PaxHeaders/padthv1_programs.cpp 0000644 0000000 0000000 00000000132 14554770535 017027 x ustar 00 30 mtime=1706291549.610007106
30 atime=1706291549.610007106
30 ctime=1706291549.610007106
padthv1-0.9.34/src/padthv1_programs.cpp 0000644 0001750 0000144 00000010003 14554770535 017011 0 ustar 00rncbc users // padthv1_programs.cpp
//
/****************************************************************************
Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1_programs.h"
//-------------------------------------------------------------------------
// padthv1_programs - Bank/programs database class (singleton).
//
// ctor.
padthv1_programs::padthv1_programs ( padthv1 *pSynth )
: m_enabled(false), m_sched(pSynth),
m_bank_msb(0), m_bank_lsb(0),
m_bank(nullptr), m_prog(nullptr)
{
}
// dtor.
padthv1_programs::~padthv1_programs (void)
{
clear_banks();
}
// prog. managers
padthv1_programs::Prog *padthv1_programs::Bank::find_prog ( uint16_t prog_id ) const
{
return m_progs.value(prog_id, nullptr);
}
padthv1_programs::Prog *padthv1_programs::Bank::add_prog (
uint16_t prog_id, const QString& prog_name )
{
Prog *prog = find_prog(prog_id);
if (prog) {
prog->set_name(prog_name);
} else {
prog = new Prog(prog_id, prog_name);
m_progs.insert(prog_id, prog);
}
return prog;
}
void padthv1_programs::Bank::remove_prog ( uint16_t prog_id )
{
Prog *prog = find_prog(prog_id);
if (prog && m_progs.remove(prog_id))
delete prog;
}
void padthv1_programs::Bank::clear_progs (void)
{
qDeleteAll(m_progs);
m_progs.clear();
}
// bank managers
padthv1_programs::Bank *padthv1_programs::find_bank ( uint16_t bank_id ) const
{
return m_banks.value(bank_id, nullptr);
}
padthv1_programs::Bank *padthv1_programs::add_bank (
uint16_t bank_id, const QString& bank_name )
{
Bank *bank = find_bank(bank_id);
if (bank) {
bank->set_name(bank_name);
} else {
bank = new Bank(bank_id, bank_name);
m_banks.insert(bank_id, bank);
}
return bank;
}
void padthv1_programs::remove_bank ( uint16_t bank_id )
{
Bank *bank = find_bank(bank_id);
if (bank && m_banks.remove(bank_id))
delete bank;
}
void padthv1_programs::clear_banks (void)
{
m_bank_msb = 0;
m_bank_lsb = 0;
m_bank = nullptr;
m_prog = nullptr;
qDeleteAll(m_banks);
m_banks.clear();
}
// current bank/prog. managers
void padthv1_programs::bank_select_msb ( uint8_t bank_msb )
{
m_bank_msb = 0x80 | (bank_msb & 0x7f);
}
void padthv1_programs::bank_select_lsb ( uint8_t bank_lsb )
{
m_bank_lsb = 0x80 | (bank_lsb & 0x7f);
}
void padthv1_programs::bank_select ( uint16_t bank_id )
{
bank_select_msb(bank_id >> 7);
bank_select_lsb(bank_id);
}
uint16_t padthv1_programs::current_bank_id (void) const
{
uint16_t bank_id = 0;
if (m_bank_msb & 0x80)
bank_id = (m_bank_msb & 0x7f);
if (m_bank_lsb & 0x80) {
bank_id <<= 7;
bank_id |= (m_bank_lsb & 0x7f);
}
return bank_id;
}
void padthv1_programs::prog_change ( uint16_t prog_id )
{
select_program(current_bank_id(), prog_id);
}
void padthv1_programs::select_program ( uint16_t bank_id, uint16_t prog_id )
{
if (!enabled())
return;
if (m_bank && m_bank->id() == bank_id &&
m_prog && m_prog->id() == prog_id)
return;
m_sched.select_program(bank_id, prog_id);
}
void padthv1_programs::process_program (
padthv1 *pSynth, uint16_t bank_id, uint16_t prog_id )
{
m_bank = find_bank(bank_id);
m_prog = (m_bank ? m_bank->find_prog(prog_id) : nullptr);
if (m_prog) {
padthv1_param::loadPreset(pSynth, m_prog->name());
pSynth->updateParams();
}
}
// end of padthv1_programs.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1widget_control.h 0000644 0000000 0000000 00000000132 14554770535 017526 x ustar 00 30 mtime=1706291549.611007099
30 atime=1706291549.611007099
30 ctime=1706291549.611007099
padthv1-0.9.34/src/padthv1widget_control.h 0000644 0001750 0000144 00000006574 14554770535 017532 0 ustar 00rncbc users // padthv1widget_control.h
//
/****************************************************************************
Copyright (C) 2012-2022, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1widget_control_h
#define __padthv1widget_control_h
#include "padthv1_controls.h"
#include "padthv1_param.h"
#include
// forward decls.
namespace Ui { class padthv1widget_control; }
class QAbstractButton;
class QCloseEvent;
//----------------------------------------------------------------------------
// padthv1widget_control -- UI wrapper form.
class padthv1widget_control : public QDialog
{
Q_OBJECT
public:
// Pseudo-singleton instance.
static padthv1widget_control *getInstance();
// Pseudo-constructor.
static void showInstance(
padthv1_controls *pControls, padthv1::ParamIndex index,
const QString& sTitle, QWidget *pParent = nullptr);
// Control accessors.
void setControls(padthv1_controls *pControls, padthv1::ParamIndex index);
padthv1_controls *controls() const;
padthv1::ParamIndex controlIndex() const;
// Process incoming controller key event.
void setControlKey(const padthv1_controls::Key& key);
padthv1_controls::Key controlKey() const;
protected slots:
void changed();
void clicked(QAbstractButton *);
void reset();
void accept();
void reject();
void activateControlType(int);
void editControlParamFinished();
void stabilize();
protected:
// Constructor.
padthv1widget_control(QWidget *pParent = nullptr);
// Destructor.
~padthv1widget_control();
// Pseudo-destructor.
void cleanup();
void closeEvent(QCloseEvent *pCloseEvent);
// Control type dependency refresh.
void updateControlType(int iControlType);
void setControlType(padthv1_controls::Type ctype);
padthv1_controls::Type controlType() const;
void setControlParam(unsigned short param);
unsigned short controlParam() const;
unsigned short controlChannel() const;
padthv1_controls::Type controlTypeFromIndex (int iIndex) const;
int indexFromControlType(padthv1_controls::Type ctype) const;
unsigned short controlParamFromIndex(int iIndex) const;
int indexFromControlParam(unsigned short param) const;
private:
// The Qt-designer UI struct...
Ui::padthv1widget_control *p_ui;
Ui::padthv1widget_control& m_ui;
// Instance variables.
padthv1_controls *m_pControls;
// Target subject.
padthv1_controls::Key m_key;
padthv1::ParamIndex m_index;
// Instance variables.
int m_iControlParamUpdate;
int m_iDirtyCount;
int m_iDirtySetup;
// Pseudo-singleton instance.
static padthv1widget_control *g_pInstance;
};
#endif // __padthv1widget_control_h
// end of padthv1widget_control.h
padthv1-0.9.34/src/PaxHeaders/padthv1_sched.h 0000644 0000000 0000000 00000000132 14554770535 015730 x ustar 00 30 mtime=1706291549.610007106
30 atime=1706291549.610007106
30 ctime=1706291549.610007106
padthv1-0.9.34/src/padthv1_sched.h 0000644 0001750 0000144 00000004601 14554770535 015721 0 ustar 00rncbc users // padthv1_sched.h
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1_sched_h
#define __padthv1_sched_h
#include
// forward decls.
class padthv1;
//-------------------------------------------------------------------------
// padthv1_sched - worker/scheduled stuff (pure virtual).
//
class padthv1_sched
{
public:
// plausible sched types.
enum Type { Sample, Programs, Controls, Controller, MidiIn };
// ctor.
padthv1_sched(padthv1 *pSynth, Type stype, uint32_t nsize = 8);
// virtual dtor.
virtual ~padthv1_sched();
// instance access.
padthv1 *instance() const;
// schedule process.
void schedule(int sid = 0);
// test-and-set wait.
bool sync_wait();
// scheduled processor.
void sync_process();
// (pure) virtual processor.
virtual void process(int sid) = 0;
// signal broadcast (static).
static void sync_notify(padthv1 *pSynth, Type stype, int sid);
// Notifier - Worker/schedule proxy decl.
//
class Notifier
{
public:
// ctor.
Notifier(padthv1 *pSynth);
// dtor.
virtual ~Notifier();
// signal notifier.
virtual void notify(padthv1_sched::Type stype, int sid) const = 0;
private:
// instance variables.
padthv1 *m_pSynth;
};
private:
// instance variables.
padthv1 *m_pSynth;
Type m_stype;
// sched queue instance reference.
uint32_t m_nsize;
uint32_t m_nmask;
int *m_items;
volatile uint32_t m_iread;
volatile uint32_t m_iwrite;
volatile bool m_sync_wait;
};
#endif // __padthv1_sched_h
// end of padthv1_sched.h
padthv1-0.9.34/src/PaxHeaders/padthv1widget_config.ui 0000644 0000000 0000000 00000000132 14554770535 017501 x ustar 00 30 mtime=1706291549.611007099
30 atime=1706291549.611007099
30 ctime=1706291549.611007099
padthv1-0.9.34/src/padthv1widget_config.ui 0000644 0001750 0000144 00000072376 14554770535 017510 0 ustar 00rncbc users
rncbc aka Rui Nuno Capela
padthv1 - an old-school additive polyphonic synthesizer
Copyright (C) 2012-2022, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
padthv1widget_config
0
0
520
340
Configure
:/images/padthv1.svg
-
0
&Options
Options
-
Whether to use desktop environment's native dialogs where applicable
Use desktop environment &native dialogs
-
&Knob dial mode:
KnobDialModeComboBox
-
Knob dial mode
false
-
(default)
-
Linear
-
Angular
-
Qt::Horizontal
20
20
-
Knob &edit mode:
KnobEditModeComboBox
-
Knob edit mode
false
-
(default)
-
Deferred
-
Custom &color theme:
CustomColorThemeComboBox
-
Custom color palette theme
false
-
(default)
-
Wonton Soup
-
KXStudio
-
22
22
24
24
Manage custom color palette themes
...
-
Custom &style theme:
CustomStyleThemeComboBox
-
Custom widget style theme
false
-
(default)
-
&Randomize factor:
RandomizePercentSpinBox
-
Randomizer deviation from current value
%
true
1
0.1
100.0
0.1
20.0
-
Qt::Vertical
20
20
&Programs
Programs
-
-
Add bank
Add &Bank
:/images/presetBank.png
Qt::ToolButtonTextBesideIcon
-
Add program
&Add Program
:/images/padthv1_preset.png
Qt::ToolButtonTextBesideIcon
-
Qt::Horizontal
20
20
-
Edit bank/program
&Edit
:/images/presetEdit.png
Qt::ToolButtonTextBesideIcon
-
Qt::Horizontal
20
20
-
Delete bank/program
&Delete
:/images/presetDelete.png
Qt::ToolButtonTextBesideIcon
-
Programs
true
true
true
2
Bank/Program
Preset
-
-
Whether MIDI bank/programs will be enabled
E&nabled
-
Qt::Horizontal
20
20
-
Whether to preview the current selected program
&Preview current program
&Controllers
Controllers
-
-
Add controller
&Add Controller
:/images/padthv1_control.png
Qt::ToolButtonTextBesideIcon
-
Qt::Horizontal
20
20
-
Edit controller
&Edit
:/images/presetEdit.png
Qt::ToolButtonTextBesideIcon
-
Qt::Horizontal
20
20
-
Delete controller
&Delete
:/images/presetDelete.png
Qt::ToolButtonTextBesideIcon
-
Controllers
true
true
false
4
Channel
Type
Parameter
Subject
-
-
Whether MIDI controllers will be enabled
E&nabled
-
Qt::Horizontal
20
20
&Tuning
Tuning
-
0
0
-
QTabBar::RoundedNorth
-
true
QFrame::NoFrame
QFrame::Plain
-
Whether to use custom tuning (micro-tonal)
&Enable custom tuning (micro-tonal)
-
Re&ference:
TuningRefNoteComboBox
-
64
24
Reference note
false
-
96
24
Reference pitch
Hz
1
20.0
8000.0
440.0
-
Reset reference note and pitch to default (A4@440Hz)
&Reset
false
-
Qt::Horizontal
20
8
-
Whether to use an alternate scale definition file (*.scl)
&Scale:
TuningScaleFileComboBox
-
360
0
Scale definition file (*.scl)
false
-
(default)
-
22
22
24
24
Qt::TabFocus
Browse for the scale file location (*.scl)
:/images/fileOpen.png
-
Whether to use an alternate keyboard-map file (*.kbm)
&Key map:
TuningKeyMapFileComboBox
-
360
0
Keyboard map file (*.kbm)
false
-
(default)
-
22
22
24
24
Qt::TabFocus
Browse for the keyboard-map file location (*.kbm)
:/images/fileOpen.png
-
Qt::Vertical
20
20
-
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
padthv1widget_controls
QTreeWidget
padthv1widget_programs
QTreeWidget
UseNativeDialogsCheckBox
KnobDialModeComboBox
KnobEditModeComboBox
CustomColorThemeComboBox
CustomColorThemeToolButton
CustomStyleThemeComboBox
ProgramsAddBankToolButton
ProgramsAddItemToolButton
ProgramsEditToolButton
ProgramsDeleteToolButton
ProgramsTreeWidget
ProgramsEnabledCheckBox
ProgramsPreviewCheckBox
ControlsAddItemToolButton
ControlsEditToolButton
ControlsDeleteToolButton
ControlsTreeWidget
ControlsEnabledCheckBox
TuningEnabledCheckBox
TuningRefNoteComboBox
TuningRefPitchSpinBox
TuningRefNotePushButton
TuningScaleFileComboBox
TuningScaleFileToolButton
TuningKeyMapFileComboBox
TuningKeyMapFileToolButton
DialogButtonBox
padthv1-0.9.34/src/PaxHeaders/padthv1_nsm.cpp 0000644 0000000 0000000 00000000132 14554770535 015772 x ustar 00 30 mtime=1706291549.610007106
30 atime=1706291549.610007106
30 ctime=1706291549.610007106
padthv1-0.9.34/src/padthv1_nsm.cpp 0000644 0001750 0000144 00000026056 14554770535 015773 0 ustar 00rncbc users // padthv1_nsm.cpp
//
/****************************************************************************
Copyright (C) 2012-2023, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1_nsm.h"
#include
#include
#define NSM_API_VERSION_MAJOR 1
#define NSM_API_VERSION_MINOR 0
#ifdef CONFIG_LIBLO
//---------------------------------------------------------------------------
// padthv1_nsm - OSC (liblo) callback methods.
static
int osc_nsm_error ( const char */*path*/, const char */*types*/,
lo_arg **argv, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
if (strcmp(&argv[0]->s, "/nsm/server/announce"))
return -1;
pNsmClient->nsm_announce_error(&argv[2]->s);
return 0;
}
static
int osc_nsm_reply ( const char */*path*/, const char */*types*/,
lo_arg **argv, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
if (strcmp(&argv[0]->s, "/nsm/server/announce"))
return -1;
pNsmClient->nsm_announce_reply(&argv[1]->s, &argv[2]->s, &argv[3]->s);
return 0;
}
static
int osc_nsm_open ( const char */*path*/, const char */*types*/,
lo_arg **argv, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
pNsmClient->nsm_open(&argv[0]->s, &argv[1]->s, &argv[2]->s);
return 0;
}
static
int osc_nsm_save ( const char */*path*/, const char */*types*/,
lo_arg **/*argv*/, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
pNsmClient->nsm_save();
return 0;
}
static
int osc_nsm_loaded ( const char */*path*/, const char */*types*/,
lo_arg **/*argv*/, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
pNsmClient->nsm_loaded();
return 0;
}
static
int osc_nsm_show ( const char */*path*/, const char */*types*/,
lo_arg **/*argv*/, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
pNsmClient->nsm_show();
return 0;
}
static
int osc_nsm_hide ( const char */*path*/, const char */*types*/,
lo_arg **/*argv*/, int /*argc*/, lo_message /*msg*/, void *user_data )
{
padthv1_nsm *pNsmClient
= static_cast (user_data);
if (pNsmClient == nullptr)
return -1;
pNsmClient->nsm_hide();
return 0;
}
#endif // CONFIG_LIBLO
//---------------------------------------------------------------------------
// padthv1_nsm - NSM OSC client agent.
// Constructor.
padthv1_nsm::padthv1_nsm (
const QString& nsm_url, QObject *pParent )
: QObject(pParent),
#ifdef CONFIG_LIBLO
m_address(nullptr),
m_thread(nullptr),
m_server(nullptr),
#endif
m_active(false),
m_dirty(false)
{
#ifdef CONFIG_LIBLO
m_address = lo_address_new_from_url(nsm_url.toUtf8().constData());
int proto = lo_address_get_protocol(m_address);
m_thread = lo_server_thread_new_with_proto(nullptr, proto, nullptr);
if (m_thread) {
m_server = lo_server_thread_get_server(m_thread);
lo_server_thread_add_method(m_thread,
"/error", "sis", osc_nsm_error, this);
lo_server_thread_add_method(m_thread,
"/reply", "ssss", osc_nsm_reply, this);
lo_server_thread_add_method(m_thread,
"/nsm/client/open", "sss", osc_nsm_open, this);
lo_server_thread_add_method(m_thread,
"/nsm/client/save", "", osc_nsm_save, this);
lo_server_thread_add_method(m_thread,
"/nsm/client/session_is_loaded", "", osc_nsm_loaded, this);
lo_server_thread_add_method(m_thread,
"/nsm/client/show_optional_gui", "", osc_nsm_show, this);
lo_server_thread_add_method(m_thread,
"/nsm/client/hide_optional_gui", "", osc_nsm_hide, this);
lo_server_thread_start(m_thread);
}
#endif
}
// Destructor.
padthv1_nsm::~padthv1_nsm (void)
{
#ifdef CONFIG_LIBLO
if (m_thread) {
lo_server_thread_stop(m_thread);
lo_server_thread_free(m_thread);
}
if (m_address)
lo_address_free(m_address);
#endif
}
// Session clieant methods.
void padthv1_nsm::announce (
const QString& app_name, const QString& capabilities )
{
#ifdef CONFIG_LIBLO
if (m_address && m_server) {
const QFileInfo fi(QApplication::applicationFilePath());
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
"/nsm/server/announce", "sssiii",
app_name.toUtf8().constData(),
capabilities.toUtf8().constData(),
fi.fileName().toUtf8().constData(),
NSM_API_VERSION_MAJOR,
NSM_API_VERSION_MINOR,
int(QApplication::applicationPid()));
}
#endif
}
// Session activation accessor.
bool padthv1_nsm::is_active (void) const
{
return m_active;
}
// Session manager accessors.
const QString& padthv1_nsm::manager (void) const
{
return m_manager;
}
const QString& padthv1_nsm::capabilities (void) const
{
return m_capabilities;
}
// Session client accessors.
const QString& padthv1_nsm::path_name (void) const
{
return m_path_name;
}
const QString& padthv1_nsm::display_name (void) const
{
return m_display_name;
}
const QString& padthv1_nsm::client_name (void) const
{
return m_client_name;
}
// Session client methods.
void padthv1_nsm::dirty ( bool is_dirty )
{
if ((!is_dirty && !m_dirty) ||
( is_dirty && m_dirty))
return;
m_dirty = is_dirty;
#ifdef CONFIG_LIBLO
if (m_address && m_server && m_active) {
const char *path = is_dirty
? "/nsm/client/is_dirty"
: "/nsm/client/is_clean";
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
path, "");
}
#endif
}
void padthv1_nsm::visible ( bool is_visible )
{
#ifdef CONFIG_LIBLO
if (m_address && m_server && m_active) {
const char *path = is_visible
? "/nsm/client/gui_is_shown"
: "/nsm/client/gui_is_hidden";
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
path, "");
}
#endif
}
void padthv1_nsm::progress ( float percent )
{
#ifdef CONFIG_LIBLO
if (m_address && m_server && m_active) {
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
"/nsm/client/progress", "f", percent);
}
#endif
}
void padthv1_nsm::message ( int priority, const QString& mesg )
{
#ifdef CONFIG_LIBLO
if (m_address && m_server && m_active) {
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
"/nsm/client/message", "is", priority,
mesg.toUtf8().constData());
}
#endif
}
// Session client reply methods.
void padthv1_nsm::open_reply ( ReplyCode reply_code )
{
reply("/nsm/client/open", reply_code);
}
void padthv1_nsm::save_reply ( ReplyCode reply_code )
{
reply("/nsm/client/save", reply_code);
}
void padthv1_nsm::reply ( const QString& path, ReplyCode reply_code )
{
const char *reply_mesg;
switch (reply_code) {
case ERR_OK: reply_mesg = "OK"; break;
case ERR_GENERAL: reply_mesg = "ERR_GENERAL"; break;
case ERR_INCOMPATIBLE_API: reply_mesg = "ERR_INCOMPATIBLE_API"; break;
case ERR_BLACKLISTED: reply_mesg = "ERR_BLACKLISTED"; break;
case ERR_LAUNCH_FAILED: reply_mesg = "ERR_LAUNCH_FAILED"; break;
case ERR_NO_SUCH_FILE: reply_mesg = "ERR_NO_SUCH_FILE"; break;
case ERR_NO_SESSION_OPEN: reply_mesg = "ERR_NO_SESSION_OPEN"; break;
case ERR_UNSAVED_CHANGES: reply_mesg = "ERR_UNSAVED_CHANGES"; break;
case ERR_NOT_NOW: reply_mesg = "ERR_NOT_NOW"; break;
default: reply_mesg = "(UNKNOWN)"; break;
}
#ifdef CONFIG_LIBLO
if (m_address && m_server) {
if (reply_code == ERR_OK) {
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
"/reply", "ss",
path.toUtf8().constData(),
reply_mesg);
} else {
lo_send_from(m_address,
m_server, LO_TT_IMMEDIATE,
"/error", "sis",
path.toUtf8().constData(),
int(reply_code),
reply_mesg);
}
}
#endif
}
// Server announce error.
void padthv1_nsm::nsm_announce_error (
const char *mesg )
{
m_active = false;
m_manager.clear();
m_capabilities.clear();
m_path_name.clear();
m_display_name.clear();
m_client_name.clear();
emit active(false);
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_announce_error: %s.", mesg);
#endif
}
// Server announce reply.
void padthv1_nsm::nsm_announce_reply (
const char *mesg,
const char *manager,
const char *capabilities )
{
m_active = true;
m_manager = manager;
m_capabilities = capabilities;
emit active(true);
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_announce_reply: %s.", mesg);
#endif
}
// Client open callback.
void padthv1_nsm::nsm_open (
const char *path_name,
const char *display_name,
const char *client_name )
{
m_path_name = path_name;
m_display_name = display_name;
m_client_name = client_name;
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_open: "
"path_name=\"%s\" display_name=\"%s\" client_name=\"%s\".",
m_path_name.toUtf8().constData(),
m_display_name.toUtf8().constData(),
m_client_name.toUtf8().constData());
#endif
emit open();
}
// Client save callback.
void padthv1_nsm::nsm_save (void)
{
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_save: "
"path_name=\"%s\" display_name=\"%s\" client_name=\"%s\".",
m_path_name.toUtf8().constData(),
m_display_name.toUtf8().constData(),
m_client_name.toUtf8().constData());
#endif
emit save();
}
// Client loaded callback.
void padthv1_nsm::nsm_loaded (void)
{
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_loaded: "
"path_name=\"%s\" display_name=\"%s\" client_name=\"%s\".",
m_path_name.toUtf8().constData(),
m_display_name.toUtf8().constData(),
m_client_name.toUtf8().constData());
#endif
emit loaded();
}
// Client show optional GUI.
void padthv1_nsm::nsm_show (void)
{
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_show: "
"path_name=\"%s\" display_name=\"%s\" client_name=\"%s\".",
m_path_name.toUtf8().constData(),
m_display_name.toUtf8().constData(),
m_client_name.toUtf8().constData());
#endif
emit show();
}
// Client hide optional GUI.
void padthv1_nsm::nsm_hide (void)
{
#ifdef CONFIG_DEBUG
qDebug("padthv1_nsm::nsm_hide: "
"path_name=\"%s\" display_name=\"%s\" client_name=\"%s\".",
m_path_name.toUtf8().constData(),
m_display_name.toUtf8().constData(),
m_client_name.toUtf8().constData());
#endif
emit hide();
}
// end of padthv1_nsm.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1_list.h 0000644 0000000 0000000 00000000132 14554770535 015615 x ustar 00 30 mtime=1706291549.609007112
30 atime=1706291549.609007112
30 ctime=1706291549.609007112
padthv1-0.9.34/src/padthv1_list.h 0000644 0001750 0000144 00000003305 14554770535 015606 0 ustar 00rncbc users // padthv1_list.h
//
/****************************************************************************
Copyright (C) 2012, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1_list_h
#define __padthv1_list_h
//-------------------------------------------------------------------------
// padthv1_list - generic double-linked list node.
template
class padthv1_list
{
public:
padthv1_list() : m_prev(0), m_next(0) {}
void append(T *p)
{
p->m_prev = m_prev;
p->m_next = 0;
if (m_prev)
m_prev->m_next = p;
else
m_next = p;
m_prev = p;
}
void remove(T *p)
{
if (p->m_prev)
p->m_prev->m_next = p->m_next;
else
m_next = p->m_next;
if (p->m_next)
p->m_next->m_prev = p->m_prev;
else
m_prev = p->m_prev;
}
T *prev() const { return m_prev; }
T *next() const { return m_next; }
private:
T *m_prev;
T *m_next;
};
#endif // __padthv1_list_h
// end of padthv1_list.h
padthv1-0.9.34/src/PaxHeaders/padthv1widget_wave.cpp 0000644 0000000 0000000 00000000132 14554770535 017343 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_wave.cpp 0000644 0001750 0000144 00000013672 14554770535 017344 0 ustar 00rncbc users // padthv1widget_wave.cpp
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#include "padthv1widget_wave.h"
#include "padthv1_wave.h"
#include
#include
#include
#include
#include
// Safe value capping.
inline float safe_value ( float x )
{
return (x < 0.0f ? 0.0f : (x > 1.0f ? 1.0f : x));
}
//----------------------------------------------------------------------------
// padthv1widget_wave -- Custom widget
// Constructor.
padthv1widget_wave::padthv1widget_wave ( QWidget *pParent )
: QFrame(pParent),
m_bDragging(false), m_iDragShape(0)
{
m_pWave = new padthv1_wave_lf(128);
setFixedSize(QSize(60, 60));
QFrame::setFrameShape(QFrame::Panel);
QFrame::setFrameShadow(QFrame::Sunken);
}
// Destructor.
padthv1widget_wave::~padthv1widget_wave (void)
{
delete m_pWave;
}
// Parameter accessors.
void padthv1widget_wave::setWaveShape ( float fWaveShape )
{
int iWaveShape = int(fWaveShape);
if (iWaveShape != int(m_pWave->shape())) {
if (iWaveShape < int(padthv1_wave::Pulse))
iWaveShape = int(padthv1_wave::Noise);
else
if (iWaveShape > int(padthv1_wave::Noise))
iWaveShape = int(padthv1_wave::Pulse);
m_pWave->reset(padthv1_wave::Shape(iWaveShape), m_pWave->width());
update();
emit waveShapeChanged(waveShape());
}
}
float padthv1widget_wave::waveShape (void) const
{
return float(m_pWave->shape());
}
void padthv1widget_wave::setWaveWidth ( float fWaveWidth )
{
if (qAbs(fWaveWidth - m_pWave->width()) > 0.001f) {
m_pWave->reset(m_pWave->shape(), safe_value(fWaveWidth));
update();
emit waveWidthChanged(waveWidth());
}
}
float padthv1widget_wave::waveWidth (void) const
{
return m_pWave->width();
}
// Draw curve.
void padthv1widget_wave::paintEvent ( QPaintEvent *pPaintEvent )
{
QPainter painter(this);
const QRect& rect = QWidget::rect();
const int h = rect.height();
const int w = rect.width();
const int h2 = (h >> 1);
const int w2 = (w >> 1);
QPainterPath path;
path.moveTo(0, h2);
for (int x = 1; x < w; ++x)
path.lineTo(x, h2 - int(m_pWave->value(float(x) / float(w)) * float(h2 - 2)));
path.lineTo(w, h2);
const QPalette& pal = palette();
const bool bDark = (pal.window().color().value() < 0x7f);
const QColor& rgbLite = (isEnabled() ? Qt::yellow : pal.mid().color());
const QColor& rgbDark = pal.window().color().darker();
painter.fillRect(rect, rgbDark);
painter.setPen(pal.mid().color());
painter.drawLine(w2, 0, w2, h);
painter.drawLine(0, h2, w, h2);
QColor rgbLite1(rgbLite);
QColor rgbDrop1(Qt::black);
rgbLite1.setAlpha(bDark ? 120 : 180);
rgbDrop1.setAlpha(80);
QLinearGradient grad(0, 0, w << 1, h << 1);
grad.setColorAt(0.0f, rgbLite1.darker(bDark ? 200 : 160));
grad.setColorAt(1.0f, rgbDrop1);
painter.setRenderHint(QPainter::Antialiasing, true);
path.translate(+1, +1);
painter.setPen(QPen(rgbDrop1, 2));
painter.setBrush(Qt::transparent);
painter.drawPath(path);
path.translate(-1, -1);
painter.setPen(QPen(rgbLite1, 2));
painter.drawPath(path);
path.lineTo(1, h2);
painter.setPen(Qt::transparent);
painter.setBrush(grad);
painter.drawPath(path);
painter.setRenderHint(QPainter::Antialiasing, false);
painter.end();
QFrame::paintEvent(pPaintEvent);
}
// Drag/move curve.
void padthv1widget_wave::dragCurve ( const QPoint& pos )
{
const int h = height();
const int w = width();
const int dx = (pos.x() - m_posDrag.x());
const int dy = (pos.y() - m_posDrag.y());
if (dx || dy) {
const int x = int(waveWidth() * float(w));
setWaveWidth(float(x + dx) / float(w));
const int h2 = (h >> 1);
m_iDragShape += dy;
if (m_iDragShape > +h2) {
setWaveShape(waveShape() - 1);
m_iDragShape = 0;
}
else
if (m_iDragShape < -h2) {
setWaveShape(waveShape() + 1);
m_iDragShape = 0;
}
m_posDrag = pos;
}
}
// Mouse interaction.
void padthv1widget_wave::mousePressEvent ( QMouseEvent *pMouseEvent )
{
if (pMouseEvent->button() == Qt::LeftButton)
m_posDrag = pMouseEvent->pos();
QFrame::mousePressEvent(pMouseEvent);
}
void padthv1widget_wave::mouseMoveEvent ( QMouseEvent *pMouseEvent )
{
const QPoint& pos = pMouseEvent->pos();
if (m_bDragging) {
dragCurve(pos);
} else if ((pos - m_posDrag).manhattanLength() > 4) {
setCursor(Qt::SizeAllCursor);
m_bDragging = true;
m_iDragShape = 0;
}
}
void padthv1widget_wave::mouseReleaseEvent ( QMouseEvent *pMouseEvent )
{
QFrame::mouseReleaseEvent(pMouseEvent);
if (m_bDragging) {
dragCurve(pMouseEvent->pos());
m_bDragging = false;
unsetCursor();
}
}
void padthv1widget_wave::mouseDoubleClickEvent ( QMouseEvent *pMouseEvent )
{
QFrame::mouseDoubleClickEvent(pMouseEvent);
if (!m_bDragging)
setWaveShape(waveShape() + 1);
}
void padthv1widget_wave::wheelEvent ( QWheelEvent *pWheelEvent )
{
const int delta = (pWheelEvent->angleDelta().y() / 60);
if (pWheelEvent->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier)) {
setWaveShape(waveShape() + (delta < 0 ? -1 : +1));
} else {
const float w2 = float(width() >> 1);
const int x = int(waveWidth() * w2);
setWaveWidth(float(x + delta) / w2);
}
}
// end of padthv1widget_wave.cpp
padthv1-0.9.34/src/PaxHeaders/padthv1widget_filt.h 0000644 0000000 0000000 00000000132 14554770535 017004 x ustar 00 30 mtime=1706291549.611007099
30 atime=1706291549.611007099
30 ctime=1706291549.611007099
padthv1-0.9.34/src/padthv1widget_filt.h 0000644 0001750 0000144 00000005121 14554770535 016773 0 ustar 00rncbc users // padthv1widget_filt.h
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1widget_filt_h
#define __padthv1widget_filt_h
#include
#include
//----------------------------------------------------------------------------
// padthv1widget_filt -- Custom widget
class padthv1widget_filt : public QFrame
{
Q_OBJECT
public:
// Constructor.
padthv1widget_filt(QWidget *pParent = nullptr);
// Destructor.
~padthv1widget_filt();
// Parameter getters.
float cutoff() const;
float reso() const;
float type() const;
float slope() const;
public slots:
// Parameter setters.
void setCutoff(float fCutoff);
void setReso(float fReso);
void setType(float fType);
void setSlope(float fSlope);
signals:
// Parameter change signals.
void cutoffChanged(float fCutoff);
void resoChanged(float fReso);
protected:
// Draw canvas.
void paintEvent(QPaintEvent *);
// Filter types/slopes.
enum Types {
LPF = 0,
BPF = 1,
HPF = 2,
BRF = 3,
L2F = 4
};
enum Slopes {
S12DB = 0,
S24DB = 1,
SBIQUAD = 2,
SFORMANT = 3
};
// Drag/move curve.
void dragCurve(const QPoint& pos);
// Mouse interaction.
void mousePressEvent(QMouseEvent *pMouseEvent);
void mouseMoveEvent(QMouseEvent *pMouseEvent);
void mouseReleaseEvent(QMouseEvent *pMouseEvent);
void wheelEvent(QWheelEvent *pWheelEvent);
// Resize canvas.
void resizeEvent(QResizeEvent *);
// Update the drawing path.
void updatePath();
private:
// Instance state.
float m_fCutoff;
float m_fReso;
int m_iType;
int m_iSlope;
// Drag state.
bool m_bDragging;
QPoint m_posDrag;
// Drawable path.
QPainterPath m_path;
};
#endif // __padthv1widget_filt_h
// end of padthv1widget_filt.h
padthv1-0.9.34/src/PaxHeaders/padthv1_fx.h 0000644 0000000 0000000 00000000132 14554770535 015257 x ustar 00 30 mtime=1706291549.609007112
30 atime=1706291549.609007112
30 ctime=1706291549.609007112
padthv1-0.9.34/src/padthv1_fx.h 0000644 0001750 0000144 00000034327 14554770535 015260 0 ustar 00rncbc users // padthv1_fx.h
//
/****************************************************************************
Copyright (C) 2012-2023, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1_fx_h
#define __padthv1_fx_h
#include
#include
#include
//-------------------------------------------------------------------------
// padthv1_fx
//
// -- borrowed, stirred and refactored from Highlife --
// Copyright (C) 2007 arguru, discodsp.com
//
// Hal Chamberlain's pseudo-random linear congruential method.
static inline float padthv1_fx_randf ()
{
static uint32_t s_srand = 0x9631; // magic!
s_srand = (s_srand * 196314165) + 907633515;
return s_srand / float(INT32_MAX) - 1.0f;
}
//-------------------------------------------------------------------------
// padthv1_fx_filter - RBJ biquad filter implementation.
//
// http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
class padthv1_fx_filter
{
public:
enum Type {
Low = 0, High, Band1, Band2, Notch, AllPass, Peak, LoShelf, HiShelf
};
padthv1_fx_filter(float srate = 44100.0f)
: m_srate(srate) { reset(); }
void setSampleRate(float srate)
{ m_srate = srate; }
float sampleRate() const
{ return m_srate; }
void reset(Type type, float freq, float q, float gain, bool bwq = false)
{
reset();
// temp vars
float alpha, a0, a1, a2, b0, b1, b2;
// peaking, lowshelf and hishelf
if (type >= Peak) {
const float amp = ::powf(10.0f, (gain / 40.0f));
const float omega = 2.0f * M_PI * freq / m_srate;
const float tsin = ::sinf(omega);
const float tcos = ::cosf(omega);
const float beta = ::sqrtf(amp) / q;
if (bwq)
alpha = tsin * ::sinhf(::logf(2.0f) / 2.0f * q * omega / tsin);
else
alpha = tsin / (2.0f * q);
switch (type) {
case Peak:
// peaking
b0 = 1.0f + alpha * amp;
b1 = -2.0f * tcos;
b2 = 1.0f - alpha * amp;
a0 = 1.0f + alpha / amp;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha / amp;
break;
case LoShelf:
// low-shelf
b0 = amp * ((amp + 1.0f) - (amp - 1.0f) * tcos + beta * tsin);
b1 = 2.0f * amp *((amp - 1.0f) - (amp + 1.0f) * tcos);
b2 = amp * ((amp + 1.0f) - (amp - 1.0f) * tcos - beta * tsin);
a0 = (amp + 1.0f) + (amp - 1.0f) * tcos + beta * tsin;
a1 = -2.0f *((amp - 1.0f) + (amp + 1.0f) * tcos);
a2 = (amp + 1.0f) + (amp - 1.0f) * tcos - beta * tsin;
break;
case HiShelf:
default:
// high-shelf
b0 = amp * ((amp + 1.0f) + (amp - 1.0f) * tcos + beta * tsin);
b1 = -2.0f * amp * ((amp - 1.0f) + (amp + 1.0f) * tcos);
b2 = amp * ((amp + 1.0f) + (amp - 1.0f) * tcos - beta * tsin);
a0 = (amp + 1.0f) - (amp - 1.0f) * tcos + beta * tsin;
a1 = 2.0f * ((amp - 1.0f) - (amp + 1.0f) * tcos);
a2 = (amp + 1.0f) - (amp - 1.0f) * tcos - beta * tsin;
break;
}
} else {
// other filters
const float omega = 2.0f * M_PI * freq / m_srate;
const float tsin = ::sinf(omega);
const float tcos = ::cosf(omega);
if (bwq)
alpha = tsin * ::sinhf(::logf(2.0f) / 2.0f * q * omega / tsin);
else
alpha = tsin / (2.0f * q);
switch (type) {
case Low:
// low-pass
b0 = (1.0f - tcos) / 2.0f;
b1 = 1.0f - tcos;
b2 = (1.0f - tcos) / 2.0f;
a0 = 1.0f + alpha;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha;
break;
case High:
// high-pass
b0 = (1.0f + tcos) / 2.0f;
b1 = -1.0f - tcos;
b2 = (1.0f + tcos) / 2.0f;
a0 = 1.0f + alpha;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha;
break;
case Band1:
// band-pass csg
b0 = tsin / 2.0f;
b1 = 0.0f;
b2 = -tsin / 2.0f;
a0 = 1.0f + alpha;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha;
break;
case Band2:
// band-pass czpg
b0 = alpha;
b1 = 0.0f;
b2 = -alpha;
a0 = 1.0f + alpha;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha;
break;
case Notch:
// notch
b0 = 1.0f;
b1 = -2.0f * tcos;
b2 = 1.0f;
a0 = 1.0f + alpha;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha;
break;
case AllPass:
default:
// all-pass
b0 = 1.0f - alpha;
b1 = -2.0f * tcos;
b2 = 1.0f + alpha;
a0 = 1.0f + alpha;
a1 = -2.0f * tcos;
a2 = 1.0f - alpha;
break;
}
}
// set filter coeffs
m_b0a0 = b0 / a0;
m_b1a0 = b1 / a0;
m_b2a0 = b2 / a0;
m_a1a0 = a1 / a0;
m_a2a0 = a2 / a0;
};
float output(float in)
{
// filter
const float out = m_b0a0 * in
+ m_b1a0 * m_in1 + m_b2a0 * m_in2
- m_a1a0 * m_out1 - m_a2a0 * m_out2;
// push in/out buffers
m_in2 = m_in1;
m_in1 = in;
m_out2 = m_out1;
m_out1 = out;
// return output
return out;
}
protected:
void reset()
{
m_b0a0 = m_b1a0 = m_b2a0 = m_a1a0 = m_a2a0 = 0.0f;
m_out1 = m_out2 = 0.0f;
m_in1 = m_in2 = 0.0f;
}
private:
// nominal sample-rate
float m_srate;
// filter coeffs
float m_b0a0, m_b1a0, m_b2a0, m_a1a0, m_a2a0;
// in/out history
float m_out1, m_out2, m_in1, m_in2;
};
//-------------------------------------------------------------------------
// padthv1_fx_comp - DiscoDSP's "rock da disco" compressor/eq.
class padthv1_fx_comp
{
public:
padthv1_fx_comp(float srate = 44100.0f)
: m_srate(srate), m_peak(0.0f),
m_attack(0.0f), m_release(0.0f),
m_lo(srate), m_mi(srate), m_hi(srate) {}
void setSampleRate(float srate)
{
m_srate = srate;
m_lo.setSampleRate(srate);
m_mi.setSampleRate(srate);
m_hi.setSampleRate(srate);
}
float sampleRate() const
{ return m_srate; }
void reset()
{
m_peak = 0.0f;
m_attack = ::expf(-1000.0f / (m_srate * 3.6f));
m_release = ::expf(-1000.0f / (m_srate * 150.0f));
// rock-da-house eq.
m_lo.reset(padthv1_fx_filter::Peak, 100.0f, 1.0f, 6.0f);
m_mi.reset(padthv1_fx_filter::LoShelf, 1000.0f, 1.0f, 3.0f);
m_hi.reset(padthv1_fx_filter::HiShelf, 10000.0f, 1.0f, 4.0f);
}
void process(float *in, uint32_t nframes)
{
// compressor
const float threshold = 0.251f; //~= powf(10.0f, -12.0f / 20.0f);
const float post_gain = 1.995f; //~= powf(10.0f, 6.0f / 20.0f);
// process buffers
for (uint32_t i = 0; i < nframes; ++i) {
// anti-denormalizer noise
const float ad = 1E-14f * padthv1_fx_randf();
// process
const float lo = m_lo.output(m_mi.output(m_hi.output(*in + ad)));
// compute peak
const float peak = ::fabsf(lo);
// compute gain
float gain = 1.0f;
if (peak > threshold)
gain = threshold / peak;
// envelope
if (m_peak > gain) {
m_peak *= m_attack;
m_peak += (1.0f - m_attack) * gain;
} else {
m_peak *= m_release;
m_peak += (1.0f - m_release) * gain;
}
// output
*in++ = lo * m_peak * post_gain;
}
}
private:
float m_srate;
float m_peak;
float m_attack;
float m_release;
padthv1_fx_filter m_lo, m_mi, m_hi;
};
//-------------------------------------------------------------------------
// padthv1_fx_flanger - Flanger implementation.
class padthv1_fx_flanger
{
public:
padthv1_fx_flanger()
{ reset(); }
void reset()
{
for(uint32_t i = 0; i < MAX_SIZE; ++i)
m_buffer[i] = 0.0f;
m_frames = 0;
}
float output(float in, float delay, float feedb)
{
// calculate delay offset
float delta = float(m_frames) - delay;
// clip lookback buffer-bound
if (delta < 0.0f)
delta += float(MAX_SIZE);
// get index
const uint32_t index = uint32_t(delta);
// 4 samples hermite
const float y0 = m_buffer[(index + 0) & MAX_MASK];
const float y1 = m_buffer[(index + 1) & MAX_MASK];
const float y2 = m_buffer[(index + 2) & MAX_MASK];
const float y3 = m_buffer[(index + 3) & MAX_MASK];
// csi calculate
const float c0 = y1;
const float c1 = 0.5f * (y2 - y0);
const float c2 = y0 - 2.5f * y1 + 2.0f * y2 - 0.5f * y3;
const float c3 = 0.5f * (y3 - y0) + 1.5f * (y1 - y2);
// compute interpolation x
const float x = delta - ::floorf(delta);
// get output
const float out = ((c3 * x + c2) * x + c1) * x + c0;
// add to delay buffer
m_buffer[(m_frames++) & MAX_MASK] = in + out * feedb;
// return output
return out;
}
void process(float *in, uint32_t nframes,
float wet, float delay, float feedb, float daft)
{
if (wet < 1E-9f)
return;
// daft effect
if (daft > 0.001f) {
delay *= (1.0f - daft);
// feedb *= (1.0f - daft);
}
delay *= float(MAX_SIZE);
// process
for (uint32_t i = 0; i < nframes; ++i)
in[i] += wet * output(in[i], delay, feedb);
}
static const uint32_t MAX_SIZE = (1 << 12); //= 4096;
static const uint32_t MAX_MASK = MAX_SIZE - 1;
private:
float m_buffer[MAX_SIZE];
uint32_t m_frames;
};
//-------------------------------------------------------------------------
// padthv1_fx_chorus - Chorus implementation.
class padthv1_fx_chorus
{
public:
padthv1_fx_chorus(float srate = 44100.0f)
: m_srate(srate) { reset(); }
void setSampleRate(float srate)
{ m_srate = srate; }
float sampleRate() const
{ return m_srate; }
void reset()
{
m_flang1.reset();
m_flang2.reset();
m_lfo = 0.0f;
}
void process(float *in1, float *in2, uint32_t nframes,
float wet, float delay, float feedb, float rate, float mod)
{
if (wet < 1E-9f)
return;
// constrained feedback
feedb *= 0.95f;
// calculate delay time
const float d0 = 0.5f * delay * float(padthv1_fx_flanger::MAX_SIZE);
const float a1 = 0.99f * d0 * mod * mod;
const float r2 = 4.0f * M_PI * rate * rate / m_srate;
// process
for (uint32_t i = 0; i < nframes; ++i) {
// modulation
const float lfo = a1 * pseudo_sinf(m_lfo);
const float delay1 = d0 - lfo;
const float delay2 = d0 - lfo * 0.9f;
// chorus mix
in1[i] += wet * m_flang1.output(in1[i], delay1, feedb);
in2[i] += wet * m_flang2.output(in2[i], delay2, feedb);
// lfo advance
m_lfo += r2;
// lfo wrap
if (m_lfo >= 1.0f)
m_lfo -= 2.0f;
}
}
protected:
float pseudo_sinf(float x) const
{
x *= x;
x -= 1.0f;
return x * x;
}
private:
float m_srate;
padthv1_fx_flanger m_flang1;
padthv1_fx_flanger m_flang2;
float m_lfo;
};
//-------------------------------------------------------------------------
// padthv1_fx_delay - Delay implementation.
class padthv1_fx_delay
{
public:
padthv1_fx_delay(float srate = 44100.0f)
: m_srate(srate) { reset(); }
void setSampleRate(float srate)
{ m_srate = srate; }
float sampleRate() const
{ return m_srate; }
void reset()
{
for (uint32_t i = 0; i < MAX_SIZE; ++i)
m_buffer[i] = 0.0f;
m_out = 0.0f;
m_frames = 0;
}
void process(float *in, uint32_t nframes,
float wet, float delay, float feedb, float bpm = 0.0f)
{
if (wet < 1E-9f)
return;
// constrained feedback
feedb *= 0.95f;
// calculate delay time
float delay_time = delay * m_srate;
if (bpm > 0.0f)
delay_time *= 60.f / bpm;
// set integer delay
uint32_t ndelay = uint32_t(delay_time);
// clamp
if (ndelay < MIN_SIZE)
ndelay = MIN_SIZE;
else
if (ndelay > MAX_SIZE)
ndelay = MAX_SIZE;
// delay process
for (uint32_t i = 0; i < nframes; ++i) {
const uint32_t j = (m_frames++) & MAX_MASK;
m_out = m_buffer[(j - ndelay) & MAX_MASK];
m_buffer[j] = *in + m_out * feedb;
*in++ += wet * m_out;
}
}
static const uint32_t MIN_SIZE = (1 << 8); //= 256;
static const uint32_t MAX_SIZE = (1 << 16); //= 65536;
static const uint32_t MAX_MASK = MAX_SIZE - 1;
private:
float m_srate;
float m_buffer[MAX_SIZE];
float m_out;
uint32_t m_frames;
};
//-------------------------------------------------------------------------
// padthv1_fx_allpass - All-pass delay implementation.
class padthv1_fx_allpass
{
public:
padthv1_fx_allpass()
{ reset(); }
void reset()
{ m_out = 0.0f; }
float output(float in, float delay)
{
const float a1 = (1.0f - delay) / (1.0f + delay);
const float out = m_out - a1 * in;
m_out = in + a1 * out;
return out;
}
private:
float m_out;
};
//-------------------------------------------------------------------------
// padthv1_fx_phaser - Phaser implementation.
class padthv1_fx_phaser
{
public:
padthv1_fx_phaser(float srate = 44100.0f)
: m_srate(srate) { reset(); }
void setSampleRate(float srate)
{ m_srate = srate; }
float sampleRate() const
{ return m_srate; }
void reset()
{
// initialize vars
m_lfo_phase = 0.0f;
m_out = 0.0f;
// reset taps
for (uint16_t n = 0; n < MAX_TAPS; ++n)
m_taps[n].reset();
}
void process(float *in, uint32_t nframes, float wet,
float rate, float feedb, float depth, float daft)
{
if (wet < 1E-9f)
return;
// daft effect
if (daft > 0.001f && daft < 1.0f) {
rate *= (1.0f - 0.5f * daft);
// feedb *= (1.0f - daft);
depth *= (1.0f - daft);
}
depth += 1.0f;
// update coeffs
const float delay_min = 2.0f * 440.0f / m_srate;
const float delay_max = 2.0f * 4400.0f / m_srate;
const float lfo_inc = 2.0f * M_PI * rate / m_srate;
// anti-denormal noise
const float adenormal = 1E-14f * padthv1_fx_randf();
// sweep...
for (uint32_t i = 0; i < nframes; ++i) {
// calculate and update phaser lfo
const float delay = delay_min + (delay_max - delay_min)
* 0.5f * (1.0f + ::sinf(m_lfo_phase));
// increment phase
m_lfo_phase += lfo_inc;
// positive wrap phase
if (m_lfo_phase >= 2.0f * M_PI)
m_lfo_phase -= 2.0f * M_PI;
// get input
m_out = in[i] + adenormal + m_out * feedb;
// update filter coeffs and calculate output
for (uint16_t n = 0; n < MAX_TAPS; ++n)
m_out = m_taps[n].output(m_out, delay);
// output
in[i] += wet * m_out * depth;
}
}
private:
float m_srate;
static const uint16_t MAX_TAPS = 6;
padthv1_fx_allpass m_taps[MAX_TAPS];
float m_dmin;
float m_dmax;
float m_feedb;
float m_lfo_phase;
float m_lfo_inc;
float m_depth;
float m_out;
};
#endif // __padthv1_fx_h
// end of padthv1_fx.h
padthv1-0.9.34/src/PaxHeaders/padthv1_nsm.h 0000644 0000000 0000000 00000000132 14554770535 015437 x ustar 00 30 mtime=1706291549.610007106
30 atime=1706291549.610007106
30 ctime=1706291549.610007106
padthv1-0.9.34/src/padthv1_nsm.h 0000644 0001750 0000144 00000006461 14554770535 015436 0 ustar 00rncbc users // padthv1_nsm.h
//
/****************************************************************************
Copyright (C) 2012-2023, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1_nsm_h
#define __padthv1_nsm_h
#include "padthv1_config.h"
#include
#ifdef CONFIG_LIBLO
#include
#endif
//---------------------------------------------------------------------------
// padthv1_nsm - NSM OSC client agent.
class padthv1_nsm : public QObject
{
Q_OBJECT
public:
// Constructor.
padthv1_nsm(const QString& nsm_url, QObject *pParent = 0);
// Destructor.
~padthv1_nsm();
// Session activation accessor.
bool is_active() const;
// Session manager accessors.
const QString& manager() const;
const QString& capabilities() const;
// Session client accessors.
const QString& path_name() const;
const QString& display_name() const;
const QString& client_name() const;
// Session client methods.
void announce(const QString& app_name, const QString& capabilities);
void dirty(bool is_dirty);
void visible(bool is_visible);
void progress(float percent);
void message(int priority, const QString& mesg);
// Status/error codes
enum ReplyCode
{
ERR_OK = 0,
ERR_GENERAL = -1,
ERR_INCOMPATIBLE_API = -2,
ERR_BLACKLISTED = -3,
ERR_LAUNCH_FAILED = -4,
ERR_NO_SUCH_FILE = -5,
ERR_NO_SESSION_OPEN = -6,
ERR_UNSAVED_CHANGES = -7,
ERR_NOT_NOW = -8,
ERR_BAD_PROJECT = -9,
ERR_CREATE_FAILED = -10
};
// Session client reply methods.
void open_reply(ReplyCode reply_code = ERR_OK);
void save_reply(ReplyCode reply_code = ERR_OK);
// Server methods response methods.
void nsm_announce_error(
const char *mesg);
void nsm_announce_reply(
const char *mesg,
const char *manager,
const char *capabilities);
void nsm_open(
const char *path_name,
const char *display_name,
const char *client_name);
void nsm_save();
void nsm_loaded();
void nsm_show();
void nsm_hide();
protected:
void reply(const QString& path, ReplyCode reply_code);
signals:
// Session client callbacks.
void active(bool is_active);
void open();
void save();
void loaded();
void show();
void hide();
private:
// Instance variables.
#ifdef CONFIG_LIBLO
lo_address m_address;
lo_server_thread m_thread;
lo_server m_server;
#endif
bool m_active;
bool m_dirty;
QString m_manager;
QString m_capabilities;
QString m_path_name;
QString m_display_name;
QString m_client_name;
};
#endif // __padthv1_nsm_h
// end of padthv1_nsm.h
padthv1-0.9.34/src/PaxHeaders/padthv1widget_control.ui 0000644 0000000 0000000 00000000132 14554770535 017714 x ustar 00 30 mtime=1706291549.611007099
30 atime=1706291549.611007099
30 ctime=1706291549.611007099
padthv1-0.9.34/src/padthv1widget_control.ui 0000644 0001750 0000144 00000012075 14554770535 017711 0 ustar 00rncbc users
rncbc aka Rui Nuno Capela
padthv1 - an old-school additive polyphonic synthesizer
Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
padthv1widget_control
0
0
320
120
MIDI Controller
:/images/padthv1_control.png
-
&Type:
ControlTypeComboBox
-
MIDI event type
-
&Channel:
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
ControlChannelSpinBox
-
MIDI channel
Auto
false
0
16
-
&Parameter:
ControlParamComboBox
-
220
0
MIDI parameter
-
&Logarithmic
-
&Invert
-
&Hook
-
Qt::Vertical
20
8
-
Qt::Horizontal
QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset
ControlTypeComboBox
ControlChannelSpinBox
ControlParamComboBox
ControlLogarithmicCheckBox
ControlInvertCheckBox
ControlHookCheckBox
DialogButtonBox
padthv1-0.9.34/src/PaxHeaders/padthv1widget_palette.ui 0000644 0000000 0000000 00000000132 14554770535 017672 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_palette.ui 0000644 0001750 0000144 00000017241 14554770535 017667 0 ustar 00rncbc users
rncbc aka Rui Nuno Capela
padthv1 - an old-school additive polyphonic synthesizer
Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
padthv1widget_palette
0
0
534
640
0
0
Color Themes
-
Name
-
0
0
320
0
Current color palette name
true
QComboBox::NoInsert
-
Save current color palette name
Save
:/images/presetSave.png
-
Delete current color palette name
Delete
:/images/presetDelete.png
-
Palette
-
280
360
Current color palette
true
-
Generate:
-
0
0
Qt::StrongFocus
Base color to generate palette
-
Reset all current palette colors
Reset
:/images/itemReset.png
-
Qt::Horizontal
8
20
-
Import a custom color theme (palette) from file
Import...
:/images/presetOpen.png
-
Export a custom color theme (palette) to file
Export...
:/images/presetSave.png
-
Qt::Horizontal
8
20
-
Show Details
-
Qt::Horizontal
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
padthv1widget_palette::ColorButton
nameCombo
saveButton
deleteButton
paletteView
generateButton
resetButton
importButton
exportButton
detailsCheck
dialogButtons
padthv1-0.9.34/src/PaxHeaders/padthv1widget_programs.h 0000644 0000000 0000000 00000000132 14554770535 017700 x ustar 00 30 mtime=1706291549.612007092
30 atime=1706291549.612007092
30 ctime=1706291549.612007092
padthv1-0.9.34/src/padthv1widget_programs.h 0000644 0001750 0000144 00000004001 14554770535 017663 0 ustar 00rncbc users // padthv1widget_programs.h
//
/****************************************************************************
Copyright (C) 2012-2023, rncbc aka Rui Nuno Capela. All rights reserved.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef __padthv1widget_programs_h
#define __padthv1widget_programs_h
#include
// forward decls.
class padthv1_programs;
//----------------------------------------------------------------------------
// padthv1widget_programs -- Custom (tree) widget.
class padthv1widget_programs : public QTreeWidget
{
Q_OBJECT
public:
// ctor.
padthv1widget_programs(QWidget *pParent = nullptr);
// dtor.
~padthv1widget_programs();
// utilities.
void loadPrograms(padthv1_programs *pPrograms);
void savePrograms(padthv1_programs *pPrograms);
QString currentProgramName() const;
public slots:
// slots.
void addBankItem();
void addProgramItem();
protected slots:
// private slots.
void itemChangedSlot(QTreeWidgetItem *, int);
void itemExpandedSlot(QTreeWidgetItem *);
void itemCollapsedSlot(QTreeWidgetItem *);
protected:
// item delegate decl..
class ItemDelegate;
// factory methods.
QTreeWidgetItem *newBankItem();
QTreeWidgetItem *newProgramItem();
};
#endif // __padthv1widget_programs_h
// end of padthv1widget_programs.h
padthv1-0.9.34/src/PaxHeaders/mimetypes 0000644 0000000 0000000 00000000132 14554770535 015001 x ustar 00 30 mtime=1706291549.608007119
30 atime=1706291549.608007119
30 ctime=1706291549.608007119
padthv1-0.9.34/src/mimetypes/ 0000755 0001750 0000144 00000000000 14554770535 015046 5 ustar 00rncbc users padthv1-0.9.34/src/mimetypes/PaxHeaders/org.rncbc.padthv1.application-x-padthv1-preset.png 0000644 0000000 0000000 00000000132 14554770535 026423 x ustar 00 30 mtime=1706291549.608007119
30 atime=1706291549.608007119
30 ctime=1706291549.608007119
padthv1-0.9.34/src/mimetypes/org.rncbc.padthv1.application-x-padthv1-preset.png 0000644 0001750 0000144 00000003256 14554770535 026421 0 ustar 00rncbc users PNG
IHDR szz pHYs od tEXtSoftware www.inkscape.org< ;IDATXml[Wھ݉8i'm&MSj[
> $U$' J Zː0IhlԗnKi6h6q'K7=}]IEս9ys[A! m7[?~~o*TR매4.]뿎G-
JZc0]C{4@%b}C.`0xdeeSOM|3W'^J`(G|uԯIܗu*;݇7n\4o:_zC)ngO?x3!r:j:0ov(17wS'`w8>WΰZBKJJпk{u݁R\zݻW'*/Zm=^nv !@6smҿvumxtFr
@TOcE):}z}tP'RUъLM]az%*>LJEL͛oW/f
j]tJZ;,N{Z=t78)dPX&D,UU"N+cpEڣ!qiʊbllQ"ńYJ!P.#{{?/ӷD67CzՍUwaP҆˳վHDM
(4fX)V)2??OcGM8,W5M'4
DJ_رGcQn`Xq7bUCtP%[U:
(a&HmJE{9iM\X"sCV|zKbfz;@z1*KXgan.x3K[7. jMOlH)4͚t\~${x fy"Ey>)Lsw}`$ -ݵj(yD0ȑ~/n~bNooc߾^"MM0hn66r<)06QVBOkx<$>˅frr~BT
MTbǎvv7T 4LLirW 4R2yڼiNrS*edd]x<9}]fllL&iz9p`!5T0:\3<:F;$L&PjgϱH$
Ex(v-I8v=
S`Tx7J|
tvdx