Skip to content

Commit dfb6264

Browse files
yaw-manyaw-manidf-boytoy
authored
MS Toolchain; Tuning Knob (#17)
* CMake and Visual Studio build files ignored * Add CMakeLists * Replace POSIX mutex with std::mutex * Mutex unlock return value isn't used, changed signature to void * C++ preprocessor demands different VA_ARGS syntax * Superfluous include directory * Expand tuning knob range to +/-1 octave. --------- Co-authored-by: yaw-man <ywmn@proton.me> Co-authored-by: wan-may <wnmy@protonmail.com>
1 parent a746e4d commit dfb6264

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616

1717
bin/
1818
build/
19+
20+
.vs/
21+
out/

Diff for: CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
add_subdirectory(dpf)
3+
add_subdirectory(plugins/Nekobi)

Diff for: plugins/Nekobi/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DPF_ADD_PLUGIN(Nekobi
2+
TARGETS vst2
3+
FILES_DSP
4+
DistrhoPluginNekobi.cpp
5+
FILES_UI
6+
DistrhoArtworkNekobi.cpp
7+
DistrhoUINekobi.cpp)
8+
9+
target_include_directories(Nekobi PUBLIC
10+
"."
11+
"nekobee-src"
12+
)

Diff for: plugins/Nekobi/DistrhoPluginNekobi.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "DistrhoPluginNekobi.hpp"
2020

21-
extern "C" {
2221

2322
#include "nekobee-src/nekobee_synth.c"
2423
#include "nekobee-src/nekobee_voice.c"
@@ -31,7 +30,7 @@ extern "C" {
3130
bool dssp_voicelist_mutex_trylock(nekobee_synth_t* const synth)
3231
{
3332
/* Attempt the mutex lock */
34-
if (pthread_mutex_trylock(&synth->voicelist_mutex) != 0)
33+
if (!synth->voicelist_mutex.try_lock())
3534
{
3635
synth->voicelist_mutex_grab_failed = 1;
3736
return false;
@@ -47,9 +46,9 @@ bool dssp_voicelist_mutex_trylock(nekobee_synth_t* const synth)
4746
return true;
4847
}
4948

50-
bool dssp_voicelist_mutex_unlock(nekobee_synth_t* const synth)
49+
void dssp_voicelist_mutex_unlock(nekobee_synth_t* const synth)
5150
{
52-
return (pthread_mutex_unlock(&synth->voicelist_mutex) == 0);
51+
synth->voicelist_mutex.unlock();
5352
}
5453

5554
// -----------------------------------------------------------------------
@@ -79,7 +78,6 @@ void nekobee_handle_raw_event(nekobee_synth_t* const synth, const uint8_t size,
7978
}
8079
}
8180

82-
} /* extern "C" */
8381

8482
START_NAMESPACE_DISTRHO
8583

@@ -109,7 +107,6 @@ DistrhoPluginNekobi::DistrhoPluginNekobi()
109107

110108
fSynth.voice = nekobee_voice_new();
111109
fSynth.voicelist_mutex_grab_failed = 0;
112-
pthread_mutex_init(&fSynth.voicelist_mutex, nullptr);
113110

114111
fSynth.channel_pressure = 0;
115112
fSynth.pitch_wheel_sensitivity = 0;
@@ -299,7 +296,7 @@ void DistrhoPluginNekobi::setParameterValue(uint32_t index, float value)
299296
break;
300297
case paramTuning:
301298
fParams.tuning = value;
302-
fSynth.tuning = (value+12.0f)/24.0f * 1.5 + 0.5f; // FIXME: log?
299+
fSynth.tuning = exp2f( value / 12.0f );
303300
DISTRHO_SAFE_ASSERT(fSynth.tuning >= 0.5f && fSynth.tuning <= 2.0f);
304301
break;
305302
case paramCutoff:

Diff for: plugins/Nekobi/DistrhoPluginNekobi.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121

2222
#include "DistrhoPlugin.hpp"
2323

24-
extern "C" {
2524
#include "nekobee-src/nekobee_synth.h"
26-
}
2725

2826
START_NAMESPACE_DISTRHO
2927

Diff for: plugins/Nekobi/nekobee-src/nekobee.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363

6464
#else /* !XSYNTH_DEBUG */
6565

66-
#define XDB_MESSAGE(type, fmt...)
67-
#define GDB_MESSAGE(type, fmt...)
66+
#define XDB_MESSAGE(type, fmt, ...)
67+
#define GDB_MESSAGE(type, fmt, ...)
6868
#define XSYNTH_DEBUG_INIT(x)
6969

7070
#endif /* XSYNTH_DEBUG */

Diff for: plugins/Nekobi/nekobee-src/nekobee_synth.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <stdio.h>
3030
#include <string.h>
3131
#include <math.h>
32-
#include <pthread.h>
32+
#include <mutex>
3333

3434
#include "nekobee.h"
3535
#include "nekobee_synth.h"

Diff for: plugins/Nekobi/nekobee-src/nekobee_synth.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#ifndef _XSYNTH_SYNTH_H
2727
#define _XSYNTH_SYNTH_H
2828

29-
#include <pthread.h>
29+
#include <mutex>
3030

3131
#include "nekobee.h"
3232
#include "nekobee_types.h"
@@ -64,7 +64,7 @@ struct _nekobee_synth_t {
6464

6565
//nekobee_voice_t *voice[XSYNTH_MAX_POLYPHONY];
6666
nekobee_voice_t *voice;
67-
pthread_mutex_t voicelist_mutex;
67+
std::mutex voicelist_mutex;
6868
int voicelist_mutex_grab_failed;
6969

7070
/* current non-paramter-mapped controller values */

0 commit comments

Comments
 (0)