Skip to content

EV3-G API: Sound #358

Closed
Closed

Description

@dwalton76

sound-01

Activity

  1. self-assigned this
    on Sep 30, 2017
  2. dwalton76 commented on Oct 1, 2017

    @dwalton76
    CollaboratorAuthor

    Per this video
    https://www.youtube.com/watch?v=D2cGnTxsdy4

    • play_type 0 is wait for completion
    • play_type 1 is "play once"...I assume do not wait for completion
    • play_type 2 is "play on a loop"
  3. dwalton76 commented on Oct 1, 2017

    @dwalton76
    CollaboratorAuthor
    class Sound:
        """  
        Sound-related functions. The class has only static methods and is not
        intended for instantiation. It can beep, play wav files, or convert text to
        speech.
    

    Unless anyone objects, I am going to make the Sound class follow the model of all of our other classes where it is expected that you create an instance of that class.

  4. ddemidov commented on Oct 1, 2017

    @ddemidov
    Member

    I think you can already create an instance of the Sound class and used it that way.

  5. dwalton76 commented on Oct 1, 2017

    @dwalton76
    CollaboratorAuthor

    self isn't expected in any of the methods though...I don't think it would work. Either way will clean it up and make it consistent.

  6. ddemidov commented on Oct 1, 2017

    @ddemidov
    Member

    That's because the methods are static. The class is stateless, so self is not necessary. But the following works for me:

    >>> from ev3dev.core import Sound
    >>> s = Sound()
    >>> s.beep()
  7. dwalton76 commented on Oct 1, 2017

    @dwalton76
    CollaboratorAuthor

    The only musical instrument I can play is the radio. My musical ignorance is making play_note() challenging to implement. @EricPobot you wrote a lot of the code in this area earlier this year, would you be willing to implement that part of the EV3-G API for the Sound class?

  8. EricPobot commented on Oct 1, 2017

    @EricPobot
    Contributor

    @dwalton76 I'd be glad to help, but I'm not sure to see clearly what is expected to be done. I understand that it has some relation with an EV3-G connection but nothing more. I confess having been a bit away from ev3dev these last months, and thus have not followed its latest evolutions. Could you give me some input please ?

  9. WasabiFan commented on Oct 1, 2017

    @WasabiFan
    Member
  10. EricPobot commented on Oct 1, 2017

    @EricPobot
    Contributor

    @WasabiFan I'm a bit confused. The related topic is about gathering sounds and graphics to be used with ev3dev. Not about software.

  11. dlech commented on Oct 1, 2017

    @dlech
    Member

    I think the question is how do you convert a musical note to a frequency. Here is a table from the official LEGO firmware.

    _NOTES = {
      'C4': 262,
      'D4': 294,
      'E4': 330,
      'F4': 349,
      'G4': 392,
      'A4': 440,
      'B4': 494,
      'C5': 523,
      'D5': 587,
      'E5': 659,
      'F5': 698,
      'G5': 784,
      'A5': 880,
      'B5': 988,
      'C6': 1047,
      'D6': 1175,
      'E6': 1319,
      'F6': 1397,
      'G6': 1568,
      'A6': 1760,
      'B6': 1976,
      'C#4': 277,
      'D#4': 311,
      'F#4': 370,
      'G#4': 415,
      'A#4': 466,
      'C#5': 554,
      'D#5': 622,
      'F#5': 740,
      'G#5': 831,
      'A#5': 932,
      'C#6': 1109,
      'D#6': 1245,
      'F#6': 1480,
      'G#6': 1661,
      'A#6': 1865,
    }
  12. WasabiFan commented on Oct 1, 2017

    @WasabiFan
    Member

    @WasabiFan I'm a bit confused. The related topic is about gathering sounds and graphics to be used with ev3dev. Not about software.

    Part of the EV3-G API lets you play named sounds (not paths, but preloaded sounds from a list). I'd imagine we will have some sort of support for that using the ev3dev-media package mentioned.

  13. ddemidov commented on Oct 2, 2017

    @ddemidov
    Member

    I believe our play_song should be enough to implement play_note: It plays a sequence of notes. (And the _NOTE_FREQUENCIES is a superset of the list @dlech provided).

  14. added a commit that references this issue on Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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