pygame / examples / sound_array_demos.py

Diff from to

examples/sound_array_demos.py

 
     a1 = sndarray.array(sound)
     if mydebug:
-        print 'SHAPE1:', a1.shape
+        print ('SHAPE1: %s' % (a1.shape,))
 
     length = a1.shape[0]
 
         #size = (a1.shape[0] + int(a1.shape[0] + (echo_length * 3000)),)
 
     if mydebug:
-        print int(echo_length * a1.shape[0])
+        print (int(echo_length * a1.shape[0]))
     myarr = zeros(size, int32)
 
 
 
     if mydebug:
-        print "size", size
-        print myarr.shape
+        print ("size %s" % (size,))
+        print (myarr.shape)
     myarr[:length] = a1
-    #print myarr[3000:length+3000]
-    #print a1 >> 1
-    #print "a1.shape", a1.shape
+    #print (myarr[3000:length+3000])
+    #print (a1 >> 1)
+    #print ("a1.shape %s" % (a1.shape,))
     #c = myarr[3000:length+(3000*mult)]
-    #print "c.shape", c.shape
+    #print ("c.shape %s" % (c.shape,))
 
     incr = int(samples_per_second / echo_length)
     gap = length
     myarr[incr*4:gap+(incr*4)] += a1>>4
 
     if mydebug:
-        print 'SHAPE2:', myarr.shape
+        print ('SHAPE2: %s' % (myarr.shape,))
 
 
     sound2 = sndarray.make_sound(myarr.astype(int16))
            rate - at which the sound should be slowed down.  eg. 0.5 would be half speed.
     """
 
-    raise NotImplementedError
+    raise NotImplementedError()
     grow_rate = 1 / rate
 
     # make it 1/rate times longer.
     a1 = sndarray.array(sound)
 
     surf = pygame.surfarray.make_surface(a1)
-    print a1.shape[0] * grow_rate
+    print (a1.shape[0] * grow_rate)
     scaled_surf = pygame.transform.scale(surf, (int(a1.shape[0] * grow_rate), a1.shape[1]))
-    print scaled_surf
-    print surf
+    print (scaled_surf)
+    print (surf)
 
     a2 = a1 * rate
-    print a1.shape
-    print a2.shape
-    print a2
+    print (a1.shape)
+    print (a2.shape)
+    print (a2)
     sound2 = sndarray.make_sound(a2.astype(int16))
     return sound2
 
         if 'numpy' in sndarray.get_arraytypes():
             sndarray.use_arraytype('numpy')
         elif 'numeric' in sndarray.get_arraytype():
-            sndfarray.use_arraytype('numeric')
+            sndarray.use_arraytype('numeric')
         else:
-            raise ImportError, 'No array package is installed'
+            raise ImportError('No array package is installed')
     else:
         sndarray.use_arraytype(arraytype)
     pygame.surfarray.use_arraytype(sndarray.get_arraytype())
     else:
         from Numeric import zeros, Int16 as int16, Int32 as int32
 
-    print "Using %s array package" % sndarray.get_arraytype()
-    print "mixer.get_init", mixer.get_init()
+    print ("Using %s array package" % sndarray.get_arraytype())
+    print ("mixer.get_init %s" % (mixer.get_init(),))
     inited = mixer.get_init()
 
     samples_per_second = pygame.mixer.get_init()[0]
 
     
 
-    print ("-" * 30) + "\n"
-    print "loading sound"
+    print (("-" * 30) + "\n")
+    print ("loading sound")
     sound = mixer.Sound(os.path.join(main_dir, 'data', 'car_door.wav'))
 
 
 
-    print "-" * 30
-    print "start positions"
-    print "-" * 30
+    print ("-" * 30)
+    print ("start positions")
+    print ("-" * 30)
 
     start_pos = 0.1
     sound2 = sound_from_pos(sound, start_pos, samples_per_second)
 
-    print "sound.get_length", sound.get_length()
-    print "sound2.get_length", sound2.get_length()
+    print ("sound.get_length %s" % (sound.get_length(),))
+    print ("sound2.get_length %s" % (sound2.get_length(),))
     sound2.play()
     while mixer.get_busy():
         pygame.time.wait(200)
 
-    print "waiting 2 seconds"
+    print ("waiting 2 seconds")
     pygame.time.wait(2000)
-    print "playing original sound"
+    print ("playing original sound")
 
     sound.play()
     while mixer.get_busy():
         pygame.time.wait(200)
 
-    print "waiting 2 seconds"
+    print ("waiting 2 seconds")
     pygame.time.wait(2000)
 
 
 
     if 0:
         #TODO: this is broken.
-        print ("-" * 30) + "\n"
-        print "Slow down the original sound."
+        print (("-" * 30) + "\n")
+        print ("Slow down the original sound.")
         rate = 0.2
         slowed_sound = slow_down_sound(sound, rate)
 
             pygame.time.wait(200)
 
 
-    print "-" * 30
-    print "echoing"
-    print "-" * 30
+    print ("-" * 30)
+    print ("echoing")
+    print ("-" * 30)
 
     t1 = time.time()
     sound2 = make_echo(sound, samples_per_second)
-    print "time to make echo", time.time() - t1
+    print ("time to make echo %i" % (time.time() - t1,))
 
 
-    print "original sound"
+    print ("original sound")
     sound.play()
     while mixer.get_busy():
         pygame.time.wait(200)
 
-    print "echoed sound"
+    print ("echoed sound")
     sound2.play()
     while mixer.get_busy():
         pygame.time.wait(200)
 
     t1 = time.time()
     sound3 = make_echo(sound, samples_per_second)
-    print "time to make echo", time.time() - t1
+    print ("time to make echo %i" % (time.time() - t1,))
 
-    print "original sound"
+    print ("original sound")
     sound.play()
     while mixer.get_busy():
         pygame.time.wait(200)
 
 
-    print "echoed sound"
+    print ("echoed sound")
     sound3.play()
     while mixer.get_busy():
         pygame.time.wait(200)
 
 
 def usage():
-    print "Usage: command line option [--numpy|--numeric]"
-    print "  The default is to use NumPy if installed,"
-    print "  otherwise Numeric"
+    print ("Usage: command line option [--numpy|--numeric]")
+    print ("  The default is to use NumPy if installed,")
+    print ("  otherwise Numeric")
 
 if __name__ == '__main__':
     if len(sys.argv) == 2:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.