28 # error This is a userspace-only header, not allowed by the current build.
31 #include <sifteo/asset.h>
32 #include <sifteo/abi.h>
51 _SYSAudioChannelID sys;
52 typedef _SYSAudioChannelID AudioChannelID;
55 static const AudioChannelID
UNDEFINED = _SYS_AUDIO_INVALID_CHANNEL_ID;
58 static const AudioChannelID
NUM_CHANNELS = _SYS_AUDIO_MAX_CHANNELS;
92 void init(AudioChannelID
id)
94 ASSERT(
id < NUM_CHANNELS &&
"AudioChannel ID is invalid");
105 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
106 return _SYS_audio_play(&asset.sys, sys, (_SYSAudioLoopType) loopMode);
114 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
115 return _SYS_audio_isPlaying(sys);
125 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
126 _SYS_audio_stop(sys);
136 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
137 _SYS_audio_pause(sys);
147 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
148 _SYS_audio_resume(sys);
158 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
159 _SYS_audio_setVolume(sys, volume);
170 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
171 _SYS_audio_setSpeed(sys, hz);
179 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
180 return _SYS_audio_volume(sys);
185 ASSERT(sys < NUM_CHANNELS &&
"AudioChannel has invalid ID");
186 return _SYS_audio_pos(sys);
203 return _SYS_tracker_play(&asset.song);
210 return _SYS_tracker_play(0);
217 _SYS_tracker_pause();
233 return _SYS_tracker_isStopped();
240 return _SYS_tracker_isPaused();
250 static void setVolume(
int volume, _SYSAudioChannelID ch = -1)
252 ASSERT(volume >= 0 && volume <= _SYS_AUDIO_MAX_VOLUME);
253 _SYS_tracker_setVolume(volume, ch);
265 _SYS_tracker_setTempoModifier(modifier);
277 _SYS_tracker_setPosition(phrase, row);
LoopMode
Loop modes available for use in play()
Definition: audio.h:64
AudioChannel(AudioChannelID id)
Initialize an AudioChannel with a concrete value.
Definition: audio.h:85
static bool play(const AssetTracker &asset)
Begin playback of a module.
Definition: audio.h:202
static void pause()
Pause playback of a module.
Definition: audio.h:216
#define ASSERT(_x)
Runtime debug assertion.
Definition: macros.h:205
AudioChannel()
Default constructor.
Definition: audio.h:76
static const AudioChannelID NUM_CHANNELS
The maximum number of supported AudioChannels in the system.
Definition: audio.h:58
static void stop()
Stop playback of the current module.
Definition: audio.h:225
void pause() const
Pause the currently playing sample in this channel.
Definition: audio.h:134
Playback interface for Tracker modules.
Definition: audio.h:197
bool isPlaying() const
Is this channel currently playing a sample?
Definition: audio.h:112
void setSpeed(unsigned hz) const
Sets the speed of this channel, in samples per second.
Definition: audio.h:168
void setVolume(int volume) const
Definition: audio.h:156
static void setPosition(uint16_t phrase, uint16_t row)
Set play position for current song.
Definition: audio.h:275
static bool isStopped()
Is the tracker currently playing a module?
Definition: audio.h:232
static bool resume()
Resume playback of a paused module.
Definition: audio.h:209
void resume() const
Resume playback on this channel.
Definition: audio.h:145
static const AudioChannelID UNDEFINED
A reserved ID, used to mark undefined AudioChannels.
Definition: audio.h:55
static void setVolume(int volume, _SYSAudioChannelID ch=-1)
Scale volume for current channel.
Definition: audio.h:250
A Tracker module, converted from XM format by stir
Definition: asset/audio.h:112
An audio asset, using any supported compression codec.
Definition: asset/audio.h:50
static bool isPaused()
Is the tracker currently playing a module?
Definition: audio.h:239
void stop() const
Stop playback of the current sample.
Definition: audio.h:123
bool play(const AssetAudio &asset, LoopMode loopMode=UNDEF_LOOP) const
Begin playback of a sample.
Definition: audio.h:103
static const int32_t MAX_VOLUME
The maximum volume for an AudioChannel.
Definition: audio.h:61
static void setTempoModifier(int modifier)
Scale tempo for current song.
Definition: audio.h:262
void init(AudioChannelID id)
Initialize a channel by assignging it an ID.
Definition: audio.h:92
One mixer channel, capable of playing AudioAssets.
Definition: audio.h:50
int volume() const
Get the current volume for this channel.
Definition: audio.h:177