def _run_test(note): res = [] for note0 in self.all_notes: _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning( [note, note0]) res.append(all(_conds(rdes, ropt, rinit))) return all(res)
def test_d6(self): '''[C, Abb]''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['c', 'abb']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_A5(self): '''[C, G#]''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['c', 'g#']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_bdiminished(self): '''B dimished triad.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['b', 'd', 'f']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_aminor(self): '''A minor triad.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['a', 'c', 'e']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_gmajor(self): '''G major triad.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['g', 'b', 'd']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_fmajor(self): '''F major triad.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['f', 'a', 'c']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_eminor(self): '''E minor triad.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['e', 'g', 'b']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_dminor7(self): '''D minor 7.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning( ['d', 'f', 'a', 'c']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_cmajor7(self): '''C major 7.''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning( ['c', 'e', 'g', 'b']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_P5(self): '''[D, A]''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['d', 'a']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
def test_d5(self): '''[C#, G]''' _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['c#', 'g']) self.assertTrue(all(_conds(rdes, ropt, rinit)))
import numpy as np from scipy.io.wavfile import write from inplacetuning import inplacetuning if __name__ == '__main__': # Try a few triads out triads = [ ['c', 'e', 'g'], ] freqs_opt = [] freqs_eq = [] for triad in triads: fopt, feq, ropt, rdes, rinit, cost = inplacetuning(triad) freqs_opt.append(fopt) freqs_eq.append(feq) print('Frequencies:') print(' fopt:', fopt) print(' feq:', feq) print('Ratios:') print(' rdes:', rdes) print(' ropt:', ropt) print(' rinit:', rinit) # make a sum of sines wave rate = 44100 sec = 2 t = np.linspace(0, sec, int(rate * sec), endpoint=False)