def audio_out(out): global dit_idx, next_ditherpt nrem = len(out) while nrem > 0: amnt = min(next_ditherpt-dit_idx, nrem) out_st = len(out)-nrem out[out_st:out_st+amnt] = cur_snd[:amnt].reshape((amnt,-1)) cur_snd[:] = np.roll(cur_snd, -len(cur_snd.shape)*amnt, axis=0) dit_idx += amnt if dit_idx >= next_ditherpt: flip() dit_idx = 0 next_ditherpt = next_zerocrossing(zerocrossings(cur_snd), DITHER_FRAMES) nrem -= amnt
def audio_out(out): global dit_idx, next_ditherpt nrem = len(out) while nrem > 0: amnt = min(next_ditherpt - dit_idx, nrem) out_st = len(out) - nrem out[out_st:out_st + amnt] = cur_snd[:amnt].reshape((amnt, -1)) cur_snd[:] = np.roll(cur_snd, -len(cur_snd.shape) * amnt, axis=0) dit_idx += amnt if dit_idx >= next_ditherpt: flip() dit_idx = 0 next_ditherpt = next_zerocrossing(zerocrossings(cur_snd), DITHER_FRAMES) nrem -= amnt
def mouse_in(type, px, py, button): global DITHER_FRAMES, dit_idx, next_ditherpt, ZC dit_idx = 0 DITHER_FRAMES = 1 + int(px * 44100) next_ditherpt = next_zerocrossing(zerocrossings(cur_snd), DITHER_FRAMES)