v1.1.0
Home
Guides
Modules
Reference
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
sdk
include
sifteo
asset
asset/audio.h
1
/* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-
2
*
3
* This file is part of the public interface to the Sifteo SDK.
4
* Copyright <c> 2012 Sifteo, Inc. All rights reserved.
5
*/
6
7
#pragma once
8
9
/*
10
* This header needs to work in both userspace and non-userspace builds.
11
*/
12
13
#include <sifteo/abi.h>
14
15
namespace
Sifteo {
16
31
struct
AssetAudio
{
32
_SYSAudioModule sys;
33
39
unsigned
speed
()
const
{
40
return
sys.sampleRate;
41
}
42
55
static
AssetAudio
fromPCM
(
const
int16_t *samples,
unsigned
numSamples)
56
{
57
const
AssetAudio
result = {{
58
/* sampleRate */
0,
59
/* loopStart */
0,
60
/* loopEnd */
numSamples,
61
/* loopType */
_SYS_LOOP_REPEAT,
62
/* type */
_SYS_PCM,
63
/* volume */
_SYS_AUDIO_DEFAULT_VOLUME,
64
/* dataSize */
numSamples *
sizeof
samples[0],
65
/* pData */
reinterpret_cast<
uintptr_t
>
(samples),
66
}};
67
return
result;
68
}
69
71
template
<
typename
T>
72
static
AssetAudio
fromPCM
(
const
T &samples) {
73
return
fromPCM
(&samples[0],
arraysize
(samples));
74
}
75
};
76
93
struct
AssetTracker
{
94
_SYSXMSong song;
95
97
unsigned
numChannels
()
const
{
98
return
song.nChannels;
99
}
100
102
unsigned
numPatterns
()
const
{
103
return
song.nPatterns;
104
}
105
107
unsigned
numInstruments
()
const
{
108
return
song.nInstruments;
109
}
110
112
unsigned
tempo
()
const
{
113
return
song.tempo;
114
}
115
117
unsigned
bpm
()
const
{
118
return
song.bpm;
119
}
120
};
121
126
};
// namespace Sifteo
Sifteo
SDK v1.1.0
(see
all versions
)
Last updated Thu Nov 14 2013, by
Doxygen