當前位置: 首頁>>代碼示例>>Python>>正文


Python sound.Sound類代碼示例

本文整理匯總了Python中rstem.sound.Sound的典型用法代碼示例。如果您正苦於以下問題:Python Sound類的具體用法?Python Sound怎麽用?Python Sound使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Sound類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sound_negative_duration_play_failure

def sound_negative_duration_play_failure():
    s = Sound(TEST_SOUND_LONG)
    try:
        s.play(duration=-1)
    except ValueError:
        return True
    return False
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:7,代碼來源:test_speaker.py

示例2: sound_chaining_test_timed

def sound_chaining_test_timed():
    # Same as sound_chaining_test(), but time it.  Does not include Sound()
    # time, as it may take a while to load an uncached sound.
    s = Sound(TEST_SOUND)
    start = time.time()
    s.play().wait().play(duration=0.1).wait().play().stop()
    return verify_duration(start, TEST_SOUND_LENGTH + 0.1)
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:7,代碼來源:test_speaker.py

示例3: sound_not_is_playing_after_play

def sound_not_is_playing_after_play():
    s = Sound(TEST_SOUND)
    print("before play")
    s.play()
    print("after play")
    time.sleep(TEST_SOUND_LENGTH + 0.5)
    print("after wait: ", s.is_playing())
    return not s.is_playing()
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:8,代碼來源:test_speaker.py

示例4: sound_play_test_sound_and_note_mixed

def sound_play_test_sound_and_note_mixed():
    n = Note('A')
    s = Sound(TEST_SOUND)
    n.play(duration=None)
    s.play()
    s.wait()
    n.stop()
    return True
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:8,代碼來源:test_speaker.py

示例5: sound_stop_time

def sound_stop_time():
    s = Sound(TEST_SOUND_LONG)
    s.play()
    time.sleep(1)
    start = time.time()
    s.stop()
    end = time.time()
    duration = end - start
    print(start, end)
    print("stop() duration: ", duration)
    return duration > 0 and duration < 0.150
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:11,代碼來源:test_speaker.py

示例6: sound_stop_time

def sound_stop_time():
    #s = Sound(TEST_SOUND_LONG)
    s = Sound('/opt/sonic-pi/etc/samples/loop_garzul.wav')
    s.play()
    time.sleep(1)
    start = time.time()
    s.stop()
    end = time.time()
    duration = end - start
    print(start, end)
    print("stop() duration: ", duration)
    return duration > 0 and duration < 0.150
開發者ID:scottsilverlabs,項目名稱:raspberrystem,代碼行數:12,代碼來源:test_speaker.py

示例7: sound_play_then_replay

def sound_play_then_replay():
    s = Sound(TEST_SOUND_LONG)
    s.play()
    time.sleep(0.5)
    playing_firsttime = s.is_playing()
    s.play(duration=1.0)
    time.sleep(0.5)
    playing_secondtime_before_end = s.is_playing()
    time.sleep(1.0)
    playing_secondtime_after_end = s.is_playing()
    s.stop()
    print('playing_firsttime: ', playing_firsttime)
    print('playing_secondtime_before_end: ', playing_secondtime_before_end)
    print('playing_secondtime_after_end: ', playing_secondtime_after_end)
    return playing_firsttime and playing_secondtime_before_end and not playing_secondtime_after_end
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:15,代碼來源:test_speaker.py

示例8: sound_manual_play_test_sound_and_note_mixed

def sound_manual_play_test_sound_and_note_mixed():
    '''The sound match1.wav will play TWO TIMES on the speaker, mixed with an
    'A' note.
    '''
    n = Note('A')
    s = Sound(TEST_SOUND)
    n.play(duration=None)
    s.play()
    s.wait()
    s.play()
    s.wait()
    n.stop()
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:12,代碼來源:test_speaker.py

示例9: sound_short_latency

def sound_short_latency():
    s = Sound(TEST_SOUND)
    s.stop()
    start = time.time()
    s.play()
    s.wait()
    duration = time.time() - start
    latency = duration - TEST_SOUND_LENGTH
    print("Latency: ", latency)
    return latency > 0 and latency < 0.050
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:10,代碼來源:test_speaker.py

示例10: sound_playing_before_end_of_duration_play

def sound_playing_before_end_of_duration_play():
    s = Sound(TEST_SOUND_LONG)
    s.play(duration=1.0)
    time.sleep(0.5)
    playing = s.is_playing()
    s.stop()
    return playing
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:7,代碼來源:test_speaker.py

示例11: sound_not_playing_after_end_of_2_loops

def sound_not_playing_after_end_of_2_loops():
    s = Sound(TEST_SOUND)
    s.play(loops=2)
    time.sleep(TEST_SOUND_LENGTH * 2 + 0.5)
    playing = s.is_playing()
    s.stop()
    return not playing
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:7,代碼來源:test_speaker.py

示例12: sound_not_playing_after_end_of_2_loops_of_fixed_duration

def sound_not_playing_after_end_of_2_loops_of_fixed_duration():
    s = Sound(TEST_SOUND_LONG)
    s.play(duration=1.0, loops=2)
    time.sleep(2.5)
    playing = s.is_playing()
    s.stop()
    return not playing
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:7,代碼來源:test_speaker.py

示例13: sound_playing_before_end_of_2_loops

def sound_playing_before_end_of_2_loops():
    s = Sound(TEST_SOUND)
    s.play(loops=2)
    time.sleep(TEST_SOUND_LENGTH * 2 - 0.5)
    playing = s.is_playing()
    s.stop()
    return playing
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:7,代碼來源:test_speaker.py

示例14: sound_get_set_volume

def sound_get_set_volume():
    # Verify Sound volume attribute can be get/set.
    s = Sound(TEST_SOUND_LONG)
    s.volume = 0
    s.play(duration=0.5)
    for i in range(10):
        s.volume += 10
        time.sleep(0.05)
    s.wait()
    return s.volume == 100
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:10,代碼來源:test_speaker.py

示例15: sound_sound_volume

def sound_sound_volume():
    '''The long test sound will play for 10 second with increasing volume.  '''
    master_volume(100)
    s = Sound(TEST_SOUND_LONG)
    s.volume = 0
    s.play(duration=10)
    for i in range(20):
        s.volume += 15
        time.sleep(0.5)
    s.wait()
開發者ID:readysetstem,項目名稱:readysetstem-api,代碼行數:10,代碼來源:test_speaker.py


注:本文中的rstem.sound.Sound類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。