Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix volume assignment for chords + repeat from GUI #296

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions marimbabot_behavior/src/marimbabot_behavior/behavior_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ def __init__(self):
# checks if the read note sequence includes a repeat symbol and updates the note sequence accordingly
def check_for_repeat(self):
if '\\repeat volta 2' in self.note_sequence:
# get the index of the first note
# get the index of the first note or rest
note_sequence_list = self.note_sequence.split(' ')
first_note_index = None
for i, x in enumerate(note_sequence_list):
if re.match(r'[a-g]\'*[0-9]+(\>)?(\.)?', x):
if re.match(r'[a-r][s,f]?\'*[0-9]+\.?', x) or re.match(r'\<[a-g][s,f]?\'*', x):
first_note_index = i
break

self.note_sequence = ' '.join(note_sequence_list[3:] + note_sequence_list[first_note_index:])
rospy.logdebug(f"updated notes: {self.note_sequence}")

Expand Down Expand Up @@ -117,10 +118,10 @@ def assign_volume(self, value='\\mp', override=False):

sequence_list = self.note_sequence.split(' ')

# get the index of the first note
# get the index of the first dynamic symbol behind the first note (or the second note if the first rule is a chord)
dynamic_index = None
for i, x in enumerate(sequence_list):
if re.match(r'[a-g]\'*[0-9]+(\>)?(\.)?', x):
if re.match(r'[a-g][s,f]?\'*[0-9]+\.?', x) or re.match(r'[a-g][s,f]?\'*\>[0-9]+\.?', x):
dynamic_index = i+1
break

Expand Down Expand Up @@ -296,6 +297,7 @@ def audio_from_lilypond_client_thread():
def callback_note_sequence(self, note_sequence_msg):
self.note_sequence = note_sequence_msg.data
rospy.loginfo(f"received note sequence: {self.note_sequence}")
self.check_for_repeat()
self.response_pub.publish('Notes recognized.')
self.update_hit_sequence()

Expand Down