Skip to content

Commit

Permalink
fix issue with playback warp processor when warping is disabled. Add …
Browse files Browse the repository at this point in the history
…new function for resetting warp markers to a steady BPM. Add new function for setting warp markers to a 2D array.
  • Loading branch information
David Braun committed Apr 4, 2022
1 parent 69e885a commit 13cf58a
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Builds/LinuxMakefile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ifeq ($(CONFIG),Debug)
TARGET_ARCH :=
endif

JUCE_CPPFLAGS := $(DEPFLAGS) "-DLINUX=1" "-DDEBUG=1" "-D_DEBUG=1" "-DPIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==" "-DSAMPLER_SKIP_UI" "-DHAVE_LIBSAMPLERATE" "-DUSE_BUILTIN_FFT" "-DUSE_PTHREADS" "-DBUILD_DAWDREAMER_FAUST" "-DBUILD_DAWDREAMER_RUBBERBAND" "-DJUCER_LINUX_MAKE_6D53C8B4=1" "-DJUCE_APP_VERSION=0.6.0" "-DJUCE_APP_VERSION_HEX=0x600" $(shell pkg-config --cflags alsa freetype2 libcurl) -pthread -I../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK -I../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I../../JuceLibraryCode -I../../JuceLibraryCode/modules -I/usr/include/python3.9 -I../../thirdparty/pybind11/include -I../../thirdparty/faust/architecture -I../../thirdparty/faust/compiler -I../../thirdparty/faust/compiler/utils -I../../thirdparty/libsamplerate/src -I../../thirdparty/libsamplerate/include -I../../thirdparty/rubberband -I../../thirdparty/rubberband/rubberband -I../../thirdparty/rubberband/src/kissfft -I../../thirdparty/rubberband/src -I../../thirdparty/portable_endian/include $(CPPFLAGS)
JUCE_CPPFLAGS := $(DEPFLAGS) "-DLINUX=1" "-DDEBUG=1" "-D_DEBUG=1" "-DPIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==" "-DSAMPLER_SKIP_UI" "-DHAVE_LIBSAMPLERATE" "-DUSE_BUILTIN_FFT" "-DUSE_PTHREADS" "-DBUILD_DAWDREAMER_FAUST" "-DBUILD_DAWDREAMER_RUBBERBAND" "-DJUCER_LINUX_MAKE_6D53C8B4=1" "-DJUCE_APP_VERSION=0.6.1" "-DJUCE_APP_VERSION_HEX=0x601" $(shell pkg-config --cflags alsa freetype2 libcurl) -pthread -I../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK -I../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I../../JuceLibraryCode -I../../JuceLibraryCode/modules -I/usr/include/python3.9 -I../../thirdparty/pybind11/include -I../../thirdparty/faust/architecture -I../../thirdparty/faust/compiler -I../../thirdparty/faust/compiler/utils -I../../thirdparty/libsamplerate/src -I../../thirdparty/libsamplerate/include -I../../thirdparty/rubberband -I../../thirdparty/rubberband/rubberband -I../../thirdparty/rubberband/src/kissfft -I../../thirdparty/rubberband/src -I../../thirdparty/portable_endian/include $(CPPFLAGS)
JUCE_CPPFLAGS_DYNAMIC_LIBRARY := "-DJucePlugin_Build_VST=0" "-DJucePlugin_Build_VST3=0" "-DJucePlugin_Build_AU=0" "-DJucePlugin_Build_AUv3=0" "-DJucePlugin_Build_RTAS=0" "-DJucePlugin_Build_AAX=0" "-DJucePlugin_Build_Standalone=0" "-DJucePlugin_Build_Unity=0"
JUCE_CFLAGS_DYNAMIC_LIBRARY := -fPIC -fvisibility=hidden
JUCE_LDFLAGS_DYNAMIC_LIBRARY := -shared
Expand All @@ -58,7 +58,7 @@ ifeq ($(CONFIG),Release)
TARGET_ARCH :=
endif

