v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
abi/audio.h
1 /* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-
2  *
3  * Sifteo SDK
4  *
5  * Copyright <c> 2012 Sifteo, Inc.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  */
25 
26 #ifndef _SIFTEO_ABI_AUDIO_H
27 #define _SIFTEO_ABI_AUDIO_H
28 
29 #include <sifteo/abi/types.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 
36 typedef uint8_t _SYSAudioChannelID;
37 
38 #define _SYS_AUDIO_INVALID_CHANNEL_ID ((_SYSAudioChannelID)-1)
39 #define _SYS_AUDIO_MAX_CHANNELS 8
40 
41 #define _SYS_AUDIO_MAX_VOLUME_LOG2 8
42 #define _SYS_AUDIO_MAX_VOLUME (1 << _SYS_AUDIO_MAX_VOLUME_LOG2)
43 #define _SYS_AUDIO_DEFAULT_VOLUME (_SYS_AUDIO_MAX_VOLUME / 2)
44 
45 
46 /*
47  * Types of audio supported by the system
48  */
49 enum _SYSAudioType {
50  _SYS_PCM = 1,
51  _SYS_ADPCM = 2
52 };
53 
54 enum _SYSAudioLoopType {
55  _SYS_LOOP_UNDEF = -1,
56  _SYS_LOOP_ONCE = 0,
57  _SYS_LOOP_REPEAT = 1,
58  _SYS_LOOP_EMULATED_PING_PONG = 2,
59 };
60 
61 struct _SYSAudioModule {
62  uint32_t sampleRate;
63  uint32_t loopStart;
64  uint32_t loopEnd;
65  uint8_t loopType;
66  uint8_t type;
67  uint16_t volume;
68  uint32_t dataSize;
69  uint32_t pData;
70 };
71 
72 struct _SYSXMPattern {
73  uint16_t nRows;
74  uint16_t dataSize;
75  uint32_t pData;
76 };
77 
78 struct _SYSXMInstrument {
79  struct _SYSAudioModule sample;
80  int8_t finetune;
81  int8_t relativeNoteNumber;
82  uint8_t compression;
83 
84  uint32_t volumeEnvelopePoints;
85  uint8_t nVolumeEnvelopePoints;
86  uint8_t volumeSustainPoint;
87  uint8_t volumeLoopStartPoint;
88  uint8_t volumeLoopEndPoint;
89  uint8_t volumeType;
90  uint8_t vibratoType;
91  uint8_t vibratoSweep;
92  uint8_t vibratoDepth;
93  uint8_t vibratoRate;
94  uint16_t volumeFadeout;
95 };
96 
97 struct _SYSXMSong {
98  uint32_t patternOrderTable;
99  uint16_t patternOrderTableSize;
100  uint8_t restartPosition;
101  uint8_t nChannels;
102 
103  uint16_t nPatterns;
104  uint32_t patterns;
105 
106  uint8_t nInstruments;
107  uint32_t instruments;
108 
109  uint8_t frequencyTable;
110  uint16_t tempo;
111  uint16_t bpm;
112 };
113 
114 #ifdef __cplusplus
115 } // extern "C"
116 #endif
117 
118 #endif