Commits

Adam Lindsay committed 76d5b03

richer environment

Comments (0)

Files changed (2)

   analysis: container for all the other analysis products in the file
   
   libraries:
-    import echonest.audio as audio
+    from echonest.audio import *
+    from echonest.audio import AudioQuantumList as aql
+    from echonest.audio import AudioQuantum as aq
     from echonest.selection import *
     from echonest.sorting import *
 
 import types
 from optparse import OptionParser
 
-from echonest import audio
+from echonest.audio import *
+from echonest.audio import AudioQuantumList as aql
+from echonest.audio import AudioQuantum as aq
 from echonest.selection import *
 from echonest.sorting import *
 
 Optional filename pre-loads the file.
 '''
 
-
 def main(argv=None):
     if argv is None:
         argv = sys.argv
     r.args = args
     r.cmdloop()
 
-
 class Remix(cmd.Cmd):
     """Loop while keeping track of the last thing."""
     
             os.chdir(self.cwd)
         else:
             try:
-                a = audio.LocalAudioFile(path, verbose=self.options.verbose)
-                self.env['afile'] = a
+                self.currfile = LocalAudioFile(path, verbose=self.options.verbose)
             except:
                 print "unable to load %s" % path
                 return
             self.currfilename = os.path.abspath(path)
             self.prompt = "%s > " % os.path.basename(self.currfilename)
-            self.renderable = a
+            self.renderable = self.currfile
             self.renderablename = self.currfilename
-            self.env['segments'] = a.analysis.segments
-            self.env['sections'] = a.analysis.sections
-            self.env['beats'] = a.analysis.beats
-            self.env['bars'] = a.analysis.bars
-            self.env['tatums'] = a.analysis.tatums
-            self.env['analysis'] = a.analysis
+            self.env['segments'] = self.currfile.analysis.segments
+            self.env['sections'] = self.currfile.analysis.sections
+            self.env['beats'] = self.currfile.analysis.beats
+            self.env['bars'] = self.currfile.analysis.bars
+            self.env['tatums'] = self.currfile.analysis.tatums
+            self.env['analysis'] = self.currfile.analysis
             self.env['_'] = None
     
     def complete_load(self, text, line, begidx, endidx):
         try:
             result = eval(rawcmd, globals(), self.env)
         except:
-            print "syntax error or file not found"
+            print "syntax error"
             return
         if isinstance(result, tuple) or isinstance(result, dict) or isinstance(result, types.StringTypes):
             print result
             return
         try:
-            if not isinstance(result, audio.AudioRenderable):
-                self.renderable = audio.AudioQuantumList(result)
+            if not isinstance(result, AudioRenderable):
+                self.renderable = AudioQuantumList(result, source=self.currfile)
+                self.renderable.attach(None)
             else:
                 self.renderable = result
             self.renderablename = ""