Skip to content

Commit c607806

Browse files
authored
More work on Python Bindings (#82)
1 parent 673e5b0 commit c607806

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5949
-369
lines changed

.github/workflows/build_android.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
- uses: actions/checkout@v4
3939
with:
4040
fetch-depth: 0
41-
- uses: seanmiddleditch/gha-setup-ninja@master
4241
- name: Setup Java
4342
uses: actions/setup-java@v3
4443
with:
@@ -66,7 +65,6 @@ jobs:
6665
- uses: actions/checkout@v4
6766
with:
6867
fetch-depth: 0
69-
- uses: seanmiddleditch/gha-setup-ninja@master
7068
- name: Setup Java
7169
uses: actions/setup-java@v3
7270
with:
@@ -98,7 +96,6 @@ jobs:
9896
- uses: actions/checkout@v4
9997
with:
10098
fetch-depth: 0
101-
- uses: seanmiddleditch/gha-setup-ninja@master
10299
- name: Setup Java
103100
uses: actions/setup-java@v3
104101
with:

.github/workflows/build_ios.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
- uses: actions/checkout@v4
3535
with:
3636
fetch-depth: 0
37-
- uses: seanmiddleditch/gha-setup-ninja@master
3837
- name: Configure
3938
run: |
4039
cmake ${{ github.workspace }} -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/ios.cmake \
@@ -57,7 +56,6 @@ jobs:
5756
- uses: actions/checkout@v4
5857
with:
5958
fetch-depth: 0
60-
- uses: seanmiddleditch/gha-setup-ninja@master
6159
- uses: actions/cache/restore@v4
6260
id: cache-restore
6361
with:
@@ -78,7 +76,6 @@ jobs:
7876
- uses: actions/checkout@v4
7977
with:
8078
fetch-depth: 0
81-
- uses: seanmiddleditch/gha-setup-ninja@master
8279
- uses: actions/cache/restore@v4
8380
id: cache-restore
8481
with:
@@ -99,7 +96,6 @@ jobs:
9996
- uses: actions/checkout@v4
10097
with:
10198
fetch-depth: 0
102-
- uses: seanmiddleditch/gha-setup-ninja@master
10399
- uses: actions/cache/restore@v4
104100
id: cache-restore
105101
with:

.github/workflows/build_linux.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
- uses: actions/checkout@v4
4141
with:
4242
fetch-depth: 0
43-
- uses: seanmiddleditch/gha-setup-ninja@master
4443
- name: Install Dependencies
4544
run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
4645
- name: Configure
@@ -63,7 +62,6 @@ jobs:
6362
- uses: actions/checkout@v4
6463
with:
6564
fetch-depth: 0
66-
- uses: seanmiddleditch/gha-setup-ninja@master
6765
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
6866
- uses: actions/cache/restore@v4
6967
id: cache-restore
@@ -84,7 +82,6 @@ jobs:
8482
- uses: actions/checkout@v4
8583
with:
8684
fetch-depth: 0
87-
- uses: seanmiddleditch/gha-setup-ninja@master
8885
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
8986
- uses: actions/cache/restore@v4
9087
id: cache-restore
@@ -105,7 +102,6 @@ jobs:
105102
- uses: actions/checkout@v4
106103
with:
107104
fetch-depth: 0
108-
- uses: seanmiddleditch/gha-setup-ninja@master
109105
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
110106
- uses: actions/cache/restore@v4
111107
id: cache-restore
@@ -125,7 +121,6 @@ jobs:
125121
- uses: actions/checkout@v4
126122
with:
127123
fetch-depth: 0
128-
- uses: seanmiddleditch/gha-setup-ninja@master
129124
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
130125
- uses: actions/cache/restore@v4
131126
id: cache-restore
@@ -145,7 +140,6 @@ jobs:
145140
- uses: actions/checkout@v4
146141
with:
147142
fetch-depth: 0
148-
- uses: seanmiddleditch/gha-setup-ninja@master
149143
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
150144
- uses: actions/cache/restore@v4
151145
id: cache-restore
@@ -165,7 +159,6 @@ jobs:
165159
- uses: actions/checkout@v4
166160
with:
167161
fetch-depth: 0
168-
- uses: seanmiddleditch/gha-setup-ninja@master
169162
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
170163
- uses: actions/cache/restore@v4
171164
id: cache-restore

.github/workflows/build_macos.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ jobs:
3333
- uses: actions/checkout@v4
3434
with:
3535
fetch-depth: 0
36-
- uses: seanmiddleditch/gha-setup-ninja@master
3736
- name: Configure
3837
run: cmake ${{ github.workspace }} -G "Ninja Multi-Config" -B ${{ runner.workspace }}/build -DYUP_ENABLE_TESTS=ON -DYUP_ENABLE_EXAMPLES=ON
3938
- name: Build SDL2
@@ -54,7 +53,6 @@ jobs:
5453
- uses: actions/checkout@v4
5554
with:
5655
fetch-depth: 0
57-
- uses: seanmiddleditch/gha-setup-ninja@master
5856
- uses: actions/cache/restore@v4
5957
id: cache-restore
6058
with:
@@ -74,7 +72,6 @@ jobs:
7472
- uses: actions/checkout@v4
7573
with:
7674
fetch-depth: 0
77-
- uses: seanmiddleditch/gha-setup-ninja@master
7875
- uses: actions/cache/restore@v4
7976
id: cache-restore
8077
with:
@@ -94,7 +91,6 @@ jobs:
9491
- uses: actions/checkout@v4
9592
with:
9693
fetch-depth: 0
97-
- uses: seanmiddleditch/gha-setup-ninja@master
9894
- uses: actions/cache/restore@v4
9995
id: cache-restore
10096
with:
@@ -113,7 +109,6 @@ jobs:
113109
- uses: actions/checkout@v4
114110
with:
115111
fetch-depth: 0
116-
- uses: seanmiddleditch/gha-setup-ninja@master
117112
- uses: actions/cache/restore@v4
118113
id: cache-restore
119114
with:
@@ -132,7 +127,6 @@ jobs:
132127
- uses: actions/checkout@v4
133128
with:
134129
fetch-depth: 0
135-
- uses: seanmiddleditch/gha-setup-ninja@master
136130
- uses: actions/cache/restore@v4
137131
id: cache-restore
138132
with:
@@ -151,7 +145,6 @@ jobs:
151145
- uses: actions/checkout@v4
152146
with:
153147
fetch-depth: 0
154-
- uses: seanmiddleditch/gha-setup-ninja@master
155148
- uses: actions/cache/restore@v4
156149
id: cache-restore
157150
with:

.github/workflows/build_wasm.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
- uses: actions/checkout@v4
4040
with:
4141
fetch-depth: 0
42-
- uses: seanmiddleditch/gha-setup-ninja@master
4342
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
4443
- name: Setup emsdk
4544
uses: mymindstorm/setup-emsdk@v14
@@ -57,7 +56,6 @@ jobs:
5756
- uses: actions/checkout@v4
5857
with:
5958
fetch-depth: 0
60-
- uses: seanmiddleditch/gha-setup-ninja@master
6159
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
6260
- name: Setup emsdk
6361
uses: mymindstorm/setup-emsdk@v14
@@ -75,7 +73,6 @@ jobs:
7573
- uses: actions/checkout@v4
7674
with:
7775
fetch-depth: 0
78-
- uses: seanmiddleditch/gha-setup-ninja@master
7976
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
8077
- name: Setup emsdk
8178
uses: mymindstorm/setup-emsdk@v14
@@ -92,7 +89,6 @@ jobs:
9289
- uses: actions/checkout@v4
9390
with:
9491
fetch-depth: 0
95-
- uses: seanmiddleditch/gha-setup-ninja@master
9692
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
9793
- name: Setup emsdk
9894
uses: mymindstorm/setup-emsdk@v14
@@ -109,7 +105,6 @@ jobs:
109105
- uses: actions/checkout@v4
110106
with:
111107
fetch-depth: 0
112-
- uses: seanmiddleditch/gha-setup-ninja@master
113108
- run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
114109
- name: Setup emsdk
115110
uses: mymindstorm/setup-emsdk@v14

.github/workflows/coverage.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ jobs:
6060
uses: actions/checkout@v4
6161
with:
6262
fetch-depth: 0
63-
- name: Setup Ninja
64-
uses: seanmiddleditch/gha-setup-ninja@master
6563
- name: Install Dependencies
6664
run: sudo apt-get update && sudo apt-get install -y ${INSTALL_DEPS}
6765
- name: Configure CMake with Coverage

cmake/yup_generate_java_header.cmake

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,25 @@ file (READ "${INPUT_FILE}" hex_content HEX)
3636
get_filename_component (INPUT_FILE_NAME "${INPUT_FILE}" NAME)
3737

3838
# Convert hex string to C++ array format
39-
string (REGEX MATCHALL "([A-Fa-f0-9][A-Fa-f0-9])" separated_hex ${hex_content})
40-
list (JOIN separated_hex ", 0x" formatted_hex)
41-
string (PREPEND formatted_hex "0x")
39+
set (count 0)
40+
set (wrapped_hex "")
41+
string (REGEX MATCHALL "([A-Fa-f0-9][A-Fa-f0-9])" separated_hex "${hex_content}")
42+
foreach (byte IN LISTS separated_hex)
43+
if (count EQUAL 0)
44+
set (current_line "0x${byte}")
45+
else()
46+
set (current_line "${current_line},0x${byte}")
47+
endif()
48+
math (EXPR count "${count} + 1")
49+
if (count EQUAL 60)
50+
list (APPEND wrapped_hex "${current_line}")
51+
set (count 0)
52+
endif()
53+
endforeach()
54+
if (count GREATER 0)
55+
list(APPEND wrapped_hex "${current_line}")
56+
endif()
57+
string (JOIN "\n" formatted_hex ${wrapped_hex})
4258

4359
# Generate timestamp
4460
string (TIMESTAMP current_time "%Y-%m-%d %H:%M:%S UTC" UTC)

cmake/yup_python.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ function (yup_prepare_python_stdlib target_name python_tools_path output_variabl
6464
"${Python_EXECUTABLE}" "${python_tools_path}/ArchivePythonStdlib.py"
6565
-r "${python_root_path}" -o "${CMAKE_CURRENT_BINARY_DIR}" -M "${Python_VERSION_MAJOR}" -m "${Python_VERSION_MINOR}"
6666
-x "\"${ignored_library_patterns}\""
67-
COMMAND_ECHO STDOUT
6867
COMMAND_ERROR_IS_FATAL ANY)
6968

7069
set (${output_variable} ${python_standard_library} PARENT_SCOPE)

modules/yup_audio_basics/synthesisers/yup_Synthesiser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Synthesiser::~Synthesiser()
106106
}
107107

