NAOqi Audio - Overview | API
Namespace : AL
#include <alproxies/alaudioplayerproxy.h>
As any module, this module inherits methods from ALModule API. It also has the following specific methods:
Returns the position in seconds in the file currently played. The Id of the playing task will be returned when calling a play method (eg. ALAudioPlayerProxy::play()) in a non-blocking manner. See below for an example in Python.
alaudioplayer_getcurrentposition.py
# -*- encoding: UTF-8 -*-
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python audioplayer_play.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
print "Could not create proxy to ALAudioPlayer"
print "Error was: ",e
sys.exit(1)
#plays a file and get the current position 5 seconds later
fileId = aup.post.playFile("/usr/share/naoqi/wav/random.wav")
time.sleep(5)
#currentPos should be near 5 secs
currentPos = aup.getCurrentPosition(fileId)
Parameters: |
|
---|---|
Returns: | Current position in seconds |
Returns the length in second of the file that is currently played.
Parameters: |
|
---|---|
Returns: | Length of the file in seconds |
Returns the list of the installed soundsets.
Returns an array containing the task Ids corresponding to the currently loaded files. File can be loaded using ALAudioPlayerProxy::loadFile().
Returns: | Array of task Ids |
---|
Returns an array containing the filenames (absolute paths) of the currently loaded files. File can be loaded using ALAudioPlayerProxy::loadFile().
Returns: | Array of filenames |
---|
Returns an array containing the currently loaded soundsets.
Returns: | Array of loaded soundsets |
---|
Returns an array containing the filenames of the corresponding soundset.
Parameters: |
|
---|---|
Returns: | Array of filenames |
Returns the master volume used by ALAudioPlayer for playback. This volume can be set by using ALAudioPlayerProxy::setMasterVolume(). This volume is independent of the system volume that can be set through ALAudioDevice.
Returns: | Volume [0.0 - 1.0] |
---|
Returns the volume level at which the specified task should be played. This volume is independent of the master volume set with ALAudioPlayerProxy::setMasterVolume(). This task dependent volume can be set by using ALAudioPlayerProxy::setVolume().
Parameters: |
|
---|---|
Returns: | Volume - [0.0 - 1.0] |
Jumps to a given position in second in the specified file.
Parameters: |
|
---|
# -*- encoding: UTF-8 -*-
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python audioplayer_goto.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
print "Could not create proxy to ALAudioPlayer"
print "Error was: ",e
sys.exit(1)
#Launchs the playing of a file, waits for 2 seconds, and goes to the 5th second
fileId = aup.post.playFile("/usr/share/naoqi/wav/random.wav")
time.sleep(1)
aup.goTo(fileId,2)
Tells if a sound is present in a given soundset.
Tells if a soundset is installed.
Tells if a given soundset is already loaded.
Preloads a file but does not play it yet. Preloading a file is a way to reduce the time necessary to actually start the playback when a “play” function is called. The playback of a loaded file can be started by calling ALAudioPlayerProxy::play().
Parameters: |
|
---|---|
Returns: | Id of the task handling the playing of the file |
Loads a soundset.
Parameters: |
|
---|
Pause the playback of the specified task. The pause can be resume by calling ALAudioPlayerProxy::play().
Parameters: |
|
---|
There are two overloads of this function:
Starts the playback of the specified task.
Parameters: |
|
---|
# -*- encoding: UTF-8 -*-
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python audioplayer_play.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
print "Could not create proxy to ALAudioPlayer"
print "Error was: ",e
sys.exit(1)
#Loads a file and launchs the playing 5 seconds later
fileId = aup.loadFile("/usr/share/naoqi/wav/random.wav")
time.sleep(5)
aup.play(fileId)
Starts the playback of the specified task, with a specific volume and stereo panorama. This task has for example been created using ALAudioPlayerProxy::loadFile().
Parameters: |
|
---|
# -*- encoding: UTF-8 -*-
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python audioplayer_play.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
print "Could not create proxy to ALAudioPlayer"
print "Error was: ",e
sys.exit(1)
#Loads a file and launchs the playing 5 seconds later
fileId = aup.loadFile("/usr/share/naoqi/wav/random.wav")
time.sleep(5)
aup.play(fileId)
There are two overloads of this function:
Starts the playback of the specified file. This call is equivalent to calling successively ALAudioPlayerProxy::loadFile() and ALAudioPlayerProxy::play().
Parameters: |
|
---|
# -*- encoding: UTF-8 -*-
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python audioplayer_playfile.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
print "Could not create proxy to ALAudioPlayer"
print "Error was: ",e
sys.exit(1)
#Launchs the playing of a file
aup.playFile("/usr/share/naoqi/wav/random.wav")
time.sleep(1.0)
#Launchs the playing of a file on the left speaker to a volume of 50%
aup.playFile("/usr/share/naoqi/wav/random.wav",0.5,-1.0)
Starts the playback of the specified file. This call is equivalent to calling successively ALAudioPlayerProxy::loadFile() and ALAudioPlayerProxy::play() with specific volume and pan.
Parameters: |
|
---|
# -*- encoding: UTF-8 -*-
import sys
import time
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python audioplayer_playfile.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
aup = ALProxy("ALAudioPlayer", IP, PORT)
except Exception,e:
print "Could not create proxy to ALAudioPlayer"
print "Error was: ",e
sys.exit(1)
#Launchs the playing of a file
aup.playFile("/usr/share/naoqi/wav/random.wav")
time.sleep(1.0)
#Launchs the playing of a file on the left speaker to a volume of 50%
aup.playFile("/usr/share/naoqi/wav/random.wav",0.5,-1.0)
There are two overloads of this function:
Starts the playback of the specified file from a given position in second.
Parameters: |
|
---|
Starts the playback of the specified file from a given position in second with a given volume and pan.
Parameters: |
|
---|
There are two overloads of this function:
Starts the playback of the specified file and loop. The playback can then be stopped by calling stop(const int & taskId).
Parameters: |
|
---|
Starts the playback of the specified file and loop, with specific volume and pan. The playback can then be stopped by calling stop(const int & taskId).
Parameters: |
|
---|
There are two overloads of this function:
Starts the playback of the specified task and loop.
Parameters: |
|
---|
Plays a wav, ogg or mp3 file in loop, with specific volume and audio balance
Parameters: |
|
---|
Play a sine wave which the specified characteristics.
Parameters: |
|
---|
There are 3 overloads of this function:
Plays a sound contained in one of the loaded soundsets.
If the same sound is present in different soundsets, it takes the sound of the first soundset loaded which contains this sound.
Parameters: |
|
---|
Plays a sound contained in a in a specified soundset with the default parameters.
Parameters: |
|
---|
Plays a sound contained in a specified soundset and with specified parameters.
Parameters: |
|
---|
Starts the playback of a web audio stream.
Parameters: |
|
---|
Sets the master volume used by ALAudioPlayer for playback. This volume is independent of the system volume that can be set through ALAudioDevice.
Parameters: |
|
---|
Sets the stereo panorama for all the playback tasks handled by ALAudioPlayer.
Parameters: |
|
---|
Sets the volume level at which the specified task should be played. This volume is independent of the master volume set with ALAudioPlayerProxy::setMasterVolume().
Parameters: |
|
---|
Unloads a file previously loaded with ALAudioPlayerProxy::loadFile().
Parameters: |
|
---|
Unloads a soundset.
Parameters: |
|
---|