:pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
[gnokii.git] / include / gsm-ringtones.h
1 /*
2
3   $Id$
4
5   G N O K I I
6
7   A Linux/Unix toolset and driver for Nokia mobile phones.
8
9   Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
10
11   Released under the terms of the GNU GPL, see file COPYING for more details.
12
13   This file provides definitions of macros from the Smart Messaging
14   Specification. It is mainly rewrite of the spec to C :-) Viva Nokia!
15
16   $Log$
17   Revision 1.1.1.1  2001/11/25 21:59:20  short
18   :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
19
20   Revision 1.2  2001/06/28 00:28:46  pkot
21   Small docs updates (Pawel Kot)
22
23
24 */
25
26 #ifndef __gsm_ringtones_h
27 #define __gsm_ringtones_h
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <ctype.h>
33 #include "misc.h"
34 #include "gsm-common.h"
35
36 #define GetBit(Stream,BitNr) Stream[(BitNr)/8] & 1<<(7-((BitNr)%8))
37 #define SetBit(Stream,BitNr) Stream[(BitNr)/8] |= 1<<(7-((BitNr)%8))
38 #define ClearBit(Stream,BitNr) Stream[(BitNr)/8] &= 255 - (1 << (7-((BitNr)%8)))
39
40 /* These values are from Smart Messaging Specification Revision 2.0.0 pages
41    3-23, ..., 3-29 */
42
43 /* Command-Part Encoding */
44
45 #define CancelCommand          (0x05<<1) /* binary 0000 101 */
46 #define RingingToneProgramming (0x25<<1) /* binary 0100 101 */
47 #define Sound                  (0x1d<<1) /* binary 0011 101 */
48 #define Unicode                (0x22<<1) /* binary 0100 010 */
49
50 /* Song-Type Encoding */
51
52 #define BasicSongType     (0x01<<5) /* binary 001 */
53 #define TemporarySongType (0x02<<5) /* binary 010 */
54 #define MidiSongType      (0x03<<5) /* binary 011 */
55 #define DigitizedSongType (0x04<<5) /* binary 100 */
56
57 /* Instruction ID Encoding */
58
59 #define PatternHeaderId      (0x00<<5) /* binary 000 */
60 #define NoteInstructionId    (0x01<<5) /* binary 001 */
61 #define ScaleInstructionId   (0x02<<5) /* binary 010 */
62 #define StyleInstructionId   (0x03<<5) /* binary 011 */
63 #define TempoInstructionId   (0x04<<5) /* binary 100 */
64 #define VolumeInstructionId (0x05<<5) /* binary 101 */
65
66 /* Style-Value Encoding*/
67
68 #define NaturalStyle    (0x00<<6) /* binary 00 */
69 #define ContinuousStyle (0x01<<6) /* binary 01 */
70 #define StaccatoStyle   (0x02<<6) /* binary 11 */
71
72 /* Note-Scale Encoding  */
73
74 #define Scale1 (0x00<<6) /* binary 00 */
75 #define Scale2 (0x01<<6) /* binary 01 */
76 #define Scale3 (0x02<<6) /* binary 10 */
77 #define Scale4 (0x03<<6) /* binary 11 */
78
79 /* Note-Value Encoding */
80
81 #define Note_Pause (0x00<<4) /* binary 0000 */
82 #define Note_C     (0x01<<4) /* binary 0001 */
83 #define Note_Cis   (0x02<<4) /* binary 0010 */
84 #define Note_D     (0x03<<4) /* binary 0011 */
85 #define Note_Dis   (0x04<<4) /* binary 0100 */
86 #define Note_E     (0x05<<4) /* binary 0101 */
87 #define Note_F     (0x06<<4) /* binary 0110 */
88 #define Note_Fis   (0x07<<4) /* binary 0111 */
89 #define Note_G     (0x08<<4) /* binary 1000 */
90 #define Note_Gis   (0x09<<4) /* binary 1001 */
91 #define Note_A     (0x0a<<4) /* binary 1010 */
92 #define Note_Ais   (0x0b<<4) /* binary 1011 */
93 #define Note_H     (0x0c<<4) /* binary 1100 */
94
95 /* Note-Duration Encoding */
96
97 #define Duration_Full (0x00<<5) /* binary 000 */
98 #define Duration_1_2  (0x01<<5) /* binary 001 */
99 #define Duration_1_4  (0x02<<5) /* binary 010 */
100 #define Duration_1_8  (0x03<<5) /* binary 011 */
101 #define Duration_1_16 (0x04<<5) /* binary 100 */
102 #define Duration_1_32 (0x05<<5) /* binary 101 */
103
104 /* Note-Duration-Specifier Encoding */
105
106 #define NoSpecialDuration (0x00<<6) /* binary 00 */
107 #define DottedNote        (0x01<<6) /* binary 01 */
108 #define DoubleDottedNote  (0x02<<6) /* binary 10 */
109 #define Length_2_3        (0x03<<6) /* binary 11 */
110
111 /* Pattern ID Encoding */
112 #define A_part (0x00<<6) /* binary 00 */
113 #define B_part (0x01<<6) /* binary 01 */
114 #define C_part (0x02<<6) /* binary 10 */
115 #define D_part (0x03<<6) /* binary 11 */
116
117 /* Command-End */
118
119 #define CommandEnd (0x00) /* binary 00000000 */
120
121 /* Definition of the Note type */
122
123 typedef struct {
124   int Scale;
125   int NoteID;
126   int Duration;
127   int DurationSpecifier;
128 } Note;
129
130 #define GSM_MAX_RINGTONE_PACKAGE_LENGTH 200
131
132 /* From PC Composer help */
133 #define GSM_MAX_RINGTONE_NOTES 130
134
135 u8 GSM_PackRingtone(GSM_Ringtone *ringtone, char *package, int *maxlength);
136 GSM_Error GSM_UnPackRingtone(GSM_Ringtone *ringtone, char *package, int maxlength);
137
138 int GSM_GetNote(int number);
139
140 #endif  /* __gsm_ringtones_h */