Skip to content

Commit

Permalink
Merge pull request #1058 from tidalcycles/update-link-1.9-dev
Browse files Browse the repository at this point in the history
Update link 1.9 dev
  • Loading branch information
yaxu authored Dec 15, 2023
2 parents 5d20eec + 47c167d commit dcb6132
Show file tree
Hide file tree
Showing 1,627 changed files with 159,424 additions and 49,644 deletions.
25 changes: 8 additions & 17 deletions tidal-link/link/.appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: macos-catalina
CONFIGURATION: Release
XCODE_VERSION: 11.7
- APPVEYOR_BUILD_WORKER_IMAGE: macos-catalina
- APPVEYOR_BUILD_WORKER_IMAGE: macos-bigsur
CONFIGURATION: Debug
XCODE_VERSION: 12.3
XCODE_VERSION: 12.5.1
- APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey
CONFIGURATION: Release
XCODE_VERSION: 12.5.1
XCODE_VERSION: 13.4.1
- APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey
CONFIGURATION: Release
XCODE_VERSION: 13.2.1
XCODE_VERSION: 14.1
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
AUDIO_DRIVER: Jack
CONFIGURATION: Debug
Expand Down Expand Up @@ -52,20 +52,10 @@ environment:
GENERATOR: Ninja
CXX: g++-7
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: OFF
CONFIGURATION: Release
GENERATOR: Visual Studio 14 2015
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Asio
AUDIO_DRIVER: Wasapi
THREAD_DESCRIPTION: OFF
CONFIGURATION: Debug
GENERATOR: Visual Studio 14 2015 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Asio
THREAD_DESCRIPTION: OFF
CONFIGURATION: Release
GENERATOR: Visual Studio 14 2015 Win64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
AUDIO_DRIVER: Wasapi
THREAD_DESCRIPTION: OFF
Expand All @@ -88,7 +78,7 @@ environment:
GENERATOR: Visual Studio 17 2022
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
ESP_IDF: true
IDF_RELEASE: v4.3.1
IDF_RELEASE: v5.1.1
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004
FORMATTING: true

Expand All @@ -100,6 +90,7 @@ for:
only:
- APPVEYOR_BUILD_WORKER_IMAGE: macos-mojave
- APPVEYOR_BUILD_WORKER_IMAGE: macos-catalina
- APPVEYOR_BUILD_WORKER_IMAGE: macos-bigsur
- APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey
build_script:
- sudo xcode-select -s /Applications/Xcode-$XCODE_VERSION.app
Expand All @@ -114,7 +105,6 @@ for:
- GENERATOR: Ninja
install:
- git submodule update --init --recursive
- sudo apt-get update
- sudo apt-get install -y libjack-dev portaudio19-dev valgrind
build_script:
- python3 ci/configure.py --audio-driver $AUDIO_DRIVER --generator "$GENERATOR" --configuration $CONFIGURATION
Expand All @@ -129,6 +119,7 @@ for:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
build_script:
- py -3 -m pip install setuptools
- py -3 ci/configure.py --audio-driver %AUDIO_DRIVER% --thread-description %THREAD_DESCRIPTION% --generator "%GENERATOR%" --flags="-DCMAKE_SYSTEM_VERSION=10.0.18362.0"
- py -3 ci/build.py --configuration %CONFIGURATION%
test_script:
Expand Down
Binary file added tidal-link/link/Ableton Link Guidelines.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions tidal-link/link/AbletonLinkConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD|GNU")
INTERFACE_COMPILE_DEFINITIONS
LINK_PLATFORM_LINUX=1
)
set_property(TARGET Ableton::Link APPEND PROPERTY
INTERFACE_LINK_LIBRARIES
atomic
pthread
)
endif()

include(${CMAKE_CURRENT_LIST_DIR}/cmake_include/AsioStandaloneConfig.cmake)
Expand Down
6 changes: 5 additions & 1 deletion tidal-link/link/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(Link)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Expand All @@ -22,6 +22,8 @@ if(WIN32)
option(LINK_BUILD_VLD "Build with VLD support (VLD must be installed separately)" OFF)
endif()

