.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.adv.Sound:

==========================================================================================================================================
|phoenix_title|  **wx.adv.Sound**
==========================================================================================================================================

This class represents a short sound (loaded from Windows ``WAV`` file), that can be stored in memory and played.          

Currently this class is implemented on Windows and Unix and can use either Open Sound System (``OSS``) or Simple DirectMedia Layer (``SDL``) under the latter. Notice that ``OSS`` is not provided any more by most, and maybe even all, Linux systems in 2017 and osspd (``OSS`` Proxy Daemon) package typically needs to be installed to make it work. 







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>Sound</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.adv.Sound_inheritance.png" alt="Inheritance diagram of Sound" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.adv.Sound.html" title="wx.adv.Sound" alt="" coords="5,83,117,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="18,5,105,35"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.adv.Sound.__init__`                                                   Default constructor.
:meth:`~wx.adv.Sound.Create`                                                     Constructs a wave object from a file or resource.
:meth:`~wx.adv.Sound.CreateFromData`                                             Create a sound object from data in a memory buffer in ``WAV`` format.
:meth:`~wx.adv.Sound.IsOk`                                                       Returns ``True`` if the object contains a successfully loaded file or resource, ``False`` otherwise.
:meth:`~wx.adv.Sound.Play`                                                       Plays the sound file.
:meth:`~wx.adv.Sound.PlaySound`                                                  Plays the sound file.
:meth:`~wx.adv.Sound.Stop`                                                       If a sound is played, this function stops it.
:meth:`~wx.adv.Sound.__bool__`                                                   
:meth:`~wx.adv.Sound.__nonzero__`                                                
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.adv.Sound(Object)

   **Possible constructors**::

       Sound()
       
       Sound(fileName)
       
   
   This class represents a short sound (loaded from Windows ``WAV`` file),
   that can be stored in memory and played.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, fileName)`
      
      Constructs a wave object from a file or, under Windows, from a Windows resource.                  
      
      Call :meth:`IsOk`   to determine whether this succeeded. 
      
      
      
      
      :param `fileName`: The filename or Windows resource.   
      :type `fileName`: string
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Create(self, fileName)

      Constructs a wave object from a file or resource.                  




      :param `fileName`: The filename or Windows resource.   
      :type `fileName`: string








      :rtype: `bool`



                  



      :returns: 

         ``True`` if the call was successful, ``False`` otherwise.   








   .. method:: CreateFromData(self, data)

      Create a sound object from data in a memory buffer in ``WAV`` format. 

      :rtype: `bool`








   .. method:: IsOk(self)

      Returns ``True`` if the object contains a successfully loaded file or resource, ``False`` otherwise.                  

      :rtype: `bool`








   .. method:: Play(self, flags=SOUND_ASYNC)

      Plays the sound file.                  

      If another sound is playing, it will be interrupted. 

      Returns ``True`` on success, ``False`` otherwise. Note that in general it is possible to delete the object which is being asynchronously played any time after calling this function and the sound would continue playing, however this currently doesn't work under Windows for sound objects loaded from memory data. 

      The possible values for `flags`  are:

      - ``wx.adv.SOUND_SYNC``:  ``Play``   will block and wait until the sound is replayed. 
      - ``wx.adv.SOUND_ASYNC``: Sound is played asynchronously,  ``Play``   returns immediately. 
      - SOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops until another sound is played, :meth:`Stop`   is called or the program terminates. 




      The static form is shorthand for this code: ::

                  wx.adv.Sound(filename).Play(flags)

                 


      :param `flags`: 




      :rtype: `bool`








   .. staticmethod:: PlaySound(filename, flags=SOUND_ASYNC)

      Plays the sound file.                  

      If another sound is playing, it will be interrupted. 

      Returns ``True`` on success, ``False`` otherwise. Note that in general it is possible to delete the object which is being asynchronously played any time after calling this function and the sound would continue playing, however this currently doesn't work under Windows for sound objects loaded from memory data. 

      The possible values for `flags`  are:

      - ``wx.adv.SOUND_SYNC``:  ``Play``   will block and wait until the sound is replayed. 
      - ``wx.adv.SOUND_ASYNC``: Sound is played asynchronously,  ``Play``   returns immediately. 
      - SOUND_ASYNC|wxSOUND_LOOP: Sound is played asynchronously and loops until another sound is played, :meth:`Stop`   is called or the program terminates. 




      The static form is shorthand for this code: ::

                  wx.adv.Sound(filename).Play(flags)

                 


      :param `filename`: 
      :type `filename`: string
      :param `flags`: 




      :rtype: `bool`








   .. staticmethod:: Stop()

      If a sound is played, this function stops it.                   





   .. method:: __bool__(self)



      :rtype: `int`








   .. method:: __nonzero__(self)



      :rtype: `int`







