The aim here is to create a random cloud of tones that

  • marginally as a flat spectrum
  • has some structure that induce streaming
    • either by frequency dependence
    • or by time dependence

Constraints

  • we tile the frequency ax in consecutive semi octave bands
  • we tile the time axis in blocs of duration of a tone atom

This means we have tiled the time log-frequency space

I will now sample one tone per tile

  • start time uniform([0, duration/2])
  • frequency uniform

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 [ ]: