Overview

This module allows to play wav and mp3 files on NAO

Methods

int playFile (const string& fileName)

Plays a wav or mp3 file. Asynchronous.

fileName

Path of the sound file

Returns

Id of the task. Can be used to interrupt it.

Example in Python :

#Launchs the playing of a file
#Creates a proxy on the audio player module 
from naoqi import ALProxy
import time
aup = ALProxy("ALAudioPlayer",IP,9559);#IP = IP address of the robot
aup.playFile("/home/nao/MyWaveFile.wav")

int playFile (const string& fileName, const float& volume, const float& pan)

Plays a wav or mp3 file, with specific volume and audio balance. Asynchronous.

fileName

Path of the sound file

volume

volume of the sound file (must be between 0.0 and 1.0)

pan

audio balance of the sound file (-1.0 : left / 1.0 : right / 0.0 : centered)

Returns

Id of the task. Can be used to interrupt it.

Example in Python :

#Launchs the playing of a file on the left speaker to a volume of 50%
#Creates a proxy on the audio player module 
from naoqi import ALProxy
import time
aup = ALProxy("ALAudioPlayer",IP,9559);#IP = IP address of the robot
aup.post.playFile("/home/nao/MyWaveFile.wav",0.5,-1.0)

int playFileInLoop (const string& fileName)

Plays a wav or mp3 file in loop. Asynchronous.

fileName

Path of the sound file

Returns

Id of the task. Can be used to interrupt it.

int playFileInLoop (const string& fileName, const float& volume, const float& pan)

Plays a wav or mp3 file in loop, with specific volume and audio balance. Asynchronous.

fileName

Path of the sound file

volume

volume of the sound file (must be between 0.0 and 1.0)

pan

audio balance of the sound file (-1.0 : left / 1.0 : right)

Returns

Id of the task. Can be used to interrupt it.

int playFileFromPosition (const string& fileName, const float& position)

Plays a wav or mp3 file from a given position in the file.. Asynchronous.

fileName

Name of the sound file

position

Position in second where the playing has to begin

Returns

Id of the task. Can be used to interrupt it.

int playFileFromPosition (const string& fileName, const float& position, const float& volume, const float& pan)

Plays a wav or mp3 file from a given position in the file, with specific volume and audio balance. Asynchronous.

fileName

Name of the sound file

position

Position in second where the playing has to begin

volume

volume of the sound file (must be between 0.0 and 1.0)

pan

audio balance of the sound file (-1.0 : left / 1.0 : right)

Returns

Id of the task. Can be used to interrupt it.

void goTo (const int& playId, const float& position)

Goes to a given position in a file which is playing.

playId

Id of the process which is playing the file

position

Position in the file (in second)

Example in Python :

#Launchs the playing of a file, waits for 2 seconds, and goes go the 5th second
#Creates a proxy on the audio player module
from naoqi import ALProxy
import time
aup = ALProxy("ALAudioPlayer",IP,9559);#IP = IP address of the robot
#Launchs the playing
fileId=aup.post.playFile("/home/nao/MyWaveFile.wav")
time.sleep(2)
aup.goTo(fileId,5)

void stopAll ()

Stops all the files that are currently playing.

void pause (const int& id)

Pause a play back

id

Id of the process that is playing the file you want to put in pause

void setVolume (const int& id, const float& volume)

Sets the volume of the player

id

Id of the process that is playing the file you want to put louder or less loud

volume

Volume - range 0.0 to 1.0

void setMasterVolume (const float& volume)

Sets the master volume of the player

volume

Volume - range 0.0 to 1.0

float getVolume ()

Returns the volume of the player

Returns

Volume of the player - range 0.0 to 1.0.

float getMasterVolume ()

Returns the master volume of the player

Returns

Volume of the master - range 0.0 to 1.0.

void setPanorama (const float& arg1)

sets the audio panorama : -1 for left speaker / 1 for right speaker

arg1

arg

int loadFile (const string& fileName)

Loads a file for ulterior playback

fileName

Path of the sound file (either mp3 or wav)

Returns

Id of the file which has been loaded. This file can then be played with the play function

void unloadFile (const int& id)

unloads a file previously loaded with the loadFile function

id

Id returned by the loadFile function

void unloadAllFiles ()

unloads all the files already loaded.

int play (const int& id)

Starts the playback of a file preloaded with the loadFile function.. Asynchronous.

id

Id returned by the loadFile function

Returns

Id of the task. Can be used to interrupt it.

Example in Python :

#Loads a file and launchs the playing 5 seconds later
#Creates a proxy on the audio player module
from naoqi import ALProxy
import time
aup = ALProxy("ALAudioPlayer",IP,9559);#IP = IP address of the robot
#launchs the playing
fileId=aup.loadFile("/home/nao/MyWaveFile.wav")
time.sleep(5)
aup.play(fileId)

int play (const int& id, const float& volume, const float& pan)

Starts the playback of a file preloaded with the loadFile function, with specific volume and audio balance. Asynchronous.

id

Id returned by the loadFile function

volume

volume of the sound file (must be between 0.0 and 1.0)

pan

audio balance of the sound file (-1.0 : left / 1.0 : right)

Returns

Id of the task. Can be used to interrupt it.

Example in Python :

#Loads a file and launchs the playing 5 seconds later
#Creates a proxy on the audio player module
from naoqi import ALProxy
import time
aup = ALProxy("ALAudioPlayer",IP,9559);#IP = IP address of the robot
#launchs the playing
fileId=aup.loadFile("/home/nao/MyWaveFile.wav")
time.sleep(5)
aup.play(fileId,1.0,0.0)

int playInLoop (const int& fileName)

Starts the playback in loop of a file preloaded with the loadFile function. Asynchronous.

fileName

Path of the sound file

Returns

Id of the task. Can be used to interrupt it.

int playInLoop (const int& fileName, const float& volume, const float& pan)

Plays a wav or mp3 file in loop, with specific volume and audio balance. Asynchronous.

fileName

Path of the sound file

volume

volume of the sound file (must be between 0.0 and 1.0)

pan

audio balance of the sound file (-1.0 : left / 1.0 : right)

Returns

Id of the task. Can be used to interrupt it.


Methods inherited from ALModule

void exit ()

Exits and unregisters the module.

string version ()

Returns the version of the module.

Returns

A string containing the version of the module.

bool ping ()

Just a ping. Always returns true

Returns

returns true

vector<string> getMethodList ()

Retrieves the module's method list.

Returns

An array of method names.

AL::ALValue getMethodHelp (const string& methodName)

Retrieves a method's description.

methodName

The name of the method.

Returns

A structure containing the method's description.

AL::ALValue getModuleHelp ()

Retrieves the module's description.

Returns

A structure describing the module.

string getBrokerName ()

Gets the name of the parent broker.

Returns

The name of the parent broker.

string getUsage (const string& name)

Gets the method usage string. This summarise how to use the method.

name

The name of the method.

Returns

A string that summarises the usage of the method.


Copyright © 2010 Aldebaran Robotics - All rights reserved