From f2ca93c2b3e9b029a4d79e8033c131f84bef7eae Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Thu, 18 Oct 2012 15:47:02 +0200 Subject: [PATCH] Added safeguards against no input devices --- praat_module/adaptPraat.patch | 22 ++++++++++++++++++++++ sgc2.praat | 3 +++ 2 files changed, 25 insertions(+) diff --git a/praat_module/adaptPraat.patch b/praat_module/adaptPraat.patch index 6c512a1..8a3ce09 100644 --- a/praat_module/adaptPraat.patch +++ b/praat_module/adaptPraat.patch @@ -213,6 +213,28 @@ diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/fon/praat_Sound_init. if (theSoundRecorder) { if (numberOfChannels == thePreviousNumberOfChannels) { theSoundRecorder -> raise (); +@@ -1418,10 +1424,21 @@ FORM (Sound_recordFixedTime, L"Record So + POSITIVE (L"Duration (seconds)", L"1.0") + OK + DO ++#if defined (_WIN32) && defined (DEMOAPP) ++ UINT numberOfDevices = waveInGetNumDevs (), i; ++ if(numberOfDevices > 0) { ++#endif + autoSound me = Sound_recordFixedTime (GET_INTEGER (L"Input source"), + GET_REAL (L"Gain"), GET_REAL (L"Balance"), + wcstod (GET_STRING (L"Sampling frequency"), NULL), GET_REAL (L"Duration")); + praat_new (me.transfer(), L"untitled"); ++#if defined (_WIN32) && defined (DEMOAPP) ++ } else { ++ // Create an empty sound if no input is available ++ autoSound me = Sound_createSimple (1, GET_REAL (L"Duration"), wcstod (GET_STRING (L"Sampling frequency"), NULL)); ++ praat_new (me.transfer(), L"untitled"); ++ }; ++#endif + END + + FORM (Sound_resample, L"Sound: Resample", L"Sound: Resample...") diff -Naurp -x '*.[oah]' -x '.git*' -x praat praat_sources/sys/UiPause.cpp demo_praat_sources/sys/UiPause.cpp --- praat_sources/sys/UiPause.cpp 2012-09-27 09:10:50.000000000 +0200 +++ demo_praat_sources/sys/UiPause.cpp 2012-09-27 13:25:18.000000000 +0200 diff --git a/sgc2.praat b/sgc2.praat index 5d122d2..b7b9027 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -781,6 +781,9 @@ procedure sound_detection .sound$ .margin select TextGrid Input'.sound$' .numberofIntervals = Get number of intervals... 1 + if .numberofIntervals < 2 + .numberofIntervals = 0 + endif # Remove buzzing and other obnoxious sounds (if switched on) for .i from 1 to .numberofIntervals -- 2.11.4.GIT