Skip to content

Commit c3a523f

Browse files
committed
fix and update softcut_jack_osc for macOS:
- remove boost depencies: lockfree_queue with moodycamel, boost_assert with cassert - add linker and include paths for homebrew / macports - fix some git merge markers that made it into main somehow
1 parent 6b6ec42 commit c3a523f

File tree

11 files changed

+2077
-40
lines changed

11 files changed

+2077
-40
lines changed

clients/softcut_jack_osc/CMakeLists.txt

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.7)
22

33
set(CMAKE_CXX_STANDARD 17)
44

5+
56
project(softcut_jack_osc)
67

78
set(SRC src/main.cpp
@@ -13,9 +14,22 @@ set(SRC src/main.cpp
1314

1415
add_executable(softcut_jack_osc ${SRC})
1516

16-
include_directories(../../softcut-lib/include)
17+
target_include_directories(softcut_jack_osc PUBLIC
18+
../../softcut-lib/include
19+
third-party
20+
)
1721

18-
target_link_libraries(softcut_jack_osc softcut jack lo pthread sndfile)
22+
if (${APPLE})
23+
message("is apple")
24+
# need to support macports or homebrew
25+
target_link_directories(softcut_jack_osc PUBLIC /usr/local/lib)
26+
target_link_directories(softcut_jack_osc PUBLIC /opt/local/lib)
27+
target_include_directories(softcut_jack_osc PUBLIC /usr/local/include)
28+
target_include_directories(softcut_jack_osc PUBLIC /opt/local/include)
29+
endif()
1930

2031
target_compile_options(softcut_jack_osc PRIVATE -Wall -Wextra -pedantic)
2132

33+
target_link_libraries(softcut_jack_osc softcut jack lo pthread sndfile)
34+
35+

clients/softcut_jack_osc/src/Bus.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef CRONE_BUS_H
66
#define CRONE_BUS_H
77

8-
#include <boost/assert.hpp>
8+
#include <cassert>
99
#include "Utilities.h"
1010

1111
namespace softcut_jack_osc {
@@ -28,7 +28,7 @@ namespace softcut_jack_osc {
2828

2929
// clear the first N frames in the bus
3030
void clear(size_t numFrames) {
31-
BOOST_ASSERT(numFrames < BlockSize);
31+
assert(numFrames < BlockSize);
3232
for(size_t ch=0; ch<NumChannels; ++ch) {
3333
for(size_t fr=0; fr<numFrames; ++fr) {
3434
buf[ch][fr] = 0.f;
@@ -38,7 +38,7 @@ namespace softcut_jack_osc {
3838

3939
// copy from bus, with no scaling (overwrites previous contents)
4040
void copyFrom(Bus &b, size_t numFrames) {
41-
BOOST_ASSERT(numFrames < BlockSize);
41+
assert(numFrames < BlockSize);
4242
for(size_t ch=0; ch<NumChannels; ++ch) {
4343
for(size_t fr=0; fr<numFrames; ++fr) {
4444
buf[ch][fr] = b.buf[ch][fr];
@@ -48,7 +48,7 @@ namespace softcut_jack_osc {
4848

4949
// copy from bus to pointer array, with no scaling (overwrites previous contents)
5050
void copyTo(float *dst[NumChannels], size_t numFrames) {
51-
BOOST_ASSERT(numFrames < BlockSize);
51+
assert(numFrames < BlockSize);
5252
for(size_t ch=0; ch<NumChannels; ++ch) {
5353
for(size_t fr=0; fr<numFrames; ++fr) {
5454
dst[ch][fr] = buf[ch][fr];
@@ -59,7 +59,7 @@ namespace softcut_jack_osc {
5959

6060
// sum from bus, without amplitude scaling
6161
void addFrom(BusT &b, size_t numFrames) {
62-
BOOST_ASSERT(numFrames < BlockSize);
62+
assert(numFrames < BlockSize);
6363
for(size_t ch=0; ch<NumChannels; ++ch) {
6464
for(size_t fr=0; fr<numFrames; ++fr) {
6565
buf[ch][fr] += b.buf[ch][fr];
@@ -69,7 +69,7 @@ namespace softcut_jack_osc {
6969

7070
// mix from bus, with fixed amplitude
7171
void mixFrom(BusT &b, size_t numFrames, float level) {
72-
BOOST_ASSERT(numFrames < BlockSize);
72+
assert(numFrames < BlockSize);
7373
for(size_t ch=0; ch<NumChannels; ++ch) {
7474
for(size_t fr=0; fr<numFrames; ++fr) {
7575
buf[ch][fr] += b.buf[ch][fr] * level;
@@ -80,7 +80,7 @@ namespace softcut_jack_osc {
8080

8181
// mix from bus, with smoothed amplitude
8282
void mixFrom(BusT &b, size_t numFrames, LogRamp &level) {
83-
BOOST_ASSERT(numFrames < BlockSize);
83+
assert(numFrames < BlockSize);
8484
float l;
8585
for(size_t fr=0; fr<numFrames; ++fr) {
8686
l = level.update();
@@ -92,7 +92,7 @@ namespace softcut_jack_osc {
9292

9393
// apply smoothed amplitude
9494
void applyGain(size_t numFrames, LogRamp &level) {
95-
BOOST_ASSERT(numFrames < BlockSize);
95+
assert(numFrames < BlockSize);
9696
float l;
9797
for(size_t fr=0; fr<numFrames; ++fr) {
9898
l = level.update();
@@ -104,7 +104,7 @@ namespace softcut_jack_osc {
104104

105105
// mix from pointer array, with smoothed amplitude
106106
void mixFrom(const float *src[NumChannels], size_t numFrames, LogRamp &level) {
107-
BOOST_ASSERT(numFrames < BlockSize);
107+
assert(numFrames < BlockSize);
108108
float l;
109109
for(size_t fr=0; fr<numFrames; ++fr) {
110110
l = level.update();
@@ -116,7 +116,7 @@ namespace softcut_jack_osc {
116116

117117
// set from pointer array, with smoothed amplitude
118118
void setFrom(const float *src[NumChannels], size_t numFrames, LogRamp &level) {
119-
BOOST_ASSERT(numFrames < BlockSize);
119+
assert(numFrames < BlockSize);
120120
float l;
121121
for(size_t fr=0; fr<numFrames; ++fr) {
122122
l = level.update();
@@ -128,7 +128,7 @@ namespace softcut_jack_osc {
128128

129129
// set from pointer array, without scaling
130130
void setFrom(const float *src[NumChannels], size_t numFrames) {
131-
BOOST_ASSERT(numFrames < BlockSize);
131+
assert(numFrames < BlockSize);
132132
for(size_t fr=0; fr<numFrames; ++fr) {
133133
for(size_t ch=0; ch<NumChannels; ++ch) {
134134
buf[ch][fr] = src[ch][fr];
@@ -138,7 +138,7 @@ namespace softcut_jack_osc {
138138

139139
// mix to pointer array, with smoothed amplitude
140140
void mixTo(float *dst[NumChannels], size_t numFrames, LogRamp &level) {
141-
BOOST_ASSERT(numFrames < BlockSize);
141+
assert(numFrames < BlockSize);
142142
float l;
143143
for(size_t fr=0; fr<numFrames; ++fr) {
144144
l = level.update();
@@ -150,7 +150,7 @@ namespace softcut_jack_osc {
150150

151151
// mix from stereo bus with 2x2 level matrix
152152
void stereoMixFrom(BusT &b, size_t numFrames, const float level[4]) {
153-
BOOST_ASSERT(numFrames < BlockSize);
153+
assert(numFrames < BlockSize);
154154
for (size_t fr = 0; fr < numFrames; ++fr) {
155155
buf[0][fr] += b.buf[0][fr] * level[0] + b.buf[1][fr] * level[2];
156156
buf[1][fr] += b.buf[0][fr] * level[1] + b.buf[1][fr] * level[3];
@@ -159,7 +159,7 @@ namespace softcut_jack_osc {
159159

160160
// mix from two busses with balance coefficient (linear)
161161
void xfade(BusT &a, BusT &b, size_t numFrames, LogRamp &level) {
162-
BOOST_ASSERT(numFrames < BlockSize);
162+
assert(numFrames < BlockSize);
163163
float x, y, c;
164164
for(size_t fr=0; fr<numFrames; ++fr) {
165165
c = level.update();
@@ -173,7 +173,7 @@ namespace softcut_jack_osc {
173173

174174
// mix from two busses with balance coefficient (equal power)
175175
void xfadeEp(BusT &a, BusT &b, size_t numFrames, LogRamp &level) {
176-
BOOST_ASSERT(numFrames < BlockSize);
176+
assert(numFrames < BlockSize);
177177
float x, y, l, c, d;
178178
for(size_t fr=0; fr<numFrames; ++fr) {
179179
l = level.update() * (float)M_PI_2;
@@ -189,7 +189,7 @@ namespace softcut_jack_osc {
189189

190190
// mix from mono->stereo bus, with level and pan (linear)
191191
void panMixFrom(Bus<1, BlockSize> a, size_t numFrames, LogRamp &level, LogRamp& pan) {
192-
BOOST_ASSERT(numFrames < BlockSize);
192+
assert(numFrames < BlockSize);
193193
static_assert(NumChannels > 1, "using panMixFrom() on mono bus");
194194
float l, c, x;
195195
for(size_t fr=0; fr<numFrames; ++fr) {
@@ -204,7 +204,7 @@ namespace softcut_jack_osc {
204204

205205
// mix from mono->stereo bus, with level and pan (equal power)
206206
void panMixEpFrom(Bus<1, BlockSize> a, size_t numFrames, LogRamp &level, LogRamp& pan) {
207-
BOOST_ASSERT(numFrames < BlockSize);
207+
assert(numFrames < BlockSize);
208208
static_assert(NumChannels > 1, "using panMixFrom() on mono bus");
209209
float l, c, x;
210210
for(size_t fr=0; fr<numFrames; ++fr) {

clients/softcut_jack_osc/src/Commands.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ Commands::Commands() = default;
1616

1717
void Commands::post(Commands::Id id, float f) {
1818
CommandPacket p(id, -1, f);
19-
q.push(p);
19+
q.enqueue(p);
2020
}
2121

2222
void Commands::post(Commands::Id id, int i, float f) {
2323
CommandPacket p(id, i, f);
24-
q.push(p);
24+
q.enqueue(p);
2525
}
2626

2727
void Commands::post(Commands::Id id, int i, int j) {
2828
CommandPacket p(id, i, j);
29-
q.push(p);
29+
q.enqueue(p);
3030
}
3131

3232
void Commands::post(Commands::Id id, int i, int j, float f) {
3333
CommandPacket p(id, i, j, f);
34-
q.push(p);
34+
q.enqueue(p);
3535
}
3636

3737

3838
void Commands::handlePending(SoftcutClient *client) {
3939
CommandPacket p;
40-
while (q.pop(p)) {
40+
while (q.try_dequeue(p)) {
4141
client->handleCommand(&p);
4242
}
4343
}

clients/softcut_jack_osc/src/Commands.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#ifndef CRONE_COMMANDS_H
66
#define CRONE_COMMANDS_H
77

8-
#include <boost/lockfree/spsc_queue.hpp>
9-
8+
//#include <boost/lockfree/spsc_queue.hpp>
9+
#include "readerwriterqueue/readerwriterqueue.h"
1010

1111
namespace softcut_jack_osc {
1212

@@ -64,6 +64,8 @@ namespace softcut_jack_osc {
6464
SET_CUT_RATE_SLEW_TIME,
6565
SET_CUT_VOICE_SYNC,
6666
SET_CUT_BUFFER,
67+
68+
SET_CUT_REC_ONCE,
6769
NUM_COMMANDS,
6870
} Id;
6971

@@ -90,8 +92,9 @@ namespace softcut_jack_osc {
9092
static Commands softcutCommands;
9193

9294
private:
93-
boost::lockfree::spsc_queue <CommandPacket,
94-
boost::lockfree::capacity<200> > q;
95+
// boost::lockfree::spsc_queue <CommandPacket,
96+
// boost::lockfree::capacity<200> > q;
97+
moodycamel::ReaderWriterQueue<CommandPacket> q;
9598
};
9699

97100
}
Binary file not shown.

0 commit comments

Comments
 (0)