[R] Limitations of audio processing in R
spencer.graves at structuremonitoring.com
Thu Sep 22 00:08:02 CEST 2011
A more general question: What tools are available in R for reading
parts of binary files? 'scan' allows you to 'skip' a certain number of
records and read the next 'nlines'. Unfortunately, scan only seems to
work for text files not binary, and I cannot find a comparable function
that would work for binary files. I tried library(sos); (rb <-
findFn('read binary')). This produced 299 matches. Something there
might solve the problem, but I haven't taken the time to study it
carefully. I hope someone else will know.
On 9/21/2011 2:15 PM, Ken wrote:
> Also with Linux you can add more swap memory(which I'm pretty sure R spills into if it hasn't reached it's internal limits on 32 bit installations). Windows pagefile is kind of obnoxious.
> Ken Hutchison
> On Sep 21, 2554 BE, at 5:05 PM, (Ted Harding)<ted.harding at wlandres.net> wrote:
>> Hi Ulisses!
>> Yes, "get more creative" -- or "get more memory"!
>> On the "creative" side, it may be worth thinking about
>> using an independent (non-R) audio file editor. I'm
>> writing from the standpoint of a Linux/Unixoid user
>> here -- I wouldn;t know how to set ebout this in WIndows.
>> You could use R to create a shell script which would run
>> the editor in such a way as to extract your 6 random samples,
>> and save them, where the script would be fed with the
>> randomly-chosen 5-minute intervals decided by R. This
>> could be done under the control of R, so you could set
>> it up for your 1500 or so sets of samples, which (with
>> the right editing program) could be done quite quickly.
>> On Linux (also available for Windows) a flexible audio
>> editor is 'sox' -- see:
>> To take, say, a 5-minute sample starting at 1 hour,
>> 10 min and 35sec into the audio file "infile.wav",
>> and save this as "outfile.wav", you can execute
>> sox infile.wav outfile.wav trim 01:10:35 00:05:00
>> and such a command could easily be generated by R and
>> fed to a shell script (or simply executed from R by
>> using the system() command). My test just now with
>> a 5-minute long sample from a .wav file was completed
>> in about 5 seconds, so it is quite efficient.
>> There is a huge number of options for 'sox', allowing
>> you to manipulate almost any aspect of the editing.
>> Hoping this helps,
>> On 21-Sep-11 19:55:22, R. Michael Weylandt wrote:
>>> If you are running Windows it may be as simple as using
>>> memory.limit() to allow R more memory -- if you are on
>>> another OS, it may be possible to get the needed memory
>>> by deleting various things in your workspace and running
>>> Of course, if your computer's memory is<3GB, you are
>>> probably going to have trouble with R's keeping all objects
>>> in memory and will have to get more creative.
>>> On Wed, Sep 21, 2011 at 3:43 PM, Ulisses.Camargo<
>>> moliterno.camargo at gmail.com> wrote:
>>>> Hello everybody
>>>> I am trying to process audio files in R and had some problems
>>>> with files size. I´m using R packages 'audio' and 'sound'.
>>>> I´m trying a really simple thing and it is working well with
>>>> small sized .wav files. When I try to open huge audio files
>>>> I received this error message: "cannot allocate vector of
>>>> size 2.7 Gb". My job is open in R a 3-hour .wav file, make six
>>>> 5-minute random audio subsamples, and than save these new files.
>>>> I have to do the same process +1500 times. My problems is not
>>>> in build the function to do the job, but in oppening the 3-hour
>>>> files. Does anybody knows how to handle big audio files in R?
>>>> Another package that allows me to do this work? I believe
>>>> this is a really simple thing, but I really don´t know what
>>>> to do to solve that memory problem.
>>>> Thank you very much for your answers,
>>>> all the best!
>> E-Mail: (Ted Harding)<ted.harding at wlandres.net>
>> Fax-to-email: +44 (0)870 094 0861
>> Date: 21-Sep-11 Time: 22:05:55
>> ------------------------------ XFMail ------------------------------
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
More information about the R-help