The aim here is to create a random cloud of tones that
Constraints
This means we have tiled the time log-frequency space
I will now sample one tone per tile
In [ ]:
import numpy as np
fb = 50 # the base frequency
duration = 0.2
nb = 5
nt = 5
indices = np.arange(nb)
log_bands_bounds = np.log(fb)+ (indices/2.)*np.log(2)
time_bounds = np.arange(nt)*duration
n_bands = len(log_bands_bounds)
n_times = len(time_bounds)
s = np.random.rand(2,n_times,n_bands)
times = (s[0] + np.tile(np.array(time_bounds), (n_bands,1)).T)
freqs = np.exp(s[1] + np.tile(np.array(log_bands_bounds), (n_times,1)))
In [ ]:
import os, sys
import copy
import numpy as np
parent_folder = os.path.split(os.path.abspath('.'))[0]
sys.path.append(parent_folder)
from TimeFreqAuditoryScene import *
from IPython.display import Audio, display, clear_output
%matplotlib inline
In [ ]:
# Parameterization
# Global parameters
fs = 44100
mu_log=np.log(500)
sigma_log=2.
genv = GaussianSpectralEnvelope(mu_log=mu_log, sigma_log=sigma_log)
In [ ]:
scene = Scene()
node = Node(delay=0)
for i in range(n_bands):
for j in range(n_times):
tmp_tone =Tone(freq=freqs[i,j], delay=times[i,j], duration=duration)
node.add(tmp_tone)
# draw spectrogram
scene.add(node)
sd = SceneDrawer()
sd.draw(scene)
plt.show()
In [ ]: