Skip to content

Commit

Permalink
fixed FluidSynth.cpp so not-chuck arrays are correctly passed into FS…
Browse files Browse the repository at this point in the history
… API, and removed tag in makefile not needed
  • Loading branch information
kellycochran committed Apr 15, 2024
1 parent d167732 commit 0421f33
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions FluidSynth/FluidSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ class FluidSynth
allChans = true;
chan = 0;
}
fluid_synth_activate_key_tuning(m_synth, 0, chan, "", (double *) tuning, false);

double * tuningArr;
tuningArr = new double[api->object->array_float_size(tuning)];
for (int i = 0; i < api->object->array_float_size(tuning); i++) {
tuningArr[i] = (double) api->object->array_float_get_idx(tuning,i);
}

fluid_synth_activate_key_tuning(m_synth, 0, chan, "", tuningArr, false);

if (allChans) {
for (chan = 0 ; chan<16 ; chan++) {
Expand All @@ -129,7 +136,14 @@ class FluidSynth
allChans = true;
chan = 0;
}
fluid_synth_activate_octave_tuning(m_synth, 0, chan, "", (double *) tuning, false);

double * tuningArr;
tuningArr = new double[api->object->array_float_size(tuning)];
for (int i = 0; i < api->object->array_float_size(tuning); i++) {
tuningArr[i] = (double) api->object->array_float_get_idx(tuning,i);
}

fluid_synth_activate_octave_tuning(m_synth, 0, chan, "", tuningArr, false);

if (allChans) {
for (chan = 0 ; chan<16 ; chan++) {
Expand Down Expand Up @@ -168,8 +182,15 @@ class FluidSynth
for (int i = 0; i < api->object->array_int_size(noteNums); i++) {
noteNumArr[i] = (int) api->object->array_int_get_idx(noteNums,i);
}

double * pitchesArr;
pitchesArr = new double[api->object->array_float_size(pitches)];
for (int i = 0; i < api->object->array_float_size(pitches); i++) {
pitchesArr[i] = (double) api->object->array_float_get_idx(pitches,i);
}

fluid_synth_tune_notes(m_synth, 0, chan, api->object->array_float_size(pitches),
noteNumArr, (double *) pitches, false);
noteNumArr, pitchesArr, false);

delete [] noteNumArr;
}
Expand Down
2 changes: 1 addition & 1 deletion FluidSynth/makefile.mac
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ARCHS?=
ARCHOPTS=$(addprefix -arch ,$(ARCHS))

# compiler flags
FLAGS+=-mmacosx-version-min=10.9 -I$(CK_SRC_PATH) $(ARCHOPTS) -fPIC -I$(FLUIDSYNTH_PREFIX)/include
FLAGS+=-mmacosx-version-min=10.9 -I$(CK_SRC_PATH) $(ARCHOPTS) -I$(FLUIDSYNTH_PREFIX)/include
# linker flags
LDFLAGS+=-mmacosx-version-min=10.9 -shared -lc++ $(ARCHOPTS) -L$(FLUIDSYNTH_PREFIX)/lib -lfluidsynth

Expand Down

0 comments on commit 0421f33

Please sign in to comment.