def geometric_delay(sig, dur, copies, pamp=.5): """ Delay effect by copying data (with Streamix). Parameters ---------- sig: Input signal (an iterable). dur: Duration, in samples. copies: Number of times the signal will be replayed in the given duration. The signal is played copies + 1 times. pamp: The relative remaining amplitude fraction for the next played Stream, based on the idea that total amplitude should sum to 1. Defaults to 0.5. """ out = Streamix() sig = thub(sig, copies + 1) out.add(0, sig * pamp) # Original remain = 1 - pamp for unused in xrange(copies): gain = remain * pamp out.add(dur / copies, sig * gain) remain -= gain return out
# Basic initialization rate = 44100 s, Hz = sHz(rate) kHz = 1e3 * Hz # Some parameters table_len = 8192 min_freq = 20 * Hz max_freq = 10 * kHz duration = 60 * s # "Track-by-track" partials configuration noctaves = abs(log2(max_freq / min_freq)) octave_duration = duration / noctaves smix = Streamix() data = [] # Global: keeps one parcial "track" for all uses (but the first) # Inits "data" def partial(): smix.add(octave_duration, partial_cached()) # Next track/partial event # Octave-based frequency values sequence scale = 2**line(duration, finish=True) partial_freq = (scale - 1) * (max_freq - min_freq) + min_freq # Envelope to "hide" the partial beginning/ending env = [k**2 for k in window.hamming(int(round(duration)))] # The generator, properly: for el in env * sinusoid(partial_freq) / noctaves: data.append(el) yield el
octave. """ tk = tkinter.Tk() tk.title("Keyboard Example") lbl = tkinter.Label(tk, text=txt, font=("Mono", 30)) lbl.pack(expand=True, fill=tkinter.BOTH) rate = 44100 s, Hz = sHz(rate) ms = 1e-3 * s attack = 30 * ms release = 50 * ms level = .2 # Highest amplitude value per note smix = Streamix(True) cstreams = {} class ChangeableStream(Stream): """ Stream that can be changed after being used if the limit/append methods are called while playing. It uses an iterator that keep taking samples from the Stream instead of an iterator to the internal data itself. """ def __iter__(self): while True: yield next(self._data) has_after = None
for staff in tab: print("\n".join("".join(el) for el in zip(*(heading_cols + staff)))) print() # # Audio # # Useful values from AudioLazy rate = 44100 s, Hz = sHz(rate) ms = 1e-3 * s kHz = 1e3 * Hz beat_duration = 60. / beat * s # In samples dur = beat_duration / notes_per_beat # Per note smix = Streamix() # That's our sound mixture env = adsr(dur, a=40 * ms, d=35 * ms, s=.6, r=70 * ms).take(inf) # Envelope # Effects used def distortion(sig, multiplier=18): return atan(multiplier * sig) * (2 / pi) # Intro count synth filt = (1 - z**-2) * .5 if starting_beats > 0: inoisy_stream = filt(gauss_noise()) * env inoisy_thub = thub( inoisy_stream.append(0).limit(beat_duration), starting_beats) inoisy = chain.from_iterable(repeat(inoisy_thub).limit(starting_beats))