def plot_square_waves(ax, fs, f0, duration, amplitude, num_partials, modal_window, phase_angles, selected_angles, color): voffset = 1 t_label = -2 phi_labels = [r'${:0.0f}\degree$'.format(np.rad2deg(phi)) for phi in phase_angles] for j, phi in enumerate(phase_angles): alpha = (1 if phi in selected_angles else 0.33) _, s, _ = util.square_wave(f0, num_partials, amplitude, duration, fs, phi, modal_window) t = 1000 * np.arange(len(s)) / fs ax.plot(t, s - j * voffset, c=color, alpha=alpha) ax.text(t_label, - j * voffset, phi_labels[j], fontsize=9, ha='right') ax.xaxis.set_ticks(np.arange(0, 80, 20)) ax.yaxis.set_ticks([]) ax.xaxis.grid() ax.set_xlim(-15, duration * 1000 + 0) ax.set_ylim(-8.5, 1) ax.set_xlabel('$t$ / ms') ax.text(20, 0.5, 'square wave', ha='center', color=color)
def plot_square_waves(ax, fs, f0, duration, amplitude, num_partials, modal_window, phase_angles, colors): voffset = 5 num_phase = len(phase_angles) for j, phi in enumerate(phase_angles): _, s, _ = util.square_wave(f0, num_partials, amplitude, duration, fs, phi, modal_window) t = 1000 * np.arange(len(s)) / fs ax.plot(t, s + j * voffset, c=colors(j / num_phase)) ax.text(0, j * voffset, '{:0.0f}$\degree$'.format(np.rad2deg(phi)), ha='right', va='center', color=colors(j / num_phase)) ax.text(50, 45, 'Phase shifted square waves', ha='center', va='center') ax.xaxis.set_ticks(np.arange(0, duration * 1000 + 20, 20)) ax.yaxis.set_ticks([]) ax.xaxis.grid() ax.set_xlim(-16, duration * 1000 + 1) ax.set_ylim(-0.5 * voffset, (num_phase - 0.5) * voffset + voffset) ax.set_xlabel('$t$ / ms')
t_intro, t_outro, channels=2, save_stimuli=False, save_crestfactor=True, db_lufs_ref=-35, out_dir=out_dir) # Square Wave Bursts fs = 44100 f0 = 50 amplitude = 0.99 duration = 10 / f0 num_partials = 10 modal_window = kaiser(2 * num_partials + 1, beta=4)[num_partials + 1:] _, y, _ = util.square_wave(f0, num_partials, amplitude, duration, fs, 0, modal_window) n_taper = util.t2n(2 / f0, fs, ms=False) y = util.fade(y, n_taper, n_taper, type='h') t_period, t_predelay, t_intro, t_outro = 500, 20, 0, 0 # in milliseconds repetition = 3 peak_db = -12 filename = 'square' util.make_periodic_stimuli(y, fs, filename, phase_angles, repetition, peak_db, t_period,