Translated using Weblate.
[gammu.git] / include / gammu-ringtone.h
blob435509e41cf46844ccec381b3835bd6a26b119e4
1 /**
2 * \file gammu-ringtone.h
3 * \author Michal Čihař
5 * Ringtone data and functions.
6 */
7 #ifndef __gammu_ringtone_h
8 #define __gammu_ringtone_h
10 /**
11 * \defgroup Ringtone Ringtone
12 * Ringtones manipulations.
15 #include <gammu-types.h>
16 #include <gammu-error.h>
17 #include <gammu-limits.h>
18 #include <gammu-statemachine.h>
20 #include <stdio.h>
22 typedef enum {
23 /**
24 * Natural style (rest between notes)
26 NaturalStyle = 0x00 << 6,
27 /**
28 * Continuous style (no rest between notes)
30 ContinuousStyle = 0x01 << 6,
31 /**
32 * Staccato style (shorter notes and longer rest period)
34 StaccatoStyle = 0x02 << 6
35 } GSM_RingNoteStyle;
37 typedef enum {
38 Note_Pause = 0x00 << 4,
39 Note_C = 0x01 << 4,
40 Note_Cis = 0x02 << 4,
41 Note_D = 0x03 << 4,
42 Note_Dis = 0x04 << 4,
43 Note_E = 0x05 << 4,
44 Note_F = 0x06 << 4,
45 Note_Fis = 0x07 << 4,
46 Note_G = 0x08 << 4,
47 Note_Gis = 0x09 << 4,
48 Note_A = 0x0a << 4,
49 Note_Ais = 0x0b << 4,
50 Note_H = 0x0c << 4
51 } GSM_RingNoteNote;
53 typedef enum {
54 Duration_Full = 0x00 << 5,
55 Duration_1_2 = 0x01 << 5,
56 Duration_1_4 = 0x02 << 5,
57 Duration_1_8 = 0x03 << 5,
58 Duration_1_16 = 0x04 << 5,
59 Duration_1_32 = 0x05 << 5
60 } GSM_RingNoteDuration;
62 typedef enum {
63 NoSpecialDuration = 0x00 << 6,
64 DottedNote = 0x01 << 6,
65 DoubleDottedNote = 0x02 << 6,
66 Length_2_3 = 0x03 << 6
67 } GSM_RingNoteDurationSpec;
69 typedef enum {
70 /**
71 * 55 Hz for note A
73 Scale_55 = 1,
74 /**
75 * 110 Hz for note A
77 Scale_110,
78 Scale_220,
79 /**
80 * first scale for Nokia
82 Scale_440,
83 Scale_880,
84 Scale_1760,
85 /**
86 * last scale for Nokia
88 Scale_3520,
89 Scale_7040,
90 Scale_14080
91 } GSM_RingNoteScale;
93 typedef struct {
94 GSM_RingNoteDuration Duration;
95 GSM_RingNoteDurationSpec DurationSpec;
96 GSM_RingNoteNote Note;
97 GSM_RingNoteStyle Style;
98 GSM_RingNoteScale Scale;
99 int Tempo;
100 } GSM_RingNote;
102 typedef enum {
103 RING_Note = 1,
104 RING_EnableVibra,
105 RING_DisableVibra,
106 RING_EnableLight,
107 RING_DisableLight,
108 RING_EnableLED,
109 RING_DisableLED,
110 RING_Repeat
111 } GSM_RingCommandType;
113 typedef struct {
114 GSM_RingCommandType Type;
115 GSM_RingNote Note;
116 unsigned char Value;
117 } GSM_RingCommand;
119 typedef struct {
120 int NrCommands;
121 gboolean AllNotesScale;
122 GSM_RingCommand Commands[GSM_MAX_RINGTONE_NOTES];
123 } GSM_NoteRingtone;
125 /* FIXME: should use BinaryTone instead? */
126 /* Structure to hold Nokia binary ringtones. */
127 typedef struct {
128 unsigned char Frame[50000];
129 size_t Length;
130 } GSM_NokiaBinaryRingtone;
132 typedef struct {
133 unsigned char *Buffer;
134 size_t Length;
135 } GSM_BinaryTone;
137 typedef enum {
138 RING_NOTETONE = 1,
139 RING_NOKIABINARY,
140 RING_MIDI,
141 RING_MMF
142 } GSM_RingtoneFormat;
145 * Structure for saving various ringtones formats
147 typedef struct {
149 * Ringtone saved in one of three formats
151 GSM_NokiaBinaryRingtone NokiaBinary;
152 GSM_BinaryTone BinaryTone;
153 GSM_NoteRingtone NoteTone;
155 * Ringtone format
157 GSM_RingtoneFormat Format;
159 * Ringtone name
161 unsigned char Name[(GSM_MAX_RINGTONE_NAME_LENGTH + 1) * 2];
163 * Ringtone location
165 int Location;
166 } GSM_Ringtone;
168 typedef struct {
170 * Nokia specific
172 int Group;
173 int ID;
174 unsigned char Name[30 * 2];
175 } GSM_RingtoneInfo;
177 typedef struct {
178 int Number;
179 GSM_RingtoneInfo *Ringtone;
180 } GSM_AllRingtonesInfo;
183 * Play one note using state machine interface.
185 GSM_Error PHONE_RTTLPlayOneNote(GSM_StateMachine * s, GSM_RingNote note,
186 gboolean first);
189 * Makes phone beek using state machine interface.
191 GSM_Error PHONE_Beep(GSM_StateMachine * s);
194 * Gets ringtone from phone.
196 GSM_Error GSM_GetRingtone(GSM_StateMachine * s, GSM_Ringtone * Ringtone,
197 gboolean PhoneRingtone);
199 * Sets ringtone in phone.
201 GSM_Error GSM_SetRingtone(GSM_StateMachine * s, GSM_Ringtone * Ringtone,
202 int *maxlength);
204 * Acquires ringtone informaiton.
206 GSM_Error GSM_GetRingtonesInfo(GSM_StateMachine * s,
207 GSM_AllRingtonesInfo * Info);
209 * Deletes user defined ringtones from phone.
211 GSM_Error GSM_DeleteUserRingtones(GSM_StateMachine * s);
214 * Plays tone.
216 GSM_Error GSM_PlayTone(GSM_StateMachine * s, int Herz, unsigned char Volume,
217 gboolean start);
219 GSM_Error GSM_RingtoneConvert(GSM_Ringtone * dest, GSM_Ringtone * src,
220 GSM_RingtoneFormat Format);
221 GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone * ringtone);
223 GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone * ringtone);
225 GSM_Error GSM_SaveRingtoneOtt(FILE * file, GSM_Ringtone * ringtone);
227 GSM_Error GSM_SaveRingtoneMidi(FILE * file, GSM_Ringtone * ringtone);
229 GSM_Error GSM_SaveRingtoneIMelody(FILE * file, GSM_Ringtone * ringtone);
231 GSM_Error GSM_SaveRingtoneWav(FILE * file, GSM_Ringtone * ringtone);
233 GSM_Error GSM_SaveRingtoneRttl(FILE * file, GSM_Ringtone * ringtone);
236 * Returns ringtone name, NULL if not found.
238 const unsigned char *GSM_GetRingtoneName(const GSM_AllRingtonesInfo * Info, const int ID);
240 int GSM_RTTLGetTempo(int Beats);
242 #endif
244 /* Editor configuration
245 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: