Hello,

I recently upgraded to hsndfile-0.4.0, and I have a few questions about its
operation.  My test program is pretty much this:

test = do
        (info, chunks) <- Sound.File.Sndfile.readFile file
        print info
        putStrLn "Max is: "
        print $ foldl' myMax 0 chunks

myMax :: Double -> Sound.File.Sndfile.Buffer.Vector.Buffer Double -> Double
myMax a = max a . V.maximum . V.map abs . fromBuffer

Initially I tried using readFileChunks, but I never got any data from it.
The info would print out, but the calculation of the maximum value would be
0 because "chunks" would be an empty list.  I tried using several different
numbers for the first argument to readFileChunks, such as 1, 2, 8, and 1024
(is it the number of frames to read?), but always received an empty list.
Could any point me to what I'm doing wrong?  This is with ghc-6.12.1.

After I couldn't get readFileChunks to work, I tried to use plain readFile.
This produced output, but not quite what I was expecting.  Note that now
"chunks" should be a (Maybe Buffer), however I'm using foldl' from
Data.Foldable so it works with a Maybe.

Now it works and reports the proper answer, but when I run the program with
+RTS -s it shows low memory usage.  Very low.

          40,488 bytes allocated in the heap
           1,484 bytes copied during GC
           6,124 bytes maximum residency (1 sample(s))
          14,356 bytes maximum slop
               1 MB total memory in use (0 MB lost due to fragmentation)

However, the system monitor shows that the program is occupying about 230MB
of RAM.  For my test file the this program reports:

Info {frames = 17479453, samplerate = 44100, channels = 2, format = Format
{headerFormat = HeaderFormatWav, sampleFormat = SampleFormatPcm16,
endianFormat = EndianFile}, sections = 1, seekable = True}

so 230MB seems consistent with allocating a single vector of Doubles.

So my second question is, why is this memory usage not reported by +RTS -s,
or -hT?

Thanks very much for any help.

Cheers,
John
_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to