option(LINK_BUILD_TESTS "Build unit test binaries" ON)

# ____ _ _
# | _ \ __ _| |_| |__ ___
# | |_) / _` | __| '_ \/ __|
Expand All @@ -36,7 +38,9 @@ include(AbletonLinkConfig.cmake)
include(extensions/abl_link/abl_link.cmake)

add_subdirectory(include)
if(LINK_BUILD_TESTS)
add_subdirectory(src)
endif()
add_subdirectory(examples)
add_subdirectory(extensions/abl_link)

Expand Down
2 changes: 1 addition & 1 deletion tidal-link/link/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ implementations. Please see:
[platforms/darwin/Clock.hpp](include/ableton/platforms/darwin/Clock.hpp)
- Windows clock implementation in
[platforms/windows/Clock.hpp](include/ableton/platforms/windows/Clock.hpp)
- C++ standard library `std::chrono::high_resolution_clock`-based implementation in
- C++ standard library `std::chrono::steady_clock`-based implementation in
[platforms/stl/Clock.hpp](include/ableton/platforms/stl/Clock.hpp)

Using the system time correctly in the context of an audio callback gets a little
Expand Down
Empty file modified tidal-link/link/ci/build.py
100644 → 100755
Empty file.
Empty file modified tidal-link/link/ci/check-formatting.py
100644 → 100755
Empty file.
Empty file modified tidal-link/link/ci/configure.py
100644 → 100755
Empty file.
Empty file modified tidal-link/link/ci/run-tests.py
100644 → 100755
Empty file.
Empty file modified tidal-link/link/ci/run_valgrind_tests.sh
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion tidal-link/link/cmake_include/ConfigureCompileFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)

set(build_flags_COMMON_LIST)
set(build_flags_DEBUG_LIST)
Expand Down Expand Up @@ -128,6 +128,8 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
"/wd4868" # Compiler may not enforce left-to-right evaluation order in braced initializer list
"/wd5026" # Move constructor was implicitly defined as deleted
"/wd5027" # Move assignment operator was implicitly defined as deleted
"/wd5262" # implicit fall-through
"/wd5264" # 'variable-name': 'const' variable is not used
)
endif()

Expand Down
8 changes: 2 additions & 6 deletions tidal-link/link/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(LinkExamples)

# _ ____ ___ ___
Expand All @@ -11,7 +11,7 @@ project(LinkExamples)
if(WIN32)
function(configure_asio asio_sdk_path_OUT)
# ASIO-related path/file variables
set(asio_download_root "https:/download.steinberg.net/sdk_downloads")
set(asio_download_root "https://download.steinberg.net/sdk_downloads")
set(asio_file_name "asiosdk_2.3.3_2019-06-14.zip")
set(asio_dir_name "asiosdk_2.3.3_2019-06-14")
set(asio_working_dir "${CMAKE_BINARY_DIR}/modules")
Expand Down Expand Up @@ -96,10 +96,6 @@ source_group("Audio Sources" FILES ${linkhut_audio_SOURCES})
#

function(configure_linkhut_executable target)
if(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD|GNU")
target_link_libraries(${target} atomic pthread)
endif()

target_link_libraries(${target} Ableton::Link)
endfunction()

Expand Down
1 change: 1 addition & 0 deletions tidal-link/link/examples/esp32/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
sdkconfig
sdkconfig.old
managed_components
17 changes: 17 additions & 0 deletions tidal-link/link/examples/esp32/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## IDF Component Manager Manifest File
dependencies:
espressif/asio: "*"
## Required IDF version
idf:
version: ">=4.1.0"
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
44 changes: 3 additions & 41 deletions tidal-link/link/examples/esp32/main/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <ableton/Link.hpp>
#include <driver/gpio.h>
#include <driver/timer.h>
#include <driver/gptimer.h>
#include <esp_event.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
Expand All @@ -21,38 +21,6 @@ char* if_indextoname(unsigned int ifIndex, char* ifName)
return nullptr;
}

