From b8134fc3069a1e7ffc8fea88b4f360228ec2297a Mon Sep 17 00:00:00 2001 From: richardash1981 Date: Sat, 16 Jun 2012 16:58:17 +0000 Subject: [PATCH] commit it tidied up version of the patch to fix bug 497, with a consistent error message (none of the others include the Error. prefix) and some documentation of what the nyx function returns for future sanity. --- lib-src/libnyquist/nyx.c | 6 +++++- lib-src/libnyquist/nyx.h | 6 ++++++ src/effects/nyquist/Nyquist.cpp | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib-src/libnyquist/nyx.c b/lib-src/libnyquist/nyx.c index b02144e6e..f8d358879 100644 --- a/lib-src/libnyquist/nyx.c +++ b/lib-src/libnyquist/nyx.c @@ -875,7 +875,11 @@ int nyx_get_audio_num_channels() } if (vectorp(nyx_result)) { - return getsize(nyx_result); + if (getsize(nyx_result) == 1) { + return -1; // invalid number of channels in array + } else { + return getsize(nyx_result); + } } return 1; diff --git a/lib-src/libnyquist/nyx.h b/lib-src/libnyquist/nyx.h index 881f76dfe..af01faa15 100644 --- a/lib-src/libnyquist/nyx.h +++ b/lib-src/libnyquist/nyx.h @@ -64,6 +64,12 @@ extern "C" nyx_rval nyx_eval_expression(const char *expr); + /** @brief Get the number of channels in the Nyquist audio object + * + * @return The positive integer number of audio channels in the + * Nyquist audio object, 0 if not an audio object, -1 one if + * Nyquist returns an array of samples (which we can't handle) + */ int nyx_get_audio_num_channels(); int nyx_get_audio(nyx_audio_callback callback, void *userdata); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index dd10b1168..6b82109db 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -917,6 +917,13 @@ bool EffectNyquist::ProcessOne() return false; } + if (outChannels == -1) { + wxMessageBox(_("Nyquist returned one audio channel as an array.\n"), + wxT("Nyquist"), + wxOK | wxCENTRE, mParent); + return false; + } + double rate = mCurTrack[0]->GetRate(); for (i = 0; i < outChannels; i++) { sampleFormat format = mCurTrack[i]->GetSampleFormat();