Skip to content

Play song rests (fixes #595) - #669

Closed
mvolfik wants to merge 2 commits into
ev3dev:ev3dev-stretchfrom
mvolfik:play_song_rests
Closed

mvolfik wants to merge 2 commits into
ev3dev:ev3dev-stretchfrom
mvolfik:play_song_rests

Conversation

@mvolfik

@mvolfik mvolfik commented Aug 27, 2019 •

Copy link
Copy Markdown
Contributor

Also fix ignoring note capitalization and add ignoring value capit.

EDIT: Sorry, I didn't know that # links don't work in title...
fixes #595

- .upper() all notes in _make_scales (so Ab gets AB, but the first reads better in source)
- remove frequencies.get(note.upper(), frequencies[note]), as now everything is upper
- add .lower() to value lookup

@WasabiFan WasabiFan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes requested.

It would be really nice to have unit tests for this (inject a fake beep method which just logs the args, play a song, then assert the beep args match the expected. Could generate that list from the previous version of this code and compare.) but only do that if you're interested in it -- we didn't have tests before and I don't expect you to have to add them.

Comment thread ev3dev2/sound.py
else:
freq = self._NOTE_FREQUENCIES[note.upper()]
self.beep('-f %d -l %d -D %d' % (freq, duration_ms, delay_ms))
except KeyError as e:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this try...except around the whole thing is scary. Can we move it to the smallest relevant statement, probably the freq lookup?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you get a chance to change this I'll merge the PR.

Comment thread ev3dev2/sound.py Resolved
@dwalton76

Copy link
Copy Markdown
Collaborator

We haven't heard from mvolfik for a few months so I grabbed his/her patch, addressed the code review comments and posted a new PR. Will give them credit or the patch in the commit message.
#701

@dwalton76 dwalton76 closed this Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rest notes to sound.Sound.play_song()

3 participants