Imported gammu 0.90.7
[gammu.git] / common / service / gsmring.h
blob8b34281c4bad4475218fbe0c5bfbf8623328ed1f
1 #ifndef __gsm_ringtones_h
2 #define __gsm_ringtones_h
4 /* --------------- Smart Messaging Specification 2.0 & 3.0 ----------------- */
6 /* Command-Part Encoding */
7 #define RingingToneProgramming (0x25<<1) /* binary 0100 101 */
8 #define Sound (0x1d<<1) /* binary 0011 101 */
9 /*...*/
11 /* Song-Type Encoding */
12 #define BasicSongType (0x01<<5) /* binary 001 */
13 /*...*/
15 /* Instruction ID Encoding */
16 #define PatternHeaderId (0x00<<5) /* binary 000 */
17 #define NoteInstructionId (0x01<<5) /* binary 001 */
18 #define ScaleInstructionId (0x02<<5) /* binary 010 */
19 #define StyleInstructionId (0x03<<5) /* binary 011 */
20 #define TempoInstructionId (0x04<<5) /* binary 100 */
21 #define VolumeInstructionId (0x05<<5) /* binary 101 */
23 /* Pattern ID Encoding */
24 #define A_part (0x00<<6) /* binary 00 */
25 /*...*/
27 /* Command-End */
28 #define CommandEnd (0x00) /* binary 00000000 */
30 /* ------ end of Smart Messaging Specification 2.0 & 3.0 definitions ------- */
32 #define MAX_RINGTONE_NOTES 255
34 /* Style-Value Encoding*/
35 typedef enum {
36 NaturalStyle = (0x00<<6), /* binary 00 */
37 ContinuousStyle = (0x01<<6), /* binary 01 */
38 StaccatoStyle = (0x02<<6) /* binary 10 */
39 } GSM_RingNoteStyle;
41 /* Note-Value Encoding */
42 typedef enum {
43 Note_Pause = (0x00<<4), /* binary 0000 */
44 Note_C = (0x01<<4), /* binary 0001 */
45 Note_Cis = (0x02<<4), /* binary 0010 */
46 Note_D = (0x03<<4), /* binary 0011 */
47 Note_Dis = (0x04<<4), /* binary 0100 */
48 Note_E = (0x05<<4), /* binary 0101 */
49 Note_F = (0x06<<4), /* binary 0110 */
50 Note_Fis = (0x07<<4), /* binary 0111 */
51 Note_G = (0x08<<4), /* binary 1000 */
52 Note_Gis = (0x09<<4), /* binary 1001 */
53 Note_A = (0x0a<<4), /* binary 1010 */
54 Note_Ais = (0x0b<<4), /* binary 1011 */
55 Note_H = (0x0c<<4) /* binary 1100 */
56 } GSM_RingNoteNote;
58 /* Note-Duration Encoding */
59 typedef enum {
60 Duration_Full = (0x00<<5), /* binary 000 */
61 Duration_1_2 = (0x01<<5), /* binary 001 */
62 Duration_1_4 = (0x02<<5), /* binary 010 */
63 Duration_1_8 = (0x03<<5), /* binary 011 */
64 Duration_1_16 = (0x04<<5), /* binary 100 */
65 Duration_1_32 = (0x05<<5) /* binary 101 */
66 } GSM_RingNoteDuration;
68 /* Note-Duration-Specifier Encoding */
69 typedef enum {
70 NoSpecialDuration = (0x00<<6), /* binary 00 */
71 DottedNote = (0x01<<6), /* binary 01 */
72 DoubleDottedNote = (0x02<<6), /* binary 10 */
73 Length_2_3 = (0x03<<6), /* binary 11 */
74 } GSM_RingNoteDurationSpec;
76 typedef enum {
77 Scale_55 = 1, /* 55 Hz for note A */
78 Scale_110, /* 110 Hz for note A */
79 Scale_220,
80 Scale_440, /* first scale for Nokia phones */
81 Scale_880,
82 Scale_1760,
83 Scale_3520, /* last scale for Nokia phones */
84 Scale_7040,
85 Scale_14080
86 } GSM_RingNoteScale;
88 typedef struct {
89 GSM_RingNoteDuration Duration;
90 GSM_RingNoteDurationSpec DurationSpec;
91 GSM_RingNoteNote Note;
92 GSM_RingNoteStyle Style;
93 GSM_RingNoteScale Scale;
94 int Tempo;
95 } GSM_RingNote;
97 typedef enum {
98 RING_Note = 1,
99 RING_EnableVibra,
100 RING_DisableVibra,
101 RING_EnableLight,
102 RING_DisableLight,
103 RING_EnableLED,
104 RING_DisableLED,
105 RING_Repeat
106 } GSM_RingCommandType;
108 typedef struct {
109 GSM_RingCommandType Type;
110 GSM_RingNote Note;
111 unsigned char Value;
112 } GSM_RingCommand;
114 typedef struct {
115 int NrCommands;
116 GSM_RingCommand Commands[MAX_RINGTONE_NOTES];
117 bool AllNotesScale;
118 } GSM_NoteRingtone;
120 /* Structure to hold Nokia binary ringtones. */
121 typedef struct {
122 unsigned char Frame[30000];
123 int Length;
124 } GSM_NokiaBinaryRingtone;
126 typedef struct {
127 unsigned char *Frame;
128 int Length;
129 } GSM_BinaryTone;
131 typedef enum {
132 RING_NOTETONE = 1,
133 RING_NOKIABINARY,
134 RING_MIDI
135 } GSM_RingtoneFormat;
137 typedef struct {
138 GSM_NokiaBinaryRingtone NokiaBinary;
140 GSM_BinaryTone BinaryTone;
141 GSM_NoteRingtone NoteTone;
142 GSM_RingtoneFormat Format;
143 char Name[20*2];
144 int Location;
145 } GSM_Ringtone;
147 typedef struct {
148 int ID;
149 char Name[30*2];
150 } GSM_RingtoneInfo;
152 typedef struct {
153 int Number;
154 GSM_RingtoneInfo Ringtone[100];
155 } GSM_AllRingtonesInfo;
157 GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone);
158 GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone);
160 GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone);
162 unsigned char GSM_EncodeNokiaRTTLRingtone (GSM_Ringtone ringtone, unsigned char *package, int *maxlength);
163 unsigned char GSM_EncodeEMSSound (GSM_Ringtone ringtone, unsigned char *package, int *maxlength, double version, bool start);
165 GSM_Error GSM_DecodeNokiaRTTLRingtone (GSM_Ringtone *ringtone, unsigned char *package, int maxlength);
167 GSM_Error GSM_RingtoneConvert(GSM_Ringtone *dest, GSM_Ringtone *src, GSM_RingtoneFormat Format);
169 int GSM_RTTLGetTempo (int Beats);
170 int GSM_RingNoteGetFrequency (GSM_RingNote Note);
171 int GSM_RingNoteGetFullDuration (GSM_RingNote Note);
173 char *GSM_GetRingtoneName(GSM_AllRingtonesInfo *Info, int ID);
175 #endif
177 /* How should editor hadle tabs in this file? Add editor commands here.
178 * vim: noexpandtab sw=8 ts=8 sts=8: