Skip to content

EV3-G API: Sound.play_note() #403

Closed
Closed

Description

@dwalton76

30606561-16a38a0e-9d40-11e7-9803-830261c4714b

@EricPobot we chatted about this for a bit in #358 ...can you take a look at implementing a

   def play_note(note, duration_ms, volume=100, play_type=PLAY_WAIT_FOR_COMPLETE)

in the Sound class?

Activity

  1. dwalton76 commented on Nov 14, 2017

    @dwalton76
    CollaboratorAuthor

    @EricPobot do you have the cycles to take a stab at this one? I don't know enough music theory to implement this :(

  2. ericpascual commented on Nov 14, 2017

    @ericpascual

    @dwalton76 I'll give it a look ASAP (maybe tonight) and keep you updated.
    I guess that "volume=100" means "volume at 100%". Right ?

  3. EricPobot commented on Nov 14, 2017

    @EricPobot
    Contributor

    What is the specification of the duration value ? Does 1.0 represent a delay in seconds or something else like a quarter note for instance (i.e. the 'q' notation as used by play_song) ?

  4. dlech commented on Nov 14, 2017

    @dlech
    Member

    duration is how long the note plays in seconds

  5. EricPobot commented on Nov 15, 2017

    @EricPobot
    Contributor

    @dlech I've noted after asking that the example of the signature in the opening post shows "duration_ms". Since play_tone uses ms too, maybe we should keep the same unit (i.e. millis, not seconds) to be homogeneous.

  6. EricPobot commented on Nov 15, 2017

    @EricPobot
    Contributor

    First implementation done (was not a big deal, since the play_tone method being already there, so it was just a matter of getting the frequency for the passed note symbol).
    I still need to do the appropriate work (fork + pull request) for submitting the changes. This will have to wait until tomorrow since time to go to bed now ;)
    I've made some minor changes in a couple of place to remove PEP compliance warnings.

  7. dlech commented on Nov 15, 2017

    @dlech
    Member

    maybe we should keep the same unit (i.e. millis, not seconds) to be homogeneous.

    It seems to me that in general, python uses seconds (e.g. time.sleep()), so that would be my preference. (and tone playback could be changed to match).

  8. ericpascual commented on Nov 15, 2017

    @ericpascual

    Agree. Let's align all involved methods to seconds. I'll integrate this in my changes.

  9. EricPobot commented on Nov 15, 2017

    @EricPobot
    Contributor

    After some thinking, and because the underlying system commands use integer counts of milliseconds, using milliseconds everywhere seemed more appropriate.

    Implementation is finished. Am I supposed to push my changes to the repo () ?

  10. WasabiFan commented on Nov 15, 2017

    @WasabiFan
    Member

    @EricPobot open a pull request and we can take a look.

  11. EricPobot commented on Nov 15, 2017

    @EricPobot
    Contributor

    @WasabiFan I need some refresher : does it mean that I have to fork the project, then put my changes in this fork and issue a pull request from it ?

  12. WasabiFan commented on Nov 15, 2017

    @WasabiFan
    Member
  13. dlech commented on Nov 16, 2017

    @dlech
    Member

    and because the underlying system commands use integer counts of milliseconds,

    Part of the reason for adding this additional api is to decouple from the underlying system commands and do things more like the EV3-G software so that it is easier for people who are familiar with the LEGO software to make the transition to python.

  14. ericpascual commented on Nov 16, 2017

    @ericpascual

    @dlech Your point makes sense WRT how the LEGO SW presents it. I'll switch all durations to milliseconds.

    However, there are also others delays which are specified in msecs, and which maybe will become a bit tedious to express as seconds, since representing short pauses (e.g. 50ms). How will users feel the obligation to write 0.05 for such quantities ?

    I do not have a definite opinion on this point.

  15. ericpascual commented on Nov 16, 2017

    @ericpascual

    @WasabiFan Thanks for the pointer. I already have an old fork, from the epoch I tried to collaborate a bit. Do you advise me to drop it and create a fresh new fork or can it be safely synced with the current status of the project ?

  16. ddemidov commented on Nov 16, 2017

    @ddemidov
    Member

    can it be safely synced with the current status of the project ?

    This should be possible with

    # Clone your old repo locally:
    $ git clone -b develop https://github.com/EricPobot/ev3dev-lang-python
    $ cd ev3dev-lang-python
    # Add reference to this repo:
    $ git remote add upstream https://github.com/ev3dev/ev3dev-lang-python
    # fetch upstream changes and sync local copy:
    $ git fetch upstream
    $ git reset --hard upstream/develop

    After this your local copy should be in sync with this one (the top commit in git log should be 923080b).

  17. ericpascual commented on Nov 16, 2017

    @ericpascual

    @ddemidov Many thanks for the detailed instructions. I'll give it a try tonight.

  18. dlech commented on Nov 16, 2017

    @dlech
    Member

    How will users feel the obligation to write 0.05 for such quantities ?

    I don't know. So my inclination is to not think about it and make it like EV3-G instead of trying to guess what other people think or spending too much time discussing it.

  19. EricPobot commented on Nov 18, 2017

    @EricPobot
    Contributor

    From the musical point of view, the default note in the play_note EV3-G block ('A5' in the screen shot included at the top of this thread) should be set to 'A4'. A4 is the 440Hz reference widely used for instrument tuning, so it sounds (!) as a good default value.

  20. dwalton76 commented on Nov 23, 2017

    @dwalton76
    CollaboratorAuthor

    @EricPobot anything else to do on this one?

  21. ericpascual commented on Nov 23, 2017

    @ericpascual

    I don't think so, since it has been implemented by the PR you just merged.
    As I mentioned in replies in the PR thread, there are some comments in parts I've not written which would deserve to be reviewed and amended. But this is not very urgent, and can be left as is for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions