Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fake merge core changes from william

  • Loading branch information...
commit d557c8abcce3e587cd3dadb18a81f5f0b7751793 1 parent 490b784
Erik Schoster authored

Showing 1 changed file with 26 additions and 7 deletions. Show diff stats Hide diff stats

  1. +26 7 dsp.py
33 dsp.py
@@ -13,7 +13,10 @@
13 13 import time
14 14 import hashlib
15 15 import subprocess
  16 +from multiprocessing import Process, Queue
16 17 import os
  18 +import sys
  19 +import cStringIO
17 20 from datetime import datetime
18 21
19 22 audio_params = [2, 2, 44100, 0, "NONE", "not_compressed"]
@@ -25,6 +28,10 @@
25 28 seedint = 0
26 29 seedstep = 0
27 30 seedhash = ''
  31 +quiet = True
  32 +
  33 +def notify(message):
  34 + sys.stderr.write(message)
28 35
29 36 def lget(list, index, default=True):
30 37 """ Safely return a selected element from a list and handle IndexErrors """
@@ -108,13 +115,14 @@ def timer(cmd='start'):
108 115 global thetime
109 116 if cmd == 'start':
110 117 thetime = time.time()
111   - print 'Started render at timestamp', thetime
  118 +
  119 + if not quiet: print 'Started render at timestamp', thetime
112 120 return thetime
113 121 elif cmd == 'stop':
114 122 thetime = time.time() - thetime
115 123 themin = int(thetime) / 60
116 124 thesec = thetime - (themin * 60)
117   - print 'Render time:', themin, 'min', thesec, 'sec'
  125 + if not quiet: print 'Render time:', themin, 'min', thesec, 'sec'
118 126 return thetime
119 127
120 128 def transpose(audio_string, amount):
@@ -556,7 +564,7 @@ def read(filename):
556 564 """ Read a 44.1k / 16bit WAV file from disk with the Python wave module.
557 565 Mono files are converted to stereo automatically. """
558 566 filename = snddir + filename
559   - print 'loading', filename
  567 + if not quiet: print 'loading', filename
560 568
561 569 file = wave.open(filename, "r")
562 570 file_frames = file.readframes(file.getnframes())
@@ -575,11 +583,19 @@ def read(filename):
575 583
576 584 return snd
577 585
578   -def play(out=''):
579   - """ A silly alsa-dependent hack to enable another silly hack """
  586 +def poly(p, a=[]):
  587 + p = Process(target=p, args=(a,))
  588 + p.start()
  589 +
  590 + return p
  591 +
  592 +def play(out='', cache=False):
  593 + """ A silly hack to enable another silly hack """
  594 + if cache: filename = cache(out)
  595 +
580 596 shhh = open(os.devnull, 'w')
581   - filename = cache(out)
582   - p = subprocess.Popen(['aplay', '-f', 'cd', filename], shell=False, stdout=shhh, stderr=shhh)
  597 + s = subprocess.Popen(['aplay', '-q', '-f', 'cd'], stdin=subprocess.PIPE, stdout=shhh, stderr=shhh)
  598 + s.communicate(out)
583 599 shhh.close()
584 600
585 601 return out
@@ -599,6 +615,9 @@ def stream(outs=['']):
599 615
600 616 return outs
601 617
  618 +def args():
  619 + return [arg for arg in sys.argv if arg != '']
  620 +
602 621 def insert_into(haystack, needle, position):
603 622 # split string at position index
604 623 hay = cut(haystack, 0, position)

0 comments on commit d557c8a

Please sign in to comment.
Something went wrong with that request. Please try again.