Lua Player Plus Vita
Documentation of lpp-vita
Sound

Module that handles audio features. More...

Enumerations

enum  ShutterId { IMAGE_CAPTURE , VIDEO_CAPTURE_START , VIDEO_CAPTURE_END }
 Shutter sound IDs for Sound.playShutter. More...
 

Functions

void Sound::init (void)
 Initialize audio subsystem. More...
 
void Sound::term (void)
 Terminate audio subsystem. More...
 
int Sound::open (string filename)
 Open an audio file. More...
 
void Sound::play (int music, bool loop)
 Play a sound. More...
 
void Sound::pause (int music)
 Pause a sound. More...
 
void Sound::resume (int music)
 Resume a sound. More...
 
void Sound::close (int music)
 Close an opened sound. More...
 
bool Sound::isPlaying (int music)
 Check if a given sound is in playing state. More...
 
void Sound::setVolume (int music, int volume)
 Set internal volume for a given sound. More...
 
int Sound::getVolume (int music)
 Get internal volume for a given sound. More...
 
string Sound::getTitle (int music)
 Get song title of a given sound. More...
 
string Sound::getAuthor (int music)
 Get song author of a given sound. More...
 
void Sound::playShutter (ShutterId id)
 Play a shutter sound. More...
 

Detailed Description

Module that handles audio features.

Enumeration Type Documentation

◆ ShutterId

enum ShutterId

Shutter sound IDs for Sound.playShutter.

Enumerator
IMAGE_CAPTURE 

Image capture shutter sound.

VIDEO_CAPTURE_START 

Video record start shutter sound.

VIDEO_CAPTURE_END 

Video record end shutter sound.

Function Documentation

◆ init()

void Sound::init ( void  )

Initialize audio subsystem.

Usage example:
Definition: luaSound.cpp:16
void init(void)
Initialize audio subsystem.

◆ term()

void Sound::term ( void  )

Terminate audio subsystem.

Usage example:
void term(void)
Terminate audio subsystem.

◆ open()

int Sound::open ( string  filename)

Open an audio file.

Usage example:
snd = Sound.open("ux0:/data/audio.opus")
int open(string filename)
Open an audio file.
Parameters
filename- Name of the file to open
Returns
A valid sound ID.
Note
Supported audio formats: .wav, .aif, .aiff, .opus, .ogg, .mid, .midi, .mp3.
This function can be used to reproduce audio track from a .pshv video file too.

◆ play()

void Sound::play ( int  music,
bool  loop 
)

Play a sound.

Usage example:
Sound.play(snd, NO_LOOP)
void play(int music, bool loop)
Play a sound.
Parameters
music- A valid sound ID.
loop- If true, playback will loop (optional).

◆ pause()

void Sound::pause ( int  music)

Pause a sound.

Usage example:
void pause(int music)
Pause a sound.
Parameters
music- A valid sound ID.

◆ resume()

void Sound::resume ( int  music)

Resume a sound.

Usage example:
void resume(int music)
Resume a sound.
Parameters
music- A valid sound ID.

◆ close()

void Sound::close ( int  music)

Close an opened sound.

Usage example:
void close(int music)
Close an opened sound.
Parameters
music- A valid sound ID.

◆ isPlaying()

bool Sound::isPlaying ( int  music)

Check if a given sound is in playing state.

Usage example:
if Sound.isPlaying(snd) then
Sound.pause(snd)
end
bool isPlaying(int music)
Check if a given sound is in playing state.
Parameters
music- A valid sound ID.
Returns
true if playing, false otherwise.

◆ setVolume()

void Sound::setVolume ( int  music,
int  volume 
)

Set internal volume for a given sound.

Usage example:
Sound.setVolume(snd, 100)
void setVolume(int music, int volume)
Set internal volume for a given sound.
Parameters
music- A valid sound ID.
volume- Volume value to set.
Note
volume must be in a range of 0 and 32767.

◆ getVolume()

int Sound::getVolume ( int  music)

Get internal volume for a given sound.

Usage example:
vol = Sound.getVolume(snd)
int getVolume(int music)
Get internal volume for a given sound.
Parameters
music- A valid sound ID.
Returns
Volume value of the given sound.

◆ getTitle()

string Sound::getTitle ( int  music)

Get song title of a given sound.

Usage example:
title = Sound.getTitle(snd)
string getTitle(int music)
Get song title of a given sound.
Parameters
music- A valid sound ID.
Returns
Song title of the given sound.
Note
This function works only with .ogg, .mp3, .opus and .wav audio files.

◆ getAuthor()

string Sound::getAuthor ( int  music)

Get song author of a given sound.

Usage example:
author = Sound.getAuthor(snd)
string getAuthor(int music)
Get song author of a given sound.
Parameters
music- A valid sound ID.
Returns
Song author of the given sound.
Note
This function works only with .ogg, .mp3, .opus and .wav audio files.

◆ playShutter()

void Sound::playShutter ( ShutterId  id)

Play a shutter sound.

Usage example:
void playShutter(ShutterId id)
Play a shutter sound.
@ IMAGE_CAPTURE
Image capture shutter sound.
Definition: luaSound.cpp:11
Parameters
id- A valid shutter sound ID.