Back

CreateAudioRecorder

AudioRecorder returns an AudioRecorder object for recording audio.

  rec = app.CreateAudioRecorder() → app object - AudioRecorder

You first have to define the recording file with

  rec.SetFile( "/sdcard/demofile.wav" );

before you can start the recording via

  rec.Start();

The recordede audio will then be written to the specified file until you stop the recording with

  rec.Stop();

For more information in the detailed docs see CreateAudioRecorder

Example - Example



function OnStart()
{
    rec = app.CreateAudioRecorder();
    rec.SetFile( "/sdcard/demofile.wav" );
    rec.Start();


    app.ShowPopup( "Please speak" );
    setTimeout( StopRecording, 5000 );
}

function StopRecording()
{
    rec.Stop();
    app.ShowPopup( "Finished recording. Now playing" );

    ply = app.CreateMediaPlayer();
    ply.SetFile( file );
    ply.SetOnReady( ply.Play );
}
    Copy     Copy All       Run      

The following methods are available on the AudioRecorder object:

  GetData() → list: [frequencies]
  GetPeak() → number: float
  GetRMS() → number: float
  GetType() → string: "AudioRecorder"
  Method( name, types, p1, p2, p3, p4 )
  Pause()
  SetFile( file )
  Start()
  Stop()

number: integer
Returns a list of 320 frequency values.
returns PMPO value (Peak music power output)
returns RMS value (Root Mean Square)
Returns the control class name.
string
string: comma separated: "boolean", "char", "byte", "short", "int", "long", "float", "double"
Allows access to other functions defined on the object in Java via reflection.
Pause the recording temporally.
string: path to file or folder ( "/absolute/..." or "relative/..." )
Define the file where the recorder should record to.
number: integer: 8000 or 11025 or 22050 or 44100 or 48000
Set the Recording frequency to one of the possible values.
Start recording to the specified file.
Stop the audio recording.