108108
//==============================================================================
109-
SynthesiserVoice* Synthesiser::getVoice (const int index) const
109+
SynthesiserVoice::Ptr Synthesiser::getVoice (const int index) const
110110
{
111111
const ScopedLock sl (lock);
112112
return voices[index];
@@ -118,7 +118,7 @@ void Synthesiser::clearVoices()
118118
voices.clear();
119119
}
120120

121-
SynthesiserVoice* Synthesiser::addVoice (SynthesiserVoice* const newVoice)
121+
SynthesiserVoice* Synthesiser::addVoice (const SynthesiserVoice::Ptr newVoice)
122122
{
123123
SynthesiserVoice* voice;
124124

modules/yup_audio_basics/synthesisers/yup_Synthesiser.h

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class YUP_API SynthesiserSound : public ReferenceCountedObject
9999
100100
@tags{Audio}
101101
*/
102-
class YUP_API SynthesiserVoice
102+
class YUP_API SynthesiserVoice : public ReferenceCountedObject
103103
{
104104
public:
105105
//==============================================================================
@@ -261,6 +261,9 @@ class YUP_API SynthesiserVoice
261261
/** Returns true if this voice started playing its current note before the other voice did. */
262262
bool wasStartedBefore (const SynthesiserVoice& other) const noexcept;
263263

264+
/** The class is reference-counted, so this is a handy pointer class for it. */
265+
using Ptr = ReferenceCountedObjectPtr<SynthesiserVoice>;
266+
264267
protected:
265268
/** Resets the state of this voice after a sound has finished playing.
266269
@@ -337,17 +340,16 @@ class YUP_API Synthesiser
337340
int getNumVoices() const noexcept { return voices.size(); }
338341

339342
/** Returns one of the voices that have been added. */
340-
SynthesiserVoice* getVoice (int index) const;
343+
SynthesiserVoice::Ptr getVoice (int index) const;
341344

342345
/** Adds a new voice to the synth.
343346
344347
All the voices should be the same class of object and are treated equally.
345348
346-
The object passed in will be managed by the synthesiser, which will delete
347-
it later on when no longer needed. The caller should not retain a pointer to the
348-
voice.
349+
The object passed in is reference counted, so will be deleted when the
350+
synthesiser and all voices are no longer using it.
349351
*/
350-
SynthesiserVoice* addVoice (SynthesiserVoice* newVoice);
352+
SynthesiserVoice* addVoice (SynthesiserVoice::Ptr newVoice);
351353

352354
/** Deletes one of the voices. */
353355
void removeVoice (int index);
@@ -400,9 +402,7 @@ class YUP_API Synthesiser
400402
401403
The midiChannel parameter is the channel, between 1 and 16 inclusive.
402404
*/
403-
virtual void noteOn (int midiChannel,
404-
int midiNoteNumber,
405-
float velocity);
405+
virtual void noteOn (int midiChannel, int midiNoteNumber, float velocity);
406406

407407
/** Triggers a note-off event.
408408
@@ -416,10 +416,7 @@ class YUP_API Synthesiser
416416
417417
The midiChannel parameter is the channel, between 1 and 16 inclusive.
418418
*/
419-
virtual void noteOff (int midiChannel,
420-
int midiNoteNumber,
421-
float velocity,
422-
bool allowTailOff);
419+
virtual void noteOff (int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff);
423420

424421
/** Turns off all notes.
425422
@@ -435,8 +432,7 @@ class YUP_API Synthesiser
435432
This method will be called automatically according to the midi data passed into
436433
renderNextBlock(), but may be called explicitly too.
437434
*/
438-
virtual void allNotesOff (int midiChannel,
439-
bool allowTailOff);
435+
virtual void allNotesOff (int midiChannel, bool allowTailOff);
440436

441437
/** Sends a pitch-wheel message to any active voices.
442438
@@ -449,8 +445,7 @@ class YUP_API Synthesiser
449445
@param midiChannel the midi channel, from 1 to 16 inclusive
450446
@param wheelValue the wheel position, from 0 to 0x3fff, as returned by MidiMessage::getPitchWheelValue()
451447
*/
452-
virtual void handlePitchWheel (int midiChannel,
453-
int wheelValue);
448+
virtual void handlePitchWheel (int midiChannel, int wheelValue);
454449

455450
/** Sends a midi controller message to any active voices.
456451
@@ -464,9 +459,7 @@ class YUP_API Synthesiser
464459
@param controllerNumber the midi controller type, as returned by MidiMessage::getControllerNumber()
465460
@param controllerValue the midi controller value, between 0 and 127, as returned by MidiMessage::getControllerValue()
466461
*/
467-
virtual void handleController (int midiChannel,
468-
int controllerNumber,
469-
int controllerValue);
462+
virtual void handleController (int midiChannel, int controllerNumber, int controllerValue);
470463

471464
/** Sends an aftertouch message.
472465
@@ -510,8 +503,7 @@ class YUP_API Synthesiser
510503
The base class implementation of this has no effect, but you may want to make your
511504
own synth react to program changes.
512505
*/
513-
virtual void handleProgramChange (int midiChannel,
514-
int programNumber);
506+
virtual void handleProgramChange (int midiChannel, int programNumber);
515507

516508
//==============================================================================
517509
/** Tells the synthesiser what the sample rate is for the audio it's being used to render.
@@ -575,7 +567,7 @@ class YUP_API Synthesiser
575567
/** This is used to control access to the rendering callback and the note trigger methods. */
576568
CriticalSection lock;
577569

578-
OwnedArray<SynthesiserVoice> voices;
570+
ReferenceCountedArray<SynthesiserVoice> voices;
579571
ReferenceCountedArray<SynthesiserSound> sounds;
580572

581573
/** The last pitch-wheel values for each midi channel. */

0 commit comments

Comments
 (0)