linux + piano keyboard support
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 4.0)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(sonobulus LANGUAGES CXX)
|
project(sonobulus LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
|
||||||
|
|
||||||
# get dependencies
|
# get dependencies
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -59,12 +60,13 @@ add_library(sonobulus_core STATIC
|
|||||||
src/synth/Instrument.cpp
|
src/synth/Instrument.cpp
|
||||||
src/synth/Instruments/PianoString.cpp
|
src/synth/Instruments/PianoString.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(sonobulus_core PRIVATE
|
target_link_libraries(sonobulus_core PRIVATE
|
||||||
Qt6::Core
|
Qt6::Core
|
||||||
Qt6::Quick
|
Qt6::Quick
|
||||||
rtaudio
|
rtaudio
|
||||||
rtmidi
|
rtmidi
|
||||||
libconfig++
|
config++
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(sonobulus_core PRIVATE
|
target_include_directories(sonobulus_core PRIVATE
|
||||||
@@ -82,6 +84,8 @@ qt_add_executable(sonobulus
|
|||||||
src/main.cpp
|
src/main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_target_properties(sonobulus PROPERTIES OUTPUT_NAME "sonobulus.out")
|
||||||
|
|
||||||
qt_add_qml_module(sonobulus
|
qt_add_qml_module(sonobulus
|
||||||
URI sonobulus
|
URI sonobulus
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
@@ -89,6 +93,7 @@ qt_add_qml_module(sonobulus
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(sonobulus PRIVATE
|
target_include_directories(sonobulus PRIVATE
|
||||||
|
${CMAKE_SOURCE_DIR}/src/
|
||||||
${rtaudio_SOURCE_DIR}
|
${rtaudio_SOURCE_DIR}
|
||||||
${rtmidi_SOURCE_DIR}
|
${rtmidi_SOURCE_DIR}
|
||||||
${libconfig_SOURCE_DIR}/lib
|
${libconfig_SOURCE_DIR}/lib
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void PianoString::noteOn(float frequency, float velocity) {
|
|||||||
}
|
}
|
||||||
// apply the velocity impulse
|
// apply the velocity impulse
|
||||||
for(size_t i = 0; i < segmentCount_ + 1; i++) {
|
for(size_t i = 0; i < segmentCount_ + 1; i++) {
|
||||||
float v0 = impulseVelocity_ * std::exp(-1.0f * (stringX_[i] - strikePosition_*L_)*(stringX_[i] - strikePosition_*L_) / ((2.0f * impulseWidth_)*(2.0f * impulseWidth_)));
|
float v0 = velocity * impulseVelocity_ * std::exp(-1.0f * (stringX_[i] - strikePosition_*L_)*(stringX_[i] - strikePosition_*L_) / ((2.0f * impulseWidth_)*(2.0f * impulseWidth_)));
|
||||||
stringY_current_[i] = stringY_current_[i] + dt_ * v0;
|
stringY_current_[i] = stringY_current_[i] + dt_ * v0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ private:
|
|||||||
float mu_ = crossSectionalArea_ * rho_; // linear mass density
|
float mu_ = crossSectionalArea_ * rho_; // linear mass density
|
||||||
float waveVelocity_ = std::sqrt(stringTension_ / mu_); // transverse wave velocity
|
float waveVelocity_ = std::sqrt(stringTension_ / mu_); // transverse wave velocity
|
||||||
float L_ = 1.0f; // length of string at a given frequency
|
float L_ = 1.0f; // length of string at a given frequency
|
||||||
float gain_ = 0.3f;
|
float gain_ = 0.5f;
|
||||||
|
|
||||||
// f0_ = waveVelocity_ / (2.0f * stringLength_); // fundamental frequency of a non-stiff string
|
// f0_ = waveVelocity_ / (2.0f * stringLength_); // fundamental frequency of a non-stiff string
|
||||||
// f1_ = f0_ * std::sqrt(1.0f + stiffness_); // fundamental frequency of the stiff string
|
// f1_ = f0_ * std::sqrt(1.0f + stiffness_); // fundamental frequency of the stiff string
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ MidiController::MidiController(ConfigService* config, LoggerService* logger, Not
|
|||||||
logger_->log("MIDI", LogFlag::Warning, msg);
|
logger_->log("MIDI", LogFlag::Warning, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
openDefaultPort();
|
openDefaultPort();
|
||||||
|
#else
|
||||||
|
openPort(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MidiController::~MidiController() {
|
MidiController::~MidiController() {
|
||||||
|
|||||||
Reference in New Issue
Block a user