JUCE_CPPFLAGS := $(DEPFLAGS) "-DLINUX=1" "-DNDEBUG=1" "-DPIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==" "-DSAMPLER_SKIP_UI" "-DHAVE_LIBSAMPLERATE" "-DUSE_BUILTIN_FFT" "-DUSE_PTHREADS" "-DBUILD_DAWDREAMER_FAUST" "-DBUILD_DAWDREAMER_RUBBERBAND" "-DJUCER_LINUX_MAKE_6D53C8B4=1" "-DJUCE_APP_VERSION=0.6.0" "-DJUCE_APP_VERSION_HEX=0x600" $(shell pkg-config --cflags alsa freetype2 libcurl) -pthread -I../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK -I../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I../../JuceLibraryCode -I../../JuceLibraryCode/modules -I/usr/include/python3.9 -I../../thirdparty/pybind11/include -I../../thirdparty/faust/architecture -I../../thirdparty/faust/compiler -I../../thirdparty/faust/compiler/utils -I../../thirdparty/libsamplerate/src -I../../thirdparty/libsamplerate/include -I../../thirdparty/rubberband -I../../thirdparty/rubberband/rubberband -I../../thirdparty/rubberband/src/kissfft -I../../thirdparty/rubberband/src -I../../thirdparty/portable_endian/include $(CPPFLAGS)
JUCE_CPPFLAGS := $(DEPFLAGS) "-DLINUX=1" "-DNDEBUG=1" "-DPIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==" "-DSAMPLER_SKIP_UI" "-DHAVE_LIBSAMPLERATE" "-DUSE_BUILTIN_FFT" "-DUSE_PTHREADS" "-DBUILD_DAWDREAMER_FAUST" "-DBUILD_DAWDREAMER_RUBBERBAND" "-DJUCER_LINUX_MAKE_6D53C8B4=1" "-DJUCE_APP_VERSION=0.6.1" "-DJUCE_APP_VERSION_HEX=0x601" $(shell pkg-config --cflags alsa freetype2 libcurl) -pthread -I../../JuceLibraryCode/modules/juce_audio_processors/format_types/VST3_SDK -I../../thirdparty/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I../../JuceLibraryCode -I../../JuceLibraryCode/modules -I/usr/include/python3.9 -I../../thirdparty/pybind11/include -I../../thirdparty/faust/architecture -I../../thirdparty/faust/compiler -I../../thirdparty/faust/compiler/utils -I../../thirdparty/libsamplerate/src -I../../thirdparty/libsamplerate/include -I../../thirdparty/rubberband -I../../thirdparty/rubberband/rubberband -I../../thirdparty/rubberband/src/kissfft -I../../thirdparty/rubberband/src -I../../thirdparty/portable_endian/include $(CPPFLAGS)
JUCE_CPPFLAGS_DYNAMIC_LIBRARY := "-DJucePlugin_Build_VST=0" "-DJucePlugin_Build_VST3=0" "-DJucePlugin_Build_AU=0" "-DJucePlugin_Build_AUv3=0" "-DJucePlugin_Build_RTAS=0" "-DJucePlugin_Build_AAX=0" "-DJucePlugin_Build_Standalone=0" "-DJucePlugin_Build_Unity=0"
JUCE_CFLAGS_DYNAMIC_LIBRARY := -fPIC -fvisibility=hidden
JUCE_LDFLAGS_DYNAMIC_LIBRARY := -shared
Expand Down
8 changes: 4 additions & 4 deletions Builds/MacOSX/DawDreamer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@
"BUILD_DAWDREAMER_FAUST",
"BUILD_DAWDREAMER_RUBBERBAND",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=0.6.0",
"JUCE_APP_VERSION_HEX=0x600",
"JUCE_APP_VERSION=0.6.1",
"JUCE_APP_VERSION_HEX=0x601",
"JucePlugin_Build_VST=0",
"JucePlugin_Build_VST3=0",
"JucePlugin_Build_AU=0",
Expand Down Expand Up @@ -908,8 +908,8 @@
"BUILD_DAWDREAMER_FAUST",
"BUILD_DAWDREAMER_RUBBERBAND",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=0.6.0",
"JUCE_APP_VERSION_HEX=0x600",
"JUCE_APP_VERSION=0.6.1",
"JUCE_APP_VERSION_HEX=0x601",
"JucePlugin_Build_VST=0",
"JucePlugin_Build_VST3=0",
"JucePlugin_Build_AU=0",
Expand Down
4 changes: 2 additions & 2 deletions Builds/VisualStudio2019/DawDreamer_DynamicLibrary.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<Optimization>Disabled</Optimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode\modules\juce_audio_processors\format_types\VST3_SDK;..\..\thirdparty\JUCE\modules\juce_audio_processors\format_types\VST3_SDK;..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;$(pythonLocation)\include;..\..\thirdparty\pybind11\include;..\..\thirdparty\faust\architecture;..\..\thirdparty\faust\compiler;..\..\thirdparty\faust\compiler\utils;..\..\thirdparty\libsamplerate\src;..\..\thirdparty\libsamplerate\include;..\..\thirdparty\rubberband;..\..\thirdparty\rubberband\rubberband;..\..\thirdparty\rubberband\src\kissfft;..\..\thirdparty\rubberband\src;..\..\thirdparty\portable_endian\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;PIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==;SAMPLER_SKIP_UI;_WIN32;__SSE__;__SSE2__;BUILD_DAWDREAMER_FAUST;BUILD_DAWDREAMER_RUBBERBAND;NOMINMAX;HAVE_LIBSAMPLERATE;HAVE_KISSFFT;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=0.6.0;JUCE_APP_VERSION_HEX=0x600;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;PIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==;SAMPLER_SKIP_UI;_WIN32;__SSE__;__SSE2__;BUILD_DAWDREAMER_FAUST;BUILD_DAWDREAMER_RUBBERBAND;NOMINMAX;HAVE_LIBSAMPLERATE;HAVE_KISSFFT;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=0.6.1;JUCE_APP_VERSION_HEX=0x601;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
Expand Down Expand Up @@ -116,7 +116,7 @@ copy &quot;..\..\thirdparty\libfaust\win-x64\Debug\bin\faust.dll&quot; &quot;$(p
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode\modules\juce_audio_processors\format_types\VST3_SDK;..\..\thirdparty\JUCE\modules\juce_audio_processors\format_types\VST3_SDK;..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;$(pythonLocation)\include;..\..\thirdparty\pybind11\include;..\..\thirdparty\faust\architecture;..\..\thirdparty\faust\compiler;..\..\thirdparty\faust\compiler\utils;..\..\thirdparty\libsamplerate\src;..\..\thirdparty\libsamplerate\include;..\..\thirdparty\rubberband;..\..\thirdparty\rubberband\rubberband;..\..\thirdparty\rubberband\src\kissfft;..\..\thirdparty\rubberband\src;..\..\thirdparty\portable_endian\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;PIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==;SAMPLER_SKIP_UI;_WIN32;__SSE__;__SSE2__;BUILD_DAWDREAMER_FAUST;BUILD_DAWDREAMER_RUBBERBAND;NOMINMAX;HAVE_LIBSAMPLERATE;HAVE_KISSFFT;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=0.6.0;JUCE_APP_VERSION_HEX=0x600;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;PIP_JUCE_EXAMPLES_DIRECTORY=QzpcdG9vbHNcSlVDRVxleGFtcGxlcw==;SAMPLER_SKIP_UI;_WIN32;__SSE__;__SSE2__;BUILD_DAWDREAMER_FAUST;BUILD_DAWDREAMER_RUBBERBAND;NOMINMAX;HAVE_LIBSAMPLERATE;HAVE_KISSFFT;JUCER_VS2019_78A5026=1;JUCE_APP_VERSION=0.6.1;JUCE_APP_VERSION_HEX=0x601;JucePlugin_Build_VST=0;JucePlugin_Build_VST3=0;JucePlugin_Build_AU=0;JucePlugin_Build_AUv3=0;JucePlugin_Build_RTAS=0;JucePlugin_Build_AAX=0;JucePlugin_Build_Standalone=0;JucePlugin_Build_Unity=0;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
Expand Down
6 changes: 3 additions & 3 deletions Builds/VisualStudio2019/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,6,0,0
FILEVERSION 0,6,1,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "DawDreamer\0"
VALUE "FileVersion", "0.6.0\0"
VALUE "FileVersion", "0.6.1\0"
VALUE "ProductName", "DawDreamer\0"
VALUE "ProductVersion", "0.6.0\0"
VALUE "ProductVersion", "0.6.1\0"
END
END

Expand Down
2 changes: 1 addition & 1 deletion DawDreamer.jucer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="EHAJpP" name="DawDreamer" projectType="dll" version="0.6.0"
<JUCERPROJECT id="EHAJpP" name="DawDreamer" projectType="dll" version="0.6.1"
bundleIdentifier="design.dirt.DawDreamer" includeBinaryInAppConfig="1"
displaySplashScreen="1" reportAppUsage="0" splashScreenColour="Dark"
cppLanguageStandard="17" companyCopyright="" jucerFormatVersion="1"
Expand Down
4 changes: 2 additions & 2 deletions JuceLibraryCode/JuceHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ProjectInfo
{
const char* const projectName = "DawDreamer";
const char* const companyName = "";
const char* const versionString = "0.6.0";
const int versionNumber = 0x600;
const char* const versionString = "0.6.1";
const int versionNumber = 0x601;
}
#endif
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ DawDreamer's foundation is [JUCE](https://github.com/julianstorer/JUCE), with a

## Installation

`pip install dawdreamer`
`pip install dawdreamer` on macOS/Windows. Use the Dockerfile on Linux.

## API Documentation

Expand Down
4 changes: 4 additions & 0 deletions Source/AbletonClipInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class AbletonClipInfo {
bool loop_on = true;
bool warp_on = false;

AbletonClipInfo() : loop_start(0), loop_end(262144), start_marker(0), hidden_loop_start(0), hidden_loop_end(262144), end_marker(262144), loop_on(true), warp_on(false) {

}

std::vector<std::pair<double, double>> warp_markers;

int beat_to_sample(double beat, double sr) {
Expand Down
58 changes: 57 additions & 1 deletion Source/PlaybackWarpProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class PlaybackWarpProcessor : public ProcessorBase
void setTimeRatio(double ratio) {
m_time_ratio_if_warp_off = ratio;
}
bool getTimeRatio() {
double getTimeRatio() {
return m_time_ratio_if_warp_off;
}

Expand Down Expand Up @@ -105,6 +105,60 @@ class PlaybackWarpProcessor : public ProcessorBase
return arr;
}

void resetWarpMarkers(double bpm) {
m_clipInfo.warp_markers.clear();

m_clipInfo.warp_markers.push_back(std::make_pair(0, 0));
double numSamples = 128;
double beats = bpm / (60. * numSamples / m_sample_rate);
m_clipInfo.warp_markers.push_back(std::make_pair(numSamples, beats));
}

void setWarpMarkers(py::array_t<float, py::array::c_style | py::array::forcecast> input) {

if (input.ndim() != 2) {
throw std::runtime_error("The warp markers must be two-dimensional and shaped (num_markers, 2).");
return;
}

const int numPairs = (int)input.shape(0);

if (numPairs < 2) {
throw std::runtime_error("The number of warp markers must be greater than one.");
return;
}

if (input.shape(1) != 2) {
throw std::runtime_error("The dimensions of the passed warp markers are incorrect.");
return;
}

std::vector<std::pair<double, double>> warp_markers;

double beat, new_beat;
double pos, new_pos;
beat = new_beat = pos = new_pos = -999999.;

float* input_ptr = (float*)input.data();

for (int pair_i = 0; pair_i < numPairs; pair_i++) {

new_pos = *input_ptr++;
new_beat = *input_ptr++;

if (new_beat <= beat || new_pos <= pos) {
throw std::runtime_error("The warp markers must be monotonically increasing. new_beat: " + std::to_string(new_beat) + " beat: " + std::to_string(beat) + " new_pos: " + std::to_string(new_pos) + " pos: " + std::to_string(pos));
}

pos = new_pos;
beat = new_beat;

warp_markers.push_back(std::make_pair(pos, beat));
}

m_clipInfo.warp_markers = warp_markers;
}

private:
class Clip {
public:
Expand Down Expand Up @@ -234,6 +288,7 @@ class PlaybackWarpProcessor : public ProcessorBase
else {
sampleReadIndex = 0;
}

continue;
}
else {
Expand Down Expand Up @@ -302,6 +357,7 @@ class PlaybackWarpProcessor : public ProcessorBase
setupRubberband(m_sample_rate, m_numChannels);

m_clipIndex = 0;
sampleReadIndex = 0;

if (m_clipIndex < m_clips.size()) {
m_currentClip = m_clips.at(0);
Expand Down
3 changes: 2 additions & 1 deletion Source/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ play the audio in double the amount of time, so it will sound slowed down.")
.def_property("loop_end", &PlaybackWarpProcessor::getLoopEnd, &PlaybackWarpProcessor::setLoopEnd, "The loop end position in beats (typically quarter notes) relative to 1.1.1")
.def_property("start_marker", &PlaybackWarpProcessor::getStartMarker, &PlaybackWarpProcessor::setStartMarker, "The start position in beats (typically quarter notes) relative to 1.1.1")
.def_property("end_marker", &PlaybackWarpProcessor::getEndMarker, &PlaybackWarpProcessor::setEndMarker, "The end position in beats (typically quarter notes) relative to 1.1.1")
.def_property("warp_markers", &PlaybackWarpProcessor::getWarpMarkers, &PlaybackWarpProcessor::setWarpMarkers, "Get/set the warp markers as a 2D array of time positions in seconds and positions in beats.")
.def("reset_warp_markers", &PlaybackWarpProcessor::resetWarpMarkers, arg("bpm"), "Reset the warp markers with a BPM.")
.def("set_clip_file", &PlaybackWarpProcessor::loadAbletonClipInfo, arg("asd_file_path"), "Load an Ableton Live file with an \".asd\" extension")
.def_property_readonly("warp_markers", &PlaybackWarpProcessor::getWarpMarkers, "Get the warp markers as a 2D array of time positions in seconds and positions in beats.")
.def("set_data", &PlaybackWarpProcessor::setData, arg("data"), "Set the audio as a numpy array shaped (Channels, Samples).")
.def("set_clip_positions", &PlaybackWarpProcessor::setClipPositions, arg("clip_positions"), R"pbdoc(
Set one or more positions at which the clip should play.
Expand Down
Loading

0 comments on commit 13cf58a

Please sign in to comment.