import numpy as np from thunderhopper.model import configuration, process_signal from thunderhopper.modeltools import load_data from IPython import embed ## SETTINGS: # General: save_path = '../data/processed/white_noise' stages = ['raw', 'filt', 'env', 'log', 'inv', 'conv', 'bi', 'feat'] sds = [1] dur = 60 # Interactivity: reload_saved = False # Processing: rate = 44100.0 env_rate = 44100.0 feat_rate = 44100.0 sigmas = [0.001, 0.002, 0.004, 0.008, 0.016, 0.032] types = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10] config = configuration(env_rate, feat_rate, types=types, sigmas=sigmas) config.update({ 'rate_ratio': None, 'env_fcut': 250, 'db_ref': 1, 'inv_fcut': 5, 'feat_thresh': np.load('../data/kernel_thresholds.npy') * 0.2, 'feat_fcut': 0.5, 'label_channels': 0, 'label_thresh': 0.5, }) ## PREPARATION: n_samples = int(dur * env_rate) rng = np.random.default_rng() # PROCESSING: for sd in sds: print('Processing: SD =', sd) # Generate white noise signal: noise = rng.normal(loc=0, scale=sd, size=n_samples) # Fetch and store representations: save = None if save_path is None else save_path + f'_sd-{sd}.npz' process_signal(config, stages, signal=noise, rate=rate, save=save) # Cross-control: if reload_saved: data, params = load_data(save, stages, ['songs', 'noise']) embed() print('Done.')