In [ ]:
import os, sys
import copy
import numpy as np
from TimeFreqAuditoryScene import *
from IPython.display import Audio, display, clear_output
%matplotlib inline

Testing inharmonic ambiguity (ambiguity in terms of proximity in log space)

Here, we construct ambiguous pairs of chords equivalent to tritone pairs

The main difference is that the interval between tones in the first chord are not in octave difference

Intervals are also not equal within a chord

Construction

The second chord T2 is constructed from the first one T1, by putting a tone in the middle of consecutives tones of T1


In [ ]:
# Parameterization
# Global parameters
fs = 44100
delay = 1./8.
duration = 1./8.
mu_log=np.log(500)
sigma_log=2.
genv = GaussianSpectralEnvelope(mu_log=mu_log, sigma_log=sigma_log)

In [ ]:
duration=0.5
delay=0.01
fb = np.random.rand()

n_tones = 20
intervals_st = np.random.randint(10,14,n_tones)
intervals_st2 = 0.5*(intervals_st[0:-1]+intervals_st[1:])


scene = Scene()

tone1 = Chord(fb=fb,
              intervals=2.**(intervals_st/12.),
              duration=duration,
              env=genv)
tone2 = Chord(fb=fb*2.**(intervals_st[0]/2./12.),
              intervals=2.**(intervals_st2/12.),
              duration=duration,
              env=genv,
              delay=duration + delay)

scene.add([tone1,tone2])


# draw spectrogram
sd = SceneDrawer()
sd.draw(scene)
plt.show()
# generate sound
x = scene.generate(fs=fs)
display(Audio(x, rate=fs, autoplay=True))

In [ ]: