Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
[submodule "source/3rdparty/freetype"]
path = source/3rdparty/freetype
url = https://github.com/freetype/freetype.git
[submodule "source/3rdparty/lunasvg"]
path = source/3rdparty/lunasvg
url = https://github.com/sammycage/lunasvg.git
9 changes: 5 additions & 4 deletions build_mac.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake -G Xcode -S . -B ./temp/cmake
cd ./temp/cmake
cmake --build . --config Release
cpack -G ZIP
cmake -G Xcode -S . -B ./temp/cmake_macos
cmake --build ./temp/cmake_macos --config Release
cd ./temp/cmake_macos
CMAKE_BIN="$(dirname "$(command -v cmake)")"
"${CMAKE_BIN}/cpack" -G ZIP
5 changes: 5 additions & 0 deletions source/3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ add_library(Freetype::Freetype ALIAS freetype)
# Lua 5.4 for RmlUi scripting
add_subdirectory(lua)

# lunasvg for RmlUi SVG plugin
set(LUNASVG_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(lunasvg)

# Enable RmlUi Lua bindings and point to our bundled Lua
set(RMLUI_LUA_BINDINGS ON CACHE BOOL "" FORCE)
set(RMLUI_LUA_BINDINGS_LIBRARY "lua_as_cxx" CACHE STRING "" FORCE)
set(RMLUI_SVG_PLUGIN ON CACHE BOOL "" FORCE)

# Create the Lua::Lua target so RmlUi's Dependencies.cmake finds it and skips find_package(Lua)
add_library(Lua::Lua INTERFACE IMPORTED)
Expand Down
1 change: 1 addition & 0 deletions source/3rdparty/lunasvg
Submodule lunasvg added at 2872af
2 changes: 1 addition & 1 deletion source/juceRmlUi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ endif()
if(APPLE)
# Universal or x86_64-only: scope flags to the x86_64 slice
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86|X86|amd64|AMD64")
target_compile_options(juceRmlUi PRIVATE -Xarch_x86_64 -mssse3 -Xarch_x86_64 -msse4.1)
target_compile_options(juceRmlUi PRIVATE "SHELL:-Xarch_x86_64 -mssse3" "SHELL:-Xarch_x86_64 -msse4.1")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|X86|amd64|AMD64|i[3-6]86")
include(CheckCXXCompilerFlag)
Expand Down
23 changes: 20 additions & 3 deletions source/synthLib/midiClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ namespace synthLib
LOGMC("Stop at ppqPos=" << _ppqPos);
stop();
}
else if(m_isPlaying && _isPlaying && _ppqPos < m_lastPpqPos - 0.5)
{
// Host looped back or seeked backward — re-sync the clock
LOGMC("Loop/seek detected: ppqPos " << m_lastPpqPos << " -> " << _ppqPos);
stop();
start(_ppqPos);
}

m_lastPpqPos = _ppqPos;

for(uint32_t i=0; i<static_cast<uint32_t>(_sampleCount); ++i)
{
Expand Down Expand Up @@ -66,10 +75,18 @@ namespace synthLib
void MidiClock::start(const float _ppqPos)
{
const double ppqPos = _ppqPos;
const auto quarterPos = (ppqPos - std::floor(ppqPos + 1.0));

m_clockTickPos = quarterPos * (ClockTicksPerQuarter);

// Compute how far through the current clock tick period we already are,
// so the first tick fires at the correct phase rather than always at the
// start of the next full tick period.
// m_clockTickPos must be in [-1, 0): the loop fires a tick each time it
// crosses 0, so starting at (fracTick - 1.0) fires the first tick after
// exactly (1 - fracTick) of a tick period.
const double absoluteTicks = ppqPos * ClockTicksPerQuarter;
const double fracTick = absoluteTicks - std::floor(absoluteTicks);
m_clockTickPos = fracTick - 1.0;

m_lastPpqPos = ppqPos;
m_isPlaying = true;

LOGMC("Start at ppqPos=" << ppqPos << ", clock tick offset " << m_clockTickPos);
Expand Down
1 change: 1 addition & 0 deletions source/synthLib/midiClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ namespace synthLib

bool m_isPlaying = false;
double m_clockTickPos = 0.0;
double m_lastPpqPos = 0.0;
};
}