summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service/gsmring.h
Unidiff
Diffstat (limited to 'gammu/emb/common/service/gsmring.h') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmring.h202
1 files changed, 202 insertions, 0 deletions
diff --git a/gammu/emb/common/service/gsmring.h b/gammu/emb/common/service/gsmring.h
new file mode 100644
index 0000000..207cf31
--- a/dev/null
+++ b/gammu/emb/common/service/gsmring.h
@@ -0,0 +1,202 @@
1/* (c) 2002-2004 by Marcin Wiacek */
2
3#ifndef __gsm_ring_h
4#define __gsm_ring_h
5
6/* --------------- Smart Messaging Specification 2.0 & 3.0 ----------------- */
7
8 #define SM_CommandEnd_CommandEnd 0x00
9
10/* specification gives also other */
11 #define SM_Command_RingingToneProgramming 0x25<<1
12 #define SM_Command_Sound 0x1d<<1
13/* specification gives also other */
14
15 #define SM_Song_BasicSongType 0x01<<5
16/* specification gives also other */
17
18 #define SM_PatternID_A_part 0x00<<6
19/* specification gives also other */
20
21 #define SM_InstructionID_PatternHeaderId 0x00<<5
22 #define SM_InstructionID_NoteInstructionId 0x01<<5
23 #define SM_InstructionID_ScaleInstructionId 0x02<<5
24 #define SM_InstructionID_StyleInstructionId 0x03<<5
25 #define SM_InstructionID_TempoInstructionId 0x04<<5
26 #define SM_InstructionID_VolumeInstructionId 0x05<<5
27
28/* ------ end of Smart Messaging Specification 2.0 & 3.0 definitions ------- */
29
30#define MAX_RINGTONE_NOTES 255
31
32typedef enum {
33 /**
34 * Natural style (rest between notes)
35 */
36 NaturalStyle = 0x00<<6,
37 /**
38 * Continuous style (no rest between notes)
39 */
40 ContinuousStyle = 0x01<<6,
41 /**
42 * Staccato style (shorter notes and longer rest period)
43 */
44 StaccatoStyle = 0x02<<6
45} GSM_RingNoteStyle;
46
47typedef enum {
48 Note_Pause = 0x00<<4,
49 Note_C = 0x01<<4,
50 Note_Cis = 0x02<<4,
51 Note_D = 0x03<<4,
52 Note_Dis = 0x04<<4,
53 Note_E = 0x05<<4,
54 Note_F = 0x06<<4,
55 Note_Fis = 0x07<<4,
56 Note_G = 0x08<<4,
57 Note_Gis = 0x09<<4,
58 Note_A = 0x0a<<4,
59 Note_Ais = 0x0b<<4,
60 Note_H = 0x0c<<4
61} GSM_RingNoteNote;
62
63typedef enum {
64 Duration_Full = 0x00<<5,
65 Duration_1_2 = 0x01<<5,
66 Duration_1_4 = 0x02<<5,
67 Duration_1_8 = 0x03<<5,
68 Duration_1_16 = 0x04<<5,
69 Duration_1_32 = 0x05<<5
70} GSM_RingNoteDuration;
71
72typedef enum {
73 NoSpecialDuration = 0x00<<6,
74 DottedNote = 0x01<<6,
75 DoubleDottedNote = 0x02<<6,
76 Length_2_3 = 0x03<<6
77} GSM_RingNoteDurationSpec;
78
79typedef enum {
80 Scale_55 = 1, /* 55 Hz for note A */
81 Scale_110, /* 110 Hz for note A */
82 Scale_220,
83 Scale_440, /* first scale for Nokia */
84 Scale_880,
85 Scale_1760,
86 Scale_3520, /* last scale for Nokia */
87 Scale_7040,
88 Scale_14080
89} GSM_RingNoteScale;
90
91typedef struct {
92 GSM_RingNoteDuration Duration;
93 GSM_RingNoteDurationSpec DurationSpec;
94 GSM_RingNoteNote Note;
95 GSM_RingNoteStyle Style;
96 GSM_RingNoteScale Scale;
97 int Tempo;
98} GSM_RingNote;
99
100typedef enum {
101 RING_Note = 1,
102 RING_EnableVibra,
103 RING_DisableVibra,
104 RING_EnableLight,
105 RING_DisableLight,
106 RING_EnableLED,
107 RING_DisableLED,
108 RING_Repeat
109} GSM_RingCommandType;
110
111typedef struct {
112 GSM_RingCommandType Type;
113 GSM_RingNote Note;
114 unsigned char Value;
115} GSM_RingCommand;
116
117typedef struct {
118 int NrCommands;
119 GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
120 bool AllNotesScale;
121} GSM_NoteRingtone;
122
123/* Structure to hold Nokia binary ringtones. */
124typedef struct {
125 unsigned char Frame[30000];
126 int Length;
127} GSM_NokiaBinaryRingtone;
128
129typedef struct {
130 unsigned char *Frame;
131 int Length;
132} GSM_BinaryTone;
133
134typedef enum {
135 RING_NOTETONE = 1,
136 RING_NOKIABINARY,
137 RING_MIDI
138} GSM_RingtoneFormat;
139
140/**
141 * Structure for saving various ringtones formats
142 */
143typedef struct {
144 /**
145 * Ringtone saved in one of three formats
146 */
147 GSM_NokiaBinaryRingtone NokiaBinary;
148 GSM_BinaryTone BinaryTone;
149 GSM_NoteRingtone NoteTone;
150 /**
151 * Ringtone format
152 */
153 GSM_RingtoneFormat Format;
154 /**
155 * Ringtone name
156 */
157 char Name[20*2];
158 /**
159 * Ringtone location
160 */
161 int Location;
162} GSM_Ringtone;
163
164typedef struct {
165 int Group;//Nokia specific
166 int ID;
167 char Name[30*2];
168} GSM_RingtoneInfo;
169
170typedef struct {
171 int Number;
172 GSM_RingtoneInfo Ringtone[100];
173} GSM_AllRingtonesInfo;
174
175GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone);
176GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone);
177
178void saveott(FILE *file, GSM_Ringtone *ringtone);
179void savemid(FILE *file, GSM_Ringtone *ringtone);
180void saverng(FILE *file, GSM_Ringtone *ringtone);
181void saveimelody(FILE *file, GSM_Ringtone *ringtone);
182GSM_Error savewav(FILE *file, GSM_Ringtone *ringtone);
183GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone);
184
185 unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone ringtone, unsigned char *package, int *maxlength);
186 unsigned char GSM_EncodeEMSSound (GSM_Ringtone ringtone, unsigned char *package, int *maxlength, double version, bool start);
187
188 GSM_Error GSM_DecodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, int maxlength);
189
190 GSM_Error GSM_RingtoneConvert(GSM_Ringtone *dest, GSM_Ringtone *src, GSM_RingtoneFormatFormat);
191
192 int GSM_RTTLGetTempo (int Beats);
193 int GSM_RingNoteGetFrequency(GSM_RingNote Note);
194 int GSM_RingNoteGetFullDuration(GSM_RingNote Note);
195
196char *GSM_GetRingtoneName(GSM_AllRingtonesInfo *Info, int ID);
197
198#endif
199
200/* How should editor hadle tabs in this file? Add editor commands here.
201 * vim: noexpandtab sw=8 ts=8 sts=8:
202 */