def test_e4_double_flat(self): midi_note = get_midi_note('__E') self.assertEqual(62, midi_note)
def test_c3(self): midi_note = get_midi_note("C,") self.assertEqual(48, midi_note)
def test_e4(self): midi_note = get_midi_note('E') self.assertEqual(64, midi_note)
def test_e4_flat(self): midi_note = get_midi_note('_E') self.assertEqual(63, midi_note)
def test_c4_sharp(self): midi_note = get_midi_note('^C') self.assertEqual(61, midi_note)
def test_c4_double_sharp(self): midi_note = get_midi_note('^^C') self.assertEqual(62, midi_note)
def test_c6(self): midi_note = get_midi_note("c'") self.assertEqual(84, midi_note)
def test_c5(self): midi_note = get_midi_note('c') self.assertEqual(72, midi_note)
def test_c4(self): midi_note = get_midi_note('C') self.assertEqual(60, midi_note)
def demo_play_sporting_nell(bpm=90, instrument='Acoustic Grand Piano'): player = snap.SingleNoteAbcPlayer() player.setup_synth() player.select_instrument(instrument) # Setup sequencer over existing player sequencer = fluidsequencer.FluidSequencer(player._handle) sequencer.beats_per_minute = bpm beat_length = sequencer.ticks_per_beat print("BPM: {0}".format(sequencer.beats_per_minute)) print("TPB: {0}".format(sequencer.ticks_per_beat)) print("TPS: {0}".format(sequencer.ticks_per_second)) dest = sequencer.add_synth(player._synth) ticks = sequencer.ticks + 10 abc_key = 'Dmix' half_bar1 = 'ADED' bar1 = 'ADED A2dc' bar2 = 'ABAG EFG2' midi_note = None for i in range(0, 3): for simple_note in half_bar1: norm_key = abcparser.normalize_abc_key(abc_key) alteration = musictheory.get_note_alteration_in_key(simple_note, norm_key) abc_note = alteration + simple_note midi_note = abc2midi.get_midi_note(abc_note) event = fluidevent.FluidEvent(player._handle) event.dest = dest[0] event.note(0, midi_note, 127, int(beat_length * 0.25)) sequencer.send(event, ticks) ticks += int(beat_length / 4) print('Waiting 4 beats...') time.sleep(60 / bpm * 4) print('Sending event in the past') event = fluidevent.FluidEvent(player._handle) event.dest = dest[0] event.note(0, midi_note, 127, int(beat_length * 0.25)) #sequencer.send(event, ticks) sequencer.send(event, 10) # time.sleep(60 / 90 * 2) # # try: # player._lock.acquire() # player._synth.noteoff(player._midi_channel, midi_note) # finally: # player._lock.release() # # del sequencer # print('Deleted sequencer') print('Waiting 2s...') time.sleep(2) del sequencer del player._driver del player._synth
def demo_play_sporting_nell(bpm=90, instrument='Acoustic Grand Piano'): player = snap.SingleNoteAbcPlayer() player.setup_synth() player.select_instrument(instrument) # Setup sequencer over existing player sequencer = fluidsequencer.FluidSequencer(player._handle) sequencer.beats_per_minute = bpm beat_length = sequencer.ticks_per_beat print("BPM: {0}".format(sequencer.beats_per_minute)) print("TPB: {0}".format(sequencer.ticks_per_beat)) print("TPS: {0}".format(sequencer.ticks_per_second)) dest = sequencer.add_synth(player._synth) ticks = sequencer.ticks + 10 abc_key = 'Dmix' half_bar1 = 'ADED' bar1 = 'ADED A2dc' bar2 = 'ABAG EFG2' midi_note = None for i in range(0, 3): for simple_note in half_bar1: norm_key = abcparser.normalize_abc_key(abc_key) alteration = musictheory.get_note_alteration_in_key( simple_note, norm_key) abc_note = alteration + simple_note midi_note = abc2midi.get_midi_note(abc_note) event = fluidevent.FluidEvent(player._handle) event.dest = dest[0] event.note(0, midi_note, 127, int(beat_length * 0.25)) sequencer.send(event, ticks) ticks += int(beat_length / 4) print('Waiting 4 beats...') time.sleep(60 / bpm * 4) print('Sending event in the past') event = fluidevent.FluidEvent(player._handle) event.dest = dest[0] event.note(0, midi_note, 127, int(beat_length * 0.25)) #sequencer.send(event, ticks) sequencer.send(event, 10) # time.sleep(60 / 90 * 2) # # try: # player._lock.acquire() # player._synth.noteoff(player._midi_channel, midi_note) # finally: # player._lock.release() # # del sequencer # print('Deleted sequencer') print('Waiting 2s...') time.sleep(2) del sequencer del player._driver del player._synth