class TestInstrument(unittest.TestCase):
    def setUp(self):
        self.scale = PythagDodecaphonic(BASE_FREQUENCY)
        # self.scale = EvenTempered(BASE_FREQUENCY)
        self.sequencer = Sequencer(BUFFER_SIZE, SAMPLE_RATE)

    def test_instantiation(self):
        self.assertIsNotNone(self.sequencer)

    def test_play(self):
        instrument = ScaleSynth(SAMPLE_RATE, BUFFER_SIZE, self.scale)
        self.sequencer.add_device(instrument)

        self.sequencer.play([(0, 0, 1, 0),
                             # (0,4,1,1),
                             # (0,7,1,0),
                             # (0,4,0,1),
                             # (0,3,1,0),
                             (0, 3, 0, 1)],
                            block=True)
DEFAULT_INSTRUMENT = "ScaleSynth EvenTempered 528"
DEFAULT_SPEED = 120

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='MSP homework 9')
    parser.add_argument('score', type=str)
    parser.add_argument('-i', '--instrument', type=str, default=DEFAULT_INSTRUMENT)
    parser.add_argument('-s', '--speed', type=int, default=DEFAULT_SPEED)
    namespace = parser.parse_args()

    dac = DAC(bufferSize=2 ** 10, rate=44100)
    dac.start()

    try:
        sequencer = Sequencer(buffer_size=dac.bufferSize, sample_rate=dac.getSamplerate(), speed=namespace.speed)
        dac.connect(sequencer.callback)

        instrument = instruments.parse(namespace.instrument.split(),
                                       buffer_size=dac.bufferSize,
                                       sample_rate=dac.getSamplerate())

        sequencer.add_instrument(instrument)

        file = open(namespace.score, 'r')
        score_string = file.read()
        file.close()
        score = Sequencer.parse_mono_score(score_string)

        sequencer.play(score=score)
 def setUp(self):
     self.scale = PythagDodecaphonic(BASE_FREQUENCY)
     # self.scale = EvenTempered(BASE_FREQUENCY)
     self.sequencer = Sequencer(BUFFER_SIZE, SAMPLE_RATE)