Skip to content

Commit

Permalink
Add get_duration method for Note object (#146)
Browse files Browse the repository at this point in the history
* Add pycharm files to gitignore

* Add duration property to Note

@Property is not used - project uses get_X convention

* Add docstring for get_duration
  • Loading branch information
Ajk4 authored and craffel committed Jul 11, 2018
1 parent bd97acd commit 9851c0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -77,3 +77,6 @@ Temporary Items
Session.vim
.netrwhist
*~

### pycharm ###
.idea
4 changes: 4 additions & 0 deletions pretty_midi/containers.py
Expand Up @@ -27,6 +27,10 @@ def __init__(self, velocity, pitch, start, end):
self.start = start
self.end = end

def get_duration(self):
"""Get the duration of the note in seconds."""
return self.end - self.start

def __repr__(self):
return 'Note(start={:f}, end={:f}, pitch={}, velocity={})'.format(
self.start, self.end, self.pitch, self.velocity)
Expand Down

0 comments on commit 9851c0c

Please sign in to comment.