Ses#
giriiş#
VEX AIR Drone Kumandası, kullanıcıların dahili sesleri, özel ses dosyalarını ve müzik notalarını çalmasına olanak tanır. Ayrıca sesleri durdurma ve sesin şu anda çalınıp çalınmadığını algılama kontrollerini de içerir.
Aşağıda mevcut tüm yöntemlerin listesi bulunmaktadır:
İşlemler - Sesleri Çal ve Durdur
play— Önceden tanımlanmış bir listeden yerleşik bir ses çalar.play_file— Kullanıcı tarafından yüklenen bir sesi oynatır.play_note— Belirtilen perde, oktav ve süreye sahip bir müzik notası çalar.stop— Şu anda çalmakta olan herhangi bir sesi durdurur.
Getter’lar - Seslerin Durumunu Al
is_active— Bir sesin şu anda çalınıp çalınmadığını kontrol eder.
Eylemler#
play#
play komutu, kumandanın dahili seslerinden birini belirtilen ses seviyesi yüzdesinde çalar. Bu bekleme gerektirmeyen bir yöntem olduğundan, kumanda dahili sesi çalar ve bitmesini beklemeden bir sonraki komuta geçer.
Kullanım:
controller.sound.play(sound, volume)
Parametre |
Tanım |
|---|---|
|
Aşağıda listelenen dahili ses seçeneklerinden biri. |
|
İsteğe bağlı. Ses seviyesi, %0 ile %100 arasında bir tamsayı olarak belirtilebilir. Varsayılan değer %50’dir. |
Dahili Sesler |
Sesi Çal |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Play the looping sound.
controller.sound.play(LOOPING)
# Play the looping sound at full volume.
controller.sound.play(LOOPING, 100)
# Play the looping sound.
# Wait until the sound is finished before taking off.
controller.sound.play(LOOPING)
while controller.sound.is_active():
wait(50, MSEC)
drone.take_off(climb_to=500)
wait(1, SECONDS)
drone.land()
play_file#
play_file komutu, kullanıcının yüklediği özel bir sesi belirtilen ses seviyesi yüzdesinde çalar. Bu bekleme gerektirmeyen bir yöntem olduğundan, drone özel sesi çalar ve bitmesini beklemeden bir sonraki komuta geçer.
Kullanım:
controller.sound.play_file(file, volume)
Parametre |
Tanım |
|---|---|
|
Kullanıcı tarafından yüklenen özel ses dosyalarından biri, |
|
İsteğe bağlı. Ses seviyesi, %0 ile %100 arasında bir tamsayı olarak belirtilebilir. Varsayılan değer %50’dir. |
# Upload a sound file in VEXcode.
# Play the custom sound.
controller.sound.play_file(SOUND1)
# Upload a sound file in VEXcode.
# Play the custom sound at full volume.
controller.sound.play_file(SOUND1, 100)
# Play the custom sound sound.
# Wait until the sound is finished before taking off.
controller.sound.play_file(SOUND1)
while controller.sound.is_active():
wait(50, MSEC)
drone.take_off(climb_to=500)
wait(1, SECONDS)
drone.land()
play_note#
play_note , belirli bir notayı belirli bir süre boyunca çalar. Bu bekleme gerektirmeyen bir yöntem olduğundan, drone belirli notayı çalar ve bitmesini beklemeden bir sonraki komuta geçer.
Kullanım:
controller.sound.play_note(note, duration, volume)
Parametre |
Tanım |
|---|---|
|
Çalınacak müzik notası, bir tel olarak yazılır (örneğin, |
|
Notanın süresi, milisaniye cinsinden tam sayı olarak verilir. |
|
İsteğe bağlı. Notanın ses seviyesi, %0 ile %100 arasında bir tamsayı olarak belirtilir. Varsayılan değer %50’dir. |
# Play C5 for 2 seconds
controller.sound.play_note("C5", 2000)
# Play C5 for 2 seconds at full volume
controller.sound.play_note("C5", 2000, 100)
# Play a short tune.
controller.sound.play_note("C5", 1000)
while controller.sound.is_active():
wait(50, MSEC)
controller.sound.play_note("D5", 1000)
while controller.sound.is_active():
wait(50, MSEC)
controller.sound.play_note("E5", 250)
while controller.sound.is_active():
wait(50, MSEC)
stop#
stop durdur. Şu anda çalmakta olan sesi durdurur.
Kullanım:
controller.sound.stop()
Parametreler |
Tanım |
|---|---|
Bu yöntemin parametresi yoktur. |
# Upload a sound 10 seconds or greater in VEXcode.
# Stop the sound while it is playing.
controller.sound.play_file(SOUND1)
wait(6, SECONDS)
controller.sound.stop()
Getters#
is_active#
is_active , dronun şu anda ses çalıp çalmadığını gösteren bir Boolean değeri döndürür.
True— Şu anda bir ses çalıyorFalse— Ses çalınmıyor
Usage:
controller.sound.is_active()
Parametreler |
Tanım |
|---|---|
Bu yöntemin parametresi yoktur. |
# Display text once a sound starts playing
controller.sound.play(LOOPING)
while not controller.sound.is_active():
wait(50, MSEC)
print("I hear the sound!")