3

How to capture current microphone data, just like using the function CurrentImage[] for capturing image?

For example, this captures an image:

Dynamic [x = CurrentImage []; EdgeDetect [x, 3]]

But I don't want to use the function

SystemDialogInput ["RecordSound"]

since it requires user interaction, and I want recording to start programmatically.


EDIT: In his answer to this question (I saw it after I posted my question), @Szabolcs says that following works, but it is undocumented:

  • FrontEndExecute[FrontEnd`RecordSound[5]] will list the available devices by number
  • FrontEndExecute[FrontEnd`RecordSound[6, deviceNumber]] will list the available formats for the device
  • FrontEndExecute[FrontEnd`RecordSound[1, deviceNumber, formatNumber]] will start recording. It returns control immediately.
  • FrontEndExecute[FrontEnd`RecordSound[2]] will stop recording and return the duration.
  • FrontEndExecute[FrontEnd`RecordSound[3]] will return the recorded sound (it's the "OK" button in the dialog)
  • FrontEndExecute[FrontEnd`RecordSound[4]] will probably discard the recorded sound (it's the Cancel button)
  • FrontEndExecute[FrontEnd`RecordSound[9, 0]] will return the current volume of the recorded sound, and is used for the progress indicator in the dialog.

Is this changed or documented in latest Mathematica?

This is current documentation on FrontEndExecute.

0 Answers0