Gammu internals
1.38.0
|
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <sys/stat.h>
#include <gammu-debug.h>
#include <gammu-unicode.h>
#include "../misc/coding/coding.h"
#include "gsmring.h"
#include "../debug.h"
Go to the source code of this file.
Macros | |
#define | chk_fwrite(data, size, count, file) if (fwrite(data, size, count, file) != count) goto fail; |
#define | PI 3.141592654 |
#define | WAV_SAMPLE_RATE 44100 |
Variables | |
static int | SM_BeatsPerMinute [] |
#define chk_fwrite | ( | data, | |
size, | |||
count, | |||
file | |||
) | if (fwrite(data, size, count, file) != count) goto fail; |
Helper define to check error code from fwrite.
Definition at line 37 of file gsmring.c.
Referenced by GSM_SaveRingtoneIMelody(), GSM_SaveRingtoneMidi(), GSM_SaveRingtoneOtt(), GSM_SaveRingtoneWav(), savebin(), savemmf(), and savepuremidi().
#define PI 3.141592654 |
Definition at line 100 of file gsmring.c.
Referenced by GSM_SaveRingtoneWav().
#define WAV_SAMPLE_RATE 44100 |
Definition at line 103 of file gsmring.c.
Referenced by GSM_SaveRingtoneWav().
|
static |
Definition at line 1328 of file gsmring.c.
References GSM_NoteRingtone::AllNotesScale, GSM_NoteRingtone::Commands, ContinuousStyle, dbgprintf, DottedNote, DoubleDottedNote, GSM_RingNote::Duration, Duration_1_16, Duration_1_2, Duration_1_32, Duration_1_4, Duration_1_8, Duration_Full, Duration_INVALID, GSM_RingNote::DurationSpec, FALSE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, Length_2_3, GSM_Ringtone::NokiaBinary, NoSpecialDuration, GSM_RingNote::Note, GSM_RingCommand::Note, Note_A, Note_Ais, Note_C, Note_Cis, Note_D, Note_Dis, Note_E, Note_F, Note_Fis, Note_G, Note_Gis, Note_H, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_Note, GSM_RingNote::Scale, Scale_1760, Scale_3520, Scale_440, Scale_880, GSM_RingNote::Style, GSM_RingNote::Tempo, TRUE, and GSM_RingCommand::Type.
Referenced by GSM_RingtoneConvert().
GSM_Error GSM_DecodeNokiaRTTLRingtone | ( | GSM_Ringtone * | ringtone, |
unsigned char * | package, | ||
size_t maxlength | UNUSED | ||
) |
Definition at line 1128 of file gsmring.c.
References BufferAlignNumber(), GSM_NoteRingtone::Commands, CopyUnicodeString(), dbgprintf, DecodeUnicodeSpecialNOKIAChars(), GSM_RingNote::Duration, Duration_1_32, Duration_Full, GSM_RingNote::DurationSpec, EncodeUnicode(), ERR_NONE, ERR_NOTSUPPORTED, GSM_Ringtone::Format, GetBuffer(), GetBufferInt(), GSM_MAX_RINGTONE_NOTES, Length_2_3, GSM_Ringtone::Name, NaturalStyle, NoSpecialDuration, GSM_RingNote::Note, GSM_RingCommand::Note, Note_C, Note_H, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_Note, RING_NOTETONE, GSM_RingNote::Scale, Scale_880, SM_BeatsPerMinute, SM_Command_RingingToneProgramming, SM_Command_Sound, SM_InstructionID_NoteInstructionId, SM_InstructionID_PatternHeaderId, SM_InstructionID_ScaleInstructionId, SM_InstructionID_StyleInstructionId, SM_InstructionID_TempoInstructionId, SM_InstructionID_VolumeInstructionId, SM_Song_BasicSongType, StaccatoStyle, GSM_RingNote::Style, GSM_RingNote::Tempo, GSM_RingCommand::Type, and UnicodeLength().
Referenced by GSM_DecodeMultiPartSMS(), loadcommunicator(), and loadott().
unsigned char GSM_EncodeEMSSound | ( | GSM_Ringtone * | ringtone, |
unsigned char * | package, | ||
size_t * | maxlength, | ||
GSM_RingtoneVersion | version, | ||
gboolean | start | ||
) |
Definition at line 1565 of file gsmring.c.
References GSM_NoteRingtone::Commands, ContinuousStyle, dbgprintf, DecodeUnicodeString(), DottedNote, DoubleDottedNote, GSM_RingNote::Duration, Duration_1_16, Duration_1_2, Duration_1_32, Duration_1_4, Duration_1_8, Duration_Full, GSM_RingNote::DurationSpec, FALSE, GSM_Ring_IMelody10, GSM_Ring_IMelody12, GSM_Ring_NoHeader, INVALIDStyle, Length_2_3, GSM_Ringtone::Name, NaturalStyle, GSM_RingNote::Note, GSM_RingCommand::Note, Note_A, Note_Ais, Note_C, Note_Cis, Note_D, Note_Dis, Note_E, Note_F, Note_Fis, Note_G, Note_Gis, Note_H, Note_INVALID, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_DisableLED, RING_DisableLight, RING_DisableVibra, RING_EnableLED, RING_EnableLight, RING_EnableVibra, RING_Note, GSM_RingNote::Scale, Scale_880, StaccatoStyle, GSM_RingNote::Style, GSM_RingNote::Tempo, TRUE, and GSM_RingCommand::Type.
Referenced by GSM_EncodeEMSMultiPartSMS(), and GSM_SaveRingtoneIMelody().
unsigned char GSM_EncodeNokiaRTTLRingtone | ( | GSM_Ringtone * | ringtone, |
unsigned char * | package, | ||
size_t * | maxlength | ||
) |
Definition at line 992 of file gsmring.c.
References AddBuffer(), AddBufferByte(), GSM_NoteRingtone::AllNotesScale, BufferAlign(), BufferAlignNumber(), GSM_NoteRingtone::Commands, DecodeUnicodeString(), GSM_RingNote::Duration, GSM_RingNote::DurationSpec, EncodeUnicodeSpecialNOKIAChars(), FALSE, GSM_RTTLGetTempo(), GSM_Ringtone::Name, GSM_RingNote::Note, GSM_RingCommand::Note, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_Note, GSM_RingNote::Scale, SM_Command_RingingToneProgramming, SM_Command_Sound, SM_CommandEnd_CommandEnd, SM_InstructionID_NoteInstructionId, SM_InstructionID_PatternHeaderId, SM_InstructionID_ScaleInstructionId, SM_InstructionID_StyleInstructionId, SM_InstructionID_TempoInstructionId, SM_PatternID_A_part, SM_Song_BasicSongType, GSM_RingNote::Style, GSM_RingNote::Tempo, TRUE, GSM_RingCommand::Type, and UnicodeLength().
Referenced by GSM_EncodeMultiPartSMS(), GSM_EncodeSMS30MultiPartSMS(), and GSM_SaveRingtoneOtt().
const unsigned char* GSM_GetRingtoneName | ( | const GSM_AllRingtonesInfo * | Info, |
const int | ID | ||
) |
Returns ringtone name, NULL if not found.
Definition at line 1713 of file gsmring.c.
References GSM_RingtoneInfo::ID, GSM_RingtoneInfo::Name, GSM_AllRingtonesInfo::Number, and GSM_AllRingtonesInfo::Ringtone.
GSM_Error GSM_ReadRingtoneFile | ( | char * | FileName, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 874 of file gsmring.c.
References GSM_NoteRingtone::AllNotesScale, dbgprintf, EncodeUnicode(), ERR_CANTOPENFILE, ERR_FILENOTSUPPORTED, ERR_MOREMEMORY, ERR_UNKNOWN, FALSE, GSM_Ringtone::Format, GSM_MAX_RINGTONE_NAME_LENGTH, loadbin(), loadcommunicator(), loadmmf(), loadott(), loadpuremidi(), loadre(), loadrttl(), GSM_Ringtone::Name, GSM_Ringtone::NoteTone, RING_MIDI, RING_MMF, RING_NOKIABINARY, and RING_NOTETONE.
int GSM_RingNoteGetFrequency | ( | GSM_RingNote | Note | ) |
Definition at line 40 of file gsmring.c.
References GSM_RingNote::Note, Note_A, Note_Ais, Note_C, Note_Cis, Note_D, Note_Dis, Note_E, Note_F, Note_Fis, Note_G, Note_Gis, Note_H, Note_INVALID, Note_Pause, GSM_RingNote::Scale, Scale_1760, Scale_3520, Scale_440, and Scale_880.
Referenced by GSM_SaveRingtoneWav(), and PHONE_RTTLPlayOneNote().
int GSM_RingNoteGetFullDuration | ( | GSM_RingNote | Note | ) |
Definition at line 76 of file gsmring.c.
References DottedNote, DoubleDottedNote, GSM_RingNote::Duration, Duration_1_16, Duration_1_2, Duration_1_32, Duration_1_4, Duration_1_8, Duration_Full, Duration_INVALID, GSM_RingNote::DurationSpec, DurationSpec_INVALID, Length_2_3, and NoSpecialDuration.
Referenced by GSM_SaveRingtoneMidi(), GSM_SaveRingtoneWav(), PHONE_RTTLPlayOneNote(), and RTTL2Binary().
GSM_Error GSM_RingtoneConvert | ( | GSM_Ringtone * | dest, |
GSM_Ringtone * | src, | ||
GSM_RingtoneFormat | Format | ||
) |
Definition at line 1543 of file gsmring.c.
References Binary2RTTL(), CopyUnicodeString(), ERR_NONE, ERR_NOTIMPLEMENTED, GSM_Ringtone::Format, GSM_Ringtone::Name, RING_NOKIABINARY, RING_NOTETONE, and RTTL2Binary().
int GSM_RTTLGetTempo | ( | int | Beats | ) |
Definition at line 979 of file gsmring.c.
References SM_BeatsPerMinute.
Referenced by GSM_EncodeNokiaRTTLRingtone().
GSM_Error GSM_SaveRingtoneFile | ( | char * | FileName, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 494 of file gsmring.c.
References ERR_CANTOPENFILE, ERR_UNKNOWN, GSM_Ringtone::Format, GSM_SaveRingtoneIMelody(), GSM_SaveRingtoneMidi(), GSM_SaveRingtoneOtt(), GSM_SaveRingtoneRttl(), GSM_SaveRingtoneWav(), RING_MIDI, RING_MMF, RING_NOKIABINARY, RING_NOTETONE, savebin(), savemmf(), and savepuremidi().
GSM_Error GSM_SaveRingtoneIMelody | ( | FILE * | file, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 377 of file gsmring.c.
References chk_fwrite, ERR_NONE, ERR_WRITING_FILE, GSM_EncodeEMSSound(), GSM_Ring_IMelody12, and TRUE.
Referenced by GSM_SaveRingtoneFile().
GSM_Error GSM_SaveRingtoneMidi | ( | FILE * | file, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 413 of file gsmring.c.
References chk_fwrite, GSM_NoteRingtone::Commands, ERR_NONE, ERR_WRITING_FILE, FALSE, GSM_RingNoteGetFullDuration(), GSM_RingNote::Note, GSM_RingCommand::Note, Note_C, Note_H, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_Note, GSM_RingNote::Scale, GSM_RingNote::Tempo, TRUE, GSM_RingCommand::Type, and WriteVarLen().
Referenced by GSM_SaveRingtoneFile().
GSM_Error GSM_SaveRingtoneOtt | ( | FILE * | file, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 481 of file gsmring.c.
References chk_fwrite, ERR_NONE, ERR_WRITING_FILE, and GSM_EncodeNokiaRTTLRingtone().
Referenced by GSM_SaveRingtoneFile().
GSM_Error GSM_SaveRingtoneRttl | ( | FILE * | file, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 201 of file gsmring.c.
References GSM_NoteRingtone::Commands, ContinuousStyle, dbgprintf, DecodeUnicodeString(), DottedNote, DoubleDottedNote, GSM_RingNote::Duration, Duration_1_16, Duration_1_2, Duration_1_32, Duration_1_4, Duration_1_8, Duration_Full, Duration_INVALID, GSM_RingNote::DurationSpec, ERR_NONE, FALSE, INVALIDStyle, GSM_Ringtone::Name, NaturalStyle, NoSpecialDuration, GSM_RingNote::Note, GSM_RingCommand::Note, Note_A, Note_Ais, Note_C, Note_Cis, Note_D, Note_Dis, Note_E, Note_F, Note_Fis, Note_G, Note_Gis, Note_H, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_Note, GSM_RingNote::Scale, Scale_14080, Scale_55, StaccatoStyle, GSM_RingNote::Style, GSM_RingNote::Tempo, TRUE, and GSM_RingCommand::Type.
Referenced by GSM_SaveRingtoneFile().
GSM_Error GSM_SaveRingtoneWav | ( | FILE * | file, |
GSM_Ringtone * | ringtone | ||
) |
Definition at line 105 of file gsmring.c.
References chk_fwrite, GSM_NoteRingtone::Commands, ERR_NONE, ERR_WRITING_FILE, GSM_RingNoteGetFrequency(), GSM_RingNoteGetFullDuration(), GSM_RingCommand::Note, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, PI, RING_Note, GSM_RingCommand::Type, and WAV_SAMPLE_RATE.
Referenced by GSM_SaveRingtoneFile().
|
static |
Definition at line 800 of file gsmring.c.
References dbgprintf, DecodeUnicodeString(), EncodeUnicode(), ERR_NONE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, GSM_Ringtone::Name, and GSM_Ringtone::NokiaBinary.
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 781 of file gsmring.c.
References ERR_UNKNOWN, GSM_DecodeNokiaRTTLRingtone(), and TRUE.
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 829 of file gsmring.c.
References GSM_Ringtone::BinaryTone, GSM_BinaryTone::Buffer, dbgprintf, DecodeUnicodeString(), ERR_MOREMEMORY, ERR_NONE, GSM_BinaryTone::Length, and GSM_Ringtone::Name.
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 771 of file gsmring.c.
References GSM_DecodeNokiaRTTLRingtone().
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 819 of file gsmring.c.
References dbgprintf, DecodeUnicodeString(), EncodeUnicode(), ERR_NONE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, GSM_Ringtone::Name, and GSM_Ringtone::NokiaBinary.
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 853 of file gsmring.c.
References CopyUnicodeString(), dbgprintf, DecodeUnicodeString(), EncodeUnicode(), ERR_NONE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, GSM_Ringtone::Name, GSM_Ringtone::NokiaBinary, and UnicodeLength().
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 537 of file gsmring.c.
References GSM_NoteRingtone::Commands, ContinuousStyle, dbgprintf, DottedNote, GSM_RingNote::Duration, Duration_1_16, Duration_1_2, Duration_1_32, Duration_1_4, Duration_1_8, Duration_Full, GSM_RingNote::DurationSpec, EncodeUnicode(), ERR_FILENOTSUPPORTED, ERR_NONE, GSM_MAX_RINGTONE_NOTES, GSM_Ringtone::Name, NaturalStyle, NoSpecialDuration, GSM_RingNote::Note, GSM_RingCommand::Note, Note_A, Note_Ais, Note_C, Note_Cis, Note_D, Note_Dis, Note_E, Note_F, Note_Fis, Note_G, Note_Gis, Note_H, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_DisableLED, RING_DisableLight, RING_DisableVibra, RING_EnableLED, RING_EnableLight, RING_EnableVibra, RING_Note, GSM_RingNote::Scale, Scale_1760, Scale_3520, Scale_440, Scale_880, StaccatoStyle, GSM_RingNote::Style, GSM_RingNote::Tempo, and GSM_RingCommand::Type.
Referenced by GSM_ReadRingtoneFile().
|
static |
Definition at line 1250 of file gsmring.c.
References GSM_NoteRingtone::Commands, GSM_NokiaBinaryRingtone::Frame, GSM_RingNoteGetFullDuration(), GSM_NokiaBinaryRingtone::Length, NaturalStyle, GSM_Ringtone::NokiaBinary, GSM_RingNote::Note, GSM_RingCommand::Note, Note_C, Note_H, Note_Pause, GSM_Ringtone::NoteTone, GSM_NoteRingtone::NrCommands, RING_Note, GSM_RingNote::Scale, Scale_1760, Scale_3520, Scale_440, Scale_880, StaccatoStyle, GSM_RingNote::Style, GSM_RingNote::Tempo, and GSM_RingCommand::Type.
Referenced by GSM_RingtoneConvert().
|
static |
Definition at line 169 of file gsmring.c.
References chk_fwrite, DecodeUnicodeString(), ERR_NONE, ERR_WRITING_FILE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, GSM_Ringtone::Name, and GSM_Ringtone::NokiaBinary.
Referenced by GSM_SaveRingtoneFile().
|
static |
Definition at line 193 of file gsmring.c.
References chk_fwrite, ERR_NONE, ERR_WRITING_FILE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, and GSM_Ringtone::NokiaBinary.
Referenced by GSM_SaveRingtoneFile().
|
static |
Definition at line 185 of file gsmring.c.
References chk_fwrite, ERR_NONE, ERR_WRITING_FILE, GSM_NokiaBinaryRingtone::Frame, GSM_NokiaBinaryRingtone::Length, and GSM_Ringtone::NokiaBinary.
Referenced by GSM_SaveRingtoneFile().
|
static |
|
static |
Definition at line 972 of file gsmring.c.
Referenced by GSM_DecodeNokiaRTTLRingtone(), and GSM_RTTLGetTempo().