void IRAM_ATTR timer_group0_isr(void* userParam)
{
static BaseType_t xHigherPriorityTaskWoken = pdFALSE;

TIMERG0.int_clr_timers.t0 = 1;
TIMERG0.hw_timer[0].config.alarm_en = 1;

xSemaphoreGiveFromISR(userParam, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken)
{
portYIELD_FROM_ISR();
}
}

void timerGroup0Init(int timerPeriodUS, void* userParam)
{
timer_config_t config = {.alarm_en = TIMER_ALARM_EN,
.counter_en = TIMER_PAUSE,
.intr_type = TIMER_INTR_LEVEL,
.counter_dir = TIMER_COUNT_UP,
.auto_reload = TIMER_AUTORELOAD_EN,
.divider = 80};

timer_init(TIMER_GROUP_0, TIMER_0, &config);
timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0);
timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, timerPeriodUS);
timer_enable_intr(TIMER_GROUP_0, TIMER_0);
timer_isr_register(TIMER_GROUP_0, TIMER_0, &timer_group0_isr, userParam, 0, nullptr);

timer_start(TIMER_GROUP_0, TIMER_0);
}

void printTask(void* userParam)
{
auto link = static_cast<ableton::Link*>(userParam);
Expand All @@ -73,7 +41,6 @@ void printTask(void* userParam)

void tickTask(void* userParam)
{
SemaphoreHandle_t handle = static_cast<SemaphoreHandle_t>(userParam);
ableton::Link link(120.0f);
link.enable(true);

Expand All @@ -86,12 +53,10 @@ void tickTask(void* userParam)

while (true)
{
xSemaphoreTake(handle, portMAX_DELAY);

const auto state = link.captureAudioSessionState();
const auto phase = state.phaseAtTime(link.clock().micros(), 1.);
gpio_set_level(LED, fmodf(phase, 1.) < 0.1);
portYIELD();
vTaskDelay(1);
}
}

Expand All @@ -102,8 +67,5 @@ extern "C" void app_main()
ESP_ERROR_CHECK(esp_event_loop_create_default());
ESP_ERROR_CHECK(example_connect());

SemaphoreHandle_t tickSemphr = xSemaphoreCreateBinary();
timerGroup0Init(100, tickSemphr);

xTaskCreate(tickTask, "tick", 8192, tickSemphr, configMAX_PRIORITIES - 1, nullptr);
xTaskCreate(tickTask, "tick", 8192, nullptr, configMAX_PRIORITIES - 1, nullptr);
}
2 changes: 2 additions & 0 deletions tidal-link/link/examples/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y

