Пример #1
0
 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)
Пример #2
0
 def test_d6(self):
     '''[C, Abb]'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['c', 'abb'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #3
0
 def test_A5(self):
     '''[C, G#]'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['c', 'g#'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #4
0
 def test_bdiminished(self):
     '''B dimished triad.'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['b', 'd', 'f'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #5
0
 def test_aminor(self):
     '''A minor triad.'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['a', 'c', 'e'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #6
0
 def test_gmajor(self):
     '''G major triad.'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['g', 'b', 'd'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #7
0
 def test_fmajor(self):
     '''F major triad.'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['f', 'a', 'c'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #8
0
 def test_eminor(self):
     '''E minor triad.'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['e', 'g', 'b'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #9
0
 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)))
Пример #10
0
 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)))
Пример #11
0
 def test_P5(self):
     '''[D, A]'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['d', 'a'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #12
0
 def test_d5(self):
     '''[C#, G]'''
     _fopt, _feq, ropt, rdes, rinit, _cost = inplacetuning(['c#', 'g'])
     self.assertTrue(all(_conds(rdes, ropt, rinit)))
Пример #13
0
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)