-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update FluidSynth.cpp to APIv10.1, fixed segfault in FluidSynth-play.ck example #98
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ class FluidSynth | |
m_settings = new_fluid_settings(); | ||
m_synth = new_fluid_synth(m_settings); | ||
|
||
fluid_synth_set_sample_rate(m_synth, m_srate); | ||
fluid_settings_setnum(m_settings, "synth.sample-rate", m_srate); | ||
} | ||
|
||
~FluidSynth() | ||
|
@@ -104,14 +104,15 @@ class FluidSynth | |
fluid_synth_bank_select(m_synth, chan, bankNum); | ||
} | ||
|
||
void setTuning(int chan, Chuck_ArrayFloat * tuning) | ||
void setTuning(int chan, Chuck_ArrayFloat * tuning, CK_DL_API api) | ||
{ | ||
bool allChans = false; | ||
if (chan < 0) { | ||
allChans = true; | ||
chan = 0; | ||
} | ||
fluid_synth_activate_key_tuning(m_synth, 0, chan, "", &tuning->m_vector[0], false); | ||
fluid_synth_activate_key_tuning(m_synth, 0, chan, "", (double *) tuning, false); | ||
|
||
if (allChans) { | ||
for (chan = 0 ; chan<16 ; chan++) { | ||
fluid_synth_activate_tuning(m_synth, chan, 0, 0, false); | ||
|
@@ -121,14 +122,15 @@ class FluidSynth | |
} | ||
} | ||
|
||
void setOctaveTuning(int chan, Chuck_ArrayFloat * tuning) | ||
void setOctaveTuning(int chan, Chuck_ArrayFloat * tuning, CK_DL_API api) | ||
{ | ||
bool allChans = false; | ||
if (chan < 0) { | ||
allChans = true; | ||
chan = 0; | ||
} | ||
fluid_synth_activate_octave_tuning(m_synth, 0, chan, "", &tuning->m_vector[0], false); | ||
fluid_synth_activate_octave_tuning(m_synth, 0, chan, "", (double *) tuning, false); | ||
|
||
if (allChans) { | ||
for (chan = 0 ; chan<16 ; chan++) { | ||
fluid_synth_activate_tuning(m_synth, chan, 0, 0, false); | ||
|
@@ -154,20 +156,20 @@ class FluidSynth | |
fluid_synth_tune_notes(m_synth, 0, chan, 1, ¬eNum , &pitch, false); | ||
} | ||
|
||
void tuneNotes(Chuck_ArrayInt * noteNums, Chuck_ArrayFloat * pitches, int chan) | ||
void tuneNotes(Chuck_ArrayInt * noteNums, Chuck_ArrayFloat * pitches, int chan, CK_DL_API api) | ||
{ | ||
/* | ||
This ugly hack is required because Chuck_ArrayInt doesn't actually | ||
contain 4-byte ints (at least on my 64-bit linux system). So we | ||
need to copy the elements into an int array. | ||
*/ | ||
int * noteNumArr; | ||
noteNumArr = new int[noteNums->size()]; | ||
for (int i = 0; i < noteNums->size(); i++) { | ||
noteNumArr[i] = (int) noteNums->m_vector[i]; | ||
noteNumArr = new int[api->object->array_int_size(noteNums)]; | ||
for (int i = 0; i < api->object->array_int_size(noteNums); i++) { | ||
noteNumArr[i] = (int) api->object->array_int_get_idx(noteNums,i); | ||
} | ||
fluid_synth_tune_notes(m_synth, 0, chan, pitches->size(), | ||
noteNumArr, &pitches->m_vector[0], false); | ||
fluid_synth_tune_notes(m_synth, 0, chan, api->object->array_float_size(pitches), | ||
noteNumArr, (double *) pitches, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to copy pitches to a new vector |
||
|
||
delete [] noteNumArr; | ||
} | ||
|
@@ -449,12 +451,12 @@ CK_DLL_MFUN(fluidsynth_setTuning) | |
|
||
Chuck_ArrayFloat * tuning = (Chuck_ArrayFloat *) GET_NEXT_OBJECT(ARGS); | ||
|
||
if (tuning->size() != 128 ) { | ||
if (API->object->array_float_size(tuning) != 128 ) { | ||
printf("FluidSynth ERROR: setTuning() requires a tuning array of exactly 128 values\n"); | ||
return; | ||
} | ||
|
||
f_data->setTuning(-1, tuning); | ||
f_data->setTuning(-1, tuning, API); | ||
} | ||
|
||
CK_DLL_MFUN(fluidsynth_setTuningChan) | ||
|
@@ -464,12 +466,12 @@ CK_DLL_MFUN(fluidsynth_setTuningChan) | |
Chuck_ArrayFloat * tuning = (Chuck_ArrayFloat *) GET_NEXT_OBJECT(ARGS); | ||
t_CKINT chan = GET_NEXT_INT(ARGS); | ||
|
||
if (tuning->size() != 128 ) { | ||
if (API->object->array_float_size(tuning) != 128 ) { | ||
printf("FluidSynth ERROR: setOctaveTuning() requires a tuning array of exactly 12 values\n"); | ||
return; | ||
} | ||
|
||
f_data->setTuning(chan, tuning); | ||
f_data->setTuning(chan, tuning, API); | ||
} | ||
|
||
CK_DLL_MFUN(fluidsynth_setOctaveTuning) | ||
|
@@ -478,12 +480,12 @@ CK_DLL_MFUN(fluidsynth_setOctaveTuning) | |
|
||
Chuck_ArrayFloat * tuning = (Chuck_ArrayFloat *) GET_NEXT_OBJECT(ARGS); | ||
|
||
if (tuning->size() != 12 ) { | ||
if (API->object->array_float_size(tuning) != 12 ) { | ||
printf("FluidSynth ERROR: setOctaveTuning() requires a tuning array of exactly 12 values\n"); | ||
return; | ||
} | ||
|
||
f_data->setOctaveTuning(-1, tuning); | ||
f_data->setOctaveTuning(-1, tuning, API); | ||
} | ||
|
||
CK_DLL_MFUN(fluidsynth_setOctaveTuningChan) | ||
|
@@ -493,12 +495,12 @@ CK_DLL_MFUN(fluidsynth_setOctaveTuningChan) | |
Chuck_ArrayFloat * tuning = (Chuck_ArrayFloat *) GET_NEXT_OBJECT(ARGS); | ||
t_CKINT chan = GET_NEXT_INT(ARGS); | ||
|
||
if (tuning->size() != 12 ) { | ||
if (API->object->array_float_size(tuning) != 12 ) { | ||
printf("FluidSynth ERROR: setOctaveTuning() requires a tuning array of exactly 12 values\n"); | ||
return; | ||
} | ||
|
||
f_data->setOctaveTuning(chan, tuning); | ||
f_data->setOctaveTuning(chan, tuning, API); | ||
} | ||
|
||
CK_DLL_MFUN(fluidsynth_resetTuning) | ||
|
@@ -543,12 +545,12 @@ CK_DLL_MFUN(fluidsynth_tuneNotes) | |
Chuck_ArrayInt * noteNums = (Chuck_ArrayInt *) GET_NEXT_OBJECT(ARGS); | ||
Chuck_ArrayFloat * pitches = (Chuck_ArrayFloat *) GET_NEXT_OBJECT(ARGS); | ||
|
||
if (pitches->size() != noteNums->size()) { | ||
if (API->object->array_float_size(pitches) != API->object->array_int_size(noteNums)) { | ||
printf("FluidSynth ERROR: tuneNotes requires pitches and noteNums arrays to be the same length\n"); | ||
return; | ||
} | ||
|
||
f_data->tuneNotes(noteNums, pitches, 0); | ||
f_data->tuneNotes(noteNums, pitches, 0, API); | ||
} | ||
|
||
CK_DLL_MFUN(fluidsynth_tuneNotesChan) | ||
|
@@ -559,12 +561,12 @@ CK_DLL_MFUN(fluidsynth_tuneNotesChan) | |
Chuck_ArrayFloat * pitches = (Chuck_ArrayFloat *) GET_NEXT_OBJECT(ARGS); | ||
t_CKINT chan = GET_NEXT_INT(ARGS); | ||
|
||
if (pitches->size() != noteNums->size()) { | ||
if (API->object->array_float_size(pitches) != API->object->array_int_size(noteNums)) { | ||
printf("FluidSynth ERROR: tuneNotes requires pitches and noteNums arrays to be the same length\n"); | ||
return; | ||
} | ||
|
||
f_data->tuneNotes(noteNums, pitches, chan); | ||
f_data->tuneNotes(noteNums, pitches, chan, API); | ||
} | ||
|
||
CK_DLL_MFUN(fluidsynth_setPitchBend) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
#----------------------------------- | ||
# makefile.mac | ||
# macOS-specific build configuration | ||
#----------------------------------- | ||
|
||
ARCHS?=x86_64 arm64 | ||
ARCHOPTS=$(addprefix -arch ,$(ARCHS)) | ||
FLUIDSYNTH_PREFIX=/usr/local | ||
|
||
FLUIDSYNTH_PREFIX=/opt/local | ||
# to build for the native architecture: (leave blank) | ||
# ARCHS?= | ||
# | ||
# to build for intel: | ||
# ARCHS?=x86_64 | ||
# | ||
# to build for apple silicon: | ||
# ARCHS?=arm64 | ||
# | ||
# to build a universal=binary chugin: | ||
# ARCHS?=x86_64 arm64 | ||
ARCHS?= | ||
|
||
FLAGS+=-mmacosx-version-min=10.9 -I$(CK_SRC_PATH) $(ARCHOPTS) -I$(FLUIDSYNTH_PREFIX)/include | ||
LDFLAGS+=-mmacosx-version-min=10.9 -shared -lc++ $(ARCHOPTS) -L$(FLUIDSYNTH_PREFIX)/lib | ||
# construct compiler option string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ask ge @gewang |
||
ARCHOPTS=$(addprefix -arch ,$(ARCHS)) | ||
|
||
LD=clang++ | ||
# compiler flags | ||
FLAGS+=-mmacosx-version-min=10.9 -I$(CK_SRC_PATH) $(ARCHOPTS) -fPIC -I$(FLUIDSYNTH_PREFIX)/include | ||
# linker flags | ||
LDFLAGS+=-mmacosx-version-min=10.9 -shared -lc++ $(ARCHOPTS) -L$(FLUIDSYNTH_PREFIX)/lib -lfluidsynth | ||
|
||
# which C++ compiler | ||
CXX=clang++ | ||
# which linker to user | ||
LD=clang++ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to extract all of the values from the tuning Array and then pass that vector