4 changes: 0 additions & 4 deletions tidal-link/link/extensions/abl_link/abl_link.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ target_include_directories(abl_link PUBLIC
set_property(TARGET abl_link PROPERTY C_STANDARD 11)

target_link_libraries(abl_link Ableton::Link)

if(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD|GNU")
target_link_libraries(abl_link atomic pthread)
endif()
7 changes: 4 additions & 3 deletions tidal-link/link/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(LinkCore)

# ____
Expand All @@ -19,6 +19,7 @@ set(link_core_HEADERS
${link_core_DIR}/LinearRegression.hpp
${link_core_DIR}/Measurement.hpp
${link_core_DIR}/MeasurementEndpointV4.hpp
${link_core_DIR}/MeasurementEndpointV6.hpp
${link_core_DIR}/MeasurementService.hpp
${link_core_DIR}/Median.hpp
${link_core_DIR}/NodeId.hpp
Expand Down Expand Up @@ -49,8 +50,9 @@ set(link_core_HEADERS

set(link_discovery_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ableton/discovery)
set(link_discovery_HEADERS
${link_discovery_DIR}/AsioTypes.hpp
${link_discovery_DIR}/InterfaceScanner.hpp
${link_discovery_DIR}/IpV4Interface.hpp
${link_discovery_DIR}/IpInterface.hpp
${link_discovery_DIR}/MessageTypes.hpp
${link_discovery_DIR}/NetworkByteStreamSerializable.hpp
${link_discovery_DIR}/Payload.hpp
Expand All @@ -77,7 +79,6 @@ set(link_platform_HEADERS
${link_platform_DIR}/asio/Context.hpp
${link_platform_DIR}/asio/LockFreeCallbackDispatcher.hpp
${link_platform_DIR}/asio/Socket.hpp
${link_platform_DIR}/asio/Util.hpp
)

if(ESP_PLATFORM)
Expand Down
32 changes: 23 additions & 9 deletions tidal-link/link/include/ableton/Link.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,33 @@ inline void BasicLink<Clock>::SessionState::requestBeatAtTime(
forceBeatAtTime(beat, time, quantum);
}

template <typename Clock>
inline void BasicLink<Clock>::SessionState::forceBeatAtTime(
const double beat, const std::chrono::microseconds time, const double quantum)
inline void forceBeatAtTimeImpl(link::Timeline& timeline,
const link::Beats beat,
const std::chrono::microseconds time,
const link::Beats quantum)
{
// There are two components to the beat adjustment: a phase shift
// and a beat magnitude adjustment.
const auto curBeatAtTime = link::Beats{beatAtTime(time, quantum)};
const auto closestInPhase =
link::closestPhaseMatch(curBeatAtTime, link::Beats{beat}, link::Beats{quantum});
mState.timeline = shiftClientTimeline(mState.timeline, closestInPhase - curBeatAtTime);
const auto curBeatAtTime = link::toPhaseEncodedBeats(timeline, time, quantum);
const auto closestInPhase = link::closestPhaseMatch(curBeatAtTime, beat, quantum);
timeline = shiftClientTimeline(timeline, closestInPhase - curBeatAtTime);
// Now adjust the magnitude
mState.timeline.beatOrigin =
mState.timeline.beatOrigin + (link::Beats{beat} - closestInPhase);
timeline.beatOrigin = timeline.beatOrigin + beat - closestInPhase;
}

template <typename Clock>
inline void BasicLink<Clock>::SessionState::forceBeatAtTime(
const double beat, std::chrono::microseconds time, const double quantum)
{
forceBeatAtTimeImpl(mState.timeline, link::Beats{beat}, time, link::Beats{quantum});

// Due to quantization errors the resulting BeatTime at 'time' after forcing can be
// bigger than 'beat' which then violates intended behavior of the API and can lead
// i.e. to missing a downbeat. Thus we have to shift the timeline forwards.
if (beatAtTime(time, quantum) > beat)
{
forceBeatAtTimeImpl(mState.timeline, link::Beats{beat}, ++time, link::Beats{quantum});
}
}

template <typename Clock>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016, Ableton AG, Berlin. All rights reserved.
/* Copyright 2023, Ableton AG, Berlin. 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
Expand All @@ -19,16 +19,19 @@

#pragma once

#include <algorithm>
#include <ableton/platforms/asio/AsioWrapper.hpp>

namespace ableton
{
namespace platforms
{
namespace asio
namespace discovery
{

// Utility for making v4 or v6 ip addresses from raw bytes in network byte-order
using IpAddress = LINK_ASIO_NAMESPACE::ip::address;
using IpAddressV4 = LINK_ASIO_NAMESPACE::ip::address_v4;
using IpAddressV6 = LINK_ASIO_NAMESPACE::ip::address_v6;
using UdpSocket = LINK_ASIO_NAMESPACE::ip::udp::socket;
using UdpEndpoint = LINK_ASIO_NAMESPACE::ip::udp::endpoint;

template <typename AsioAddrType>
AsioAddrType makeAddress(const char* pAddr)
{
Expand All @@ -38,6 +41,14 @@ AsioAddrType makeAddress(const char* pAddr)
return AsioAddrType{bytes};
}

} // namespace asio
} // namespace platforms
template <typename AsioAddrType>
AsioAddrType makeAddress(const char* pAddr, uint32_t scopeId)
{
using namespace std;
typename AsioAddrType::bytes_type bytes;
copy(pAddr, pAddr + bytes.size(), begin(bytes));
return AsioAddrType{bytes, scopeId};
}

} // namespace discovery
} // namespace ableton
Loading

0 comments on commit dcb6132

Please sign in to comment.