summaryrefslogtreecommitdiff
path: root/srec/include/frontapi.h
blob: b25b3de623d9504c3e25e26741e94f007aa0c23d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
/*---------------------------------------------------------------------------*
 *  frontapi.h                                                               *
 *                                                                           *
 *  Copyright 2007, 2008 Nuance Communciations, Inc.                         *
 *                                                                           *
 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
 *  you may not use this file except in compliance with the License.         *
 *                                                                           *
 *  You may obtain a copy of the License at                                  *
 *      http://www.apache.org/licenses/LICENSE-2.0                           *
 *                                                                           *
 *  Unless required by applicable law or agreed to in writing, software      *
 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
 *  See the License for the specific language governing permissions and      *
 *  limitations under the License.                                           *
 *                                                                           *
 *---------------------------------------------------------------------------*/



#ifndef _h_frontapi_
#define _h_frontapi_

#include "creccons.h"   /* CREC Public Constants    */

#include "front.h"
#include "sample.h"
#include "utteranc.h"
#include "caexcept.h"

#ifdef __cplusplus
extern "C"
{
#endif

  /**
   ************************************************************************
   * SwigImageBegin       <- DO NOT MOVE THIS LINE !
   *
   * This is a CADOC Keyword section.
   *
   * If CADOC is instructed to create a SWIG I-File and this is one of the
   * files in the input list, everything between the 'SwigImage Begin' and
   * 'SwigImage End' keywords comment blocks will be copied 'as-is' to the
   * SWIG I-File specified on the CADOC command line.
   *
   ************************************************************************
   */
#include "mutualob.h"

#ifndef SWIGBUILD

  typedef struct
  {
    int                 ca_rtti;
    booldata            is_configured;
    booldata            is_configuredForAgc;
    booldata            is_configuredForVoicing;
    booldata            is_attached;
    wave_info           data;
    voicing_info        voice;
  }
  CA_Wave;

  typedef struct
  {
    int                 ca_rtti;
    booldata            is_configured;
    booldata            is_filter_loaded;
    int                 status;
    int                 samplerate;
    float               src_scale;
    float               sink_scale;
    int                 offset;
    front_config        *config;
  }
  CA_Frontend;

#endif

  /**
   ************************************************************************
   * SwigImageEnd         <- DO NOT MOVE THIS LINE !
   ************************************************************************
   */

  /*
  **  Frontend
  */

  CA_Frontend* CA_AllocateFrontend(float srcscale,
                                   int offset,
                                   float sinkscale);
  /**
   *
   * Params       srcscale    Gain applied to incoming wave data
   *              offset      DC offset applied to incoming wave data
   *              sinkscale   Gain applied to any wave data sinks
   *
   * Returns      Handle to new Front End object
   *
   * See          CA_FreeFrontend
   *
   ************************************************************************
   * Allocates a front-end object
   ************************************************************************
   */


  void CA_FreeFrontend(CA_Frontend* hFrontend);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *
   * Returns      void
   *
   * See          CA_AllocateFrontend
   *
   ************************************************************************
   * Deletes a front-end object
   ************************************************************************
   */


  void CA_ConfigureFrontend(CA_Frontend *hFrontend,
                            CA_FrontendInputParams *hFrontArgs);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *              hFrontpars  Handle to valid front-end input parameters object
   *
   * Returns      void
   *
   * See          CA_UnconfigureFrontend
   *
   ************************************************************************
   * Set up the front end using the paramteters. This function
   * configures the member Wave, Freq and Cep objects, by calling their
   * create and setup functions.
   ************************************************************************
   */


  void CA_SetWarpScale(CA_Frontend *hFrontend, float wscale);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *              wscale      warp scale
   *
   * Returns      void
   *
   * See          CA_SetFrontendParameter
   *
   ************************************************************************
   ************************************************************************
   */

  void CA_UnconfigureFrontend(CA_Frontend *hFrontend);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *
   * Returns      void
   *
   * See          CA_ConfigureFrontend
   *
   ************************************************************************
   * Undo all of the front end configurations
   ************************************************************************
   */


  int  CA_MakeFrame(CA_Frontend* hFrontend,
                    CA_Utterance* hUtt,
                    CA_Wave* hWave);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *              hUtt        Handle to valid utterance object
   *              hWave       Handle to valid wave object
   *
   * Returns      non-zero if a frame was constructed
   *
   ************************************************************************
   * Constructs a single frame from audio in the wave object.  The output
   * frame is inserted into the utterance.
   *
   * Frames may not be built. An initial start-up condition prevents
   * the first few frames of audio from being used for frames, in this case
   * this method returns zero to the caller.
   ************************************************************************
   */


  int  CA_GetFrontendFramesPerValidFrame(CA_Frontend *hFrontend);
  int  CA_GetFrontendSampleRate(CA_Frontend *hFrontend);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *
   * Returns       Current sample rate (Hz)
   *
   * See          CA_ConfigureFrontend
   *
   ************************************************************************
   * Gets the sample rate from the front end object
   ************************************************************************
   */


  int  CA_GetFrontendUtteranceDimension(CA_Frontend *hFrontend);
  /**
   *
   * Params       hFrontend   Handle to valid front-end object
   *
   * Returns      The dimension of utterance that the front end will build
   *
   * See          CA_InitUtteranceForFile
   *              CA_InitUtteranceForFrontend
   *              CA_LoadUtteranceFrame
   *
   ************************************************************************
   * Returns the number of items in an utterance.
   ************************************************************************
   */


  int  CA_GetRecognitionHoldoff(CA_FrontendInputParams *hFrontPar);
  /**
   *
   * Params       hFrontpar  Handle to valid front-end input parameters object
   *
   * Returns      The minimum recognition holdoff period, i.e. the minimum
   *              gap between the frontend and recognizer.
   *
   ************************************************************************
   * Computes the Recognition Holdoff Parameter value.  Setting the par in
   * a par file is unnecessary if this function is used.
   ************************************************************************
   */


  /*
  **  Channel normalization
  */
ESR_ReturnCode CA_GetCMSParameters ( CA_Wave *hWave, LCHAR *param_string, size_t* len );
ESR_ReturnCode CA_SetCMSParameters ( CA_Wave *hWave, const LCHAR *param_string );


  void CA_ReLoadCMSParameters(CA_Wave *hWave,
                              const char *basename);

  void CA_LoadCMSParameters(CA_Wave *hWave,
                            const char *basename,
                            CA_FrontendInputParams
                            *hFrontArgs);
  /**
   *
   * Params       hWave       Handle to valid wave object
   *              basename    Forename of .cmn and .tmn files that store the parameters
   *              hFrontPar       Handle to a valid CRhFrontendInputParams
   *
   * Returns      Nothing
   *
   * See          CA_ConfigureCMSparameters
   *              CA_SaveCMSParameters
   *              CA_AttachCMStoUtterance
   *
   ************************************************************************
   * Loads CMS parameters from file.  Sets up the CMS calculations
   * The .cmn and .tmn files must obviously have the same basename.
   ************************************************************************
   */


  void CA_SaveCMSParameters(CA_Wave *hWave,
                            const char *basename);
  /**
   *
   * Params       hWave       Handle to valid wave object
   *              basename    Forename of .cmn and .tmn files that are
   *                          to store the parameters
   *
   * Returns      Nothing
   *
   * See          CA_LoadCMSParameters
   *              CA_ClearCMSParameters
   *
   ************************************************************************
   * This method writes out .CMN and .TMN files.
   *
   * The .CMN file may differ from the one used during a call to
   * CA_LoadCMSParameters() due to channel adaptation.
   *
   * The .cmn and .tmn files will obviously have the same basename.
   ************************************************************************
   */


  void CA_ClearCMSParameters(CA_Wave *hWave);
  /**
   *
   * Params       hWave       Handle to valid wave object
   *
   * Returns      Nothing
   *
   * See          CA_LoadCMSParameters
   *              CA_SaveCMSParameters
   *              CA_DetachCMSfromUtterance
   *
   ************************************************************************
   * This method clears any CMS information.  Must call
   * CA_DetachCMSfromUtterance on the Wave first, if CA_AttachCMStoUtterance
   * has been called.
   ************************************************************************
   */

  void CA_AttachCMStoUtterance(CA_Wave *hWave,
                               CA_Utterance *hUtt);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *              hUtt    Handle to an utterance object to clear
   *
   * Returns      Nothing.
   *
   * See          CA_LoadCMSParameters
   *              CA_DetachCMStoUtterance
   *
   ************************************************************************
   *  The CMS data items are inherited from the CA_Wave object to the
   *  CA_Utterance.  All calculations carried out with this utterance
   *  object will now result in new statistics being inherited by the
   *  CA_Wave object.
   ************************************************************************
   */

  /**
   * Returns true if CMS is attached to utterance.
   *
   * @param hWave wave handle
   * @param isAttached [out] True if attached
   */
  ESR_ReturnCode CA_IsCMSAttachedtoUtterance(CA_Wave* hWave, ESR_BOOL* isAttached);

  /**
   * Returns true if CA_Wave is configured for Agc.
   *
   * @param hWave wave handle
   * @param isAttached [out] True if attached
   */
  ESR_ReturnCode CA_IsConfiguredForAgc(CA_Wave* hWave, ESR_BOOL* isConfigured);

  void CA_DetachCMSfromUtterance(CA_Wave *hWave,
                                 CA_Utterance *hUtt);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *              hUtt    Handle to an utterance object to clear
   *
   * Returns      Nothing.
   *
   * See          CA_LoadCMSParameters
   *              CA_AttachCMStoUtterance
   *              CA_ClearCMSParameters
   *
   ************************************************************************
   *  The CMS data items are now dis-inherited by the CA_Utterance object.
   *  Calculations carried out with this utterance
   *  object will no longer result in new statistics being inherited by the
   *  CA_Wave object.
   ************************************************************************
   */


  void CA_CalculateCMSParameters(CA_Wave *hWave);
  /**
   *
   * Params       hWave       Handle to valid wave object
   *
   * Returns
   *
   * See          CA_LoadCMSParameters
   *              CA_AttachCMStoUtterance
   *              CA_DiscardCMSAccumulates
   *
   ************************************************************************
   * This routine updates the values used for cepstrum mean subtraction
   * using a running estimation algorithm.
   * A call must first have been made to CA_LoadCMSparameters and
   * subsequently to a CA_AttachCMStoUtterance.
   ************************************************************************
   */


  void CA_DiscardCMSAccumulates(CA_Wave *hWave);
  /**
   *
   * Params       hWave       Handle to valid wave object
   *
   * Returns
   *
   * See          CA_LoadCMSParameters
   *              CA_AttachCMStoUtterance
   *              CA_CalculateCMSParameters
   *
   ************************************************************************
   * This routine clears the updates used for the running estimation of
   * cepstrum mean subtraction.
   * CMS parameters must have been loaded and attached to the wave.
   ************************************************************************
   */



  /*
  **  Wave
  */
  /**
   ************************************************************************
   * CA_Wave methods
   *
   * The wave-input object that represents a file or a device.
   * It maintains sample buffers and data associated with that input stream
   * such as agc, talk-over etc.
   *
   * However the process of getting samples into the CA_Wave object from
   * a physical device is external to CREC-API.
   ************************************************************************
   */

  CA_Wave* CA_AllocateWave(char typ);
  /**
   *
   * Params       typ     A waveform type charcater
   *
   * Returns      Handle to a new Wave structure
   *
   * See          CA_FreeWave
   *              CA_ConfigureWave
   *
   ************************************************************************
   * Creates a Wave structure.
   *
   * There are several options for the 'typ' character, each is listed below:
   *  'M' mu-Law
   *  'P' PCM  (i.e. 8k or 11kHz PCM Files)
   *  'R' RIFF
   *  'N' NIST
   *
   * Once allocated, the returned object should be configured with a call
   * to CA_ConfigureWave().
   ************************************************************************
   */


  void CA_ConfigureWave(CA_Wave *hWave,
                        CA_Frontend *hFrontend);
  /**
   *
   * Params       hWave   Handle to a previously created Wave structure
   *              hFrontend   Handle to valid front-end object
   *
   * Returns      void
   *
   * See          CA_UnconfigureWave
   *
   ************************************************************************
   * Initializes a Wave structure.
   *
   * This should be called before any other Wave methods.
   ************************************************************************
   */


  void CA_ConfigureVoicingAnalysis(CA_Wave *hWave,
                                   CA_FrontendInputParams *hFrontPar);
  /**
   *
   * Params       hWave           Handle to a previously created Wave structure
   *              hFrontPar       Handle to a valid CRhFrontendInputParams
   *
   * Returns      void
   *
   ************************************************************************
   * Initializes a Wave's voicin analysis module.
   ************************************************************************
   */


  void CA_ResetWave(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to a previously created Wave structure
   *
   * Returns      Nothing
   *
   ************************************************************************
   * This prepares the wave object for re-use.  The voicing information
   * is cleared. It is *essential* to call this function if the Wave object
   * is used for streaming live data, or multiple-utterance wave files.
   *
   ************************************************************************
   */


  void CA_UnconfigureWave(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to a previously created Wave structure
   *
   * Returns      void
   *
   * See          CA_ConfigureWave
   *
   ************************************************************************
   * Uninitializes a Wave structure.
   ************************************************************************
   */


  void CA_FreeWave(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to a previously created Wave structure
   *
   * Returns      Nothing, the Wave object is no longer valid
   *
   * See          CA_AllocateWave
   *
   ************************************************************************
   * Removes a previously allocated Wave structure
   ************************************************************************
   */


  int  CA_OpenWaveFromFile(CA_Wave *hWave,
                           char* filename,
                           char typ,
                           int endian,
                           int do_write,
                           int samplerate);
  /**
   *
   * Params       hWave       Handle to valid Wave structure
   *              filename    ASCII, null-terminated filename string
   *              typ         File attribute character
   *              endian      Binary storage, use 'LITTLE' or 'BIG'
   *              do_write    Adds a RIFF header if non-ZERO
   *              samplerate  File's sample rate (Hz)
   *
   * Returns      non-ZERO if successful
   *
   * See          CA_CloseFile
   *
   ************************************************************************
   * Initializes the Wave structure for use with a known filename.
   *
   * There are several options for the 'typ' character, each is listed below:
   *  'M' mu-Law Files
   *  'P' PCM Files (i.e. 8k or 11kHz PCM Files)
   *  'R' RIFF
   *  'N' NIST
   *
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  void CA_CloseFile(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Nothing, the opened file is closed
   *
   * See          CA_OpenWaveFromFile
   *
   ************************************************************************
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  int  CA_OpenWaveFromDevice(CA_Wave *hWave,
                             int wave_type,
                             int samplerate,
                             int device_id,
                             int device_type);
  /**
   *
   * Params       hWave       Handle to valid Wave structure
   *              wave_type   Audio format
   *              samplerate  Device sample rate (Hz)
   *              device_id   The Physical device number of the
   *                          waveform hardware (normally starting at 0)
   *              device_type The type of device
   *
   * Returns      non-ZERO if successful
   *
   * See          CA_CloseDevice
   *
   ************************************************************************
   * Initializes the Wave structure for use with a known filename.
   *
   * 'wave_type' should be either DEVICE_MULAW or DEVICE_RAW_PCM.  This
   * enables correct internal interpretation of the audio samples.  If the
   * device is an output device 'wave_type' should be 0 (ZERO).
   *
   * It is an error to call this function without first configuring hWave
   *
   * 'device_type' should be one of WAVE_DEVICE_MSWAVE (for real devices)
   * or WAVE_DEVICE_RAW (if using the raw interface - CA_LoadSamples)
   ************************************************************************
   */


  void CA_CloseDevice(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Nothing, the opened device is closed
   *
   * See          CA_OpenWaveFromDevice
   *
   ************************************************************************
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  void CA_SetWaveBoostValue(CA_Wave *hWave,
                            int waveBoost);
  /**
   *
   * Params       hWave       Handle to valid Wave structure
   *              waveBoost   The input sample scaling value (in %)
   *
   * Returns      void
   *
   ************************************************************************
   * The 'offset' and 'gain' parameters are applied to the current
   * waveform buffer and the resultant samples clamped to a 16-bit
   * audio range.
   *
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  int  CA_GetWaveBoostValue(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      The input sample scaling value (in %)
   *
   ************************************************************************
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  int  CA_GetSampleRate(CA_Wave *hWave);
  /**
   *
   * Params       hWave       Handle to valid Wave structure
   *
   * Returns      Sample rate used by the wave device
   *
   * See          CA_LoadSamples
   *              CA_ConfigureWave
   *
   ************************************************************************
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  void CA_CopyWaveSegment(CA_Wave *source,
                          CA_Wave *sink,
                          unsigned long offset,
                          unsigned long length);
  /**
   *
   * Params       source  Handle to valid Wave structure for source
   *              sink    Handle to valid Wave structure for destination
   *              offset  Sample number starting the segment (first sample == 0)
   *              length  Number of samples in the segment
   *
   * Returns      Nothing, the wave segment in 'source' is copied to 'sink'
   *
   ************************************************************************
   * This is useful when copying selected sections of a waveform.  It is
   * employed within the SDXCollect_SinkWaveSegment() method.
   *
   * 'source' and 'sinks' must be different objects.
   *
   * It is an error to call this function without first configuring
   * the 'source' and 'sink' wave objects.
   ************************************************************************
   */


  int  CA_GetBufferSize(CA_Wave *hWave);
  /**
   *
   * Params       hWave       Handle to valid Wave structure
   *
   * Returns      Buffer size (in bytes) used by the wave device for
   *              the construction of a single frame.
   *
   * See          CA_LoadSamples
   *              CA_ConfigureWave
   *
   ************************************************************************
   * This function is supplied for use in conjunction with CA_LoadSamples.
   * The application should call CA_CetBufferSIze on the current input Wave
   * object and use the result to create the wave sample buffer that it will
   * supply to CA_LoadSamples.
   *
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


#ifndef SWIGBUILD
  int  CA_LoadSamples(CA_Wave *hWave,
                      samdata *pPCMData,
                      int sampleCount);
#else
  int  CA_LoadSamples(CA_Wave *hWave,
                      short *pPCMData,
                      int sampleCount);
#endif
  /**
   *
   * Params       hWave       Handle to valid Wave structure
   *              pPCMData    Pointer to a buffer created by the application.
   *              sampleCount The number of samples in the supplied buffer.
   *
   * Returns      Buffer size (in bytes) used by the wave device for
   *              the construction of a single frame.
   *
   * See          CA_GetBufferSize
   *              CA_ConfigureWave
   *
   ************************************************************************
   * The buffer contains exactly enough wave data to make one frame of an
   * utterance. The required buffer size can be got by calling CA_GetBufferSize.
   * The application is responsible for ensuring that the supplied sample
   * data is in the correct format. The sample rate should match that of the
   * recognizer, and the sample size should be of size 16 bits. CA_LoadSamples
   * will check the sample count, and report an error if it does not match
   * the front end's required buffer size.
   *
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  int  CA_ReadSamplesForFrame(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      The number of samples read; <0 on failure.
   *
   * See          CA_SaveSamplesForFrame
   *
   ************************************************************************
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  int  CA_SaveSamplesForFrame(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      The number of samples read; <0 on failure.
   *
   * See          CA_ReadSamplesForFrame
   *
   ************************************************************************
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  void CA_ConditionSamples(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Nothing. The incoming audio buffer is 'conditioned'.
   *
   ************************************************************************
   * The 'offset' and 'gain' parameters are applied to the current
   * waveform buffer and the resultant samples clamped to a 16-bit
   * audio range.
   *
   * It is an error to call this function without first configuring hWave
   ************************************************************************
   */


  void CA_CopyWaveSamples(CA_Wave *hWaveIn,
                          CA_Wave *hWaveOut);
  /**
   *
   * Params       hWaveIn     Handle to valid Wave object
   *              hWaveOut    Handle to valid Wave object
   *
   * Returns      The audio samples in the In channel are
   *              copied to the Out channel
   *
   ************************************************************************
   * This method is provided to permit incoming audio sample to be copied
   * to the sink for file storage.  The wave objects should have been
   * created as appropriate sources or sinks.
   *
   * 'hWaveIn' and 'hWaveOut' must be different objects.
   *
   * It is an error to call this function without first configuring
   * the 'hWaveIn' and 'hWaveOut' wave objects.
   ************************************************************************
   */


  int  CA_WaveIsOutput(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Boolean.
   *
   ************************************************************************
   * Returns true if the Wave is setup as a sink of data
   *
   * It is an error to call this function without first configuring hWave
   * and setting it up as a device or a file
   ************************************************************************
   */


  int  CA_WaveIsInput(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Boolean.
   *
   ************************************************************************
   * Returns true if the Wave is setup as a source of data
   *
   * It is an error to call this function without first configuring hWave
   * and setting it up as a device or a file
   ************************************************************************
   */


  int  CA_WaveIsADevice(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Boolean.
   *
   ************************************************************************
   * Returns true if the Wave is setup as a device
   *
   * It is an error to call this function without first configuring hWave
   * and setting it up as a device or a file
   ************************************************************************
   */


  int  CA_WaveIsAFile(CA_Wave *hWave);
  /**
   *
   * Params       hWave   Handle to valid Wave structure
   *
   * Returns      Boolean.
   *
   ************************************************************************
   * Returns true if the Wave is setup as a file of data
   *
   * It is an error to call this function without first configuring hWave
   * and setting it up as a device or a file
   ************************************************************************
   */

  void CA_StartSigCheck(CA_Wave *hWave);
  void CA_StopSigCheck(CA_Wave *hWave);
  void CA_ResetSigCheck(CA_Wave *hWave);
  void CA_GetSigStats(CA_Wave *hWave, int *nsam, int *pclowclip, int *pchighclip,
                      int *dc_offset, int *amp, int *pc5, int *pc95,
                      int *overflow);
  ESR_BOOL CA_DoSignalCheck(CA_Wave *hWave, ESR_BOOL *clipping, ESR_BOOL *dcoffset,
                        ESR_BOOL *highnoise, ESR_BOOL *quietspeech, ESR_BOOL *too_few_samples,
                        ESR_BOOL *too_many_samples);



  /*  Frontend parameter API
  */
  /**
   ************************************************************************
   * CA_FrontendInputParams methods
   *
   * To load the front-end parameters from a par file
   *
   * This object holds input parameters (objtained from an ASCII
   * parameter file) for the Front-End object.
   *
   * Apart from allocating and freeing the object it also has a method
   * used to read a given parameter file.
   ************************************************************************
   */



  CA_FrontendInputParams* CA_AllocateFrontendParameters(void);
  /**
   *
   * Params       void
   *
   * Returns      Handle to new front-end input object
   *
   * See          CA_FreeFrontendParameters
   *              CA_ConfigureFrontend
   *
   ************************************************************************
   * Creates a new front-end input paramater onject
   ************************************************************************
   */


  void CA_LoadFrontendParameters(CA_FrontendInputParams* hFrontpar,
                                 const char* parfile);
  /**
   *
   * Params       hFrontpar   valid front-end input object handle
   *              parfile     par file
   *
   * Returns      void
   *
   * See          CA_SaveFrontendParameters
   *              CA_ConfigureFrontend
   *
   ************************************************************************
   * Loads known front-end parameters from the given .PAR file.
   * The file is a .par file
   ************************************************************************
   */


  void CA_FreeFrontendParameters(CA_FrontendInputParams* hFrontpar);
  /**
   *
   * Params       hFrontpar   valid front-end input object handle
   *
   * Returns      void        front-end object is no longer valid
   *
   * See          CA_AllocateFrontendParameters
   *
   ************************************************************************
   * Removes a previously allocated parameter object
   ************************************************************************
   */


  void CA_SaveFrontendParameters(CA_FrontendInputParams* hFrontpar,
                                 const char* parfile);
  /**
   *
   * Params       hFrontpar   valid front-end input object handle
   *              parfile     parameter (.par) file to read
   *
   * Returns      void
   *
   * See          CA_LoadFrontendParameters
   *              CA_ConfigureFrontend
   *
   ************************************************************************
   * Saves a previously loaded (modified) parameter file
   *
   * It is an error to call this function without first loading
   * front-end input parameters.
   ************************************************************************
   */


  int  CA_SetFrontendParameter(CA_FrontendInputParams *hFrontpar,
                               char *key,
                               char *value);
  /**
   *
   * Params       hFrontpar   valid Front End Parameter handle
   *              key         parameter key (text label)
   *              value       new parameter value (text)
   *
   * Returns      Zero on error
   *
   * See          CA_GetFrontendStringParameter
   *              CA_GetFrontendIntParameter
   *              CA_GetFrontendFloatParameter
   *              CA_LoadFrontendParameters
   *
   ************************************************************************
   * Sets/Modifies a known Front End Input parameter.
   *
   * It is an error to call this function without first loading
   * front-end input parameters.
   ************************************************************************
   */


  int  CA_GetFrontendParameter(CA_FrontendInputParams *hFrontpar,
                               char *key,
                               void *value);
  /**
   *
   * Params       hFrontpar   valid Front End Parameter handle
   *              key         parameter key (text label)
   *              value       pointer to store parameter value (text)
   *              valueLen    size of value buffer
   *
   * Returns      False on error
   *
   * See          CA_SetFrontendParameter
   *              CA_LoadFrontendParameters
   *
   ************************************************************************
   * Reads a known Front End Parameter.
   *
   * It is an error to call this function without first loading
   * front-end input parameters.
   ************************************************************************
   */

  int  CA_GetFrontendStringParameter(CA_FrontendInputParams *hFrontpar,
                                     char *key,
                                     char *value,
                                     int valueLen,
                                     int *bytes_required);
  /**
   *
   * Params       hFrontpar   valid Front End Parameter handle
   *              key         parameter key (text label)
   *              value       pointer to store parameter value
   *  value_len   number of bytes pointed to by value
   *  bytes_required holds the number of bytes neededf to store the data
   *
   * Returns      False on error
   *
   * See          CA_SetFrontendParameter
   *              CA_LoadFrontendParameters
   *
   ************************************************************************
   * Reads a known Front End Parameter.
   *
   * It is an error to call this function without first loading
   * front-end input parameters.
   ************************************************************************
   */

  int CA_LoadSpectrumFilter(CA_Frontend *hFrontend, char *basename);
  /**
   *
   * Params       hFrontend   valid Frontend handle
   *              basename    basename of filter file (a text file)
   *              hFrontArs   valid Frontend parameters handle
   *
   * Returns      False on error
   *
   * See          CA_SetFrontendParameter
   *              CA_LoadFrontendParameters
   *
   ************************************************************************
   * Loads a spectrum filter from a file.
   *
   * It is an error to call this function without first loading
   * front-end input parameters.
   ************************************************************************
   */

  void CA_ClearSpectrumFilter(CA_Frontend *hFrontend);
  /**
   *
   * Params       hFrontend   valid Frontend handle
   *
   * Returns      void
   *
   * See          CA_LoadSpectrumFilter
   *
   ************************************************************************
   * Clears a front end spectrum filter.
   *
   * It is an error to call this function without first loading
   * front-end input parameters.
   ************************************************************************
   */

  int CA_IsSpectrumFilterLoaded(CA_Frontend *hFrontend);
  /**
   *
   * Params       hFrontend   valid Frontend handle
   *
   * Returns      True if front end is loaded with a spectrum filter.
   *
   * See          CA_LoadSpectrumFilter
   *
   ************************************************************************
   *
   ************************************************************************
   */

  void CA_EnableNonlinearFilter(CA_Frontend *hFrontend);
  void CA_DisableNonlinearFilter(CA_Frontend *hFrontend);
  void CA_EnableSpectrumFilter(CA_Frontend *hFrontend);
  void CA_DisableSpectrumFilter(CA_Frontend *hFrontend);

#ifdef __cplusplus
}
#endif


#endif