In [ ]:
import os, sys
import numpy as np
from TimeFreqAuditoryScene import *
from IPython.display import Audio, display, clear_output
from IPython.html import widgets
from IPython.html.widgets import interactive
%matplotlib inline
I here generate a sequence of shepard tones with a constant interval in semitones
One can vary
Because of the periodic nature of shepard tones with base frequency, sequences are periodic
Perceptually, a 'reset' is experienced when the first tone of the sequence is reheard
This is interesting because it is not due to an intrinsic property of the stimulus.
In [ ]:
# Parameterization
# Global parameters
fs = 44100
# Shepard tones
short_delay = 0.1
delay =0.1
duration = 1./8.
# declare gaussian envelope on log frequency
mu_log=np.log(200)
sigma_log=2.
genv = GaussianSpectralEnvelope(mu_log=mu_log, sigma_log=sigma_log)
fb1 = 12.
# sequence
n_sequence = 26
st_step = 3
In [ ]:
def reset(st_step=1, delay=0.1, duration=1./8.):
scene = Scene()
run_time = 0
# Constructing the sequence
sequence = []
for i in range(n_sequence):
tmp_st = ShepardTone(fb=fb1*2.**(i*st_step/12.), env=genv, delay=run_time, duration=duration)
run_time += duration + delay
sequence.append(tmp_st)
# uncomment the 3 next line for repetition
tmp_st = ShepardTone(fb=fb1*2.**(i*st_step/12.), env=genv, delay=run_time, duration=duration)
run_time += duration + short_delay
sequence.append(tmp_st)
scene.add(sequence)
# draw spectrogram
sd = SceneDrawer()
sd.draw(scene)
plt.show()
# generate sound
x = scene.generate(fs=fs)
display(Audio(x, rate=fs, autoplay=True))
w = interactive(reset, st_step=(-6,6), delay=(0.,2), duration =(0.1,1.))
display(w)