MICILE EZ_Sound Documentation
version: 0.9
A few notes about our documentation:
  • The intentions of this documentation are to keep things simple.
  • Please see the examples at the end of each section for concrete examples of how to use each function.
  • If in doubt how to use a function, experiment!
  • We don't believe in writing more words just to make the documentation look more substantial
  • Quick Reference
    Function List
    Compatible Devices
    Microphone, Speaker, and Line Out Jack built into every tablet

    * Please contact us for information on adding support for a device.

    Sound Functions
    Returns 1 when a sound capture is in progress, 0 when the sound capture has completed. The capture_sound_start function is usually called first to initiate
    a sound capture from the microphone, then this function is called to determine when sampling has completed. The completed sample can be retrieved
    using the get_captured_sound function.
    Plays the sound sound. Multiple overlapping sounds can be played with multiple calls to play_sound
    Returns the current volume. The returned value will be between 0 and 100, with 0 being mute and 100 being full volume.
    Sets the current volume. The volume parameter must be an integer between 0 and 100, with 0 being mute and 100 being full volume.
    For example, to set the volume to half of maximum, use a value of 50.

    The library will attempt to set the volume to the closest value possible to the volume which it is capable of. The returned value from
    a call to get_volume may not match exactly the value which was passed in to set_volume because of quantization errors caused by the hardware
    having a different number of discreet volume levels than 100. For example, many sound systems only support 64 discreet volume levels which does not
    evenly divide into 100.

    This example will play a cymbal sound, record sound from the microphone for 3.5 seconds, play the recorded sound, and then save the recorded sound to a file.

    You will need to upload the open_hh.wav sound to your project in order for this demo to work.
    You can download the open_hh.wav sound from here.
    Make sure to right click on the link and select "save as" and then upload the file to your project.

    # --------------------------------------------------
    # sound_demo.py
    # --------------------------------------------------
    # import the ez_sound library v0.9
    from ez_sound_09 import *
    from ez_ui_09 import *
    import time
    import os
    # check if sound file exists
    if not os.path.exists('open_hh.wav'):
        show_messagebox(message='Please upload the open_hh.wav file first')
    # set the volume
    # play the sound
    snd = load_sound('open_hh.wav')
    # play the sound
    # wait a half a second for the sound to finish playing
    # start record a sound for 3.5 seconds at 8000hz
    recsnd = capture_sound_start(80003.5)
    # wait for the sound to finish recording
    while capture_sound_busy() == 1:
        # we could be something useful right now like drawing stuff on the screen
        # but for this demo, we will just do nothing
    # get the captured sound
    recsnd = get_captured_sound()
    # play the sound
    # save the sound to a file