2
$\begingroup$

I want to import sound from a file, record, and import sound.

Manipulate[{
  (*Audio Import Browse*)
  Audiopath1 = 
    FileNameJoin[{$UserDocumentsDirectory, "Audio.wav"}]}, 
  Column["Audio File (.wav) " 
    {Row[{InputField[Dynamic[Audiopath1], String, Enabled -> False], 
       FileNameSetter[Dynamic[Audiopath1], "Open", {".wav" -> {"*.wav"}}]}]}],
 (*Audio Record*)"Audio \Record", 
 Button["Record", Sound[SystemDialogInput["RecordSound"]]]]
$\endgroup$
  • $\begingroup$ For import of sound files, try ?Import for exporting, try ?Export for recording, see this thread mathematica.stackexchange.com/questions/4451/… $\endgroup$ – bill s Apr 23 '13 at 10:58
  • $\begingroup$ Do you mean "I want to import sound from a file, record, and export sound."? $\endgroup$ – m_goldberg Apr 23 '13 at 13:40
  • $\begingroup$ If I click browse button, It will Import sound from file. If I click a record button, It will record sound and show the waveform $\endgroup$ – Oropher Telemna Apr 24 '13 at 6:48
2
$\begingroup$

You have to use Method -> "Queued" to make the frontend to wait for the input from the sound recorder before finishing dynamic evaluation:

DynamicModule[{input = "ExampleData/rule30.wav", sound = ""},
 Panel@Column@{
    Row@{"Record: ", Button["Record", sound = SystemDialogInput@"RecordSound", 
       Method -> "Queued"], Button["Reset", sound = ""]},
    Row@{"Import: ",
         FileNameSetter[Dynamic[FindFile@input,
            (input = #; If[(input =!= $Failed \[Or] input =!= $Canceled) && 
            FileExistsQ@input, sound = Import@input]) &], "Open",
            {".wav" -> {"*.wav"}, ".*" -> {"*.*"}}],
         InputField[Dynamic[input], String, Enabled -> False]},
    Dynamic@sound
    }]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.