recording audio

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

recording audio

Post by minogaade » Thu Nov 24, 2016 4:21 pm

Hi, all. Could someone tell me the status of audio recording in LiveCode? I know things got interrupted by the demise of QuickTime. Has this been dealt with LC 8 or 9? If so, is there a pertinent tutorial anywhere on how to do recording and playback? I’m making some language-learning apps, and want to allow learners to record themselves to compare their pronunciations with those provided in the app. Playback is a snap, but I don’t know how to record. Thanks!

Minogaade

peachboy
Posts: 8
Joined: Fri Nov 25, 2016 12:49 pm

Re: recording audio

Post by peachboy » Fri Nov 25, 2016 1:01 pm

This is my own code which works well for a recording button:-

Code: Select all

on mouseUp
   if mergMicrophoneIsRecording() is true then
      mergMicrophoneStopRecording
      set the label of button "record" to "Record Audio Now!"
      set the backgroundColor of button "record" to "red"
   else
      mergMicrophoneStartRecording test.wav
      set the label of button "record" to "Recording..."
      set the backgroundColor of button "record" to "blue"
      local x
      repeat with x = 0 to 100
         set the label of button "record" to x
      end repeat
      wait for 1 seconds
      mergMicrophoneStopRecording
      set the label of button "record" to "Record Audio Now!"
      set the backgroundColor of button "record" to "red"
   end if
   
   end mouseUp
Then I use this to playback:-

Code: Select all

on mouseUp
   play test.wav
   set the label of button "Playback" to "Playing back..."
   set the backgroundColor of button "Playback" to "blue"
   wait until the sound is done
   set the label of button "Playback" to "Play back"
   set the backgroundColor of button "Playback" to "green"
end mouseUp
As you can see the key functions to use are:-

mergMicrophoneStartRecording [filename.wav]
mergMicrophoneStopRecording

Hope that helps!

minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

Re: recording audio

Post by minogaade » Fri Nov 25, 2016 3:49 pm

Super! That works well. Thank you so much for taking the time to answer my question.

minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

Re: recording audio

Post by minogaade » Fri Nov 25, 2016 4:29 pm

Okay, I’ve been playing with this and it works very well for recording and comparison of pronunciation with a native speaker. However, there is one small problem, and that it is that there is almost always a "tick" sound at the beginning of my recording. This may not be a LiveCode issue, but I’m wondering if anyone knows why this happens and if there’s any way to prevent it. I’m using a very fast recent-model MacBook Pro.

minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

Re: recording audio

Post by minogaade » Fri Nov 25, 2016 4:50 pm

A little experimentation shows that if I use

mergMicrophoneSetNumberOfChannels mono

i.e., set the number of channels to 1, then the tick seems to only occur the first time I record a sound on a new page. I’ll have to test things on other computers, too. Wish I knew more about sound and the many parameters of recording!

peachboy
Posts: 8
Joined: Fri Nov 25, 2016 12:49 pm

Re: recording audio

Post by peachboy » Fri Nov 25, 2016 5:05 pm

Also you may want to try this little hack:-

Code: Select all

mergMicrophoneStartRecording test.wav
mergMicrophoneStopRecording
mergMicrophoneStartRecording test.wav
Essentially this starts it recording, then immediately stops recording, and then restarts again.

This should (hopefully) remove the initial pop.

:)

minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

Re: recording audio

Post by minogaade » Fri Nov 25, 2016 5:17 pm

Your hack works, thanks so much. I wonder why we need to pay a pop tax? :o Anyway, really helpful to be able to add recording to my app, thanks again.

minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

Re: recording audio

Post by minogaade » Fri Nov 25, 2016 8:23 pm

Okay, in a sense, back to square 1, because the mergMicrophone functions only seem to work on MacOS, but not Windows. I'm trying things on Windows 10, and the MergMicrophone functions cause scripts to crash. The standalone builder also crashes on Windows. Are there platform specific microphone (recording) functions for Windows?

Joop Sleijster
Posts: 46
Joined: Mon Aug 26, 2013 6:49 pm

Re: recording audio

Post by Joop Sleijster » Mon Dec 12, 2016 8:17 pm

Hi minogaade,

I don’t have a solution for you, but may be an explanation:
I fount some info on: https://bitbucket.org/mgoulding/mergmic ... /wiki/Home
and on:
https://searchcode.com/codesearch/view/45702774/

I am using an iMac 2.93 GHz, 8 GB RAM and OS X 10.11.6. and I don’t have “a ‘tick’ sound at the beginning of my recording”.

I don’t know if an external for Windows 10 does exist.

Hope this helps (a little bit),

Joop

minogaade
Posts: 9
Joined: Fri Aug 15, 2008 10:27 pm
Location: Madison, WI, USA

Re: recording audio

Post by minogaade » Sat Dec 17, 2016 12:53 am

Hi, Joop, and apologies for taking so long to reply to your post on my behalf. Yes, I figured out that the MERG record function is designed for iOS -- it works fine in LiveCode running on my Mac, though, but not in a standalone, and inclusion of the MERG functions in Windows does not allow me to even successfully compile Windows standalones, even when I branch the code out of Windows. I’m a professor of linguistics specializing in American Indian languages at the U of Wisconsin-Madison and have been trying to help a fledgling language program we have in the Hoocąk language, by designing an app for them using LiveCode. I’ve had great success in everything except recording, true testimony to the RAD capabilities of LiveCode, since I can only code in my spare time. Hopefully the LiveCode team can figure out a way to give us recording capabilities for MacOS and Windows, it’s a pity we don’t have them, but not the fault of the LC team. I have the utmost respect for them.

I thank you and peachboy, who took the time to reply to my original post, truly a kind gesture on both of your parts.

Post Reply

Return to “Multimedia”