| 1 | /* melder_play.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2018 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "melder.h"cxx . . $ `<file>/melder/melder.h`/ |
| 20 | #ifdef _WIN32 |
| 21 | #include <windows.h> |
| 22 | #endif |
| 23 | |
| 24 | #ifdef macintosh |
| 25 | #include "macport_on.h" |
| 26 | #include <AudioToolbox/AudioToolbox.h> |
| 27 | #include "macport_off.h" |
| 28 | #endif |
| 29 | |
| 30 | static int defaultRecordcxx . . $ defaultRecord(620b9ac44d2573a6). (double duration) { |
| 31 | (void) duration; |
| 32 | return 0; // nothing recorded |
| 33 | } |
| 34 | |
| 35 | static int defaultRecordFromFilecxx . . $ defaultRecordFromFile(a963d4eadbe2a039). (MelderFilecxx . . $ MelderFile# file) { |
| 36 | (void) file; |
| 37 | return 0; // nothing recorded |
| 38 | } |
| 39 | |
| 40 | static void defaultPlaycxx . . $ defaultPlay(49f6e7a06ebc5aa8). () {} |
| 41 | |
| 42 | static void defaultPlayReversecxx . . $ defaultPlayReverse(49f6e7a06ebc5aa8). () {} |
| 43 | |
| 44 | static int defaultPublishPlayedcxx . . $ defaultPublishPlayed(b126dc7c1de90089). () { |
| 45 | return 0; // nothing published |
| 46 | } |
| 47 | |
| 48 | void Melder_beepcxx . . $ Melder_beep(49f6e7a06ebc5aa8). () { |
| 49 | #ifdef macintosh |
| 50 | AudioServicesPlayAlertSound (kSystemSoundID_UserPreferredAlert); |
| 51 | #else |
| 52 | fprintf (Melder_stderrcxx . . $ Melder_stderr., "\a"); |
| 53 | #endif |
| 54 | } |
| 55 | |
| 56 | /********** Current message methods: initialize to default (batch) behaviour. **********/ |
| 57 | |
| 58 | static structcxx . . $ $anonymous_type_e7c7995c17363107_0# { |
| 59 | int (*recordcxx . . $ $anonymous_type_e7c7995c17363107_0#record.) (double duration); |
| 60 | int (*recordFromFilecxx . . $ $anonymous_type_e7c7995c17363107_0#recordFromFile.) (MelderFilecxx . . $ MelderFile# file); |
| 61 | void (*playcxx . . $ $anonymous_type_e7c7995c17363107_0#play.) (); |
| 62 | void (*playReversecxx . . $ $anonymous_type_e7c7995c17363107_0#playReverse.) (); |
| 63 | int (*publishPlayedcxx . . $ $anonymous_type_e7c7995c17363107_0#publishPlayed.) (); |
| 64 | } |
| 65 | theMelderFunctionscxx . . $ theMelderFunctions. = { |
| 66 | defaultRecordcxx . . $ defaultRecord(620b9ac44d2573a6)., defaultRecordFromFilecxx . . $ defaultRecordFromFile(a963d4eadbe2a039)., defaultPlaycxx . . $ defaultPlay(49f6e7a06ebc5aa8)., defaultPlayReversecxx . . $ defaultPlayReverse(49f6e7a06ebc5aa8)., defaultPublishPlayedcxx . . $ defaultPublishPlayed(b126dc7c1de90089). |
| 67 | }; |
| 68 | |
| 69 | int Melder_recordcxx . . $ Melder_record(620b9ac44d2573a6). (double duration) { |
| 70 | return theMelderFunctionscxx . . $ theMelderFunctions.. recordcxx . . $ $anonymous_type_e7c7995c17363107_0#record. (duration); |
| 71 | } |
| 72 | |
| 73 | int Melder_recordFromFilecxx . . $ Melder_recordFromFile(a963d4eadbe2a039). (MelderFilecxx . . $ MelderFile# file) { |
| 74 | return theMelderFunctionscxx . . $ theMelderFunctions.. recordFromFilecxx . . $ $anonymous_type_e7c7995c17363107_0#recordFromFile. (file); |
| 75 | } |
| 76 | |
| 77 | void Melder_playcxx . . $ Melder_play(49f6e7a06ebc5aa8). () { |
| 78 | theMelderFunctionscxx . . $ theMelderFunctions.. playcxx . . $ $anonymous_type_e7c7995c17363107_0#play. (); |
| 79 | } |
| 80 | |
| 81 | void Melder_playReversecxx . . $ Melder_playReverse(49f6e7a06ebc5aa8). () { |
| 82 | theMelderFunctionscxx . . $ theMelderFunctions.. playReversecxx . . $ $anonymous_type_e7c7995c17363107_0#playReverse. (); |
| 83 | } |
| 84 | |
| 85 | int Melder_publishPlayedcxx . . $ Melder_publishPlayed(b126dc7c1de90089). () { |
| 86 | return theMelderFunctionscxx . . $ theMelderFunctions.. publishPlayedcxx . . $ $anonymous_type_e7c7995c17363107_0#publishPlayed. (); |
| 87 | } |
| 88 | |
| 89 | /********** Procedures to override message methods (e.g., to enforce interactive behaviour). **********/ |
| 90 | |
| 91 | void Melder_setRecordProccxx . . $ Melder_setRecordProc(121202e7f306f80f). (int (*record) (double)) |
| 92 | { theMelderFunctionscxx . . $ theMelderFunctions.. recordcxx . . $ $anonymous_type_e7c7995c17363107_0#record. = record ? record : defaultRecordcxx . . $ defaultRecord(620b9ac44d2573a6).; } |
| 93 | |
| 94 | void Melder_setRecordFromFileProccxx . . $ Melder_setRecordFromFileProc(c7c905eaf0249da4). (int (*recordFromFile) (MelderFilecxx . . $ MelderFile#)) |
| 95 | { theMelderFunctionscxx . . $ theMelderFunctions.. recordFromFilecxx . . $ $anonymous_type_e7c7995c17363107_0#recordFromFile. = recordFromFile ? recordFromFile : defaultRecordFromFilecxx . . $ defaultRecordFromFile(a963d4eadbe2a039).; } |
| 96 | |
| 97 | void Melder_setPlayProccxx . . $ Melder_setPlayProc(964b12a25712bdc3). (void (*play) ()) |
| 98 | { theMelderFunctionscxx . . $ theMelderFunctions.. playcxx . . $ $anonymous_type_e7c7995c17363107_0#play. = play ? play : defaultPlaycxx . . $ defaultPlay(49f6e7a06ebc5aa8).; } |
| 99 | |
| 100 | void Melder_setPlayReverseProccxx . . $ Melder_setPlayReverseProc(964b12a25712bdc3). (void (*playReverse) ()) |
| 101 | { theMelderFunctionscxx . . $ theMelderFunctions.. playReversecxx . . $ $anonymous_type_e7c7995c17363107_0#playReverse. = playReverse ? playReverse : defaultPlayReversecxx . . $ defaultPlayReverse(49f6e7a06ebc5aa8).; } |
| 102 | |
| 103 | void Melder_setPublishPlayedProccxx . . $ Melder_setPublishPlayedProc(231822f2a2a10318). (int (*publishPlayed) ()) |
| 104 | { theMelderFunctionscxx . . $ theMelderFunctions.. publishPlayedcxx . . $ $anonymous_type_e7c7995c17363107_0#publishPlayed. = publishPlayed ? publishPlayed : defaultPublishPlayedcxx . . $ defaultPublishPlayed(b126dc7c1de90089).; } |
| 105 | |
| 106 | /* End of file melder_play.cpp */ |