def _note_sequence(mn=None, attr_name_idx_map=None, attr_val_default_map=None, num_attributes=None): mn.attr_name_idx_map = attr_name_idx_map or ATTR_NAME_IDX_MAP mn.attr_val_default_map = attr_val_default_map or ATTR_VAL_DEFAULT_MAP mn.num_attributes = num_attributes or NUM_ATTRIBUTES return NoteSequence(num_notes=NUM_NOTES, mn=mn)
def test_note_sequence_insert_remove_getitem(make_note_config): note_sequence = NoteSequence(num_notes=NUM_NOTES, mn=make_note_config) # Get the first note in the sequence, and get its amplitude note_front = note_sequence.note(0) note_front_amp = note_front.amplitude # Insert a new note at the front of the sequence, with a different amplitude new_amp = AMP + 1 new_note = _note(mn=make_note_config) new_note.amplitude = new_amp note_sequence.insert(0, new_note) new_note_front = note_sequence[0] new_note_front_amp = new_note_front.amplitude # Assert that the new note inserted can be retrieved and is the expected new first note assert note_front_amp != new_note_front_amp assert new_note_front_amp == new_amp # After removing a note, the new front note is the one added second to most recently expected_amp = note_sequence[1].amplitude note_sequence.remove((0, 1)) note_front = note_sequence[0] assert expected_amp == note_front.amplitude
def note_sequence(make_note_config): return NoteSequence(num_notes=NUM_NOTES, mn=make_note_config)
note_config.synth_def = fd_sc_synth note_config.amp = 1.0 note_config.oct = 2 note_config.scale = 'lydian' idur = 1.0 delay = 0.0 for i in range(15): note_config.delay = int(round(delay, 5)) note_config.dur = round(idur - ((i + 1) * 0.05), 5) note_config.degree = i % 5 note = FoxDotSupercolliderNote(**note_config.as_dict(), performance_attrs=performance_attrs) notes.append(note) delay += note_config.dur note_sequence = NoteSequence(notes) player = FoxDotSupercolliderPlayer(note_sequence) player.play_each() sleep(3) notes = [] note_config.name = 'test_note' note_config.synth_def = fd_sc_synth note_config.amp = 1.0 note_config.oct = 5 note_config.scale = 'chromatic' idur = 1.0 delay = 0.0 for i in range(15): note_config.delay = round(delay, 5)