Quantcast
Channel: The Echo Nest Developer Forum
Viewing all articles
Browse latest Browse all 1582

deferred audio file loading in multitest

$
0
0

Hitting memory limitations and looking to Multitest.py for insights into "deferred audio file loading used in conjunction with render_serially()".

Loading around 250Mb of mp3s, but the file is requiring over a GB to process. The following is output from

memory_profiler
Line #    Mem usage    Increment   Line Contents
================================================
31   19.918 MiB    0.000 MiB   @profile
32                             def main(num_beats, directory, outfile):
33                                 
34   19.922 MiB    0.004 MiB       aud = []
35   19.922 MiB    0.000 MiB       ff = os.listdir(directory)
36 1140.059 MiB 1120.137 MiB       for f in ff:
37                                     # collect the files
38 1090.156 MiB  -49.902 MiB           if f.rsplit('.', 1)[1].lower() in ['mp3', 'aif', 'aiff', 'aifc', 'wav']:
39 1140.059 MiB   49.902 MiB               aud.append(audio.LocalAudioFile(os.path.join(directory,f)))
40                                         # mind the rate limit
41                                 
42 1140.059 MiB    0.000 MiB       num_files = len(aud)
43 1140.059 MiB    0.000 MiB       x = audio.AudioQuantumList()
44                                 
45 1140.059 MiB    0.000 MiB       print >> sys.stderr, "Assembling beats.",
46 1157.688 MiB   17.629 MiB       for w in range(num_beats):
47 1157.688 MiB    0.000 MiB           print >> sys.stderr, '.',
48 1157.688 MiB    0.000 MiB           ssong = aud[w%num_files].analysis
49 1157.688 MiB    0.000 MiB           s = ssong.beats[w%len(ssong.beats)]
50 1157.688 MiB    0.000 MiB           tsong = aud[(w-1)%num_files].analysis
51 1157.688 MiB    0.000 MiB           t = tsong.beats[w%len(tsong.beats)]
52                                     
53 1157.688 MiB    0.000 MiB           x.append(audio.Simultaneous([s,t]))
54                                 
55 1157.688 MiB    0.000 MiB       print >> sys.stderr, "\nStarting rendering pass..."
56                                 
57 1157.688 MiB    0.000 MiB       then = time.time()
58                                 # call render_sequentially() with no arguments, and then it calls itself with
59                                 #  contextual arguments for each source, for each AudioQuantum. It's a lot of
60                                 #  tree-walking, but each source file gets loaded once (and takes itself from)
61                                 #  memory when its rendering pass finishes.
62 1299.441 MiB  141.754 MiB       x.render().encode(outfile)
63                                 
64 1299.484 MiB    0.043 MiB       print >> sys.stderr, "%f sec for rendering" % (time.time() - then,)

What is happening at x.render().encode(outfile), and is there any way to keep the memory usage below a specified threshold?


Viewing all articles
Browse latest Browse all 1582

Trending Articles