Page 1 of 1
[Help Please] Sound data and files
Posted: Wed Jul 12, 2017 8:57 pm
by rayaman
Is it possible to store a sounddata object to the disk?
I know it has a getString() method, but how would I recreate the sound data using the string data?
Thanks
Re: [Help Please] Sound data and files
Posted: Wed Jul 12, 2017 9:20 pm
by raidho36
You would need to copy it byte by byte into memory of a new empty sounds data object using FFI.
You can try using codecs or PCM wav libraries for saving normal audio files.
Re: [Help Please] Sound data and files
Posted: Wed Jul 12, 2017 10:34 pm
by rayaman
Ok thanks, that sounds doable... I think I can figure out how to work this... Would I need to use the pointer data or what? I haven't really used the FFI library before. Any tips or examples of something like this being done?
Re: [Help Please] Sound data and files
Posted: Wed Jul 12, 2017 11:05 pm
by zorg
To clarify things a bit, you could do SoundData:getString(), and then write out that whole string into a file... thing is, it would just be a raw dump of bytes (or words, depending on whether the sounddata was 8 or 16 bit); some programs can open such raw files, but most can't.
As raidho said, löve doesn't have a way to encode sound into a playable format, however, finding or even writing a wav (riff/pcm that is) exporter is not too complicated.
Re: [Help Please] Sound data and files
Posted: Thu Jul 13, 2017 12:26 am
by rayaman
hmm... Ill look into it thanks for the replies
Ill post what I come up with on the forums
Re: [Help Please] Sound data and files
Posted: Thu Jul 13, 2017 12:00 pm
by bartbes
Though I can't help but wonder how you got the SoundData in the first place...
Re: [Help Please] Sound data and files
Posted: Thu Jul 13, 2017 3:36 pm
by rayaman
Oh I am using the love-microphone module that someone created and I can play back the audio while it is in memory, but I wanted people to be able to save the audio as well.
https://love2d.org/forums/viewtopic.php ... 24#p180124