• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Numeric Values
      • String Values
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
        • Audio Statement
        • Audio.load Function
        • Audio.save Function
        • Audio.play Function
        • Audio.recordInteractive Function
        • Audio.record Function
        • Audio.stop Function
        • Audio.concat Function
        • Audio.length Function
        • Audio.clear Function
        • JSON Representation
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • StringWriter Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Audio Statement

Format
Audio audio_name;
Description
The Audio statement creates an Audio object with the name audio_name. The Audio name must be unique and must contain only letters, numbers, or the underscore character. The name must begin with a letter. You can declare Audio objects globally in PROC GLOBAL or locally in functions or procedures.
Audio recording and playback are currently only supported on Android.
Variable Modifiers
The following variable modifiers apply to Audio objects:
  • persistent: to persist the variable's value from one run of an application to another.
Example
PROC AUDIO_QUESTION

onfocus

   
// Variable to store the recording
    Audio recording;

   
// Save recording to a file that includes case id-items to differentiate it from
    // audio saved in other cases
    string nameOfAudioFile = maketext("%v%v%vAUDIO_QUESTION.m4a", PROVINCE, DISTRICT, EA);

   
// If no audio is recorded for this question then the only option is to record,
    // otherwise allow user to re-record, play or clear recording before continuing
    ValueSet vs;
   
if fileexist(nameOfAudioFile) and recording.load(nameOfAudioFile) then
        vs.
add("Re-record", 1);
        vs.
add("Play recording", 2);
        vs.
add("Clear recording", 3);
        vs.
add("Next question", 4);
   
else
        vs.
add("Record", 1);
   
endif;

   
setvalueset($, vs);

postproc

   
if $ = 1 then
       
// Record/re-record
        recording.clear();
       
string message = "Record the respondent's answer to this question";
       
numeric seconds = recording.recordInteractive(message);
       
if seconds > 0 then
            recording.
save(nameOfAudioFile);
       
else
           
errmsg("No audio recorded. Please try again");
       
endif;
       
reenter;
   
elseif $ = 2 then
       
// Play back recording
        recording.play();
       
reenter;
   
elseif $ = 3 then
       
// Clear the recording
        filedelete(nameOfAudioFile);
       
reenter;
   
elseif $ = 4 then
       
// Continue to next question
    endif;
See also: Audio Object