2014-09-12 16:08:58 -04:00
|
|
|
/**
|
|
|
|
* @file
|
2013-12-24 20:17:44 -05:00
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-06-21 09:37:47 -04:00
|
|
|
#ifndef OCARINA_CORE_AUDIO_H
|
|
|
|
#define OCARINA_CORE_AUDIO_H
|
2013-12-24 20:17:44 -05:00
|
|
|
|
2014-12-02 08:16:22 -05:00
|
|
|
#include <core/tags/track.h>
|
2014-01-22 22:31:42 -05:00
|
|
|
#include <string>
|
|
|
|
|
2014-09-12 16:08:58 -04:00
|
|
|
/**
|
|
|
|
* Namespace for higher-level audio controls.
|
|
|
|
*/
|
2013-12-24 20:17:44 -05:00
|
|
|
namespace audio
|
|
|
|
{
|
|
|
|
|
2014-09-12 16:08:58 -04:00
|
|
|
/**
|
|
|
|
* Initializes the audio layer and currently configured audio driver.
|
|
|
|
*
|
|
|
|
* @param argc Pointer to the argc initially passed to core :: init().
|
|
|
|
* @param argv Pointer to the argv initially passed to core :: init().
|
|
|
|
*/
|
2013-12-24 20:17:44 -05:00
|
|
|
void init(int *, char ***);
|
|
|
|
|
2014-12-19 13:45:34 -05:00
|
|
|
void play(); /** Begin playback. */
|
|
|
|
void pause(); /** Pause playback. */
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Seek to a specific point in the track.
|
|
|
|
*
|
|
|
|
* @param pos Offset (in nanoseconds) from the beginning of the track.
|
|
|
|
*/
|
2014-06-01 17:52:49 -04:00
|
|
|
void seek_to(long);
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop playback (equivalent to pause(); seek_to(0);).
|
|
|
|
*/
|
2014-01-04 13:09:44 -05:00
|
|
|
void stop();
|
2013-12-24 20:17:44 -05:00
|
|
|
|
2014-09-12 16:08:58 -04:00
|
|
|
/**
|
|
|
|
* @return The current position of the audio playback (in nanoseconds).
|
|
|
|
*/
|
2013-12-24 22:07:23 -05:00
|
|
|
long position();
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return The duration of the currently loaded track (in nanoseconds).
|
|
|
|
*/
|
2013-12-24 22:07:23 -05:00
|
|
|
long duration();
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return The current audio position, in a human readable format.
|
|
|
|
*/
|
2014-06-01 17:52:49 -04:00
|
|
|
std::string position_str();
|
|
|
|
|
2014-12-19 13:45:34 -05:00
|
|
|
void next(); /** Find and load the next track that should be played. */
|
|
|
|
void prev(); /** Call the deck :: previous() function and load the result. */
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a specific track for playback.
|
2014-12-19 13:45:34 -05:00
|
|
|
*
|
|
|
|
* @param track The track that should be loaded.
|
2014-09-12 16:08:58 -04:00
|
|
|
*/
|
2014-06-01 17:52:49 -04:00
|
|
|
void load_track(Track *track);
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return A pointer to the currently playing track object.
|
|
|
|
*/
|
2014-06-01 17:52:49 -04:00
|
|
|
Track *current_track();
|
2013-12-25 14:35:33 -05:00
|
|
|
|
2014-09-12 16:08:58 -04:00
|
|
|
/**
|
|
|
|
* Configure the automatic pausing feature.
|
|
|
|
*
|
|
|
|
* @param enabled Set to true to enable pausing, false to disable.
|
|
|
|
* @param n Number of tracks to play before pausing.
|
|
|
|
*/
|
2013-12-25 14:35:33 -05:00
|
|
|
void pause_after(bool, unsigned int);
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call to find the current automatic pausing state.
|
|
|
|
*
|
|
|
|
* @return True if automatic pausing is enabled, false otherwise.
|
|
|
|
*/
|
2013-12-25 14:35:33 -05:00
|
|
|
bool pause_enabled();
|
2014-09-12 16:08:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call to find the number of tracks remaining before pausing.
|
|
|
|
*
|
|
|
|
* @return The number of tracks before pausing.
|
|
|
|
*/
|
2013-12-25 14:35:33 -05:00
|
|
|
unsigned int pause_count();
|
2013-12-24 20:17:44 -05:00
|
|
|
};
|
|
|
|
|
2014-06-21 09:37:47 -04:00
|
|
|
#endif /* OCARINA_CORE_AUDIO_H */
|