[Resolved] Save sound to device

Hey guys,

Sorry if this has been posted, im unable to search due to lack of time atm… but i was wondering if it is possible to save a audio recording to the device?

What i want to do is using the media.newRecording, record audio from the user and then save the file into a folder they can access at a later time…via my application or just the default sound player for their device…
Is this even possible?

Thanks in advanced! [import]uid: 141138 topic_id: 25988 reply_id: 325988[/import]

It sure is. Take a look over the media.newRecording reference. http://developer.anscamobile.com/reference/index/medianewrecording

You simply pass a name to save the recording as and the directory to save it in and your good to go :slight_smile: [import]uid: 84637 topic_id: 25988 reply_id: 105886[/import]

Hello,

Sorry for opening up such an old post again, but I really needed help regarding a similar issue.

I’ve saved the sound file using media.newRecording… I want to record multiple files. But at the moment if I press the record button again, the previous file is over-written. I want to save the first audio file, and then record the next.

I’ve done the same for images, using display.save and incrementing the name after every image is captured… I need a command equivalent to display.save for saving audio.

Thanks. [import]uid: 175611 topic_id: 25988 reply_id: 133659[/import]

Here is the code I used to save multiple files. Datafile is the actual name of the file saved on the phone or device. I set this in the EnterScene of my Game.lua file so that it would save the date as an easy way to ensure all names were unique. Its been awhile since ive actually done any coding and this was an old project, so if this no longer works or isnt what ur looking for I appologize. Also r is just a variable I had declared to hold the reference to the recording.

[code]
– Located in EnterScene
local d = os.date("*t")
datafile = d.month … “_” … d.day … “_” … d.year … “_” … d.hour … “_” … d.min … “_” … d.sec … “.pcm”

– Located in a custom function called when I wanted to start recording
– Record sound
local filePath = system.pathForFile( datafile, system.DocumentsDirectory)
r = media.newRecording(filePath)
r:startRecording()[/code]

Also be sure that the file extension is the one you need. In this example it was for an android device.

Hope this helps and goodluck! [import]uid: 141138 topic_id: 25988 reply_id: 133754[/import]

Hello,

Sorry for opening up such an old post again, but I really needed help regarding a similar issue.

I’ve saved the sound file using media.newRecording… I want to record multiple files. But at the moment if I press the record button again, the previous file is over-written. I want to save the first audio file, and then record the next.

I’ve done the same for images, using display.save and incrementing the name after every image is captured… I need a command equivalent to display.save for saving audio.

Thanks. [import]uid: 175611 topic_id: 25988 reply_id: 133659[/import]

Here is the code I used to save multiple files. Datafile is the actual name of the file saved on the phone or device. I set this in the EnterScene of my Game.lua file so that it would save the date as an easy way to ensure all names were unique. Its been awhile since ive actually done any coding and this was an old project, so if this no longer works or isnt what ur looking for I appologize. Also r is just a variable I had declared to hold the reference to the recording.

[code]
– Located in EnterScene
local d = os.date("*t")
datafile = d.month … “_” … d.day … “_” … d.year … “_” … d.hour … “_” … d.min … “_” … d.sec … “.pcm”

– Located in a custom function called when I wanted to start recording
– Record sound
local filePath = system.pathForFile( datafile, system.DocumentsDirectory)
r = media.newRecording(filePath)
r:startRecording()[/code]

Also be sure that the file extension is the one you need. In this example it was for an android device.

Hope this helps and goodluck! [import]uid: 141138 topic_id: 25988 reply_id: 133754[/import]